Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assembly Language: For each sequence of instructions, indicate whether or not th

ID: 669706 • Letter: A

Question

Assembly Language: For each sequence of instructions, indicate whether or not the conditional jump will be taken.

a. mov al, –2

cmp al, 3

jle label [Will jump to label] [Will not jump]

b. mov al, –2

cmp al, 3

jb label [Will jump to label] [Will not jump]

c. mov al, 255

add al, 1

jo label [Will jump to label] [Will not jump]

d. mov al, -3

test al, 80h

jnz label [Will jump to label] [Will not jump]

Further: Consider the following.

mov al, 1

cmp al, 0 ; After this, flags are: CF = 0, SF = 0, ZF = 1, OF = 0

jg label

The jg instruction will jump to label, since 1 > 0. In a sentence, briefly but precisely explain how the jg instruction determines whether or not to jump.

Explanation / Answer

a) Will jump to label. Because -2 is less than 3

b) Will not jump to label. Because JB is for unsigned comparison. So it works with the complement of the number.

c) Will jump to label. Because 225 + 1 = 256 and this, in binary, is bigger than a 8 bytes registry all set to 1. (Having in mind that registry is 8bits long.)

d) Will not jump to label because the test is the result of AND operation. Which would set the ZF to 1 if al==0, but it is not. Then ZF is never set to 1, and JNZ jumps if ZF is NOT zero.

I think there is an error in the question. It says that the ZF is 1 and it still jumps. But the thing is that the cmp instruction sets ZF to 1 only if the values are equal, which in this case they are not. So, it would still be ZF=0

However, if you just one the explanation on how the JG works here you go:

The JG determines whether or not to jump considering the Zero Flag, Sign Flag and Overflow Flag. The condition for JG to jump is that ZF=0 and SF=OF if those conditions are set, then it jumps. In this case it would jump indeed. But the value given in the exercise for ZF is not right.

You could look for a Intel x86 JUMP quick reference so ou can see what I'm saying.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote