Write an assembly program within a file named compare asm th

Write an assembly program within a file named compare. asm that takes two single-digit decimal numbers from the user, and compares them to identify whether they equal to each other, or one of the numbers is greater than the other. Upon execution, the program should ask the user to Enter the FIRST number to compare: after which the user presses a number in the keyboard. Afterwards, the program asks the user to Enter the SECOND number to compare after which the user inputs the second number the same way. Both number values should be loaded into two variables NUM1 and NUM2. The program then proceeds to compare the numbers, and decide on which of the following three messages to display on screen: The first number is EQUAL to the second number. The first number is GREATER than the second number. The first number is LESS than the second number.

Solution

ContinueMsg TEXTEQU <“Do you wish to continue (Y/N)?”>
rowSize = 5

DATA SEGMENT
NUM1 DB ?
NUM2 DB ?
MSG1 DB 10,13,\"ENTER FIRST NUMBER TO COMPARE : $\"
MSG2 DB 10,13,\"ENTER SECOND NUMBER TO COMPARE : $\"
MSG3 DB 10,13,\"The first number is greater than Second number\"
MSG4 DB 10,13,\"The first number is smaller than Second number \"
MSG5 DB 10,13,\"The first number is Equal to Second number \"
prompt1 BYTE continueMsg

count TEXTEQU %(rowSize * 2) ; evaluates the expression

setupAL TEXTEQU <mov al,count>
ENDS
CODE SEGMENT
ASSUME DS:DATA CS:CODE
START:
MOV AX,DATA
MOV DS,AX

LEA DX,MSG1
MOV AH,9
INT 21H

MOV AH,1
INT 21H
MOV NUM1,AL

LEA DX,MSG2
MOV AH,9
INT 21H

MOV AH,1
INT 21H
MOV NUM2,AL

MOV AL,NUM1

CMP AL,NUM2
JG SECOND

CMP AL,NUM2
JE THIRD

SECOND: LEA DX,MSG3
MOV AH,9
INT 21H
JMP EXIT

THIRD: LEA DX,MSG5
MOV AH,9
INT 21H
JMP EXIT

FIRST: LEA DX,MSG4
MOV AH,9
INT 21H

EXIT: setupAL
MOV AH,4CH
INT 21H   
ENDS
END START

 Write an assembly program within a file named compare. asm that takes two single-digit decimal numbers from the user, and compares them to identify whether the
 Write an assembly program within a file named compare. asm that takes two single-digit decimal numbers from the user, and compares them to identify whether the

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site