Question: Programming Model 3 Introduction Objectives At the end of this lab you should be able to: Explain how common program variables are stored Distinguish between
Programming Model
Introduction
Objectives
At the end of this lab you should be able to:
Explain how common program variables are stored
Distinguish between different types of highlevel program
statements
Understand lowlevel code corresponding to program
statements
Explain how program subroutines work
Use the simulator to create user interrupts
Processor CPU Simulators
The computer architecture tutorials are supported by simulators, which
are created to underpin theoretical concepts normally covered during
the lectures. The simulators provide visual and animated
representation of mechanisms involved and enable the students to
observe the hidden inner workings of systems, which would be difficult
or impossible to do otherwise. The added advantage of using
simulators is that they allow the students to experiment and explore
different technological aspects of systems without having to install and
configure the real systems.
Basic Theory
Highlevel language HLL programs are made of variables holding
data values and multiple program statements as algorithms. These
statements often control the flow of program execution under certain
conditions. Calls to subroutines and interrupts all change the sequential
flow of a program execution without which feature programs would not
do any useful work.
Simulator Details
This section includes some basic information on the simulator, which
should enable the students to use the simulator. The tutors will be
available to help anyone experiencing difficulty in using the simulator.
The simulator for this lab is an application running on a PC and is
composed of multiple windows.
Image Main simulator window
The main window shown in Image is composed of several subviews, which
represent different functional parts of the simulated processor. For this lab
session we are interested only in the compiler part of the simulator.
In order to access the compiler, click on the
COMPILER... button as shown in Image
on the right. The compiler window shown in
Image below will show.
Image Advanced functions
Image The main compiler window
In the compiler window there are three main subwindows
Program Source all highlevel source statements appear here.
Compiler Progress information on the progress of a compilation
appear here.
Program Code assembly code generated by the compiler appear
here.
Lab Exercises Investigate and Explore
The lab exercises are a series of experiments, which are attempted by
the students under guidelines. The students are expected to carry out
further investigations on their own in order to form a better
understanding of the technology.
Now, have a go at the following activities:
Enter the following source code and compile it
program Test
var IntVar integer
var BoolVar boolean
var StrVar string
var StrVar string
IntVar
BoolVar true
StrVar "Hello"
StrVar "And again"
end
Now click on the SYMBOL TABLE... button. The Symbol Table
window will show. Observe the kind of information kept in the symbol
table. Make a note of the type, size and address fields for each of the
entries in the table.
Next, load the compiled program in memory. In the CPU simulator
window click on the SHOW PROG MEMORY... button. The contents of
the program data memory will show. Make sure it stays on top. Then
run the program at maximum speed. Observe the contents of the
memory paying attention to the address locations you noted before.
Enter the following source statements
Program Test
n
i n
p i
writeln n n i i p p
end
Compile the above program. Now observe the code generated in the
PROGRAM CODE window. You dont need to analyse it in detail.
However, count the number of jump instructions ie those that start
with a letter J and note this down. Can you tell what kind of program
statements this program is using?
Enter the following source statements
Program Test
n
if n then
p p
end if
end
Compile the above program. Now observe the code generated. How
many jump instructions are there? What do you think is the purpose of
the jump instruction in this code? What kind of a statement is an if
statement?
Enter the following source statements
program Test
p
for n to
p p
next
end
Compile the above program. Now observe the code generated. How
many jump instructions are there? What do you think is the purpose of
each of the jump instructions in this code? What kind of a statement is
a for statement? Can you think of another statement of this kind you
can give an example from any programming language you are familiar
with
Enter the following source statements
Program Test
sub One
writelnI am sub One
end sub
sub Two
call One
writelnI am sub Two
end sub
call Two
End
Compile the above program. Next, load the compiled program in
memory. In the CPU simulator window click on the SHO
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
