# One Instruction Set Computer

This single instruction computer design and simulator was put together by Peter Crampton, one of my Computer Science students at Drexel University. It is a classic subtract and branch if negative design. Some of the design details and the simulator are based on the CARDIAC (CARDboard Illustrative Aid to Computation) produced by Bell Labs in the late '60s.

## Architecture

### Memory

This OISC is a decimal machine. There are 100 memory locations, each of which hold a signed 6-digit decimal number. Thus, all memory addresses are exactly two digits. Memory location 99 holds the fixed value 0, which is interpreted as a halt. So jumping to location 99 halts the CPU. Memory location 98 is used for I/O as described below.

### Instructions

Each instruction of the OISC consists of three two-digit fields. The most sigificant field contains the address of the source operand, the middle field contains the address of the destination operand, and the least significant field contains a branch target address. Informally, the instruction results in the source and destination operands being fectched, the difference of the destination and source being computed, and the result being stored in the destination location. If the result of the subtraction is negative, execution continues at the branch target address. Otherwise, it continues with the next memory location.

### CPU

The CPU of the OISC consists of an instruction pointer (IP), an instruction register (IR), a subtractor, and a fixed sequencer. In the following, we denote the instruction value in the IR as i and the source address is given by s =⌊i /10000⌋, the destination address is given by d =⌊i /100⌋ mod 100, and the branch target address is give by t =i mod 100. With this notation and two temporary registers O1 and O2, we can describe the sequencer operation as follows:

1. IR ← Mem[IP]
2. If IR = 0 Halt
3. IP ← IP + 1
4. O1 ← Mem[s ]
5. O2 ← Mem[d ]
6. Mem[d] ← O2 − O1
7. If O2 − O1 < 0 IP ← t

### I/O

OISC has memory-mapped I/O devices. Any value stored to location 98 is written to the output. The current version of the simulator does not yet support input via location 98.

## Examples

The following are examples that Peter wrote to demonstrate the capabilities of his design and simulator.

### Adds the Numbers 1 - 5:

```00 		919008
01 		928802
02 		888900
03 		888804
04 		978805
05 		880100
06 		888807
07 		101000
08 		898809
09 		889899
10 		000000
89 		000000
90 		000006
91 		000001
92 		000001
93 		000002
94 		000003
95 		000004
96 		000005
97 		010000
```

### Print Multiples of a Specific Number Using Division:

```00 	929301	; Add one to the current number
01 	939002
02  	939303	; Make sure we clear the "anti-counter"

03  	908904	; Copy the original number so we don't lose it
04  	898805
05  	898906

06  	919008	; Check if the number is less than or equal to 0, if it is jump to 10
07  	979706	; Otherwise keep doing the opertion

08  	908920	; We have to figure out whether the number was 0 or < 0

09  	898910	; Clear the "anti-number"
10  	888911 	; Copy back the original number
11  	909012
12  	899013

13  	888814	; Clear everything and begin the loop again
14  	898915
15  	979700

20  	888921	; By getting here we know the number was 0, meaning perfect divison
21  	899822	; We want to print the number
22  	899023

23  	898924	; Clear everything and begin the loop again
24 	888825
25 	979700

90 	Starting Number
91 	Divisor
92 	0000001
```

Brian L. Stuart, Drexel University