Previous       Table of Contents       Next

Simulation

In order to illustrate the nature of programming with some of the early computers, we have written a simulator which will allow simple programs to be tested and executed. This simulator, called here a "Simple Computer", has been suggested by the simple programming examples given in Chapter 6 of Hollingdale and Tootill's admirable little book Electronic Computers, now unfortunately outdated in many respects. We give one-address, two-address, and three-address versions of the computer. In the one-address version each command is of the form "Op Addr" giving the operation and the location in memory of the operand. In the two-address version each command is of the form "Op Addr1 Addr2", where the first address gives the location of the operand and the second the location of the next instruction. In the three-address version each command is of the form "Op Addr1 Addr2 Addr3" where the addresses give the locations of the three operands. The memory in all three versions has 50 locations with addresses 00, 01, 02, ..., 49.

The following are the operations for the Simple Computer and the one-digit operation codes:
     1 Add
     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.


Previous       Table of Contents       Next