Branching

Lecture 8: Branching

261 Questions205 MCQs51 Short Questions5 Long Questions
Showing 241250 of 261 Questions
Page 25 of 27
Q241❓ MCQ📑 Lec 3Easy🔁RepeatedHigh-Yield💡Conceptual
Which conditional jump instruction is taken if the last arithmetic operation produced a zero in its destination, or after CMP if both operands were equal?
💻 assembly Snippet
cmp ax, bx
je match_label  ; Jumps if AX == BX (ZF = 1)
  1. A.Jump if Zero (JZ) / Jump if Equal (JE)
  2. B.Jump if Equal (JE) only
  3. C.Jump if Zero (JZ) only
  4. D.No jump for this condition
Q242📝 Short Q📑 Lec 3EasyHigh-Yield💡Conceptual
How does the CMP (Compare) instruction operate in 8086 assembly language, and how does it update processor status flags compared to the SUB instruction?
💻 assembly Snippet
; CMP vs SUB Example
mov ax, 24
cmp ax, 12    ; Calculates 24 - 12 = 12; Sets ZF = 0, AX remains 24
sub ax, 12    ; Calculates 24 - 12 = 12; Sets ZF = 0, AX becomes 12
Q243📝 Short Q📑 Lec 3MediumHigh-Yield💡Conceptual
Explain the operational logic of the JNE (Jump if Not Equal) / JNZ (Jump if Not Zero) conditional branch instruction and its reliance on the Zero Flag (ZF).
💻 assembly Snippet
; Conditional Branching with JNE
mov ax, 24
cmp ax, 12          ; Operands unequal -> ZF = 0
jne target_address  ; Jump taken because ZF == 0
Q244📝 Short Q📑 Lec 3EasyHigh-Yield💡Conceptual
What is the JNZ (Jump if Not Zero) instruction in 8086 assembly language, and how does its execution depend on the status of the Zero Flag (ZF)?
💻 assembly Snippet
; JNZ Conditional Branching Example
mov ax, 5
sub ax, 2     ; Result = 3 (Non-zero -> ZF = 0)
jnz loop_body ; Jump taken because ZF == 0
Q245📝 Short Q📑 Lec 3MediumHigh-Yield💡Conceptual
How are comparison operations and conditional branching used in assembly language to emulate high-level relational and boolean control logic?
💻 assembly Snippet
; High-level Relational Logic in Assembly
cmp ax, bx       ; Compare AX and BX (sets ZF, CF, SF, OF flags)
jg ax_is_greater ; Branch if AX > BX (Signed Greater)
Q246📝 Short Q📑 Lec 3EasyHigh-Yield💡Conceptual
How does the CMP (Compare) instruction function in 8086 assembly language, and why is it described as a non-destructive subtraction operation?
💻 assembly Snippet
; CMP Instruction Example
cmp ax, bx    ; Calculates AX - BX, sets flags, preserves AX and BX
je values_equal ; Jump if ZF = 1 (AX == BX)
Q247📝 Short Q📑 Lec 3MediumHigh-Yield💡Conceptual
Explain how the Carry Flag (CF), Zero Flag (ZF), Sign Flag (SF), and Overflow Flag (OF) reflect relations between operands during a CMP operation.
💻 assembly Snippet
; Status Flags after CMP
cmp ax, 10    ; If AX = 10 -> ZF=1, CF=0
              ; If AX = 5  -> ZF=0, CF=1 (Borrow required)
              ; If AX = 15 -> ZF=0, CF=0
Q248📝 Short Q📑 Lec 3MediumHigh-Yield💡Conceptual
What is the key difference between conditional jump instructions used for signed comparisons (JG/JL) and unsigned comparisons (JA/JB) in x86 assembly?
💻 assembly Snippet
; Signed vs Unsigned Branching Example
cmp ax, bx
jg signed_greater   ; Signed comparison: branches if AX > BX (Signed)
ja unsigned_above   ; Unsigned comparison: branches if AX > BX (Unsigned)
Q249📝 Short Q📑 Lec 3EasyHigh-Yield💡Conceptual
How do JZ (Jump if Zero) and JNZ (Jump if Not Zero) conditional jump instructions operate following a CMP operation?
💻 assembly Snippet
; JZ and JNZ Example
cmp ax, bx
jz values_are_equal    ; Jumps if AX == BX (ZF == 1)
jnz values_are_unequal  ; Jumps if AX != BX (ZF == 0)
Q250📝 Short Q📑 Lec 3MediumHigh-Yield💡Conceptual
Why does Intel assembly language provide instruction aliases (synonyms) such as JE/JZ, JNE/JNZ, and JB/JNAE/JC, and how do they map to machine code opcodes and status flags?
💻 assembly Snippet
; Instruction Mnemonic Aliases
cmp ax, bx
je targets_equal   ; Assembly alias for JZ (Opcode 74h)
cmp ax, bx
jz targets_zero    ; Same opcode as JE (Opcode 74h)