113k views
3 votes
Assembly Lang Prog/Comp Org Submit your code solution in .asm files. Please also submit a screenshot showing that you ran the code inside Visual Studio. Suppose you wanted a subroutine to return to an address that was 3 bytes higher in memory than the return address currently on the stack. Write a sequence of instructions that would be inserted just before the subroutine’s RET instruction that accomplish this task

User Cookandy
by
6.9k points

1 Answer

5 votes

Final answer:

To return to an address that is 3 bytes higher in memory than the current return address, we need to adjust the stack pointer accordingly by adding the value 3 to it before executing the RET instruction.

Step-by-step explanation:

In assembly language, when a subroutine is called, the return address is pushed onto the stack. To return to an address that is 3 bytes higher in memory than the current return address, we need to adjust the stack pointer accordingly. This can be done by adding the value 3 to the stack pointer before executing the RET instruction.

Here is a sequence of instructions that accomplishes this task: ADD SP, 3 ; Add 3 to the stack pointer, RET ; Return from the subroutine . By adding 3 to the stack pointer, we effectively move the return address higher in memory, allowing the subroutine to return to the desired address.

User Mark Maxey
by
8.9k points