汇编 累加修改 超过11111提示错误

来源:百度知道 编辑:UC知道 时间:2024/06/17 10:14:49
;转换 ------------宏
bc macro ;把BX中的和 调整转换成ascii能输出
mov ax,bx
mov dx,0
div cx ;除法cx和ax dx中保留余数 ax保留商
mov bx,dx
mov dl,al
add dl,30h ;变成能显示的ascii

mov ah,02h ;输出al
int 21h
endm

enter macro ;回车换行 ---------宏
mov dl,0dh
mov ah,2
int 21h
mov dl,0ah
mov ah,2
int 21h
endm

;以上为需要调用的宏

data segment
msg db 'The result only can show 5 long number!',' ','Press "Esc" to exit',13,10,'$'
msg2 db ' ',13,10,'input N (small than "11111")',13,10,'cin N :$'
error db 13,10,' The char you pressed Not a number!',13,10,'$'
space db ' ',13,10,'$'
;tast db 'tast is Test!',13,10,'$'
data ends

code segment
assume cs:

不知道你是不是这个意思。
add bx,ax ;加法
cmp bx,11111
jb @F
mov dx,offset msg
mov ah,9
int 21h
mov ah,4ch
int 21h
@@:
jmp nechr ;无条件循环,做下一个数字

bc macro ;把BX中的和 调整转换成ascii能输出
mov ax,bx
mov dx,0
div cx ;除法cx和ax dx中保留余数 ax保留商
mov bx,dx
mov dl,al
add dl,30h ;变成能显示的ascii

mov ah,02h ;输出al
int 21h
endm

enter macro ;回车换行 ---------宏
mov dl,0dh
mov ah,2
int 21h
mov dl,0ah
mov ah,2
int 21h
endm

;以上为需要调用的宏

data segment
msg db 'The result only can show 5 long number!',' ','Press "Esc" to exit',13,10,'$'
msg2 db ' ',13,10,'input N (small than "11111")',13,10,'cin N :$'
msg3 db 13,10,'The number you input is bigger than "11111"!',13,10,'$' ;增加的提示字符串
error db 13,10,' The char you pressed Not a n