Assembly program to input two numbers and check if they are equal, unequal, greater or lesser

 If you are looking for a Assembly program to input two numbers and check if they are equal, unequal, greater or lesser or a assembly program to find the largest number between two numbers or how to check the numbers are equal or unequal

You are at right place. Following is the complete program with comments as you can understand easily. Additionally, if you have any questions, you can comment below.


___________
Dosseg
.model small
.stack 100h
.data
MsgEq db 'Numbers are Equal $'
MsgUneq db 'Numbers are Unequal and $'
MsgGr db ' First Number is greater than second number $'
MsgLs db ' First Number is lesser than second number $'
.code
main proc
mov ax, @data
mov ds, ax

mov ah, 1     ; input first number
int 21h
mov bl, al     ; saving first number to bl from al

mov al, 1      ; input second number
int 21h
mov cl, al    ; saving second number to cl from al

L1:            
cmp bl,cl       ; Comparing whether they are equal or not
je EQUAL    ; Jump to Equal box, where we print the equal msg

mov dl, 10     ; for next line feed
mov ah, 2
int 21h
mov dl, 13      ; for carriage return
mov ah, 2
int 21h

mov dx, offset MsgUneq   ; but if not equal, then print msg they are not equal
mov ah, 9
int 21h

cmp bl, cl          ; again compare to check the first is greater or lesser
jge Greater         ; if greater, jump to greater to print a greater msg

mov dx, offset MsgLs  ; but if not greater, print lesser msg
mov ah, 9
int 21h
jmp PRINT



Greater:
mov dx, offset MsgGr
mov ah, 9
int 21h
jmp PRINT


EQUAL:
mov dl, 10     ; for next line feed
mov ah, 2
int 21h
mov dl, 13      ; for carriage return
mov ah, 2
int 21h

mov dx, offset MsgEq
mov ah, 9
int 21h
jmp PRINT



PRINT:
mov ah,4ch
int 21h
main endp

end main

___







Tags:
How to find the largest number in assembly, how to find the greater number in assembly, how to find the larger number between two numbers, assembly language program to find largest of two numbers, program to find larger number assembly, 8086 assembly language program to find the largest number in an array, assembly language program to find largest of three numbers, assembly language program to find smallest number in an array, 8086 microprocessor program to find smallest number, write an assembly language program to find the largest number in an array, assembly language program to find smallest number in an array, 8086 microprocessor program to find smallest number, assembly language program to find smallest number, assembly language program to find largest of n numbers, write a program in assembly language to find the largest of 2 numbers, write an assembly program to find greatest between two numbers, largest number program in 8086, find the largest number in assembly language

Comments

Post a Comment

Popular posts from this blog

Types of Addressing Modes in Assembly Language / Computer Architecture

How to print a single character in assembly language