Subroutines

Lecture 13: Subroutines

222 Questions172 MCQs45 Short Questions5 Long Questions
Showing 7180 of 222 Questions
Page 8 of 23
Q71❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
When the stack becomes completely filled with data such that `SP` decrements down to 0 and wraps around, corrupting existing data, this condition is known as stack __________.
  1. A.Overflow
  2. B.Leakage
  3. C.Error
  4. D.Pointer
Q72❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
The `POP` instruction copies the word from the top of the stack (`[SS:SP]`) into its specified __________ and then increments the Stack Pointer (`SP`) by 2.
💻 assembly Snippet
pop ax ; Copies [SS:SP] into destination register AX, then SP = SP + 2
  1. A.destination operand (register or memory)
  2. B.source operand
  3. C.instruction pointer
  4. D.flag register
Q73❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
Which x86 instruction decrements the Stack Pointer (`SP`) by 2 and then transfers a 16-bit word from the source operand onto the top of the stack?
💻 assembly Snippet
push ax ; Decrements SP by 2, then copies AX to [SS:SP]
  1. A.PUSH
  2. B.POP
  3. C.CALL
  4. D.RET
Q74❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
The `POP` instruction transfers the word at the top of the stack (pointed to by `SS:SP`) into the destination operand and then __________ `SP` by two to point to the new top of stack.
💻 assembly Snippet
pop ax ; Copies [SS:SP] to AX, then increments SP by 2
  1. A.increments
  2. B.decrements
  3. C.'++
  4. D.'--
Q75❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
To preserve register values across subroutine calls, the standard programming convention is to use __________ operations to save caller register values prior to subroutine execution and restore them upon return.
💻 assembly Snippet
my_func:
  push ax ; Save register state
  push bx
  ; ... subroutine body ...
  pop  bx ; Restore register state
  pop  ax
  ret
  1. A.POP, ADC
  2. B.CALL, RET
  3. C.CALL, RET n
  4. D.PUSH, POP
Q76❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
To access subroutine arguments passed on the stack, an immediate (though destructive) method is to __________ them off the stack into general registers.
💻 assembly Snippet
pop ax ; Retrieves top argument from stack
  1. A.PUSH
  2. B.POP
  3. C.CALL
  4. D.Register
Q77❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
In standard x86 subroutine stack frame initialization, what is accomplished by executing the instruction `push bp`?
💻 assembly Snippet
push bp ; Saves caller's BP on stack
mov bp, sp ; Sets up new stack frame pointer
  1. A.sending bp copy to stack
  2. B.making bp copy from stack
  3. C.pushing bp on the stack
  4. D.doing nothing
Q78❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
Local variables in assembly language programming are defined as temporary variables whose scope and lifetime are restricted to the __________.
💻 assembly Snippet
push bp
mov bp, sp
sub sp, 4 ; Allocates space for local variables on stack
  1. A.Subroutine
  2. B.Program
  3. C.CALL
  4. D.Label
Q79❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
When the __________ instruction is encountered in a subroutine, program execution is transferred back to the instruction immediately following the `CALL` instruction.
💻 assembly Snippet
ret ; Pops return address from stack into IP
  1. A.CALL
  2. B.RET
  3. C.AND
  4. D.XOR
Q80❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
The `POP` operation reads a word from the top of the stack (`[SS:SP]`) and copies it into its __________.
💻 assembly Snippet
pop ax ; Copies top of stack to destination register operand AX
  1. A.Register
  2. B.operand
  3. C.RET n
  4. D.Pointer