Subroutines

Lecture 13: Subroutines

222 Questions172 MCQs45 Short Questions5 Long Questions
Showing 5160 of 222 Questions
Page 6 of 23
Q51❓ MCQ📑 Lec 5Medium🔁RepeatedHigh-Yield💡Conceptual
In assembly language subroutine stack frame management, how are local variables allocated on the stack?
💻 assembly Snippet
push bp
mov  bp, sp
sub  sp, 4 ; Allocates space for 4 bytes of local variables on stack
; ...
mov  sp, bp ; Deallocates local variables
pop  bp
ret
  1. A.By subtracting the required byte size from SP
  2. B.By adding the required byte size to SP
  3. C.By pushing segment registers onto the stack
  4. D.By calling INT 0x21
Q52❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
Local variables are variables that are defined and used exclusively within a __________.
  1. A.Subroutine
  2. B.Program
  3. C.CALL
  4. D.Label
Q53❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
To transfer control back from a subroutine to the caller, the standard near `RET` instruction takes how many explicit parameters/arguments?
💻 assembly Snippet
ret ; Pops saved return address from stack (0 operands)
  1. A.1 argument
  2. B.2 arguments
  3. C.3 arguments
  4. D.No arguments
Q54❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
In 16-bit x86 architecture, what is the maximum number of parameters a subroutine can receive directly through general-purpose registers (AX, BX, CX, DX, SI, DI, BP)?
  1. A.6
  2. B.7
  3. C.8
  4. D.9
Q55📝 Short Q📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
How many explicit parameters/arguments does the standard `RET` (Return from subroutine) instruction take?
💻 assembly Snippet
ret ; Pops saved IP from stack (0 parameters)
Q56📝 Short Q📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
Describe the function and operational steps performed by the `PUSH` instruction on the stack.
💻 assembly Snippet
push ax ; Decrements SP by 2, copies AX to [SS:SP]
Q57❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
The physical memory address of data located on the execution stack is calculated using which segment-offset register combination?
  1. A.SS:SP combination
  2. B.SS:SI combination
  3. C.ES:BP combination
  4. D.ES:SP combination
Q58❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
Upon execution of the standard near return instruction `RET`, how is the Stack Pointer (`SP`) modified?
💻 assembly Snippet
ret ; Pops 2-byte IP offset from [SS:SP], SP = SP + 2
  1. A.SP is incremented by 2
  2. B.SP is decremented by 2
  3. C.SP is incremented by 1
  4. D.SP is decremented by 1
Q59📝 Short Q📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
What structural changes occur to the Stack Pointer (`SP`) register upon executing the instruction `RET 2`?
💻 assembly Snippet
ret 2 ; Pops 2-byte IP, then adds 2 bytes to SP -> Total SP = SP + 4
Q60❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
When executing a far return instruction `RETF`, into which CPU register is the first 16-bit word popped from the stack loaded?
💻 assembly Snippet
retf ; Pops IP first, then CS second
  1. A.BP
  2. B.IP
  3. C.SP
  4. D.SI