CPU Sim is a software development environment for the simulation of simple computers. It was developed by Dale Skrien to help students understand computer architectures. With this application the user is able to simulate new or existing simple CPUs. Users can create new virtual CPUs with custom machine language instructions, which are implemented by a sequence of micro instructions. CPU Sim allows the user to edit and run assembly language programs for the CPU being simulated.
CPU Sim has been programmed using the Java Swing package. This means that it is platform independent (runs on every platform that has a Java virtual machine installed).
A sample computer system, the Wombat 1, is provided with CPU Sim. It has the following registers:
The assembly language of the Wombat 1 computer consists of 12 instructions. Each instruction is stored on 16 bits; the first 4 are the opcode and the other 12 are the address field.
CPU Sim has the following features:
This program reads in integers until a negative integer is read. It then outputs the sum of all the positive integers.
Start: read // read n -> accjmpn Done // jump to Done if acc < 0.add sum // add sum to the accstore sum // store the new sumjump Start // go back & read in next numberDone: load sum // load the final sumwrite // write the final sumstop // stopsum: .data 2 0 // 2-byte location where sum is stored
The following modification of the program is also used sometimes:
Start: read // read n -> accjmpz Done // jump to Done if nacc is 0.add sum // add sum to the accstore sum // store the new sumjump Start // go back & read in next numberDone: load sum // load the final sumwrite // write the final sumstop // stopsum: .data 2 0 // 2-byte location where sum is stored
This one can use negative input to subtract, or 0 to break the loop.