;This is made by wq
;编程从键盘读入不超越256个字符的字符串;
;编程计算其间数字的个数,并将结果在屏幕上输出。
;经进一步完善(能输出三位数啦)
DATAS SEGMENT
sum db 00h ;累加器
string db 256 dup(0dh);寄存字符
tital db This program is made by wq.,0dh,0ah
db It is used to calculater the amout of the number in the string ,0dh,0ah,$
tital1 db PLease input the string: ,$
overs db Amout of the nember is : ,$
tital2 db Do you want to have a try again(if yes,input “y” else “n”) : ,0dh,0ah, $
tital3 db Welcome to use this program again,$
kongzi db 0dh,0ah,$
result db 256 dup(?)
DATAS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS
START:
MOV AX,DATAS
MOV DS,AX
mov ax,offset tital;输出昂首
mov dx,ax
mov ah,09h
int 21h
main:
lea dx,kongzi
mov ah,09h
int 21h
lea dx,tital1 ;输出昂首1
mov ah,09h
int 21h
mov si,0
mov ax,offset string
mov dx,ax
again: ;输入字符
mov ah,01h
int 21h
cmp al,0dh
jz then
mov string[si],al
inc si
jmp again ;输入结束
then: ;传输
mov di,0
mov si,0
mov bl,0
exchang: ;判别字符的性质
lea dx,string
cmp string[si],0dh
jz over
cmp string[si],30h
jnb next
inc si
dec cx
jmp exchang
next:
mov al,string[si]
cmp string[si],39h
jbe calculator
inc si
dec cx
jmp exchang