HomePage | Recent changes | View source | Discuss this page | Page history | Log in |

Printable version | Disclaimers | Privacy policy

The PDP-8 was a 12-bit machine with 4096 words of memory. It had 8 instructions, and one register, the accumulator. It operated at a clock rate of 1MHz, and took (I think) 10 clocks for each instruction, so that it ran at 0.1MIP.

All operations were done to and from memory. [If I remember rightly...] The instructions were: SUB (subtract memory from the accumulator, borrowing the borrow bit) AND (logical AND from memory to the accumulator) JZ (jump to a memory address if the accumulator is zero) NOT (logical not of accumulator) SHR (shift accumulator right) CB (clear borrow) IN (get input from a port to the accumulator) OUT (put output from the accumulator to an output port)

The subtract instruction was guinely preferable to add, because loop counters could be more easily subtracted, and compared to zero.

To add two numbers, one first negates one, and adds 1 to it, making it the additive inverse of itself, then one subtracts it from the accumulator.

To get a left shift, add a number to itself.

To call a subroutine, one must jump to code that pushes and pops the stack.

It really is possible to write anything for this machine, but it is painful. The best method is to write a simple interpreter, and then write code in the interpreted language.