Question

# Assembly Code & debug the following program in VS, then answer these questions at the end...

Assembly

Code & debug the following program in VS, then answer these questions at the end of the code using comments:

a) To which label the program jumped?

c) Why the program didn’t jump to the other label, since ‘80h > 7Fh’ is correct?

mov al,+127 ;hex value is 7Fh (+127)

cmp al,-128 ;hex value is 80h (-128)

ja IsAbove

jg IsGreater

IsAbove:

exit

IsGreater:

exit

To answer this question lets, first understand the JA and JF flags.

JA Flag : Algorithm: if (CF = 0) and (ZF = 0) then jump

JG Flag : if (ZF = 0) and (SF = OF) then jump

Now, let us understand the CMP label:

Compare. Algorithm: operand1 - operand2

The immediate result is not stored anywhere, flags are set (OF, SF, ZF, AF, PF, CF) according to result.

Now in the question we are using CMP on +127 and -128, when subtracting it will result in -1.

For jump condtion to stasify we need to set ZF = 0.

But ZF = 0 only if  After any arithmetical or logical operation if the result is 0 or 00H, the zero flag becomes set i.e. 1, otherwise it becomes reset i.e. 0.
We can see that carry flag is also 0.

So JA Flag would be used.

a) isAbove label

b) I have explained it above.

c) Because the result is not stored in immediate result, but using flags, as explained above.

#### Earn Coins

Coins can be redeemed for fabulous gifts.

##### Need Online Homework Help?

Most questions answered within 1 hours.

##### Active Questions
• MS KP MM Corporation is a manufacturer that produces cosmetics. The following information has been taken...
• Dr. Bunson Honeydew and Dr. Strangepork both wanted to know how effective TV ads were at...
• 1)  Consider the following temperature surroundings. Ground level, 21oC; 500m, 20oC; 600m, 19oC; 1000m, 20oC. If we...
• 1. An AA iron-nickel battery delivers a constant current of 750 mA at 1.2 V (a)Calculate...
• In the process of recrystallization, after dissolving the product in hot methanol, why do we have...
• Finish buildFloat(): It does three things: Given exponent it computes exponentPattern. If exponent is less than...