top | item 24821836

(no title)

drudru11 | 5 years ago

What does that mov do?

discuss

order

hazeii|5 years ago

The PC (R7 is the program counter on PDP-11's) would have been auto-incremented to point to the next word in memory, so the first -(PC) pre-decrements the PC with the result it points back to the instruction in memory. The contents of this location (the instruction itself) is read, and now the second -(PC) comes into play as the destination. The PC is again pre-decremented (so it now points to the word before the instruction) and the source operand (the instruction) is stored in this location.

In other words, the net effect is the instruction has been copied down 1 word in memory. Finally, because it's the PC that's in use and it's been decremented to point to the new copy of the instruction, the copy of the instruction is fetched and the operation repeats. So the instruction copies itself down in memory, until all memory below the starting point is filled with 014747; what happens next depends on the particular system, but generally not useful (the instruction was often used to check memory; key it in at the highest address, run it and then inspect memory to see if it has the same value everywhere).

As an aside, in octal this translates to 014747; 01 is the MOV, 4 is the pre-decrement mode and 7 indicates R7. Thus an assembler is barely needed on a PDP-11, because knowing the opcodes for the common instructions and the addressing modes makes it trivial to convert an assembly instruction like MOV #123,@#1000 into the octal 012737 000123 001000.

The bootstrap routines are often only a few lines of assembler, thus it was easy to remember, translate to octal on the fly and key them into the front panel switches with a few well-practiced sweeps across the toggle keys.