|
楼主 |
发表于 2019-6-19 13:05:21
|
显示全部楼层
好的,谢谢啦,我已经做好了
data segment
A db 0
B db 0
D db 0
buf db 3
db 0
inn db 3 dup(0)
msg0 db 0dh, 0ah, 'Please enter a decimal number(10-99):$'
msg1 db 0dh, 0ah, 'The max number (in Binary) is :$'
data ends
assume cs:code, ds:data
code segment
start:
mov ax, data
mov ds, ax
lea si, A
call readdecimal
lea si, B
call readdecimal
lea si, D
call readdecimal
xor bx, bx
mov al, A
cmp al, B
ja m1 ;A>B
cmp al, D ;A<B
ja m4 ;B>A>D
mov al, B ;B>A, D>A, B>D?
cmp al, D
ja m5 ;B>D>A
mov bl, D
jmp printit
m1: ;A>B, then judge B>D?
mov al, B
cmp al, D
jb m2 ; B<D
mov bl, A ; found it, then print it
jmp printit
m2: ;A>B, D>B, then judge A>D?
mov al, A
cmp al, D
ja m3 ;A>D, found D
mov bl, D ;A<D, found A
jmp printit
m3:
mov bl, A
jmp printit
m4:
mov bl, B
jmp printit
m5:
mov bl, B
jmp printit
printit:
mov ah,9
lea dx, msg1
int 21h
call printbin
mov ax, 4c00h
int 21h
;read decimal
;store to (si)
readdecimal proc near
lea dx, msg0
mov ah, 9
int 21h
lea dx, buf
mov ah,10
int 21h
mov byte ptr [si], 0
mov dl, 10
xor cx, cx
mov cl, buf+1
xor bx, bx
r0:
mov al, inn[bx]
and al, 0fh
xchg al, [si]
mul dl
add [si], al
inc bx
loop r0
ret
readdecimal endp
;print(bx)
printbin proc near
mov cx, 16
mov ah,0eh
p0:
rol bx, 1
mov al, bl
and al, 01h
xor al,30h
int 10h
loop p0
ret
printbin endp
code ends
end start
你看看有没有问题 |
|