Search code examples
assemblypdp-11

PDP-11 assembler: how do "single operand instructions" work


I'm trying to understand PDP-11 assembly. For that I'm going through this document.

The PDP-11 has several sets of instruction-types. One being single operand instructions, an other is double operand instructions. A double operand instructions would be for example:

MOV   @(R0)+,R1

...which (if I understood it correctly) picks the data from the memory pointed to by R0, then increments R0 and then stores the data it got from memory into R1.

But what about single operand instructions? E.g.:

INC  @(R0)+

What will happen? Will it:

  1. retrieve the value pointed to by R0
  2. increase R0
  3. increase the value
  4. store the result into the new address pointed to by R0?
  5. increase R0 again?

or is 2 skipped or is 5 skipped?


Solution

  • This manual contains an example of INC -(R0) in §3.3.3 that clarifies that the increment/decrement happens once before/after the main operation of the instruction:

    3.3.3 Autodecrement Mode

    ...

    Autodecrement Mode Examples

    1. Symbolic: INC -(R0), Octal code: 005240, Instruction Name: Increment

      Operation: The contents of R0 are decremented by two and used as the address of the operand. The operand is increased by one.

    2. Symbolic: INCB -(R0), Octal code: 105240, Instruction Name: Increment

      Operation: The contents of R0 are decremented by one and used as the address of the operand. The operand is increased by one.