急求汇编高手帮忙

来源:百度知道 编辑:UC知道 时间:2024/06/01 23:22:24
输入两个数,通过比较 输出大数的原码
data segment
a db 'please input first number:','$',
b db 'please input second number:','$'
c db 'its yuanma shows:','$'
x db ?
y db ?
data ends
code segment
assume cs:code,ds:data
start:mov ax,data
mov ds,ax
mov ah,09h
mov dx,offset a
int 21h
mov ah,01h
int 21h
sub al,30h
mov y,al
mov ah,09h
mov dx,offset b
int 21h
mov ah,01h
int 21h
sub al,30h
mov dl,al
mov cx,8
mov dl,0ah
mov ah,02h
int 21h
mov dl,0dh
int 21h
mov ah,09h
lea dx,c
int 21h
mov dl,y
cmp bl,dl
mov x,dl
jge l1
l1:mov x,bl
l3:shl x,1
jnc l1

因有事在你的代码的基础上改正,简单调试通过
1.你的因原代码问题,只能输入1-9 ,宜扩展
2,未处理负数(你代码只输入一个字符),宜增加负数处理
可能要重写代码,有时间给你搞

data segment
a db 13,10,'please input first number:','$'
b db 13,10,'please input second number:','$'
c1 db 13,10,'its yuanma shows:','$'
x db ?
y db ?
data ends
code segment
assume cs:code,ds:data
start:mov ax,data
mov ds,ax
mov ah,09h
mov dx,offset a
int 21h
mov ah,01h
int 21h
sub al,30h
mov X,al
mov ah,09h
mov dx,offset b
int 21h
mov ah,01h
int 21h
sub al,30h
mov y,al
lea dx,c1
mov ah,09h
int 21h
mov dl,y
mov bl,x
cmp bl,dl
mov al,y ;暂设y 大
jb l1
mov al,x
l1:
MOV BL,AL
;以下输出bl
MOV AX,8
KK2:
PUSH AX
MOV CX,1
MOV DL,31H
RCL BL,CL
JC DISP
MOV DL,30H
DISP: