您的位置 首页 硬件

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

;Thisismadebywq;编程从键盘读入不超过256个字符的字符串;;编程统计其中数字的个数,并将结果在屏幕上输出。;经进一步完善(能输出

;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

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/qianrushi/yingjian/255105.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部