Computers and Processors: Reference Manual
Computers and Processors: Reference Manual
Important
You will be required to take this reference manual into the T224
examination with you, and when you do so it must be free of all
notes and/or highlighting. Therefore do not write in it or highlight
anything while you are studying the course.
Section 1: The simulated processor 5
1.1 Overview
The simulated processor has a load–store, Harvard architecture.
It is essentially a 16-bit machine, in that all the general-purpose registers
are 16-bit, as are the data and address buses to data memory and the
address bus to program memory. The exception is the data bus between
the processor and program memory, which is 24 bits wide because the
instruction codes are all 24-bit.
It uses memory-mapped input–output.
It offers a two-level interrupt-handling facility.
1.2 Registers
The simulated processor has 17 registers (see Figure 1):
l 14 general-purpose registers, each 16 bits wide
l 1 instruction pointer (IP), 16 bits wide
l 1 stack pointer (SP), 16 bits wide
l 1 status register, 16 bits wide but only the least-significant 4 bits
are used.
16 bits
r1
r2
r3
r4
r5
r6
14 general-purpose r7
registers
r8
r9
rA
rB
rC
rD
rE
instruction pointer IP
status register
4 bits
000000 no-op
010R1R2R3 OR register
020R1R2R3 add register
030R1R2R3 subtract register
040R1R2R3 AND register
05000R complement register
06000R shift left register
07000R shift right register
250R00 push register
26000R pop register
2A00R1R2 copy register
2E00R1R2 load register-indirect
2F0R1R20 store register-indirect
81nnnn jump absolute
82nnnn jump relative
83nnnn jump if negative relative
84nnnn jump if zero relative
85nnnn call absolute
860000 return
870000 return from interrupt
880000 stop
9Rnnnn OR immediate
ARnnnn add immediate
BRnnnn subtract immediate
CRnnnn AND immediate
DRnnnn load immediate
ERnnnn load direct
FRnnnn store direct
Section 1: The simulated processor 9
add immediate
Hexadecimal instruction code
ARnnnn
l Add the value nnnn to the contents of Register rR and put the result
in Register rR.
l Set the zero flag if the result is 0; otherwise clear the zero flag.
l Set the negative flag if the most-significant bit of the result is 1;
otherwise clear the negative flag.
add register
Hexadecimal instruction code
020R1R2R3
l Add the contents of Register rR1 to the contents of Register rR2 and
put the result in Register rR3 (it is permissible for R3 to be the same as
R1 or R2).
l Set the zero flag if the result is 0; otherwise clear the zero flag.
l Set the negative flag if the most-significant bit of the result is 1;
otherwise clear the negative flag.
AND immediate
Hexadecimal instruction code
CRnnnn
l Perform an AND operation between the value nnnn and the contents
of Register rR and put the result in Register rR.
l Set the zero flag if the result is 0; otherwise clear the zero flag.
l Set the negative flag if the most-significant bit of the result is 1;
otherwise clear the negative flag.
10 Computers and processors: Reference manual
AND register
Hexadecimal instruction code
040R1R2R3
call absolute
Hexadecimal instruction code
85nnnn
complement register
Hexadecimal instruction code
05000R
copy register
Hexadecimal instruction code
2A00R1R2
jump absolute
Hexadecimal instruction code
81nnnn
Actions
If the zero flag is set to 1
l Increase the instruction pointer’s contents by 1.
l Add nnnn to the incremented contents of the instruction pointer and
put the result in the instruction pointer.
l Do not change the zero or negative flags.
jump relative
Hexadecimal instruction code
82nnnn
load direct
Hexadecimal instruction code
ERnnnn
load immediate
Hexadecimal instruction code
DRnnnn
load register-indirect
Hexadecimal instruction code
2E00R1R2
no-op
Hexadecimal instruction code
000000
OR immediate
Hexadecimal instruction code
9Rnnnn
OR register
Hexadecimal instruction code
010R1R2R3
pop register
Hexadecimal instruction code
26000R
push register
Hexadecimal instruction code
250R00
return
Hexadecimal instruction code
860000
l Shift the contents of register rR one bit to the left (towards the most-
significant bit); fill the least-significant bit with 0.
l Set the zero flag if the result is 0; otherwise clear the zero flag.
l Set the negative flag if the most-significant bit of the result is 1;
otherwise clear the negative flag.
l Shift the contents of register rR one bit to the right (towards the least-
significant bit); fill the most-significant bit with 0.
l Set the zero flag if the result is 0; otherwise clear the zero flag.
l Clear the negative flag.
16 Computers and processors: Reference manual
stop
Hexadecimal instruction code
880000
store direct
Hexadecimal instruction code
FRnnnn
store register-indirect
Hexadecimal instruction code
2F0R1R20
subtract immediate
Hexadecimal instruction code
BRnnnn
subtract register
Hexadecimal instruction code
030R1R2R3
l Subtract the contents of Register rR1 from the contents of Register rR2
and put the result in Register rR3 (it is permissible for R3 to be the
same as R1 or R2).
l Set the zero flag if the result is 0; otherwise clear the zero flag.
l Set the negative flag if the most-significant bit of the result is 1;
otherwise clear the negative flag.
3 Input–output associated
with the simulated
processor
The input–output facilities are available only in the extended version of
the simulated processor.
3.1 Overview
In the simulation, the processor is implemented with the following input
devices:
l a bank of 8 switches
l a ‘scalepan’ input
l an interrupt button
Data register
Memory-mapped address 0F13.
Only the least-significant eight bits are used, with the least-significant bit
corresponding to the rightmost switch.
1 corresponds to ‘on’ and 0 to ‘off’.
Status register
Memory-mapped address 0F14.
The least-significant bit is set to 1 when an interrupt (see below) has
occurred.
Interrupt facility
This facility can be switched on (activated) or switched off, using the
‘properties’ tab. The default setting is off.
When the interrupt facility is on, an interrupt is caused when any one of
the switches changes its state.
Using the ‘properties’ tab, the switch bank’s input can be set up to cause
an interrupt on either Interrupt 1 or Interrupt 2. The default setting for
the interrupt facility is Interrupt 1.
When an interrupt occurs, the status register is set to 0001.
Scalepan (input)
By selecting the ‘hardware’ tab for this device, the user can duplicate the
effects of placing different weights in the scalepan by clicking with the
mouse to move the scalepan up or down.
Data register
Memory-mapped address 0F11.
The contents are set to the digital equivalent of the vertical position of
the scalepan, with 0000 corresponding to the highest position.
In 3-bit mode (see below) the three least-significant bits of the data
register are used; in 8-bit mode the eight least-significant bits are used.
Status register
Memory-mapped address 0F12.
The least-significant bit is set to 1 when an interrupt (see below) has
occurred.
Interrupt facility
This facility can be switched on (activated) or switched off, using the
‘properties’ tab. The default setting is off.
22 Computers and processors: Reference manual
Status register
Memory-mapped address 0F10.
When an interrupt occurs, the status register is set to 0001.
Data register
Memory-mapped address 0F06.
Only the least-significant eight bits are used, with the least-significant bit
corresponding to the rightmost LED.
1 corresponds to ‘on’ and 0 to ‘off’.
Leading zeros are inserted for hexadecimal displays, but not for denary
ones. The error message ‘Err’ is displayed if denary mode has been
chosen and the binary number in the data register is greater than denary
9999.
Data register
Memory-mapped address 0F04.
Buzzer (output)
This device buzzes when the least-significant bit of its data register is set
to 1. It is silent when the least-significant bit of its data register is cleared
to 0. There is also an associated on-screen graphic.
Data register
Memory-mapped address 0F05.
Data register
Memory-mapped address 0F07.
Only the least-significant eight bits are used, so only values from 0000 to
00FF can be displayed correctly (higher values are displayed as if they
were 00FF).
24 Computers and processors: Reference manual
4 The simulation
environment
IP field
The leftmost field of the window, IP, shows a c symbol alongside the
address corresponding to the instruction pointer’s contents. By double-
clicking in this field alongside a different address, the user can move the
highlight and also change the instruction pointer’s contents to that
address.
Instruction field
The rightmost field of the window, Instruction, shows the instruction
corresponding to the adjacent instruction code in the Contents field. The
user can change this instruction by first double-clicking on the instruction
Section 4: The simulation environment 25
already present and then either single-clicking on items in the drop down
menus (using the t symbol to open the menus where necessary) or
typing in a hexadecimal number, as appropriate. A double-click will
terminate the entry at any time.
The instructions can be edited using the cut, copy and paste facilities in
the Edit menu.
Single instructions or blocks of instructions can be deleted by first
highlighting the instruction or instructions and then cutting. No-op
instructions replace the cut instructions.
Single instructions can be moved from one location to another by first
highlighting the instruction, then cutting, then clicking on the line where
the instruction is to go, then pasting.
Blocks of instructions can be moved by first highlighting them, then
cutting, then clicking on the first line where the instructions are to go,
then pasting.
Individual instructions or blocks of instructions can also be copied and
pasted elsewhere in program memory.
All instructions can be simultaneously changed to no-ops by selecting
Reset from the Options menu and then selecting Program memory. This
action clears the contents of all locations in program memory to 000000.
Run button
By clicking on the Run button at the bottom of the window, the user
causes the simulated processor to execute instructions, starting with the
one in the location whose address is in the instruction pointer. While the
processor is running in this way, the Run button becomes a Stop button
and clicking on this button stops the processor.
Step button
By clicking on the Step button at the bottom of the window, the user
causes the simulated processor to execute the instruction in the location
whose address is in the instruction pointer.
Trace button
By clicking on the Trace button at the bottom of the window, the user causes
the simulated processor to execute instructions, starting with the one in the
location whose address is in the instruction pointer. This execution is
sufficiently slow that the user can follow what is happening, and the trace
speed can be set to Fast, Medium or Slow from the Options menu. The
default is Fast. While the processor is tracing in this way, the Trace button
becomes a Stop button and clicking on this button stops the processor.
Go to IP button
Clicking on the Go to IP button at the bottom of the window causes the
Program editor window to scroll to show a block of program memory
which includes the location whose address is currently in the instruction
pointer.
26 Computers and processors: Reference manual
Go to button
Clicking on the Go to button at the bottom of the window opens a
dialogue box which prompts the user to enter an address in program
memory; the Program editor window then scrolls to show the contents of
locations at and near that address.
Figure 4 The Program Clicking on the Go to button at the bottom of the window opens a
memory window dialogue box which prompts the user to enter an address in program
memory; the Program memory window then scrolls to show that address.
Figure 5 The Registers window: (a) in the basic simulated processor; (b) in the
extended simulated processor
The default contents of all locations in data memory are 0000. The user
can return the contents of all locations to this default value by selecting
Reset from the Options menu and then selecting Data memory.
The user can alter the contents of any location in data memory by
double-clicking in the Contents field alongside the address of that
location and then entering the new contents and pressing Enter.
The contents can be edited using the cut, copy and paste facilities in the
Edit menu.
Blocks of data can be deleted by first highlighting them in the Contents
field and then cutting. The contents of these locations become 0000.
Blocks of data can be moved by first highlighting them in the Contents
field, then cutting, then clicking in the Contents field alongside the first
address which is to hold the data block, then pasting.
Data can also be copied and pasted elsewhere in program memory. Figure 6 The Data
memory window
Clicking on the Go to button at the bottom of the window opens a
dialogue box which prompts the user to enter an address in data
memory; the Data memory window then scrolls to show that address.
Open
This allows the user to open an existing file, which will contain a
program and associated data memory contents and register contents.
28 Computers and processors: Reference manual
The default sub-folder the first time the Open command is chosen is the
CT programs sub-folder. This sub-folder will have been created as part of
the software installation process and resides within the hierarchy of
folders My Documents\T224\Simulated processor\ unless stipulated
otherwise by the user during the installation process. CT programs
remains the default sub-folder for the Open command until the user
opens a program from another sub-folder.
When the new program and data are loaded, any previous instructions,
data values and register contents which the user may have been working
with are lost. Hence the user is prompted, where necessary, to save any
work before the new program is loaded.
Merge
This brings in a program from a specified file and appends it to the
program already in the program memory and shown in the Program
editor window. If the new program and the existing program have
instructions in the same locations(s) in program memory, the instructions
in the new program will overwrite the instructions in the existing
program in those locations.
Merge also brings in any associated data and appends it to the data
already in the data memory. If the new program and the existing
program have associated data in the same locations(s) in data memory,
the data associated with the new program will overwrite the data
associated with the existing program in those locations.
The registers are not affected by the Merge command.
If appropriate, the user is prompted to save any work before the new
program is merged.
Save
If a program was retrieved from the CT programs sub-folder, it is
necessary to use the Save As option to save it to another folder (thus
preventing programs supplied by the course team from being
overwritten).
Otherwise, Save saves the program and associated data memory contents
and register contents with the same file name as the file from which they
were retrieved, thus over-writing the previously saved version of the
program, data memory and register contents.
Save As
This opens a dialogue box so that the user can enter the new file name
and/or choose a new folder. The default sub-folder the first time the
command is chosen is My programs, which will be in My
Documents\T224\Simulated processor\ unless stipulated otherwise by
the user during the installation process. Save As then saves the program
and associated data memory contents and register contents.
Save As does not allow files to be saved to the CT programs sub-folder.
Section 4: The simulation environment 29
Save workspace
This allows the user to save the current size and window arrangement of
the simulated processor screen. These then become the default.
Print
This allows the user to print the contents either of the currently
highlighted window or of all windows. Except in the case of the registers,
it does not print out any details for locations whose contents are zero.
When ‘print all’ is selected, the contents of the Program memory window
are not printed, as this would duplicate what is shown in the contents of
the Program editor window.
Exit
This closes the simulation program. If appropriate, it prompts the user to
save the current program first.
Cut
This allows highlighted instructions in the Program editor or highlighted
contents in the Data memory to be cut.
Copy
This allows highlighted instructions in the Program editor or highlighted
contents in the Data memory to be copied.
Paste
This allows cut or copied instructions from the Program editor to be
inserted where the user clicks. In the case of a block of instructions, the
block will be inserted such that the first instruction goes where the user
clicks.
Paste also allows cut or copied contents in the Data memory to be
inserted where the user clicks. In the case of a block of data, the block
will be inserted such that the first data item goes where the user clicks.
Reset
This allows the user to reset any of: Data memory; Program memory;
Registers. In the extended version of the simulation it also allows the user
to reset the Interrupt system. All of these can also be reset
simultaneously. The user is asked to confirm the reset before it is
implemented.
Reset returns the chosen entity to the state it has when the simulation is
first opened.
Input devices
This allows the user to open Scalepan, Switch bank or Interrupt button.
It is possible to have more than one copy of the windows for these
devices open simultaneously.
Output devices
This allows the user to open LED bank, Analogue gauge, Simple
7-segment display, Smart 7-segment display or Buzzer.
It is possible to have more than one copy of the windows for these
devices open simultaneously.
ASCII
; 011 1011 3B 59
< 011 1100 3C 60
= 011 1101 3D 61
> 011 1110 3E 62
? 011 1111 3F 63
@ 100 0000 40 64
A 100 0001 41 65
B 100 0010 42 66
C 100 0011 43 67
D 100 0100 44 68
E 100 0101 45 69
F 100 0110 46 70
G 100 0111 47 71
H 100 1000 48 72
I 100 1001 49 73
J 100 1010 4A 74
K 100 1011 4B 75
L 100 1100 4C 76
M 100 1101 4D 77
N 100 1110 4E 78
O 100 1111 4F 79
P 101 0000 50 80
Q 101 0001 51 81
R 101 0010 52 82
S 101 0011 53 83
T 101 0100 54 84
U 101 0101 55 85
V 101 0110 56 86
W 101 0111 57 87
X 101 1000 58 88
Y 101 1001 59 89
Z 101 1010 5A 90
[ 101 1011 5B 91
\ 101 1100 5C 92
] 101 1101 5D 93
^ 101 1110 5E 94
_ 101 1111 5F 95
‘ 110 0000 60 96
Appendix: ASCII codes 33
a 110 0001 61 97
b 110 0010 62 98
c 110 0011 63 99
d 110 0100 64 100
e 110 0101 65 101
f 110 0110 66 102
g 110 0111 67 103
h 110 1000 68 104
i 110 1001 69 105
j 110 1010 6A 106
k 110 1011 6B 107
l 110 1100 6C 108
m 110 1101 6D 109
n 110 1110 6E 110
o 110 1111 6F 111
p 111 0000 70 112
q 111 0001 71 113
r 111 0010 72 114
s 111 0011 73 115
t 111 0100 74 116
u 111 0101 75 117
v 111 0110 76 118
w 111 0111 77 119
x 111 1000 78 120
y 111 1001 79 121
z 111 1010 7A 122
{ 111 1011 7B 123
|
| 111 1100 7C 124
} 111 1101 7D 125
~ 111 1110 7E 126
delete 111 1111 7F 127
Course team list
Academic staff
Bernie Clark, Production Course Chair
Geoff Einon
David Gorham, Presentation Course Chair
Reza Latif-Shabgahi
Mike Meade
Tony Nixon
Adrian Poulton
Richard Seaton
Mirabelle Walker
Production staff
Deirdre Bethune, Course Secretary
Colin Bluck, Project Officer
Philippa Broadbent, Buyer, Materials Procurement
Roger Courthold, Graphic Artist
Sarah Crompton, Graphic Designer
Daphne Cross, Assistant Buyer, Materials Procurement
Tony Duggan, Learning Projects Manager
Joanne Fellows, QA Engineer
Alison George, Project Manager
David Gosnell, Software Designer
Roger Harris, Production Course Manager
Lori Johnston, Editor
Karen Lemmon, Compositor
Deborah Mairs, Presentation Course Manager
Jane Moore, Editor
Jon Owen, Graphic Artist
Val Price, Rights Executive
Colin Thomas, Software Designer