Since the basic idea is understood, I am now directly writing the programs now.
Finding the LARGER of the two 8 bit numbers. the CMP would perform the following: @2001 - @2000 reg A - reg B So, if @2001 is greater, no carry. However, if @2001 is NOT greater, a carry/borrow is generated. So, if carry/borrow is generated, then reg B is greater, and therefore, move the value of B back to A and print or store A as the greater of the two. if carry/borrow is not generated, reg A is already the greater and is directly stored as greater of two. A condition is required to perform the underline if there is a carry/borrow. The compare instruction (CMP) in the 8085 subtracts the two operands but does not store the results. What it does do is set flags, in particular, zero, negative, carry, parity, and auxillary carry, so you can follow up the instruction with a conditional branch or call instruction to perform some operation based on the comparison of those two numbers.
To find the SMALLER of the two numbers, conveniently change the JNC to JC and reverse the meaning altogether.
|