Answer the question
In order to leave comments, you need to log in
How to compare numbers and display the result?
Using CMP and JMP to compare and display the result of the comparison. For example:
a = 5
b = 2
The result should look like: A>B, B>A or A=B (based on the entered numbers)
Answer the question
In order to leave comments, you need to log in
First you need to determine where the numbers come from - are they loaded from memory or from somewhere else. These numbers must be placed in registers; or you can put one number in a register and leave the other in memory - *86 allows you to compare a register with memory; but ARM requires both numbers to be placed in registers, it does not know how to operate with memory.
Then compare the registers with the CMP command. This will set the flags.
Next, using conditional jump operators, you need to output the program to three branches that print the corresponding lines. And then after printing - either immediately a shutdown statement, or a transition to the end of the program, where something else is supposed to be done before the work is completed.
You would first decide which assembler - * 86, ARM, MIPS, etc; and bit depth - 32 or 64 bits.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question