新闻中心

EEPW首页>嵌入式系统>设计应用> 汇编:统计输入字符串内的数字个数(最多三位数0—256)

汇编:统计输入字符串内的数字个数(最多三位数0—256)

作者: 时间:2016-12-01 来源:网络 收藏
;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

上一页 1 2 下一页

评论


技术专区

关闭