Professional Documents
Culture Documents
OBJECTIVES
At the end of this laboratory exercise, you should be able to:
I. MATERIALS NEEDED
DESCRIPTION QUANTITY
Laptop 1
CPU-OS Simulator 1
II. ACTIVITIES
1. Save your work at regular intervals.
2. The CPU simulator is work in progress so it may crash from time to time. If
this happens then restart it and load your latest code.
3. The simulator is there to help you understand the theory covered in lectures
so make the most of it.
Learning objective: To enter CPU instructions and describe effect of compare instruction on
CPU status flags Z and N.
In theory In practice
The CPU instruction sets are often 1. Enter the following code and run it:
grouped together into categories
containing instructions with related MOV #1, R01
functions. MOV #2, R02
ADD R01, R02
This exercise familiarizes you with the
way the instructions are entered using 2. Add the following code and note the states of the status
the simulator. flags Z and N after each compare instruction is executed:
Learning objective: To construct a loop and explain jump instructions that use Z and N flags
In theory In practice
The computer programs often contain 4. Add the following code and run it (ask your tutor how to
loops where the same sequence of code enter a label):
is repeatedly executed until or while
certain condition is met. Loops (or MOV #0, R01
Label1
iterative statements) are the most useful
ADD #1, R01
features of programming languages.
CMP #3, R01
At the instruction level, loops use JLT $Label1
conditional jump instructions to jump
back to the start of the loop or to jump Summarize what the above code is doing in plain
out of the loop. English:
This exercise introduces an indirect Make a note of what you see in the program’s data area:
method of accessing memory. This is
called register indirect addressing. There
is also the memory indirect addressing Explain the significance of @ in @R03 above:
but this is left as an exercise for you.
Arithmetic instructions
ADD Add number to register; add register to register
e.g.
ADD #3, R02 adds number 3 to contents of register R02 and stores the
result in register R02.
ADD R00, R01 adds contents of register R00 to contents of register R01
and stores the result in register R01.
CAL Jump to subroutine address (saves the return address on program stack)
This instruction is used in conjunction with the MSF instruction. You’ll need
an MSF instruction before the CAL instruction. See the example above
Comparison instruction
CMP Compare number with register; compare register with register
e.g.
CMP #5, R02 compare number 5 with the contents of register R02
CMP R01, R03 compare the contents of registers R01 and R03
Note:
If R01 = R03 then the status flag Z will be set, i.e. the Z box is checked. If
R03 > R01 then non of the status flags will be set, i.e. none of the status
flag boxes are checked.
If R01 > R03 then the status flag N will be set, i.e. the N status box is
checked.
Source:
http://en.freedownloadmanager.org/Windows-PC/CPU-OS-Simulator-
FREE.html
http://www.teach-sim.com/
http://softdeluxe.com/CPU-OS-Simulator-1264697/download/