汇编语言输入一些字符计算其长度
DATA SEGMENT
MAXLEN DB 200
ACTLEN DB ?
DB 200 DUP(?)
INFO1 DB 0AH,0DH,'input the string:','$'
INFO2 DB 0AH,0DH,'string length:'
N DB 20H,20H,20H,'$'
DATA ENDS
STACK SEGMENT STACK
DB 200 DUP(0)
STACK ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK
START: MOV AX,DATA
MOV DS,AX
LEA DX,INFO1
MOV AH,09H
INT 21H
LEA DX,MAXLEN
MOV AH,0AH ;输入字符
INT 21H
;*************
MOV SI,2
MOV BL,10
MOV AH,0
MOV AL,ACTLEN
NEXT: DIV BL
ADD AH,30H ;将数字转化为ASCII
MOV N[SI],AH
DEC SI
CMP AL,9
JLE FIN
MOV AH,0
JMP NEXT
FIN: ADD AL,30H
MOV N[SI],AL
LEA DX,INFO2
MOV AH,09H
INT 21H ;输出最终结果
MOV AH,4CH ;程序结束
INT 21H
CODE ENDS
END START
程序运行结果: