What does the command "MOV -(PC), -(PC)" do in PDP-11 assembly?
- User
What does the command "MOV -(PC), -(PC)" do in PDP-11 assembly?
Assistant
The MOV -(PC), -(PC) instruction in PDP-11 assembly is used to push the current program counter (PC) onto the stack. Here's a breakdown:
- -(PC) refers to the program counter pre-decremented. This decrements the PC by 2 bytes before using its value.
So this instruction does two things:
-
Decrements the PC by 2 bytes, then copies the new PC value into the address pointed to by the new decremented PC. This pushes the original PC onto the stack.
-
It then decrements the PC by 2 bytes again. So the PC is decremented a total of 4 bytes as a result of this instruction.
In summary, it pushes the current PC onto the stack, and then decrements the PC by 4 bytes in preparation for a subroutine call or interrupt. The effect is to save the return address on the stack and move the PC to the next instruction.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.