A | B | C | D | E | F | G | H | CH | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
Designer | Digital Equipment Corporation |
---|---|
Bits | 16-bit |
Introduced | 1970 |
Design | CISC |
Type | Register–register Register–memory Memory–memory |
Encoding | Variable (2 to 6 bytes) |
Branching | Condition code |
Endianness | Mixed (little-endian for 16-bit integers) |
Extensions | EIS, FIS, FPP, CIS |
Open | No |
Successor | VAX |
Registers | |
General-purpose | 8 × 16-bit |
Floating point | 6 × 64-bit floating-point registers if FPP present |
The PDP-11 architecture[1] is a 16-bit CISC instruction set architecture (ISA) developed by Digital Equipment Corporation (DEC). It is implemented by central processing units (CPUs) and microprocessors used in PDP-11 minicomputers. It was in wide use during the 1970s, but was eventually overshadowed by the more powerful VAX architecture in the 1980s.
Memory
Data formats
The smallest unit of addressable and writable memory is the 8-bit byte. Bytes can also be held in the lower half of registers R0 through R5.
16-bit words are stored little-endian with least significant bytes at the lower address. Words are always aligned to even memory addresses. Words can be held in registers R0 through R7.
32-bit double words in the Extended Instruction Set (EIS) can only be stored in register pairs with the lower word being stored in the lower-numbered register. Double words are used by the MUL, DIV, and ASHC instructions. Other 32-bit data are supported as extensions to the basic architecture: floating point in the FPU Instruction Set or long data in the Commercial Instruction Set are stored in more than one format, including an unusual middle-endian format[2][3] sometimes referred to as "PDP-endian."
A 64-bit double precision floating point format is supported by the floating point processor option (FPP) for 11/45 and most subsequent models.
Memory management
The PDP-11's 16-bit addresses can address 64 KB. By the time the PDP-11 yielded to the VAX, 8-bit bytes and hexadecimal notation were becoming standard in the industry; however, numeric values on the PDP-11 always use octal notation, and the amount of memory attached to a PDP-11 is always stated as a number of words. The basic logical address space is 32K words, but the high 4K of physical address space (addresses 1600008 through 1777778 in the absence of memory management) are not populated because input/output registers on the bus respond to addresses in that range. So originally, a fully expanded PDP-11 had 28K words, or 56 kbytes in modern terms.
The processor reserves low memory addresses for two-word vectors that give a program counter and processor status word with which to begin a service routine. When an I/O device interrupts a program, it places the address of its vector on the bus to indicate which service routine should take control. The lowest vectors are service routines to handle various types of trap. Traps occur on some program errors, such as an attempt to execute an undefined instruction; and also when the program executes an instruction such as BPT, EMT, IOT, or TRAP to request service from the operating system.
Memory expansion
During the life of the PDP-11, the 16-bit logical address space became an increasing limitation. Various techniques were used to work around it:
- Later-model PDP-11 processors include memory management to support virtual addressing. The physical address space was extended to 18 or 22 bits, hence allowing up to 256 KB or 4 MB of RAM. The logical address space (that is, the address space available at any moment without changing the memory mapping table) remains limited to 16 bits.
- Some models, beginning with the PDP-11/45, can be set to use 32K words (64 KB) as the "instruction space" for program code and a separate 32K words of "data space". Some operating systems—notably Unix since edition V7, and RSX11-M+—rely on this feature.
- Programming techniques, such as overlaying a block of stored instructions or data with another as needed, can conceal paging issues from the application programmer. For example, the Modula-2 compiler produces code under which the run-time system swaps 8 Kb pages into memory as individual procedures receive control.[4]
CPU registers
|
The CPU contains eight general-purpose 16-bit registers (R0 to R7). Register R7 is the program counter (PC). Although any register can be used as a stack pointer, R6 is the stack pointer (SP) used for hardware interrupts and traps. R5 is often used to point to the current procedure call frame. To speed up context switching, some PDP-11 models provide dual R0-R5 register sets. Kernel, Supervisor (where present), and User modes have separate memory maps, and also separate stack pointers (so that a user program cannot cause the system to malfunction by storing an invalid value in the stack pointer register).
Addressing modes
Most instructions allocate six bits to specify an operand. Three bits select one of eight addressing modes, and three bits select a general register.
The encoding of the six bit operand addressing mode is as follows:
5 | 3 | 2 | 0 | ||
Mode | Register |
In the following sections, each item includes an example of how the operand would be written in assembly language. Rn means one of the eight registers, written R0 through R7.
General register addressing modes
The following eight modes can be applied to any general register. Their effects when applied to R6 (the stack pointer, SP) and R7 (the program counter, PC) are set out separately in the following sections.
Code | Name | Example | Description |
---|---|---|---|
0n | Register | Rn | The operand is in Rn |
1n | Register deferred | (Rn) | Rn contains the address of the operand |
2n | Autoincrement | (Rn)+ | Rn contains the address of the operand, then increment Rn |
3n | Autoincrement deferred | @(Rn)+ | Rn contains the address of the address of the operand, then increment Rn by 2 |
4n | Autodecrement | −(Rn) | Decrement Rn, then use the result as the address of the operand |
5n | Autodecrement deferred | @−(Rn) | Decrement Rn by 2, then use the result as the address of the address of the operand |
6n | Index | X(Rn) | Rn+X is the address of the operand |
7n | Index deferred | @X(Rn) | Rn+X is the address of the address of the operand |
In index and index deferred modes, X is a 16-bit value taken from a second word of the instruction. In double-operand instructions, both operands can use these modes. Such instructions are three words long.
Autoincrement and autodecrement operations on a register are by 1 in byte instructions, by 2 in word instructions, and by 2 whenever a deferred mode is used, since the quantity the register addresses is a (word) pointer.
Program counter addressing modes
When R7 (the program counter) is specified, four of the addressing modes naturally yield useful effects:
Code | Name | Example | Description |
---|---|---|---|
27 | Immediate | #n | The operand is the next word of the instruction |
37 | Absolute | @#a | The address of the operand is the next word of the instruction |
67 | Relative | a | The address of the operand is the next word of the instruction added to the PC |
77 | Relative deferred | @a | The address of the address of the operand is the next word of the instruction added to PC |
The only common use of absolute mode, whose syntax combines immediate and deferred mode, is to specify input/output registers, as the registers for each device have specific memory addresses. Relative mode has a simpler syntax and is more typical for referring to program variables and jump destinations. A program that uses relative mode (and relative deferred mode) exclusively for internal references is position-independent; it contains no assumptions about its own location, so it can be loaded into an arbitrary memory location, or even moved, with no need for its addresses to be adjusted to reflect its location (relocated). In computing such addresses relative to the current location, the processor performed relocation on the fly.
Immediate and absolute modes are merely autoincrement and autoincrement deferred mode, respectively, applied to PC. When the auxiliary word is "in the instruction" as the above table says, the PC for the next instruction is automatically incremented past the auxiliary word. As PC always points to words, the autoincrement operation is always by 2.
Stack addressing modes
R6, also written SP, is used as a hardware stack for traps and interrupts. A convention enforced by the set of modes the PDP-11 provides is that a stack grows downward—toward lower addresses—as items are pushed onto it. When a mode is applied to SP, or to any register the programmer elects to use as a software stack, the addressing modes have the following effects:
Code | Name | Example | Description |
---|---|---|---|
16 | Deferred | (SP) | The operand is on the top of the stack |
26 | Autoincrement | (SP)+ | The operand is on the top of the stack, then pop it off |
36 | Autoincrement deferred | @(SP)+ | A pointer to the operand is on top of the stack; pop the pointer off |
46 | Autodecrement | −(SP) | Push a value onto the stack |
66 | Indexed | X(SP) | This refers to any item on the stack by its positive distance from the top |
76 | Indexed deferred | @X(SP) | This refers to a value to which a pointer is at the specified location on the stack |
Although software stacks can contain bytes, SP is always a stack of words. Autoincrement and autodecrement operations on SP is always by 2.
Instruction set
The PDP-11 operates on bytes and words. Bytes are specified by a register number—identifying the register's low-order byte—or by a memory location. Words are specified by a register number or by the memory location of the low-order byte, which must be an even number. In most instructions that take operands, bit 15 is set to specify byte addressing, or clear to specify word addressing. In the lists in the following two sections, the assembly-language programmer appended B to the instruction symbol to specify a byte operation; for example, MOV became MOVB.
A few instructions, for example MARK and SOB, were not implemented on some PDP-11 models.
Double-operand instructions
The high-order four bits specify the operation to be performed (with bit 15 generally selecting word versus byte addressing). Two groups of six bits specify the source operand addressing mode and the destination operand addressing mode, as defined above.
15 | 12 | 11 | 9 | 8 | 6 | 5 | 3 | 2 | 0 | ||||||
Opcode | Src | Register | Dest | Register |
Opcode | Mnemonic | Operation |
---|---|---|
01 | MOV | Move: Dest ← Src
Note: Moving byte to a register sign-extends into bits 8-15 |
11 | MOVB | |
02 | CMP | Compare: Set-flags(Src − Dest)
|
12 | CMPB | |
03 | BIT | Bit test: Set-flags(Src ∧ Dest)
|
13 | BITB | |
04 | BIC | Bit clear: Dest ← Dest ∧ Ones-complement(Src)
|
14 | BICB | |
05 | BIS | Bit set: Dest ← Dest ∨ Src
|
15 | BISB | |
06 | ADD | Add: Dest ← Dest + Src
|
16 | SUB | Subtract: Dest ← Dest − Src
|
The ADD and SUB instructions use word addressing, and have no byte-oriented variations.
Some two-operand instructions utilize an addressing mode operand and an additional register operand: