Overview
The earliest PDP-8 model, informally known as a "Straight-8", was introduced on 22 March 1965 priced at $18,500 (). It usedArchitectural significance
The PDP-8 combines low cost, simplicity, expandability, and careful engineering for value. The greatest historical significance was that the PDP-8's low cost and high volume made a computer available to many new customers for many new uses. Its continuing significance is as a historical example of value-engineered computer design. The low complexity brought other costs. It made programming cumbersome, as is seen in the examples in this article and from the discussion of "pages" and "fields". Much of one's code performed the required mechanics, as opposed to setting out the algorithm. For example, subtracting a number involves computing its two's complement then adding it; writing a conditional jump involves writing a conditional skip around the jump, the skip coding the condition negative to the one desired. Some ambitious programming projects failed to fit in memory or developed design defects that could not be solved. For example, as notedDescription
The PDP-8 used ideas from several 12-bit predecessors, most notably theVersions of the PDP-8
The total sales figure for the PDP-8 family has been estimated at over 300,000 machines. The following models were manufactured:Latter-day implementations
The PDP-8 is readilyInput/output
The I/O systems underwent huge changes during the PDP-8 era. Early PDP-8 models use aProgramming facilities
Early PDP-8 systems were shipped with no pre-installed software; each time the PDP-8 was powered up, the user hand-entered instructions using a bank of 12 toggle switches. Typically, these instructions were aInstruction set
The three high-order bits of the 12-bit instruction word (labelled bits 0 through 2) are the operation code. For the six operations that refer to memory, bits 5 through 11 provide a 7-bit address. Bit 4, if set, says to complete the address using the 5 high-order bits of theBasic instructions
:000 – AND –IOT (Input-Output Transfer) instructions
The PDP-8 processor defined few of the IOT instructions, but simply provided a framework. Most IOT instructions were defined by the individual I/O devices. ; Device Bits 3 through 8 of an IOT instruction select an I/O device. Some of these device addresses are standardized by convention: *00 is handled by the processor and not sent to any I/O device (see below). *01 is usually the high-speed paper tape reader. *02 is the high-speed paper tape punch. *03 is the console keyboard (and any associated low-speed paper tape reader). *04 is the console printer (and any associated low-speed paper tape punch). Instructions for device 0 affect the processor as a whole. For example, ION (6001) enables interrupt processing, and IOFF (6002) disables it. ; Function Bits 9 through 11 of an IOT instruction select the function(s) the device performs. Simple devices (such as the paper tape reader and punch and the console keyboard and printer) use the bits in standard ways: *Bit 11 causes the processor to skip the next instruction if the I/O device is ready. *Bit 10 clears AC. *Bit 9 moves a word between AC and the device, initiates another I/O transfer, and clears the device's "ready" flag. These operations take place in a well-defined order that gives useful results if more than one bit is set. More complicated devices, such as disk drives, use these 3 bits in device-specific fashions. Typically, a device decodes the 3 bits to give 8 possible function codes.OPR (OPeRate)
Many operations are achieved using OPR, including most of the conditionals. OPR does not address a memory location; conditional execution is achieved by conditionally skipping one instruction, which is typically a JMP. The OPR instruction was said to be "microcoded." This did not mean what the word means today (that a lower-level program fetched and interpreted the OPR instruction), but meant that each bit of the instruction word specifies a certain action, and the programmer could achieve several actions in a single instruction cycle by setting multiple bits. In use, a programmer can write several instruction mnemonics alongside one another, and the assembler combines them with OR to devise the actual instruction word. Many I/O devices support "microcoded" IOT instructions. Microcoded actions take place in a well-defined sequence designed to maximize the utility of many combinations. The OPR instructions come in Groups. Bits 3, 8 and 11 identify the Group of an OPR instruction, so it is impossible to combine the microcoded actions from different groups.Group 1
00 01 02 03 04 05 06 07 08 09 10 11 ___________________________________ , 1, 1, 1, 0, , , , , , , , , , __, __, __, __, __, __, __, __, __, __, __, __, , CLA CMA RAR BSW CLL CML RAL IAC Execution order 1 1 2 2 4 4 4 3:7200 – CLA – Clear Accumulator :7100 – CLL – Clear the L Bit :7040 – CMA – Ones Complement Accumulator :7020 – CML – Complement L Bit :7001 – IAC – Increment
Group 2, Or Group
00 01 02 03 04 05 06 07 08 09 10 11 ___________________________________ , 1, 1, 1, 1, , , , , 0, , , 0, , __, __, __, __, __, __, __, __, __, __, __, __, , CLA SZA OSR SMA SNL HLT 2 1 1 1 3 3:7600 – CLA – Clear AC :7500 – SMA – Skip on AC < 0 (or group) :7440 – SZA – Skip on AC = 0 (or group) :7420 – SNL – Skip on L ≠ 0 (or group) :7404 – OSR – logically 'or' front-panel switches with AC :7402 – HLT – Halt When bit 8 is clear, a skip is performed if any of the specified conditions are true. For example, "SMA SZA", opcode 7540, skips if AC ≤ 0. A Group 2 OPR instruction that has none of the microprogrammed bits set is another No-Op instruction.
Group 2, And Group
00 01 02 03 04 05 06 07 08 09 10 11 ___________________________________ , 1, 1, 1, 1, , , , , 1, , , 0, , __, __, __, __, __, __, __, __, __, __, __, __, , CLA SNA OSR SPA SZL HLT 2 1 1 1 3 2:7410 – SKP – Skip Unconditionally :7610 – CLA – Clear AC :7510 – SPA – Skip on AC ≥ 0 (and group) :7450 – SNA – Skip on AC ≠ 0 (and group) :7430 – SZL – Skip on L = 0 (and group) When bit 8 is set, the Group 2, Or skip condition is inverted, via
Group 3
Unused bit combinations of OPR are defined as a third Group of microprogrammed actions mostly affecting the MQ (Multiplier/Quotient) register. The MQ register and the extended arithmetic element (EAE) instructions are optional and only exist when EAE option was purchased.00 01 02 03 04 05 06 07 08 09 10 11 ___________________________________ , 1, 1, 1, 1, , , , , , , , 1, , __, __, __, __, __, __, __, __, __, __, __, __, , CLA SCA \_ _/ , MQA MQL CODE 1* 2 2 2 3:7601 – CLA – Clear AC :7501 – MQA – Multiplier Quotient with AC (logical or MQ into AC) :7441 – SCA – Step counter load into AC :7421 – MQL – Multiplier Quotient Load (Transfer AC to MQ, clear AC) :7621 – CAM – CLA + MQL clears both AC and MQ. Typically CLA and MQA were combined to transfer MQ into AC. Another useful combination is MQA and MQL, to exchange the two registers. Three bits specified a multiply/divide instruction to perform: :7401 – No operation :7403 – SCL – Step Counter Load (immediate word follows, PDP-8/I and up) :7405 – MUY – Multiply :7407 – DVI – Divide :7411 – NMI – Normalize :7413 – SHL – Shift left (immediate word follows) :7415 – ASR – Arithmetic shift right :7417 – LSR – Logical shift right
Memory control
A 12-bit word can have 4,096 different values, and this is the maximum number of words the original PDP-8 can address indirectly through a word pointer. 4,096 12-bit words represent 6,144 bytes in modern terminology, or 6 kB. As programs became more complex and the price of memory fell, it became desirable to expand this limit. To maintain compatibility with pre-existing programs, new hardware outside the original design added high-order bits to the effective addresses generated by the program. The Memory Extension Controller expands the addressable memory by a factor of 8, to a total of 32,768 words. This expansion was thought sufficient because, with core memory then costing about 50 cents a word, a full 32K of memory would equal the cost of the CPU. Each 4K of memory is called a field. The Memory Extension Controller contains two three-bit registers: the DF (Data Field) and the IF (Instruction Field). These registers specify a field for each memory reference of the CPU, allowing a total of 15 bits of address. The IF register specifies the field for instruction fetches and direct memory references; the DF register specifies the field for indirect data accesses. A program running in one field can reference data in the same field by direct addressing, and reference data in another field by indirect addressing. A set of I/O instructions in the range 6200 through 6277 is handled by the Memory Extension Controller and give access to the DF and IF registers. The 62X1 instruction (CDF, Change Data Field) set the data field to X. Similarly 62X2 (CIF) set the instruction field, and 62X3 set both. Pre-existing programs would never execute CIF or CDF; the DF and IF registers would both point to the same field, a single field to which these programs were limited. The effect of the CIF instruction was deferred to coincide with the next JMP or JMS instruction, so that executing CIF would not cause a jump. It was more complicated for multiple-field programs to deal with field boundaries and the DF and IF registers than it would have been if they could simply generate 15-bit addresses, but the design provided backward compatibility and is consistent with the 12-bit architecture used throughout the PDP-8. Compare the laterExamples
The following examples show code in PDP-8Comparing two numbers
The following piece of code shows what is needed just to compare two numbers:/Compare numbers in memory at OPD1 and OPD2 CLA CLL /Must start with 0 in AC and link TAD OPD1 /Load first operand into AC (by adding it to 0); link is still clear CIA /Complement, then increment AC, negating it TAD OPD2 /AC now has OPD2-OPD1; if OPD2≥OPD1, sum overflows and link is set SZL /Skip if link is clear JMP OP2GT /Jump somewhere in the case that OPD2≥OPD1; /Otherwise, fall through to code below.As shown, much of the text of a typical PDP-8 program focuses not on the author's intended algorithm but on low-level mechanics. An additional readability problem is that in conditional jumps such as the one shown above, the conditional instruction (which skips around the JMP) highlights the opposite of the condition of interest.
String output
This complete PDP-8 assembly language program outputs "Hello, world!" to the teleprinter.*10 / Set current assembly origin to address 10, STPTR, STRNG-1 / An auto-increment register (one of eight at 10-17) *200 / Set current assembly origin to program text area HELLO, CLA CLL / Clear AC and Link again (needed when we loop back from tls) TAD I Z STPTR / Get next character, indirect via PRE-auto-increment address from the zero page SNA / Skip if non-zero (not end of string) HLT / Else halt on zero (end of string) TLS / Output the character in the AC to the teleprinter TSF / Skip if teleprinter ready for character JMP .-1 / Else jump back and try again JMP HELLO / Jump back for the next character STRNG, 310 / H 345 / e 354 / l 354 / l 357 / o 254 /, 240 / (space) 367 / w 357 / o 362 / r 354 / l 344 / d 241 / ! 0 / End of string $HELLO /DEFAULT TERMINATOR
Subroutines
The PDP-8 processor does not implement a*10 / Set current assembly origin to address 10, STPTR, STRNG-1 / An auto-increment register (one of eight at 10-17) *200 / Set assembly origin (load address) LOOP, TAD I STPTR / Pre-increment mem location 10, fetch indirect to get the next character of our message SNA / Skip on non-zero AC HLT / Else halt at end of message JMS OUT1 / Write out one character JMP LOOP / And loop back for more OUT1, 0 / Will be replaced by caller's updated PC TSF / Skip if printer ready JMP .-1 / Wait for flag TLS / Send the character in the AC CLA CLL / Clear AC and Link for next pass JMP I OUT1 / Return to caller STRNG, "H / A well-known message "e / "l / NOTE: "l / "o / Strings in PAL-8 and PAL-III were "sixbit" ", / To use ASCII, we spell it out, character by character " / "w / "o / "r / "l / "d / "! / 015 / 012 / 0 / Mark the end of our null-terminated string (.ASCIZ hadn't been invented yet!)The fact that the JMS instruction uses the word just before the code of the subroutine to deposit the
JUMPL, DCA TEMP / Deposit the accumulator in some temporary location TAD JUMPL+3 / Load the return address into the accumulator: hard coded JMP SUBRO / Go to the subroutine, and have it handle jumping back (to JUMPL+3)The use of the JMS instruction makes debugging difficult. If a programmer makes the mistake of having a subroutine call itself, directly or by an intermediate subroutine, then the return address for the outer call is destroyed by the return address of the subsequent call, leading to an infinite loop. If one module is coded with an incorrect or obsolete address for a subroutine, it would not just fail to execute the entire code sequence of the subroutine, it might modify a word of the subroutine's code, depositing a return address that the processor might interpret as an instruction during a subsequent correct call to the subroutine. Both types of error might become evident during the execution of code that was written correctly.
Software stack
Though the PDP-8 does not have a hardware*100 /make routines accessible for next example PUSH, 0 DCA DATA CLA CMA / -1 TAD SP DCA SP TAD DATA DCA I SP JMP I PUSH /Return POP, 0 CLA CLL TAD I SP ISZ SP JMP I POP DATA, 0 SP, 0And here is "Hello World" with this "stack" implemented, and "OUT" subroutine:
*200 MAIN, CLA CLL /Set the message pointer TAD (MESSG /To the beginning of the message (literal) DCA SP LOOP, JMS POP SNA /Stop execution if zero HLT JMS OUT /Otherwise, output a character JMP LOOP MESSG, "H "e "l "l "o ", " "w "o "r "l "d "! 015 012 0 OUT, 0 / Will be replaced by caller's updated PC TSF / Skip if printer ready JMP .-1 / Wait for flag TLS / Send the character in the AC CLA CLL / Clear AC and Link for next pass JMP I OUT / Return to caller
Linked list
Another possible subroutine for the PDP-8 is a linked list.GETN, 0 /Gets the number pointed to and moves the pointer CLA CLL /Clear accumulator TAD I PTR /Gets the number pointed to DCA TEMP /Save current value ISZ PTR /Increment pointer TAD I PTR /Get next address DCA PTR /Put in pointer JMP I GETN /return PTR, 0 TEMP, 0
Interrupts
There is a singleJMS
to location 0000. As it is difficult to write reentrant subroutines, it is difficult to nest interrupts and this is usually not done; each interrupt runs to completion and re-enables interrupts just before executing the JMP I 0
instruction that returns from the interrupt.
Because there is only a single interrupt line on the I/O bus, the occurrence of an interrupt does not inform the processor of the source of the interrupt. Instead, the interrupt service routine has to serially poll each active I/O device to see if it is the source. The code that does this is called a ''skip chain'' because it consists of a series of PDP-8 "test and skip if flag set" I/O instructions. (It was not unheard-of for a skip chain to reach its end without finding any device in need of service.) The relative interrupt priority of the I/O devices is determined by their position in the skip chain: If several devices interrupt, the device tested earlier in the skip chain is serviced first.
Books
An engineering textbook popular in the 1980s, ''The Art of Digital Design'' by David Winkel and Franklin Prosser, contains an example problem spanning several chapters in which the authors demonstrate the process of designing a computer that is compatible with the PDP-8/I. The function of every component is explained. Although it is not a production design, as it uses more modern SSI and MSI components and solid state rather than core memory, the exercise provides a detailed description of the computer's operation.Unlicensed clones
The USSR produced the minicomputers Saratov-1 and Saratov-2, which cloned the PDP-8 and PDP-8/E, respectively.References
*C.External links