The length of the string assembler language statistics

Required length of the string. Defining a data segment address of the first string String, the character string "$" marks the end of no longer than 100 bytes, and the length of the string statistics stored in the memory unit of Len.

data segment
String db 100,?,100 dup('$')
Len db 0
data ends

code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax

lea dx,String
mov ah,0ah   ;输入字符串
int 21h

mov dl,0ah   ;换行
mov ah,2
int 21h
mov dl,0dh
mov ah,2
int 21h

mov bx,offset String[2]
mov al,0
mov cl,0

do:
mov al,String[bx]
cmp al,'$'
je over
inc bx
inc cl
jmp do

over:
mov Len,cl
mov ah,4ch
int 21h

code ends
end start

Pro-test error-free,
⬇ remember thumbs up!

Released four original articles · won praise 1 · views 26

Guess you like

Origin blog.csdn.net/qq_45014208/article/details/103996702
Recommended