DATAS SEGMENT
msg db "Please input text : ",'$'
buf db 15
db ?
b2 db 15 dup(?)
db 13,10,'$'
result db 13,10,"the result is:",'$'
DATAS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS
START:
MOV AX,DATAS
MOV DS,AX
;;;;;;;;;;; BEGIN ;;;;;;;;;;;;;;;;;
mov ah, 9
mov dx,offset msg
int 21h ;display the msg:Please input:
mov ah, 0ah
mov dx,offset buf ;wait for input and save the text to the buf
int 21h
mov si,offset buf
inc si
xor cx,cx
mov cl,[si]
mov dl,cl
mov ah,2
;int 21h
mov dl,30h
compare: ;loop to compare to 0 and 9
inc si
mov al,[si]
cmp al,39h ;big than 9
ja plus
cmp al,30h ;low than 0
jb plus
jmp again
plus:
inc dl ;count ++
again:
loop compare ;loop again
mov cl,dl
mov ah,9
mov dx,offset result
int 21h ;output information: the result is
mov ah,2
mov dl,cl
int 21h ;output the count
;;;;;;;;;;;;;; END ;;;;;;;;;;;;;;
MOV AH,4CH
INT 21H ;program exit to dos
CODES ENDS
END START
江编最后一个程序
最新推荐文章于 2025-07-28 18:32:59 发布
本文介绍了一个使用汇编语言实现的简单程序,该程序提示用户输入文本,并统计输入中0到9数字字符出现的次数。通过具体的代码示例,展示了如何使用INT 21H中断来显示消息、读取用户输入并处理ASCII码。
3106

被折叠的 条评论
为什么被折叠?



