0

Hello Guys
I want to make an assembly program that get 2 inputs and compare between them if equal or not and if not I want to say which number is the maximum and which one is the minimum

I did the Equal part , I need help with the maximum and minimum part, I cant get its Idea year im still a nOOb with assembly

Best Regards

.MODEL SMALL
.DATA
                V3 DB   'EQUAL$'
                V4 DB   'NOTEQAUL$'
.CODE
MAIN    PROC 
        MOV  AX,@DATA
        MOV  DS,AX 
        MOV  AH,01H
        INT  21H
        MOV  DL,AL   
        INT 21H     
        CMP AL,DL
        JNE NOEQUAL
        MOV AH,09H
        LEA DX,V3
        INT 21H
        JMP BYE
NOEQUAL:
 
        MOV AH,09H
        LEA DX,V4       ; LOAD EFECTIVE ADDRESS OF V4 IN DX
        INT 21H
BYE:
        MOV AH,4CH
        INT 21H
MAIN    ENDP
        END  MAIN
2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by davio1
0

Since you need to differentiate between min and max, I suggest you use something else instead of JNE.

Suppose you want the max to be in AL, and min in DL then:

...
CMP AL,DL
JG notequal  ; max is in AL, nothing should be done
JE equal     ; jump to equal part
XCHG AL,DL   ; since the only possibility left is that AL<DL, they are exchanged
jmp notequal ; now you can jump to notequal
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.