Site Logo

Using the Simulator - Getting Started


Home | Previous | Next

User Interface Layout Image

On Line Help

Press the F1 key to get on line help.

Writing a Program

To write and run a program using the simulator, select the source code editor tab by pressing Alt+U.

Type in your program. It is best to get small parts of the program working rather than typing it all in at once.

Here is a simple example. Also look at the tutorial example programs. You can type this into the simulator or copy and paste it. The assembly code has been annotated with comments that explain the code. These comments are ignored by the assembler program. Comments begin with a semicolon and continue to the end of the line.

; ===== COUNT =================================================
	MOV	AL,0	; Move 0 into the AL register
REP:			; This label is used with jump commands
	ADD	AL,2	; Add two to AL
	JMP	REP	; Jump back to the rep label
	END		; Program ends here
; =============================================================


Running a Program

Step Button Image To run a program, you can step through it one line at a time by pressing Alt+P or by clicking this button repeatedly.
Run Button Image You can run a program continuously by pressing F9 or Alt+R or by pressing this button
Faster and Slower Button Images To speed up or slow down a running program use these buttons or type Alt+L or Alt+T
Stop Button Image To stop a running program press Alt+O or click or press Escape or press this button.
Continue Button Image To restart a paused program, continuing from where it left off, press Alt+N or click this button.
CPU Reset Button Image To restart a program from the beginning, reset the CPU by pressing Alt+E or click this button.
Show Ram Button Image To re-open the RAM display window, press Alt+M or click this button.


Assembly Code

Assemble Button Image
The code you type is called assembly code. This human-readable code is translated into machine code by the Assembler. The machine code (binary) is understood by the CPU. To assemble a program, press Alt+A or click this button.
Log Activity Button Image You can see an animation of the assembler process by checking this box.
Run Button Image
When you run or setp a program, if necessary, the code is assembled.


Assembler Phases

There is short delay while the assembbler goes through all the stages of assembling the program. The steps are

  1. Save the source code.
  2. Convert the source code into tokens (this simulator uses human readable tokens for educational value rather than efficiency).
  3. Parse the source code and (if necessary) generate error messages. If there are no errors, generate the machine codes. This process could be coded more efficiently. If the tokens representing machine op codes like MOV and JMP were numerical, the assembler could look up the machine code equivalents in an array instead of ploughing through many if-then-else statements. Once again, this has been done to demonstrate the process of assembling code for educational reasons.
  4. Calculate jumps, the distances of the jump/branch instructions.

Viewing Machine Code

The machine code stored in RAM can be viewed in three modes by selecting the appropriate radio button.

Ram Contents Image

Hexadecimal - This display corresponds exactly to the binary executed by the CPU.

ASCII - This display is convenient if your program is processing text. The text is readable but the machine codes are not.

Source Code - This display shows how the assembly code commands are placed in memory.

Tutorial Examples

The tutorial examples provide a step by step introduction to the commands and techniques of low level programming. Each program has one or more learning tasks associated with it. Some of the tasks are simple. Some are real brain teasers.

Home | Previous | Next

© C Neil Bauers 2003