home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_02_11 / 2n11056b < prev    next >
Text File  |  1991-09-29  |  1KB  |  29 lines

  1.  
  2. Listing 2.  LODSW Method of Finding Terminator Zero
  3.    string    DB    "This is a string",0
  4.    .....
  5.    cld                     ;  clear direction
  6.    mov   si,offset string  ;  load offset
  7.    mov   cx,si             ;  get offset into counter
  8. repeat:
  9.    lodsw                   ;  load word from string
  10.    test  ah,al             ;  zero yet?
  11.    jz    end_repeat        ;  if so exit and adjust
  12.    lodsw                   ;  load word from string
  13.    test  ah,al             ;  zero yet?
  14.    jz    end_repeat        ;  if so exit and adjust
  15.    lodsw                   ;  load word from string
  16.    test  ah,al             ;  zero yet?
  17.    jnz   repeat            ;  if not repeat
  18. end_repeat:
  19.    sub   si,cx             ;  get unadjusted count
  20.    mov   cx,si             ;  move to return register
  21.    cmp   al,0              ;  is lead byte zero?
  22.    jz    adj_two           ;  if so adjust back two
  23.    dec   cx                ;  else adjust back one
  24.    jmp   adj_end           ;   then exit
  25. adj_two:
  26.    sub   cx,2              ;  adjust back two
  27.    adj_end:
  28.    .....
  29.