Note 4/20/17: Due to circumstances I have had to move my web pages here.

One Instruction Computers - How Low Can You Go?

  • Download the simulator and macros

    Features:

    All files and programs are copyright 1996 by Eugene Styer. They may be distributed freely, but modifications are not allowed without permission.

    Things I'd like to add:

    Machines:

    Six machines have been defined. They range from the easy to use with powerful operations, to the extremely ackward, but all are capable of running 'normal' programs with suitable macros. To see these machines in action, I will mention how to increment a word. Assume 'temp' is a temporary location, and the words 'zero' and 'one' and 'negone' are memory locations holding the constants with the values 0, 1 and -1 respectively.
    Subtract and Branch on Negative
    This machine takes instructions of the form "A B C D", with them meaning "Read A, Subtract B, Store in C, and Branch to D if negative". The branch occurs result is (or should be except for overflow) less than 0. This machine is very easy to work with, and the flexibility of the multiple operands tends to produce fast programs.
    
    		x negone x next		; x+1 = x-(-1)
    next				; might be negative
    
    
    Subtract
    This machine takes the basic two-operand subtract instruction, and builds the entire machine around it. The instruction is "A B", with the meaning "Read B, Subtract A, and store in B". Branches are done by subtracting the proper value from the PC. Conditional branches are generally done by calculating an offset into a lookup table, and subtracting that from the Program Counter (PC).
    
    		negone x		; subtract -1 (== +1)
    
    
    Reverse Subtract and Skip on Borrow
    This is one of the more interesting machines. This machine includes an accumulator, and each instruction has the single address. The instruction "A" has the following meaning: "Read A, Calculate A - Acc, store this in both A and Acc, and skip the next instruction if the subtraction resulted in a borrow. Even simple operations like move turn out not to be since skips may not occur where we want them.
    
    		temp			; clear working space
    		temp
    		temp
    		negone			; get -1
    		x			; do increment, allow for skip
    		temp			; allow for various skip patterns
    		temp
    		temp
    
    
    Byte Move with 16-bit addresses and byte-addressable memory
    Something that seems to be too simple to work, this machine takes instructions of the form "A B" and moves the byte at A to B. This machine depends heavily on self-modifying code and about 11K of lookup tables. Most operations turn out to be straightforward if a bit tedious. Most arithmetic operations require splitting each byte into halves for the operation, then combining them to get the final result. One exception is jumps - since only one byte of the PC can be changed at a time. Changing the high byte of the PC doesn't change the low byte (although that might be a useful modification), so the first 12 bytes of each 256-byte page (all addresses ..00 through ..0b) are reserved for handling jumps. Then a jump from XXYY to AABB occurs as follows: First AABB is stored in a known location. Then the program jumps to XX04, which changes the high byte to get to AA08 (PC is incremented as the instruction is read). Then AA08 does the rest of the jump to AABB. If AA and XX are the same, BB can be simply copied to the PC.
    
    		x+1 a+1			; get low byte
    	a	inc x+1			; increment and store
    		a+1 b+1			; check for carry
    	b	inccy c			; get address of increment/identity table
    		x c+1			; get top byte
    	c	0 x			; handle carry, store
    
    
    Byte Move with 24-bit addresses and byte-addressable memory
    The basic "A B" instruction is the same, but the larger addresses allow bytes to be the basic unit of operation. Only the bottom 64K (000000 to 00FEFF) is available for programs and data, but higher addresses (E80000 to FFFFFF) are used for the larger lookup tables required. Jumps are also implemented differently. The jump part of the ALU (see below) is used to implement jumps. A jump writes the high part of the (64K) address to 00FF38, and the low byte to 00FF39. This latter write causes a jump to occur to the specified location.
    		d+1 a+1			; get low byte of x
    	a	add+1 d+1		; increment, store
    		a+1 b+1			; get low byte of x
    	b	addcy+1 c		; determine carry if any
    		d c+1			; get high byte of x
    	c	0 d			; process carry, store
    
    
    Word Move with memory-mapped ALU
    This machine has instructions of the form "A B", but moves an entire 16-bit word each time. This machine also takes full advantage of the ALU to assist with all instructions. Because of this, programs are usually the shortest and fastest, although subtract and branch on negative is very competitive. This form of the move machine does not require byte-addressable memory.
    		x ALU_RegA		; copy number
    		one ALU_RegB		; and value 1
    		ALU_Add x		; add, put back
    
    

    It should be noted that with the exception of Word Move, none of the machines has any requirement for 'magic' locations except for the program counter and ordinary memory-mapped I/O devices (although Byte Move 24-bit uses some, those are for convience and not necessity). This is in contrast to some Move machine designs that use special addresses for addition, subtraction, etc. (write A to 0010, B to 0020, read A+B from 0030).

    Return to my home page

    Send Mail