Subroutines

Lecture 13: Subroutines

222 Questions172 MCQs45 Short Questions5 Long Questions
Showing 101110 of 222 Questions
Page 11 of 23
Q101❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
When a subroutine finishes execution, encountering which instruction returns execution flow back to the instruction immediately following the original `CALL`?
💻 assembly Snippet
ret ; Pops saved return address off stack into IP
  1. A.CALL
  2. B.RET
  3. C.AND
  4. D.XOR
Q102❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
Which pair of instructions is commonly used together for subroutine linkage, despite being operationally independent instructions?
💻 assembly Snippet
call sub_func ; Invokes subroutine
; ...
sub_func:
  ; body
  ret         ; Returns from subroutine
  1. A.RET and ADC
  2. B.Cal and SSb
  3. C.CALL and RET
  4. D.ADC and SSB
Q103❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
The execution of a `CALL` instruction breaks normal sequential execution flow and updates register __________ to point to the new subroutine offset.
💻 assembly Snippet
; CALL saves IP to stack and loads target offset into IP
  1. A.SI
  2. B.IP
  3. C.DI
  4. D.SP
Q104❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
The CPU stack is an area of physical memory organized as a __________ that operates in a Last-In, First-Out (LIFO) manner.
  1. A.Program
  2. B.data structure
  3. C.Heap
  4. D.None of the Given
Q105❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
If the x86 instruction __________ is not available, clearing parameters from the stack by the callee subroutine becomes a complicated multi-step process.
💻 assembly Snippet
ret 4 ; Pops return address and discards 4 parameter bytes from stack
  1. A.CALL
  2. B.SBB
  3. C.RET n
  4. D.None of the Given
Q106❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
When excessive items are pushed onto the stack causing `SP` to decrement down to 0 and wrap around, corrupting memory data, this condition is known as stack __________.
  1. A.Overflow
  2. B.Leakage
  3. C.Error
  4. D.Pointer
Q107❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
The `POP` operation copies the word from the top of the stack into its specified __________.
💻 assembly Snippet
pop ax ; Destination operand AX receives top of stack word [SS:SP]
  1. A.Register
  2. B.operand
  3. C.RET n
  4. D.Pointer
Q108❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
Which x86 instruction decrements the Stack Pointer (`SP`) by two and then transfers a word from the source operand to the top of the stack?
💻 assembly Snippet
push ax ; SP = SP - 2, then [SS:SP] = AX
  1. A.PUSH
  2. B.POP
  3. C.CALL
  4. D.RET
Q109❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
The `POP` instruction transfers the word at the top of the stack (pointed to by `SP`) to the destination operand and then __________ `SP` by two to point to the new top of stack.
💻 assembly Snippet
pop bx ; Copies [SS:SP] to BX, then increments SP by 2
  1. A.increments
  2. B.decrements
  3. C.'++
  4. D.'--
Q110❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
To preserve caller register values across a subroutine call, the standard technique is to use __________ and __________ operations to save register states on the stack upon entry and restore them before returning.
💻 assembly Snippet
my_sub:
  push ax ; Save AX
  push bx ; Save BX
  ; ... subroutine work ...
  pop bx  ; Restore BX
  pop ax  ; Restore AX
  ret
  1. A.POP, ADC
  2. B.CALL, RET
  3. C.CALL, RET n
  4. D.PUSH, POP