Copyright

mov ax, 32770d cmp ax, 2d jge xyz ; A jump occurs: True or false?

Question:

mov ax, 32770d

cmp ax, 2d

jge xyz ;

A jump occurs: True or false?

8086 Assembly:

The cmp instruction compares the first operand and the second operand by executing a Sub instruction that does not affect the operands themselves, but it does affect the flags. It is often used with a jump instruction afterwards; jge refers to "jump if greater than or equal" and occurs when overflow flag (OF) is equal to sign flag (SF).

Answer and Explanation:

The cmp instruction performs the operation sub ax, 2d and sets the appropriate flags, in this case (32770 - 2 = 32768):

  1. PF = 1, because the result has an even number of bits.
  2. SF = 1, because a Sub operation was performed (this flag is set for all arithmetic operations except Division and Multiplication in 8086).

Next, the jge instruction, jump if greater or equal, works by checking the Sign Flag and the Overflow flags, and performs a jump if SF = OF.

In this case, since OF was not set, the jump operation will not be performed, and the answer is false.


Learn more about this topic:

Practical Application for Computer Architecture: Instruction Set Architecture
Practical Application for Computer Architecture: Instruction Set Architecture

from Computer Science 306: Computer Architecture

Chapter 7 / Lesson 12
54

Related to this Question

Explore our homework questions and answer library