Jason Hyman's Homepage

COMPUTER SIMULATOR



This is a simulator for a very basic computer.  This project was done for my computer architecture class (CP SC 231).  I have made some modifications to the original to make it more presentable here.  Namely, the original was not an applet.  The input to the program came from a text file.  The output of the program was a printout of the registers after each instruction.

To make the program a little more interesting, I have put a friendly face on the engine.  As such, the register contents are now displayed on the applet.  Also, a neat feature is that you can type in a program and the applet will step through (or run the whole thing at once) the program that you typed in.

Of course, you need to know the architecture and the instruction codes.  They are as follows.

Registers

Register/Number of Bits

AR/12
PC/12
DR/16
AC/16
INPR/8
IR/16
TR/16
OUTR/8

Instruction codes

Hex Code/Symbol/Description

0xxx/AND/AND memory word at cell xxx to AC
1xxx/ADD/ADD memory word at cell xxx to AC
2xxx/LDA/Load memory word at cell xxx to AC
3xxx/STA/Store content of AC in memory at xxx
4xxx/BUN/Brach unconditionally to xxx
5xxx/BSA/Branch and save return address to xxx
6xxx/ISZ/Increment memory word at xxx and skip next instruction if increment results in zero
(8-E)xxx=(1-6)xxx except xxx is now the address of target instead of the actual target
7800/CLA/Clear AC
7400/CLE/Clear E
7200/CMA/Complement AC
7100/CME/Complement E
7080/CIR/Circulate AC and E (into AC high) right
7040/CIL/Circulate AC and E (into AC low) left
7020/INC/Increment AC
7010/SPA/Skip next instruction ifAC>0
7008/SNA/Skip next instruction ifAC<0
7004/SZA/Skip next instruction if AC=0
7002/SZE/Skip next instruction if E=0
7001/HLT/Halt simulation
F800/INP/Input character to AC
F400/OUT/Output character from AC
F200/SKI/Skip on input flag
F100/SKO/Skip on output flag
F080/ION/Interrupt on
F040/IOF/Interrupt off

Program structure

When entering a program in the applet, use the following template.

(PC Startup value)
ORG (define memory start loc)
(memory word)
(memory word)
...
ORG (define memory start loc)
(memory word)
(memory word)
...

Example Program - Adding two numbers

The following program is annotated.  Italicized text should not be entered.

200 ORG of first instruction to be executed
ORG 100 Following should be put in memory loc 100
C3A9 This word is in memory loc 100
0011 This word is in memory loc 101
ORG 200 Following should be put in memory loc 200
2100 This word is in memory loc 200 (first instruction)
1101 This word is in memory loc 201
7001 This word is in memory loc 202 (halt command)

The first line says that the first instruction is at memory word 200.  Program starts with the instruction at memory location 200, 2100 = load accumulator with value in memory location 100 (AC = C3A9).  The next instruction (at memory location 201) is 1101 = add memory data at cell 101 to accumulator (AC = C3A9 + 0011 = C3BA).  The last instruction (at memory cell 202) is 7001 = halt.

Applet follows (may take some time to load):



Last updated: 8/9/2005
Send comments to me here.
Copyright 2005 Jason Hyman
Version 2.0