Csa Lab 1
Csa Lab 1
Csa Lab 1
College of Engineering
CpE Department
Computer Systems Architecture
College of Engineering
Experiment No. 1
Programming Model 1
Remarks
I. OBJECTIVES
PC
CPU OS Simulator
III. DEFINITION
The programming model of computer architecture defines those low‐level architectural
components, which include the following
CPU instruction set
CPU registers
Different ways of addressing instructions and data in instructions It also defines
interaction between the above components. It is this low‐level programming model
which makes programmed computations possible.
Simulator Details
This section includes some basic information on the simulator, which should enable the students to use
the simulator. The tutor(s) will be available to help anyone experiencing difficulty in using the
simulator. The simulator for this lab is an application running on a PC running MS Windows
operating system.
The main window is composed of several views, which represent different functional parts of the
simulated processor. These are shown in Image 1 below and are composed of
Experiment No.1:
Program Model 1 2
ENGR. CYD LAURENCE B. SANTOS
University of Perpetual Help System Dalta
College of Engineering
CpE Department
Computer Systems Architecture
Experiment No.1:
Program Model 1 3
ENGR. CYD LAURENCE B. SANTOS
University of Perpetual Help System Dalta
College of Engineering
CpE Department
Computer Systems Architecture
Experiment No.1:
Program Model 1 4
ENGR. CYD LAURENCE B. SANTOS
University of Perpetual Help System Dalta
College of Engineering
CpE Department
Computer Systems Architecture
Experiment No.1:
Program Model 1 5
ENGR. CYD LAURENCE B. SANTOS
University of Perpetual Help System Dalta
College of Engineering
CpE Department
Computer Systems Architecture
Experiment No.1:
Program Model 1 6
ENGR. CYD LAURENCE B. SANTOS
University of Perpetual Help System Dalta
College of Engineering
CpE Department
Computer Systems Architecture
Experiment No.1:
Program Model 1 7
ENGR. CYD LAURENCE B. SANTOS
University of Perpetual Help System Dalta
College of Engineering
CpE Department
Computer Systems Architecture
Experiment No.1:
Program Model 1 8
ENGR. CYD LAURENCE B. SANTOS
University of Perpetual Help System Dalta
College of Engineering
CpE Department
Computer Systems Architecture
Experiment No.1:
Program Model 1 9
ENGR. CYD LAURENCE B. SANTOS
University of Perpetual Help System Dalta
College of Engineering
CpE Department
Computer Systems Architecture
Experiment No.1:
Program Model 1 10
ENGR. CYD LAURENCE B. SANTOS
University of Perpetual Help System Dalta
College of Engineering
CpE Department
Computer Systems Architecture
IV. ACTIVITY
2. Execute the above instruction (to do this simply double click on it in the Instruction Memory View).
Observe the result in the CPU Registers view (Image 4).
Experiment No.1:
Program Model 1 11
ENGR. CYD LAURENCE B. SANTOS
University of Perpetual Help System Dalta
College of Engineering
CpE Department
Computer Systems Architecture
7. Execute it.
8. Observe which register the result is put in.
Experiment No.1:
Program Model 1 13
ENGR. CYD LAURENCE B. SANTOS
University of Perpetual Help System Dalta
College of Engineering
CpE Department
Computer Systems Architecture
9. Create an instruction, which pushes the above result to the top of the hardware stack, and then
execute it.
Experiment No.1:
Program Model 1 14
ENGR. CYD LAURENCE B. SANTOS
University of Perpetual Help System Dalta
College of Engineering
CpE Department
Computer Systems Architecture
10. Create an instruction to push number ‐2 on top of the stack and execute it. Observe the value in
Program Stack (Image 5).
11. Observe the value in the SP register (Special CPU Registers view – Image 3). Whenever you push
a value on Program Stack, the SP register is updated.
Experiment No.1:
Program Model 1 15
ENGR. CYD LAURENCE B. SANTOS
University of Perpetual Help System Dalta
College of Engineering
CpE Department
Computer Systems Architecture
12. Create an instruction to compare the values in registers R00 and R01.
13. Execute it.
14. Observe the value in the SR register (Special CPU Registers view – Image 3).
15. Observe the status of the OV/Z/N parts of the status register. Which boxes are checked and which
are not? What do they indicate?
18. Observe the value in the PC register. This is the address of the next instruction to be executed.
Make a note of which instruction it is pointing to?
19. Observe the values in the PAdd and LAdd columns. What do these values indicate? Are they
different (Hint: Check out the Base Address value)?
20. What is the difference between the LAdd value of the first instruction and the LAdd value of the
second instruction? What does this value indicate (Hint: Think of the instruction lengths in bytes)?
21. Create an instruction to pop the value on top of the Program Stack into register R02.
Experiment No.1:
Program Model 1 17
ENGR. CYD LAURENCE B. SANTOS
University of Perpetual Help System Dalta
College of Engineering
CpE Department
Computer Systems Architecture
24. Create an instruction to pop the value on top of the Program Stack into register R03.
25. Execute it.
26. Observe the value in the SP register.
Experiment No.1:
Program Model 1 18
ENGR. CYD LAURENCE B. SANTOS
University of Perpetual Help System Dalta
College of Engineering
CpE Department
Computer Systems Architecture
31. Which of the status flags OV/Z/N is set (i.e. box is checked)? Why?
32. Manually insert a value in register R05 greater than that in register R04.
33. Execute the compare instruction in step 28 above.
34. Which of the status flags OV/Z/N is set? Why?
Experiment No.1:
Program Model 1 20
ENGR. CYD LAURENCE B. SANTOS
University of Perpetual Help System Dalta
College of Engineering
CpE Department
Computer Systems Architecture
35. Manually insert a value in register R04 greater than that in register R05.
36. Execute the compare instruction in step 28 above.
37. Which of the status flags OV/Z/N is set? Why?
Experiment No.1:
Program Model 1 21
ENGR. CYD LAURENCE B. SANTOS
University of Perpetual Help System Dalta
College of Engineering
CpE Department
Computer Systems Architecture
38. Create an instruction, which will jump to the first instruction if the values in registers R04 and R05
are equal.
39. Test the above instruction by manually putting equal values in registers R04 and R05, then first
executing the compare instruction followed by executing the jump instruction (Remember: You execute
an instruction by double‐clicking on it). Did it work?
Experiment No.1:
Program Model 1 22
ENGR. CYD LAURENCE B. SANTOS
University of Perpetual Help System Dalta
College of Engineering
CpE Department
Computer Systems Architecture
40. Save the instructions in the Instruction Memory View in a file by clicking on the SAVE… button
(Image 7).
V. OBSERVATION
This activity shows the basic instructions of the CPU simulator, like MOV which allows to
move data to a register, ADD which adds the value of registers and the value will show in the
destination operand, There is compare that Compares register to one another, Push that
Experiment No.1:
Program Model 1 23
ENGR. CYD LAURENCE B. SANTOS
University of Perpetual Help System Dalta
College of Engineering
CpE Department
Computer Systems Architecture
stacks the given value to another register and it also shows the top of the stack and the bellow
of the stack. There is pop instruction that reduces the program stack and can also lead to a
stack underflow. There is a Jump instruction that allows you to jump unconditionally or it can
only allow you when there are certain condition are met when comparing the previous
comparison instruction. Also there must always a halt instruction at the end of the address to
indicate the end of the program. There are status flag that will be checked if certain register
is equal, greater than, or has a carry when the instruction is executed.
VI. CONCLUSION
The CPU simulator is interactive computer simulation package in which the user specifies the
details of the CPU to be simulated, including the register set, memory, the microinstruction
set, machine instruction set, and assembly language instructions. This simulator helps us to
have a better understanding with how the instructions of a program is being executed with it
from a different perspective aside from lines of code. This allows us to manipulate and
experiment on different control, data transferring, arithmetic, logical, etc… instructions
within our ability and to also understand it in a simpler way. CPU simulator though it doesn’t
show the whole process of how a cpu works it is a nice simulator to have a better look to the
computer architecture.
Experiment No.1:
Program Model 1 24
ENGR. CYD LAURENCE B. SANTOS