Subroutines

Lecture 13: Subroutines

222 Questions172 MCQs45 Short Questions5 Long Questions
Showing 6170 of 222 Questions
Page 7 of 23
Q61❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
When the instruction `RET 2` completes execution, by how many bytes is the Stack Pointer (`SP`) incremented in total?
💻 assembly Snippet
ret 2 ; SP = SP + 2 (return address) + 2 (operand) = SP + 4
  1. A.SP is incremented by 2
  2. B.SP is decremented by 2
  3. C.SP is incremented by 4
  4. D.SP is decremented by 4
Q62❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
In 8088 / 8086 architecture, whenever an element is pushed onto the stack using `PUSH`, how is the Stack Pointer (`SP`) modified?
💻 assembly Snippet
push ax ; Decrements SP by 2 and writes AX to [SS:SP]
  1. A.SP is decremented by 1
  2. B.SP is decremented by 2
  3. C.SP is decremented by 3
  4. D.SP is decremented by 4
Q63❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
When a subroutine finishes execution, which instruction retrieves the saved return address from the stack and transfers program control back to that location?
💻 assembly Snippet
ret ; Pops saved return address from stack into IP
  1. A.RET instruction
  2. B.CALL instruction
  3. C.POP instruction
  4. D.Jump instruction
Q64❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
Which x86 control flow instruction pushes the return address onto the stack and transfers execution to a subroutine, enabling code modularity and reusability?
💻 assembly Snippet
call my_subroutine ; Pushes IP, jumps to my_subroutine
  1. A.CALL
  2. B.JMP
  3. C.RET
  4. D.MOV
Q65❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
The `CALL` instruction takes a subroutine name or label as its __________, and program execution branches to that label.
💻 assembly Snippet
call my_subroutine ; 'my_subroutine' label is passed as operand argument
  1. A.argument
  2. B.Label
  3. C.Text
  4. D.Register
Q66❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
When the __________ instruction is encountered inside a subroutine, it pops the saved return address from the stack and transfers execution back to the instruction immediately following the `CALL`.
💻 assembly Snippet
ret ; Pops saved return address into IP
  1. A.CALL
  2. B.RET
  3. C.AND
  4. D.XOR
Q67❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
Which pair of instructions is commonly used together for subroutine control flow, although technically each operates independently?
💻 assembly Snippet
call sub_routine ; Subroutine invocation
... 
sub_routine:
  ; procedure code
  ret            ; Subroutine return
  1. A.RET and ADC
  2. B.CALL and SBB
  3. C.CALL and RET
  4. D.ADC and SBB
Q68❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
The `CALL` mechanism breaks the linear thread of execution and preserves general registers, modifying only the __________ (and Stack Pointer SP).
💻 assembly Snippet
call target ; Modifies IP to target offset and SP (pushes return address)
  1. A.SI
  2. B.IP
  3. C.DI
  4. D.SP
Q69❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
In computer science, a stack is a linear __________ that operates in a First-In, Last-Out (FILO) or Last-In, First-Out (LIFO) manner.
  1. A.Program
  2. B.data structure
  3. C.Heap
  4. D.None of the Given
Q70❓ MCQ📑 Lec 5Easy🔁RepeatedHigh-Yield💡Conceptual
If the __________ instruction is not available, clearing stack arguments by the callee subroutine becomes a complicated and inefficient process.
💻 assembly Snippet
ret 4 ; Pops 2-byte return IP, then adds 4 to SP to discard 2 word parameters
  1. A.CALL
  2. B.SBB
  3. C.RET n
  4. D.None of the Given