Simulation

The following are the operations for the Simple Computer and the one-digit operation codes:
2 Subtract
3 Copy from memory to accumulator
4 Store from Accumulator to memory
5 Transfer on negative
6 Read one number from tape
7 Print one number
8 Halt
In the three-address version, the operations "Copy" and "Store" are not required.

To illustrate programming for the Simple Computer we give three documented programs, one for each version, for reading two arbitrary numbers and calculating and printing the maximum. In the comments parentheses will be used to represent the contents of any location in memory, and, for example, "(12)" represents the contents of location "12". In the one-address and two-address versions the accumulator is represented by "A" and its contents by "(A)".
 ``` 00 600 Read x 01 412 x -> 12 02 600 Read y 03 413 y -> 13 04 212 y - x -> A 05 509 Trans. if (A) < 0 06 313 y -> A 07 700 Print y 08 800 Halt 09 312 x -> A 10 700 Print y 11 800 Halt ``` One-address    Simple Computer ``` 00 60007 Read x 01 60008 Read y 02 21203 y - x -> A 03 50904 Trans. if x < y 04 31305 y -> A 05 70006 Print max. 06 80000 Halt 07 41201 x -> 12 08 41302 y -> 13 09 31205 x -> A ``` Two-address    Simple Computer ``` 00 6000012 Read x 01 6000013 Read y 02 5121305 Trans. if x < y 03 7000012 Print x 04 8000000 Halt 05 7000013 Print y 06 8000000 Halt ``` Three-address    Simple Computer
The following are the test calculations for the One-address Simple Computer:

```
SC1max=: 600 412 600 413 212 509 313 700 800 312 700 800
T=: 5 9
SC1 SC1max
PR
9
T=: 15 _6
SC1 SC1max
PR
15
T=: 12 12
SC1 SC1max
PR
12
```

The only purpose of the simulator is to enable a few simple examples to be tested and run. Usually only those commands necessary to run the sample program described in the next section have been implemented. There has been no attempt to simulate either the logic or the binary arithmetic operaions of any computer that is being considered.

The simulator has been written in J, an array language to be discussed in the section Array Languages later in the paper. Although it is not necessary to know anything about either J or the details of the simulator to appreciate the examples, a few remarks about the implementation of the simulator will be given here for the interested reader. Each simulation requires two text or "script" files. The first one, common to all simulations, is called abc.ijs for "A Basic Computer" and describes the overall structure of the simulator and allows for the command-by-command decoding and execution of a program. The second gives the address structure of the programming language of a particular simulation, the amount of memory, and the definition of the implemented operations. The secondary simulators for the three versions of the Simple Computer are given in the script files SC1.ijs, SC2.ijs, and SC3.ijs, respectively.