PiDP-8/I Software

Changes To PDP-8 Memory Addressing
Log In

Changes to "PDP-8 Memory Addressing" between 2017-04-01 15:33:59 and 2017-04-01 15:41:03

55
56
57
58
59
60
61
62

63
64
65
66

67
68
69
70
71
72
73
74





75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90





91
92
93
94
95
96
97
55
56
57
58
59
60
61

62
63
64
65

66
67
68
69
70
71



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104







-
+



-
+





-
-
-
+
+
+
+
+
















+
+
+
+
+








For example, let's say you're currently executing in page 0 and need to jump to code that resides at address 234₈, which is in page 1.⁵ You could store the 12-bit value 0234₈ at address 0177₈, then do an indirect jump through page address 177₈.

PDP-8 programmers normally don't have to think too much about such things, even at the assembly language level, because the assembler automatically generates "links" when needed to cross field boundaries like this. Thus, the assembly code looks like a single instruction:

            JMP 0234

But in reality, this instruction takes two words of core memory: one for the indirect JMP instruction, and one for the link.
But in reality, this instruction takes two words of core memory: one for the indirect `JMP` instruction, and one for the link.

Since all those links chew into the 4 to 32 kW core limit of any given PDP-8 machine, one of the common games PDP-8 masters play is reusing *instruction* words for target address values and operands to save a word or two.  

PDP-8 master Rick Murphy taught me this one: If your program needs to return control to OS/8, its entry point is at address 7600, which happens to be the same as the “clear accumulator” instruction’s value, and most programs have at least one of those sitting around somewhere. Therefore, instead of saying
PDP-8 master Rick Murphy taught me one of these games. Instead of saying:

            JMP 7600

and taking a "link" penalty, you find a nearby CLA instruction, give it a label in the assembly code, and jump indirectly through that label:

OS8ENT, CLA          / CLA = 7600, the OS/8 entry point
        ...             / some number of other instructions, but less than a page worth
        JMP OS8ENT     / return control to OS/8
    OS8ENT, CLA          / CLA = 7600, the OS/8 entry point
            ...          / some number of other instructions, but less than a page worth
            JMP I OS8ENT / return control to OS/8

The `I` modifies the `JMP` instruction, telling the PDP-8 to load the value at the memory location referred to by the `OS8ENT` label, load up the value it finds there (7600₈) and jump to *that* address.

Barf bags are in the seat pocket ahead of you.

Once you've relieved yourself, please read on, because we're not done yet.


# Level 3: Instruction and Data Fields

By this point, you'll be wondering how a PDP-8 can be expanded beyond its stock 4 kW of core to its maximum of 32 kW, and why is that the limit anyway?

The answer to both questions is that the PDP-8 has a pair of 3-bit registers for setting the instruction field and the data field. 2³ = 8, and 8 fields × 4 kW = 32 kW.

Thus, when a program is currently executing code in field 0 but wants to address data in field 1, it sets the data field (DF) register to 1, and now all data fetches pull data from field 1. Likewise, to jump to an address in field 1 from field 0, it sets the instruction field (IF) register to 1. 

This is also why your PDP-8/I has two sets of 3 switches on the front and a set of indicator lights labeled "Data Field" and "Instruction Field." Together, this gives you a combined 15-bit extended address. A jump or fetch between fields thus takes two instructions, rather than the indirect addressing for in-field operations or the direct addressing of in-page operations. This gives a hierarchy of expense: a diligent PDP-8 programmer tries to keep data and instructions close together and logically bunched to avoid needless page and field transitions.


# Conclusion

I hope you've found that interesting an enlightening. If you would like more on this topic, the various versions of DEC's Small Computer Handbook for the PDP-8 cover this in more detail and take you beyond it, into actual programming of a PDP-8.


---------------------

**Footnotes and Digressions**

1. You sometimes see the term [octet](https://en.wikipedia.org/wiki/Octet_(computing)) to unambiguously refer to a group of 8 bits as a result.