欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

汇编语言——输入两位数比较大小

程序员文章站 2022-03-10 09:49:54
...

源代码 

code    segment
        assume cs:code
        org 100h
start:
        jmp bbb
msg1    db 10,13,'please input x:','$'
msg2    db 10,13,'please input y:','$'
x       db 0
y       db 0
msg3    db 10,13,'x=y','$'
msg4    db 10,13,'x>y','$'
msg5    db 10,13,'x<y','$'
 
bbb:
        push cs
        pop ds
        lea dx,msg1
        mov ah,09h
        int 21h
        mov ah,1
        int 21h
        sub al,30h
        mov ah,0
        mov bl,10
        mul bl
        mov cl,al
        mov ah,1
        int 21h
        sub al,30h
        mov ah,0
        add al,cl
        mov byte ptr[x],al
 
        lea dx,msg2
        mov ah,09h
        int 21h
        mov ah,1
        int 21h
        sub al,30h
        mov ah,0
        mov bl,10
        mul bl
        mov cl,al
        mov ah,1
        int 21h
        sub al,30h
        mov ah,0
        add al,cl
        mov byte ptr[y],al
 
        mov bl,byte ptr[x]
        sub al,bl
        jz l1
        jc l2
        jmp l3
l1:
        lea dx,msg3
        mov ah,9
        int 21h
        jmp exit1
l2:
        lea dx,msg4
        mov ah,9
        int 21h
        jmp exit1
l3:
        lea dx,msg5
        mov ah,9
        int 21h
;        jmp exit1
 
exit1:
        mov ah,4ch
        int 21h
code    ends
        end start

参考文章

https://zhidao.baidu.com/question/562479802788685844.html