简体   繁体   中英

Get string length from input buffer 8086

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

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
; STRLEN
LEA SI,PARA
MOV CX,-1
DO:
    LODSB
    INC CX
    CMP AL,0
    JNE DO

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM