how do i assembly program to find the smallest among two numbers.
assuming that first number is located a memory address : 0x2001 second number is located a memory address : 0x2002
store the smaller number in Accumulator
Here is what i attempted :
LDA 0x2001
MOV B, A
LDA 0x2002
CMP B
JNC smaller
exit
smaller :
MOV A, B
exit : HLT
is my solution correct?
XRA ; clear the accumulator
MVI B, 30H ; load a number to B Register
MVI C, 40H ; load a number to C Register
MOV A, B ; Move the content of B to A
CMP C ; Compare value of C against A
JNC SMALL ; Jump if smaller
**JMP END** ; Halt program if not small
SMALL: MOV A, C ; save smaller num in accumulator
**END: HLT**