Help Simulator
Help Simulator
Contents:
Computer Simulator general help
Using the Simulator
By Nicholas Duchon, copyright 2009-2017, v1 The Assembler
Menus and
This is the basic help file for the computer simulator. Commands
Features
This program is designed to simulate small computers appropriate for student Defining the
projects. Computer
RTL Instructions
Assembler
Instructions
Assembler (top)
There are a number of features of the assembler independent of the particular architecture being simulated:
sandsduchon.org/duchon/cs311/CompSim/helpSimulator.html 1/7
4/12/22, 2:26 AM HelpSimulator
File menu
Assembler - toggle displaying the assembler panel
New - to be implemented
Open - load a new computer definition, clearing the current one
Save - to be implemented
Save As ... - to be implemented
Print - to be implemented
Quit
Control
Run - after a machine language program has been loaded into memory and Reset, this will run
the program until a halt command is executed
Kill Run - tries to stop a runaway program, still being developed
Next Tick - executes the current FSM event
Next Instruction - executes the current instruction
Reset - sets the PC to value set by SETPCSTART and activates the Run, Kill Run, Next Tick
and Next Instruction buttons
Set Value - used to set the value of a register or a memory location
Clear Registers - sets the values in all the registers to 0
Clear Memory - sets the values of all the memory locations to 0
Load File - used to add to the current computer definition. Best use is to set registers and
memory locations
Load Asm - reads additional specifications for the assembler from a file
Dump - various information about the current computer
Help
About - general and copyright information
Simulator Help - this help file
Computer Help - a section of the computer definition file explaining some details about the
particular computer being simulated
Assembler Help - a section of the computer definition file explaining the features of the
assembly language for the particular computer being simulated
Main buttons
Load Program From Assembler - the machine code generated by the assembler, as shown in the
Machine Code text area, is transfered to the memory, and SETPCSTART gives the value of the
PC when Reset is pressed.
Reset - sets the PC to its initial value, and releases the simulator to start executing a program
Next T - executes the current FSM event (as the Next Tick menu selection)
Next I - executes the next instruction (as the Next Instruction menu selection)
Run - runs the program to a halt instruction (as the Run menu selection)
Kill - as the Kill menu selection
Set Value - as the Set Value menu selection
Clear Registers - as the Clear Registers menu selection
Clear Memory - as the Clear Memory menu selection
Load Program From File - as the Load Program From File menu selection
Dump - as the Dump menu selection
Assembler panel
Assemble - tries to assemble the text in the Source Code text area, results are displayed in the
Machine Code text area, and the symbol table is shown in the Assembler Messages area
Dump - various information about the assembler is shown in the Assembler Messages area
Central Panel
Input - type the input stream for a run of the program, byte/character oriented
Hex - the data in this display is interpretted as hex numbers. Use only 2 hex digits, and
spaces between bytes.
sandsduchon.org/duchon/cs311/CompSim/helpSimulator.html 2/7
4/12/22, 2:26 AM HelpSimulator
Features: (top)
Computer defined by a text file
Will simulate the operations of a computer defined as a finite state machine
Specifications look like a register transfer language
It will show the registers and memory, and update them as the simulator executes a machine language
program stored in the memory.
It can handle input and output as either ASCII or hex
It can assemble source code to machine code, and load the machine code into memory
By default, the simulator is set up to load the definitions of Mano's basic computer, which he describes in
Chapter 5 of Computer Systems Architecture, 3rd edition. Other computer definitions are possible, and may
be loaded from appropriate text files.
Syntax:
sandsduchon.org/duchon/cs311/CompSim/helpSimulator.html 3/7
4/12/22, 2:26 AM HelpSimulator
flag, name I
flag name <name> [, size <size (dec)>]
flag, name IEN, size 5
helpComputer
The keyword lines have not options. <html><body>
helpComputer If first characters are "<html>", then the lines in ComputerSimulator
This computer is defined in
endHelp between the two flags are handled as html, Computer System
otherwise as plain text. </body></html>
endHelp
helpAssembler
<html><body>
helpAssembler ComputerSimulator
As helpComputer This computer is defined in
endHelp Computer System
</body></html>
endHelp
Assembler
The keyword lines have no options. Example
endAssembler
RTLinstructions
The keyword lines have no options.
endInstructions
InstructionCycleStart The state code for the start of an instruction cycle InstructionCycleStart, 200
Thus, every state of the computer must have a unique index, which is pretty much up to the programmer
defining this configuration file.
The basic format for all RTL instructions is an index followed by some comma separated specifications.
Conditions: (top)
Conditions use the following format:
Operations: (top)
Addressing:
sandsduchon.org/duchon/cs311/CompSim/helpSimulator.html 5/7
4/12/22, 2:26 AM HelpSimulator
The RHS (right hand side) of an assignment expression may reference 0, 1, 2, or even more registers
or memory locations.
Example of 0, incrementing SC: SC ++
Example of 0, assigning a value (0) to IEN, R and SC:
22000, f 21000, t 2, PC ++, IEN 0, R 0, SC 0, n 100
Example of 1: PC < AR
Example of 2: AC < AC ALU_And DR
Example of 3: AC < AC ALU_Add DR E
Register references may include start bit and end bit references, as described in Conditions above.
Example: , I < IR 15, CODE < IR 12 14, AR < IR 0 11
Example: AC 0 7 < INPR
Ram references must be followed by a register whose value is used to compute the location in memory.
Example: M AR < DR
Example: DR < M AR
The code is set up to make it relatively easy to add more functions by creating new classes based on the
samples provided. This requires the source code and a Java programming environment. For addition
information, see the comments in the source code.
At the moment, the assembler will only support 0 and 1 address instructions, and will treat 2 address
instructions as a special case, indicating indirect addressing. All 1 address instructions use direct addressing.
If there is more than one machine code associated with a mnemonic, the program currently determines which
one to choose based on the field count defined by the format specification in this section of the file and by
the number of fields encountered in the assembly language program being processed.
sandsduchon.org/duchon/cs311/CompSim/helpSimulator.html 6/7
4/12/22, 2:26 AM HelpSimulator
The keywords the program recognizes at this time are "word" and "format". All other lines assume that a
mnemonic is being specified. For example:
sandsduchon.org/duchon/cs311/CompSim/helpSimulator.html 7/7