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 >
Wrap
Text File
|
1991-09-29
|
1KB
|
29 lines
Listing 2. LODSW Method of Finding Terminator Zero
string DB "This is a string",0
.....
cld ; clear direction
mov si,offset string ; load offset
mov cx,si ; get offset into counter
repeat:
lodsw ; load word from string
test ah,al ; zero yet?
jz end_repeat ; if so exit and adjust
lodsw ; load word from string
test ah,al ; zero yet?
jz end_repeat ; if so exit and adjust
lodsw ; load word from string
test ah,al ; zero yet?
jnz repeat ; if not repeat
end_repeat:
sub si,cx ; get unadjusted count
mov cx,si ; move to return register
cmp al,0 ; is lead byte zero?
jz adj_two ; if so adjust back two
dec cx ; else adjust back one
jmp adj_end ; then exit
adj_two:
sub cx,2 ; adjust back two
adj_end:
.....