Get string length from input buffer 8086

assemblyx86

Assuming you've read some ascii text into a character buffer of length say, 255 . How can you retrieve the length of the ascii text stored in the buffer into a CX register? (EDITED)

Thanks

Best Answer

Search for the '$' using rep scasb, then subtract to get the distance from the beginning of the string.

; warning: untested code.
mov di, offset buffer
mov al, '$'
mov cx, 255
repnz scasb
sub di, offset buffer
mov cx, di
Related Topic