Systems Software Question
Systems Software Question
Programs written by the user for the purpose of solving particular problems
using a computer as a tool e.g. application packages.
Decode the instructions and use them to control the activities within the
system. It also performs the arithmetic and logical computations.
Stores both data and instructions that are currently being used.
Directive: Gives directions to the assembler during the assembly process but
they are not translated into machine code. e.g. the directive COST : DS 1
will causes the assembler to reserve a byte and associate a symbol COST to
it
Reserves memory and assigns a label to the first byte of the reserved area.
e.g. ARRAY: DS 20 reserves 20 bytes and assigns the label ARRAY to
the byte with the lowest address.
DB (Define Byte)
Puts values into or pre-assign values to memory locations as well as reserve
space and assign labels. e.g. DATA: DB 5 , puts a value 5 into a reserved
memory location called DATA.
DW (Define Word)
Puts words into or pre-assign values to memory locations as well as reserve
space and assign labels.
LDA ZERO
STA SUM
LDX SUM
LOOP: LDA SUM
ADD NUMS, X
STA SUM
LDA INDEX
ADD THREE
STA INDEX
COMP K300
JLT LOOP
INDEX RESW 1
RESULT RESW 1
SUM RESW 1
NUMS RESW 100
ZERO WORD 0
K300 WORD 300
(ii) LOCCTR
A Location Counter: used to help in the assignment of addresses. It is
initialized to the beginning address specified in the START statement.
After each source statement is processed the length of the assembled
instruction or data area to be generated is added to the LOCCTR.
(iii) OPTAB
Operation Code Table: used to look up and validate operation codes in
the source program. In pass 2 it is used to translate the opcodes to
machine language
(iv) LITTAB
Literal table: It contains the literal name, the operand value and the
address assigned to the literal
2. Given below is a program PROG that has been written using the SIC/XE
machine.
LDT NUM
LDA ALPHA
ADDR T, A
SUB #8
STA SUM1
LDA GAMMA
ADDR T,A
SUB #12
STA SUM2
ALPHA RESW 1
SUM1 RESW 1
GAMMA RESW 1
SUM2 RESW 1
NUM RESW1 1
(iii) Write the corresponding text listing for the generated machine
instructions.
H^ PROG ^000058^000028
T^000058^19^772022^032013^9050^1D0008^0F200E^03200E^9050^1D000C^0F2003
E^000058
3. (a) (i) What is program relocation?
Ability of a program to be able to run successfully in memory without
considering the address where it is going to be loaded.
2004
!! " # $ % #
#
System software are programs that control the operation of the machine and carry out the
most basic functions the computer performs. They control the way in which the computer
receives input, produces output, manages and stores data, carries out or executes
instructions of other programs etc. Examples of systems programs include language
processors (compilers and assemblers that accept people like languages and translate them
into machine language), loaders (they prepare machine language programs for execution),
macro processors (allow programmers to use abbreviations), operating systems and file
systems (allow flexible storing and retrieval of information).
Application programs are written by the user for the purpose of solving particular problems
using a computer as a tool e.g. application packages like MSWORD, EXCEL etc.
The microprocessor
• Decodes the instructions and use them to control the activities within the system
• Performs the arithmetic( + , -, /, *) and logical (>,>=,<,<=, =, =!) computations.
Timing Circuitry (Clock)
Used to synchronise the activities within the microprocessor and the bus control logic.
Memory
Stores both data and instructions that are currently being used. locations.
I/O Devices
Devices for communicating with the external world.
System Bus.
A set of conductors that connect the CPU to its memory and I/O devices. The bus conductors
are normally separated into 3 groups:
• The Data Lines: for transmitting information
• Address Lines: Indicate where information is to come from or where it is to be
placed.
• Control Lines: To regulate the activities on the bus.
Interface
Circuitry needed to connect the bus to a device
Working Registers
(i) Arithmetic Registers: They temporarily hold the operands and the result of the
arithmetic operations.
(ii) Address Registers: for addressing data and instructions in main memory.
Arithmetic/Logic Unit
It performs arithmetic and logical operations on the contents of the working registers, the
PC, memory locations etc.. It also sets and clears the appropriate flags.
The format of an instruction is the arrangement of the instruction with respect to assigning
meaning to its various groups of bits is called its format.
It consists of
Operation code: The portion of the instruction that specifies what the instruction
Operands: Any address or piece of data that is required by the instruction to complete its
execution
e.g.
Register to register transfer
0 1 0 0 0 1 1 1
6 11 1 11 1 12
Opcode n i x b p e displacement
6 11 1 11 1 20
Opcode n i x b p e address
S exponent fraction
# $ % &''&'' % ( % )* % ) $+ , + -+ +
.$$+ , $ % (9 " ' $$+ , # %' $ %'
+, $$+ / % '0 % '0 $ # % &&
1& 2 '3&& 2 && % +
" - , + :.
Opcode n i x b p e displacement
064050 = 000001 1 0 0 10 0 000001010000
TEST 2
(3 marks)
(iii) The SYMTAB
(3 marks)
(iv) The LOCCTR
(3 marks)
(iii) Write the object code for this program as it would appear on
an output device.
%&'# (&))))))&))))*+
&))))))&))))!,&-.)))$&*/))!+&)/))))&)$ )!0&!1 )$!&)2 )0+&,)0!& )
!/&$1"22)
+&))))))
(5 marks)
3. (a) What are literals?
3
4 5+ 25 $
3 + 2
(3 marks)
+6
. 7$ $
)!)))$
))! . 4 5+ 25 + 2
3
)$")!) + 2 ))".
(8 marks)
9
:
(3 marks)
. 7$ 3
(3 marks)
(6 marks)
(ii) Modify the program below so that it can run on a
machine that uses only direct addressing like the simple
SIC machine.
)))) '< # )
)))) 2# #+ .# !0))$$
)))- ' = >1 #.#+ 01")))
))) . +?( % ))))$-
))). ;' @+# "A))".
))!) =+B +?.2 $)))!
))!$ = >1 C##+ 01$)))
))!* = ' $ )))-
))! +?.2 . + 2 ))))"
))!. 1>22+# ) ))$,
))") . %#++ ))))$)
))"$ +?( % ) ))$-
))"- = >1 C##+ 01$)))
))" + 2 1< + 5+ 25 0/020-
))". @+# C #. ) ))))))
))$) %#++ C #. $ )))))$
))$$ #+ .# #+ C !
))$- +?( % #+ C !
))$, 1>22+# #+ 1 0),-
!)$, 1>2+?.
!)$
"))) #.#+
$))) C##+
(24 marks)
- # # !8 ' # # # # ! " -
(i) An option that allows the selection of alternative sources of input e.g.
INCLUDE program_name (library_name) directs the loader to read the
designated object program from a library and treat it as if it were part of the
primary loader input.
(ii) An option to allow the user to delete external symbols or entire control
sections e.g. DELETE csect_name instructs the loader to delete the named
control section from the set of programs being loaded.
(iii) An option to change external symbols e.g. CHANGE name1, name2 causes
the external symbol name1 to be changed to name2 wherever it appears in the
object programs.
(iv) An option to specify alternative libraries to be searched e.g. LIBRARY
MYLIB will cause library MYLIB to be searched before the standard system
libraries.
(v) Loaders that perform automatic library search may be asked to exclude some
functions that come with the library search e.g. NOCALL STDEV, PLOT,
CORREL will instruct the loader to exclude the said functions. This avoids the
overhead of loading and linking the unneeded routines and saves on memory
space.
(vi) Options to control outputs from the loader. The user can specify whether an
output is needed or not.
(vii) Options to specify whether external references will be resolved by library
search.
(viii) An option to specify the location at which execution is to begin thus overriding
any information given in the object program.
(ix) An option to control whether or not the loader should attempt to execute the
program if errors are detected during the load.
B G
C D/E H/I K
F J
( ) #, ! , # " ! % =
, # & #, , # & #,
($ ) ($ )
. '&&& 5 3&&
6 ';&& : ;&&
3&&& '&&&
* ;&& < ;&&
;&& > &&&
'&&&
# *+ ? + + ## +$ , # ,+ + - +
- ? , + /
(i) .) :. @ 6 . A 5. .
<exp>
<exp> <term>
<term>
<term> <factor>
<factor>
<factor>
id id id
{ALPHA} - {BETA} * {GAMMA}
<expr> <term>
<term>
<term> <factor>
<expr> <factor>
<factor>
<expr>
<term> <term>
<factor> <factor>
id DIV id + id - id
{ALPHA} {BETA} {GAMMA} {DELTA}
OR
<term>
<term> <factor>
<factor> <expr>
>
<expr>
<term>
<expr> <term>
<term>
<factor> <factor>
<factor>
id DIV id + id -
id
{ALPHA} {BETA} {GAMMA}
{DELTA}
<expr>
<expr> <factor>
<factor> <expr>
<expr>
<factor>
<expr> <factor>
<term>
<factor>
id DIV id + id -
id
{ALPHA} {BETA} {GAMMA}
{DELTA}
MAKERERE UNIVERSITY
INSTITUTE OF COMPUTER SCIENCE
FINAL EXAMINATION
DURATION: - 3 HOURS
INSTRUCTIONS
Candidates MUST answer ALL questions in section A and any THREE questions from Section B
Section A: (40 marks): All Questions are Compulsory.
1. Use examples to help you differentiate between Systems Software and Application
Software.
System software are programs that control the operation of the machine and carry out
the most basic functions the computer performs. They control the way in which the
computer receives input, produces output, manages and stores data, carries out or
executes instructions of other programs etc. Examples of systems programs include
language processors (compilers and assemblers that accept people like languages
and translate them into machine language), loaders (they prepare machine language
programs for execution), macro processors (allow programmers to use
abbreviations), operating systems and file systems (allow flexible storing and
retrieval of information).
Application programs are written by the user for the purpose of solving particular
problems using a computer as a tool e.g. application packages like MSWORD,
EXCEL etc. (4 Marks)
2. Use an example to help you explain the Format of the Machine Language
Instruction
The format of an instruction is the arrangement of the instruction with respect to
assigning meaning to its various groups of bits. It consists of
Operation code: The portion of the instruction that specifies what the instruction
Operands: Any address or piece of data that is required by the instruction to complete
its execution
e.g.
Register to register transfer
0 1 0 0 0 1 1 1
X PC B
50 1400 2000
Opcode n i x b p e displacement
6FAC00 = 011011 11 1 01 0 110000000000
Opcode n i x b p e displacement
064050 = 000001 1 0 0 10 0 000001010000
5. Use relevant examples to help you explain the difference between the following:
Program Blocks and Control Sections
Program Blocks are segments of code that are re-arranged within a single object unit
while Control Sections are parts of the program that maintain their identities after
assembly; each section can be loaded and relocated independently of each other.
references in the usual way because the assembler does not know where any other
control section will be loaded at execution time. (2 Marks)
Relevant Examples (2 Marks)
Section B: (60 marks): Attempt only THREE questions from this section.
9. (a) List and explain the main components of a typical microprocessor
• The Program Counter (PC): It holds the address of the main memory location
from which the next instruction is to be fetched. (1 Mark)
• Instruction Register (IR) Receives the instruction when it is brought from
memory and holds it while it gets decoded and executed. (1 Mark)
• Processor Status Word (PSW) contains condition flags which indicate the
current status of the CPU and the important characteristics of the result of the
previous instruction. (1 Mark)
• Stack Pointer (SP): Accesses a special part of memory called a stack. It hold
the address at the top of the stack. (1 Mark)
• Arithmetic Registers: They temporarily hold the operands and the result of
the arithmetic operations. (1 Mark)
• Address Registers: for addressing data and instructions in main memory.
(1 Mark)
(b) List all the registers of the Intel 8085 microprocessor that have similar
functions like those ones listed in part (b) above.
SIC/XE Intel 8085
Accumulator (A) Accumulator
Linkage Register (L) Stack Pointer
Program Counter (PC) Program Counter (PC)
Status Word (SW) Processor Status Word (PSW)
General Working Registers General Working Registers
(S, T) (B, C, D, E, H, L)
(4 Marks)
(c) Explain the formats of the machine language instructions for the SIC/XE
computer.
Format 1 (1 byte)
8
Opcode
Format 2 (2 bytes)
8 4 4
opcode r1 r2
Format 3 (3 bytes)
6 1 1 1 1 1 1 12
opcode n i x b p e disp
Format 4 (4 bytes)
6 1 1 1 1 1 1 20
opcode n i x b p e address
(4 Marks)
10. (a) An array ARR1 at a memory location 0030 contains 10 integers. Write a
SIC/XE Assembler Language program that will add up all the integers of
this array and store the answer at a memory location GREATER if the
answer is greater than 100 or at a memory location LESS if the answer is
less than 100
LDS #3
LDT #30
LDX #0
LDA ARR1, X
LOOP : ADDR S, X
ADD ARR1, X
COMPR X, T
JLT LOOP
COMP #100
JLT SMALLER
STA GREATER
J OUT
SMALLER STA LESS
OUT
ARR1 RESW 10
GREATER RESW 1
LESS RESW 1 (10 Marks)
(b) Assume that the program is to be assembled from memory location 000H
and that GREATER is at a memory location after the array ARR1 and
LESS is at a memory location next to GREATER generate machine code
for this program using Appendix C
A
1000
B G H I
2000 700 900 1000
C J K/L
500 2500 1000
D/E M O
1000 200 850
F N P
800 2000 900
12 (a) The program below consists of three different control sections; write
down the machine code for the instructions and directives for control
section PROGA.
(b) Write down the object code for PROGA as it would appear on an output
device.
H^PROGA ^000000^000063
D^LISTA ^000040^ENDA ^000054
R^LISTB ^ENDB ^LISTC ^ENDC
T^000020^0A^03201D^77100004^050014
T^000054^0F^000000^FFFFFD^000040^FFFF9C^FFFFEC
M^000024^05^+LISTB
M^000054^06^+LISTC
M^000057^06^+LISTB
M^00005A^06^+LISTB
M^00005A^06^+PROGA
M^00005D^06^+ENDC
M^00005D^06^-LISTC
M^000060^06^-LISTB
M^000060^06^+ENDB
E^000020 (5 Marks)
(c) Draw an external symbol table (ESTAB) for this program assuming that
PROGA is to be loaded from a memory location 2500 and that PROGB
immediately follows PROGA and PROGC immediately follows PROGB.
<exp> <term>
<term>
<term> <factor>
<factor>
<factor>
id id id
{ALPHA} - {BETA} * {GAMMA} (5 marks)
<expr> <term>
<term>
<factor>
<expr>
<expr> <term>
<term>
<factor> <factor>
id DIV ( id + id ) - id
{ALPHA} {BETA} {GAMMA} {DELTA}
(5 marks)
(b) Use a bottom up method to parse the following statements using the
operator precedence table in Appendix B. Assume that a semicolon
preceded the given expressions.
(i) SUMQ := SUMQ + VALUE * VALUE;
(ii) ANS:= ALPHA DIV (BETA + GAMMA) – DELTA ;
id2
{SUMQ}
<N2> * <N3>
id1 := <N1> + <N4> ; <N5>
< = < N5 >
<N1> + <N4>
id1 := <N5> ; <N6>
< N6 >
id1 := <N5>
<N6>
<N5>
<N1> <N4>
<N2> <N3>
id2
{ALPHA}
<N2> + <N3>
( <N4> )
id1 := <N6> - id5 ; <N6>
< = < < N7 > <N7>
<N8> <N9>
id1 := <N8> ;
< = <N9> >
<N8>
<N6> <N7>
<N1> <N5>
<N4>
<N2> <N3>
9 16
(b) List any three Systems software and explain their functions.
(i) Compilers: Translate high level languages to machine language
(ii) Assemblers: Translate Assembler languages to machine language
(iii) Loader: Prepare machine language programs for execution
(iv) Macro processors: allow programmers to use abbreviations
(v) Operating systems and file systems allow flexible storing and retrieval
of information. (3 marks)
(iii) Destination
The location that is changed or where the source operand is taken
(1 mark)
(b) Use examples to help you explain the difference between an instruction
and a Directive
An instruction is translated into machine code by the assembler
e.g. LDA NUM (1 mark)
A Directive gives directions to the assembler during the assembly process but
is not translated into machine code e.g. COST : DS 1 (1 mark)
(i) What does the instruction at address 0016 do and what is the addressing
mode used?
It loads 0050H into the accumulator. Addressing Mode is Indirect Addressing
(2 marks)
(ii) Write machine code for this instruction.
Displacement = 0050 – 0019 = 037
Opcode n i x b p e displacement
000000 1 0 0 0 1 0 0 3 7 = 022037 (3 marks)
(iii) CSADDRR
CSADDR is the starting address assigned to the control section currently
being scanned by the loader. (1 mark)
(ii) A Token
The fundamental building blocks of the language (1 mark)
Memory
Stores both data and instructions that are currently being used. address.
System Bus.
A set of conductors that connect the CPU to its memory and I/O devices.
Interfaces
Circuitry needed to connect the bus to a device.
(b) List and explain the uses of the registers found in the control unit of a
typical microprocessor.
The Program Counter (PC)
It holds the address of the main memory location from which the next
instruction is to be fetched.
11. (a) An array ARR1 contains 20 words of both positive and negative integers.
Write a SIC/XE program that will add up all these integers and store the
sum at a memory location POSIT if the sum is positive or NEGAT if the
sum is negative.
LDS #3
LDS #60
LDX #0
STX SUM
LOOP: LDA NUMBER, X
ADD SUM
STA SUM
ADDR S, X
COMPR X, T
JLT LOOP
LDS #0
COMPR A, S
JLT NEGATIVE
STA POSIT
J OUT
NEGATIVE: STA NEGAT
OUT: (10 marks)
(b) Generate machine code for the first five executable instructions of your
program assuming that the program is loaded from an address 0000H,
the beginning address of ARR1 is 1000H, memory location POSIT is at a
memory location 2000H and NEGAT is at a memory location 3000H
Slightly modify the above piece of code so that it can be assembled in one
pass.
1000 COPY START 1000
1000 EOF BYTE C’EOF’ 454F46
1003 THREE WORD 3 000003
1006 ZERO WORD 0 000000
1009 RETADR RESW 1
100C LENGTH RESW 1
100F BUFFER RESB 4096
200F FIRST STL RETADR 141009
2012 CLOOP JSUB RDREC 480000
2015 LDA LENGTH 00100C
2018 COMP ZERO 281006
201B JEQ ENDFIL 300000
201E JSUB WRREC 480000
2021 J CLOOP 3C2012
2024 ENDFIL LDA EOF 001000
2027 STA BUFFER 0C100F
202A LDA THREE 001003
202D STA LENGTH 0C100C
2030 JSUB WRREC 480000
2033 LDL RETADR 081009
2036 RSUB 4C0000
(5 marks)
Generate the text listing for the above code assuming a one pass
assembler that generates object code on an output device.
H^COPY ^001000^001039
T^001000^09^454F46^000003^000000
T^00200F^15^141009^480000^00100C^281006^300000^480000^3C2012
T^00201C^02^2024
T^002024^19^001000^0C100F^001003^0C100C^480000^081009^4C0000
(10 marks)
13. (a) List and explain any five common loader options.
(i) An option that allows the selection of alternative sources of input e.g.
INCLUDE program_name (library_name) directs the loader to read the
designated object program from a library and treat it as if it were part of
the primary loader input.
(ii) An option to allow the user to delete external symbols or entire control
sections e.g. DELETE csect_name instructs the loader to delete the
named control section from the set of programs being loaded.
(iii)An option to change external symbols e.g. CHANGE name1, name2
causes the external symbol name1 to be changed to name2 wherever it
appears in the object programs.
(iv) An option to specify alternative libraries to be searched e.g. LIBRARY
MYLIB will cause library MYLIB to be searched before the standard
system libraries.
(v) Loaders that perform automatic library search may be asked to exclude
some functions that come with the library search e.g. NOCALL STDEV,
PLOT, CORREL will instruct the loader to exclude the said functions. This
avoids the overhead of loading and linking the unneeded routines and
saves on memory space.
(vi) Options to control outputs from the loader. The user can specify whether
an output is needed or not.
(vii) Options to specify whether external references will be resolved by
library search.
(viii) An option to specify the location at which execution is to begin thus
overriding any information given in the object program.
(ix) An option to control whether or not the loader should attempt to execute
the program if errors are detected during the load. (5 marks)
( b) Given below is piece of code for a control section. There are also other
control sections in memory referencing this section. Assume that the
variables LENGTH and BUFFER of this section are referenced by other
control sections.
(i) Rewrite the piece of code above to reflect these assumptions.
B E H/L
C D/K F G I J
(5 marks)
(ii) Which segments can be in memory at the same time together with
segment J.
Segments A , H and L (2 marks)
(iii) Assume the lengths of the segments are as follows:
Segment Length Segment Length
(bytes) (bytes)
A 1000 G 400
B 1800 H 800
C 4000 I 1000
D 2800 J 800
E 800 K 2000
F 1000 L 2000
Assume also that the actual starting address of the program is 5000 fill
the following table below.
Segment Starting Address
Relative Actual Length
1 0000 5000 1000
2 1000 6000 1800
3 2800 7800 4000
4 2800 7800 4800
5 1000 6000 800
6 1800 6800 1000
7 1800 6800 400
8 1000 6000 2800
9 3800 8800 1000
10 3800 8800 800
(10 marks)
Opcode R1 R2
Opcode n i x b p e Displacement
Opcode n i x b p e address
(b)
.
SIC Intel 8085
A Accumulator
L Stack Pointer
PC Program Counter
SW Processor Status Word
- 15 = -1111 = -000000001111
invert bits and add 1 = 111111110000 + 1 = 111111110001
+- .
42
? " + + # , , + # - + 84
# ? # + # $ - + + # -+ , + 40
0 $ 6 + ? $ # - + # ? +
# + ?
B # + # ##
$$+ , $ $ # + #
+, $$+ - + # + #
B $ - + ,+ !
X PC B
50 90 A0
100 300 200
50 100 300
Memory addresses
opcode n i x b p e displacement
. :
(ii) LOCCTR
A location counter LOCCTR is used to help in the assignment of
addresses. It is initialized to the beginning address specified in the
START statement. After each source statement is processed the length
of the assembled instruction or data area to be generated is added to
the LOCCTR
(iii) OPTAB
A table used to look up mnemonic operation codes and translate them
into their machine language equivalents.
Explain what happens when each of the following instructions is executed. Write
machine code for each of the instructions and in each case state the addressing
mode and the format of the instruction which has been used.
(i) 0016 LDA NUM1
• Loads a number 0100H into the accumulator.
• Displacement = 0050 – 0019 = 037
opcode n i x b p e displacement
000000 1 1 0 0 1 0 0 3 7 = 032037
Machine Code = 032037
• Addressing Mode: = Simple / Direct
• Format: Format 3
3. Explain what is meant by Program Relocation and use an example to show how
it is done.
Ability of loading a program anywhere in memory without stating the actual starting
address.
It is done by writing modification records e.g. for an instruction
006 +JSUB RDREC 4B101036 the modification record would be
M00000705
(b) Use examples to explain the difference between Absolute expressions and
Relative expressions.
An absolute expression contains only absolute terms or relative terms so long
as the relative terms occur in pairs and the terms in each pair have opposite
signs. e.g. MAXLEN EQU BUFEND – BUFFER
A relative expression is one in which all the relative terms except one can be
paired. The remaining unpaired relative term must have a positive sign e.g.
MAXLEN EQU BUFEND + 100
5 (a) Modify the SIC piece of code below by declaring the variables first so that
it can be assembled in one pass.
1000 COPY START 1000
1000 EOF BYTE C’EOF’ 454F46
1003 THREE WORD 3 000003
1006 ZERO WORD 0 000000
1009 RETADR RESW 1
100C LENGTH RESW 1
100F BUFFER RESB 4096
200F FIRST STL RETADR 141009
2012 CLOOP JSUB RDREC 480000
2015 LDA LENGTH 00100C
2018 COMP ZERO 281006
201B JEQ ENDFIL 300000
201E JSUB WRREC 480000
2021 J CLOOP 3C2012
2024 ENDFIL LDA EOF 001000
2027 STA BUFFER 0C100F
202A LDA THREE 001003
202D STA LENGTH 0C100C
2030 JSUB WRREC 482061
2033 LDL RETADR 081009
2036 RSUB 4C0000
(b) Generate the text listing for the modified code assuming a one pass
assembler that generates object code on an output device.
H^COPY ^00100^001039
T^001000^09^454F46^000003^000000
T^00200F^15^141009^480000^00100C^281006^300000^480000^3C2012
T^00201C^02^2024
T^002024^15^001000^0C100F^001003^0C100C^480000^081009^4C0000
E^00200F
MAKERERE UNIVERSITY
FACULTY OF COMPUTING & INFORMATION TECHNOLOGY
3. Use examples to explain the difference between Direct and Indirect addressing of the
SIC/XE machine. (4 marks)
! " #
! " #
$ % &
! & '
'
% ( !
$ % & )
* %
! + , ,
&
! " #
$ % & )
"
- + , ,
)
! " # )
&
.
& ! ( & -
' / ! ( & & ! 0 &
(a) Write machine code for the instructions at addresses 0000, 0003, and 000D.
(6 marks)
(b) What does the Directive at address 1036 mean? (2 marks)
(c) Write all the Modification Records that may be needed in this piece of code.
Why don’t the other remaining instructions need Modification Records?
(8 marks)
(d) Assume that RDREC and WRREC are in different control sections and that
the variables LENGTH, BUFFER and BUFEND are referenced by these other
control sections, insert some extra lines of code in the above program to reflect
this assumption. (4 marks)
13. The program below consists of two different control sections that are to be linked
together.
(a) Write down the machine code for the instructions and directives for control
section PROGA. (5 Marks)
(d) Write down the object code (Text Listing) for PROGA as it would appear on
an output device. (5 Marks)
(e) Draw an external symbol table for this program assuming that PROGA is to be
loaded in memory from a memory location 2500 and that PROGB will
immediately follows PROGA (4 Marks)
(d) Using the assumptions made in part (c) above calculate the values for REF6
and REF7. (6 Marks)
14. A diagram of Overlay control sections is as shown below and the number of bytes
occupied by each control section in memory is also given.
A
1
2 7 4
B X E/F
3 8 5 6
C/D Y H G
15. (a) Assume the PASCAL grammar and draw a top down parse tree for this
expression:
FOR I := 1 to 10 DO SUM := SUM + I (10 Marks)
(c) Use a bottom up method to parse the following statement using the operator
precedence method.
ANS := ALPHA DIV (BETA + GAMMA) – DELTA; (10 marks)
EXAMINATION INSTRUCTIONS
3. Use examples to explain the difference between Direct and Indirect addressing of the
SIC/XE machine. (4 marks)
! " #
! " #
$ % &
! & '
'
% ( !
$ % & )
* %
! + , ,
&
! " #
$ % & )
"
- + , ,
)
! " # )
&
.
& ! ( & -
' / ! ( & & ! 0 &
(a) Write machine code for the instructions at addresses 0000, 0003, and 000D.
(6 marks)
(b) What does the Directive at address 1036 mean? (2 marks)
(c) Write all the Modification Records that may be needed in this piece of code.
Why don’t the other remaining instructions need Modification Records?
(8 marks)
(d) Assume that RDREC and WRREC are in different control sections and that
the variables LENGTH, BUFFER and BUFEND are referenced by these other
control sections, insert some extra lines of code in the above program to reflect
this assumption. (4 marks)
16. The program below consists of two different control sections that are to be linked
together.
(a) Write down the machine code for the instructions and directives for control
section PROGA. (5 Marks)
(f) Write down the object code (Text Listing) for PROGA as it would appear on
an output device. (5 Marks)
(g) Draw an external symbol table for this program assuming that PROGA is to be
loaded in memory from a memory location 2500 and that PROGB will
immediately follows PROGA (4 Marks)
(d) Using the assumptions made in part (c) above calculate the values for REF6
and REF7. (6 Marks)
17. A diagram of Overlay control sections is as shown below and the number of bytes
occupied by each control section in memory is also given.
A
1
2 7 4
B X E/F
3 8 5 6
C/D Y H G
18. (a) Assume the PASCAL grammar and draw a top down parse tree for this
expression:
FOR I := 1 to 10 DO SUM := SUM + I (10 Marks)
(d) Use a bottom up method to parse the following statement using the operator
precedence method.
ANS := ALPHA DIV (BETA + GAMMA) – DELTA; (10 marks)
EXAMINATION INSTRUCTIONS
2. Explain briefly:
(i) The Format of a machine language instruction.
It is the arrangement of an instruction with respect to assigning meaning to its
various groups of bits. It consists of the Operation Code which is a portion
that specifies what the instruction does and the Operand which is any piece of
data or address that is required by the instruction to complete its execution.
(2 marks)
(ii) The Format of an Assembler Language instruction.
Label: Mnemonic Operand, Operand, ; remarks
Label: It is a symbol assigned to the address of the first byte of the instruction
in which it appears.
A mnemonic is the abbreviation for the real instruction.
The Operand(s) is the data or the address needed to complete the instruction.
Remarks are for documenting the program. (2
marks)
3. Use examples to help you explain any 3 addressing modes for the Intel 8085
microprocessor.
(Any 3 of the following)
• Immediate Addressing: Information is part of the instruction
• Direct addressing: The address is part of the instruction.
• Register addressing: The operand is in the register and the register’s address is part
of the instruction.
• Indirect Addressing: The address is in the location whose address is specified as part
of the instruction.
• Base addressing: The address is formed by adding the contents of a memory location
or register to a number called a displacement which is part of the instruction.
• Indexing: It is a process of incrementing or decrementing an address as the computer
sequences through a set of consecutive or evenly spaced addresses. (6 marks)
(b) Assume that each of the instructions in part (a) above were executed and
explain what each of the following instruction does and the contents of the
registers involved in each case.
(i) INX D
Increment register pair DE; i.e. D = 00; E = 47 (2 marks)
(ii) INR M
Increment contents of a memory location whose address is in the
register pair H.L i.e. M = 51 (2 marks)
(iii) LDAX D
Load the Accumulator with contents of a memory location whose
address is in the DE register pair; A = 30 (2 marks)
13. Give the Mnemonics of any five registers found in the SIX/XE and state their
uses.
(Any 5 of the following)
A Accumulator; used for arithmetic Operations
X Index register; used for addressing
L Linkage register; the Jump to subroutine (JSUB) instruction stores the return
address in this register.
PC Program Counter; Contains the address of the next instruction to be fetched
for execution.
SW Status word; contains the condition codes
B Base register, used for addressing
S General Working register, no special use.
T General Working register, no special use.
F Floating Point Accumulator. (5 marks)
6. Assume the following code for the SIC machine. The Operation Code for the
Mnemonic STL is 14
0022 STL Buffer, X
2020 Buffer: RESW 1
Derive machine code for the instruction at address 0022.
6 1 1 1 1 1 1 20
opcode n i x b p e address
(ii) Explain why some instruction need modification records during program
relocation and others do not.
Instruction that have been assembled using addresses are the ones that need to
be modified; format 1, format 2 do need have address operands; and format 3
instructions that have been assembled using program counter relative or base
relative are similarly not affected because the displacements do not change
when the program is loaded. (2 marks)
(iii) CSADDR
The starting address assigned to the control section currently being scanned
by the loader. (1 marks)
Section B: (60 marks): Attempt only THREE questions from this section.
9. (a) Briefly explain the uses of the components of the of the Control Unit of a
typical microprocessor.
• The Program Counter (PC) :It holds the address of the main memory
location from which the next instruction is to be fetched.
• Instruction Register (IR) Receives the instruction when it is brought from
memory and holds it while it gets decoded and executed.
• Processor Status Word (PSW) contains condition flags which indicate the
current status of the CPU and the important characteristics of the result of
the previous instruction.
• Stack Pointer (SP): Accesses a special part of memory called a stack. It is
used to temporarily store important information while sub routines are
being executed. It hold the address at the top of the stack. (8 marks)
(c) Give and explain the components of the Processor Status Word for the
Intel 8085 microprocessor.
S Z AC P C
The PSW for the Intel 8085 has 5 flags.
• Zero (Z): set when the result of the operation is zero.
• Sign (S): set when sign of the result is negative.
• Parity (P): When the parity of the bits in the result is even.
• Carry (C): Addition resulted into a carry or subtraction or comparison
resulted into a borrow.
• Auxiliary Carry (AC) Carry in BCD arithmetic. (5 marks)
10. (a) An array MYARRY contains 10 integers (negative and positive). Write an
Intel 8085 Assembler language program that will add up all the integers
of this array and store the answer at a memory location GREATER if the
answer is greater than 100 or at a memory location LESS if the answer is
less than 100.
MVI D, 10
LXI H, MYARRAY
MOV A, M
LOOP: INX H
ADD M
DCR D
JNZ LOOP
CPI 100
JP MORE
STA LESS
JMP OUT
MORE: STA GREATER
MYARRAY DS 10
GREATER: DS 1
LESS DS 1
(10 Marks)
(b) Write an equivalent program for the same problem using the SIC/XE
machine code.
LDS #100
LDT # 10
LDA #0
LDX #1
AGAIN: ADD MYARRAY, X
TIXR T
JLT AGAIN
COMPR A, S
JLT SMALL
STA GREATER
J OUT
SMALL: STA LESS
OUT:
MYARRAY: RESW 10
GREATER: RESW 1
LESS: RESW 1 (10 Marks)
(iv) Study the program carefully and explain briefly what is being
accomplished.
The program adds up 10 integers in an array ALPHA and stores the answer at
a memory location RESULT (3 Marks)
12. (a) Two passes are usually used to translate an Assembler Language
program to machine code; explain briefly what is accomplished in each
pass and state the tables and variables used in each pass.
• Pass 1 (Define symbols)
• Scans the source program for label definitions using the LOCATION
COUNTER and assigns addresses to all statements in the program.
• Saves the addresses assigned to all labels for use in pass 2 in the
SYMBOL TABLE
• Perform some processing of the assembler directives.
(i) Some instructions in the code above will change when the program
is loaded in memory from a different memory location other than
0000. Give the addresses of the instructions which will change and
explain why the others will not change.
Instructions at addresses 0006, 0013 and 0026 will change. The others
will not change because their machine codes do not contain addresses.
(3 marks)
(i) Generate the object code for the program above.
H^ EXAM ^000000^ 001036
T^000000^1D^17202D^69202D^4B101036^032026^290000^332007^4B10105D^3F2FEC^032010
T^000001D^13^0F2016^010003^0F200D^4B10105D^3E2003^454F46
M^000007^05
M^000014^05
M^000027^05
E^000000 (12 marks)
13. Consider the program code below written in the simple SIC format.
(a) Modify the program so that it can be assembled in one pass. (10 marks)
(b) Use the Load and Go method to show how the above program will appear
in memory.
1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 100A 100B 100C 100D 100E 100F
1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 101A 101B 101C 101D 101E 101F
00 00 03 00 00 00 00 01 2C
1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 102A 102B 102C 102D 102E 102F
00 10 2A 0C 10 00 04 10 00 00 90 03 18 90 0F 0C
1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 103A 103B 103C 103D 103E 103F
90 1B 00 10 00 18 10 27 0C 10 00 28 10 2D 38 10
1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 104A 104B 104C 104D 104E 104F
36
1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 105A 105B 105C 105D 105E 105F
(6 marks)
(c) Explain the following
(i) Programs with Overlay Structures.
They are programs that are designed to execute in such a way that if
both or all of them are not needed in memory at the same time, one
can execute first and the other will execute in the same memory space
after the first one has been executed. (2 marks)
(ii) The meaning of the expression: MYNUM EQU *
The current value of the location counter is assigned to the variable
MYNUM (2 marks)
14. (a) (i) Briefly explain the difference between Program Blocks and
Control Sections.
Control sections differ from program blocks in that they are handled
separately by the assembler. It is not necessary for all control sections
in a program to be assembled at the same time. Each control section is
independent of another whereas Program Blocks are sections of code
re-arranged in the same unit. (2 marks)
(ii) What are the directives used to indicate a new Program Block and
a new Control section respectively in a program?
The directive USE indicates a new Program Block while the Directive
CSECT announces a new Control Section. (2 marks)
(b) Assume that the following piece of code is in a program block called
PROGA.
001C LDT NUM
002C Number: RESB 1
(ii) Assume that NUM is defined at address 000E in the next Program
Block PROGB which begins at address 0000H. If the Operation
Code for the instruction LDT is 74, derive the machine instruction
for the Assembler instruction at address 001C in PROGA.
The displacement = 002D – 001F + 000E = 01C
6 1 1 1 1 1 1 12
opcode n i x b p e disp
(c) Explain any 5 Loader Options that can be used to modify the standard
processing of a program.
15. Given below are two control sections PROG1 and PROG2 both loaded in
memory.
(a) Give the operands for the Directives EXTREF and EXTDEF in each
control section.
Prog1 Prog2
EXDEF NUM1 EXDEF STORE2
EXTREF STORE2 EXTREF NUM1 (2 marks)
(b) Derive machine code for the instructions at addresses 0020, 0027, 0060 in
PROG1 and 0036, 003D and 007C in PROG2 assuming that the operation
codes for the instructions LDT and STT are 74 and 84 respectively.
6 1 1 1 1 1 1 20
opcode n i x b p e address
(c) Write the object code for the two Control Sections.
H^PROG1 ^000000^000063
D^NUM1 ^000040
R^STORE2
T^000020^0B^77201D ^8710000
T^000060^03^FFFFC0
M^000028^05^+STORE2
M^000060^06^+STORE2
M^000060^06^-PROG1
E^000020 (4 marks)
H^PROG2 ^000000^00007F
D^STORE2 ^000060
R^NUM1
T^000036^0A^77100000^872020
T^00007C^03^000060
M^000037^05^+NUM1
M^00007C^06^+PROG2
M^00007C^06^-NUM1
E (4 marks)
(d) Assume that the first control section PROG1 is loaded in memory at
address 1200 and that PROG2 is loaded immediately after PROG1,
calculate the value of RESULT
( 001200 + 63 + 60) – (001200 + 40) = 000083 (4 marks)
PROG1 START 0
0000
EXTDEF
EXTREF
.
MAKERERE UNIVERSITY
FACULTY OF COMPUTING & INFORMATION TECHNOLOGY
EXAMINATION INSTRUCTIONS
(b) How does Systems Software differ from Application Software? (1 mark)
2. Explain briefly:
(i) The Format of a Machine Language instruction. (2 marks)
(ii) The Format of an Assembler Language instruction. (2 marks)
3. Use examples to help you explain any 3 addressing modes for the Intel 8085
microprocessor. (6 marks)
(b) Assume that each of the instructions in part (a) above were executed and
explain what each of the following instructions does and the contents of the
registers involved in each case.
(i) INX D (ii) INR M (iii) LDAX D (6 marks)
5. Give the Mnemonics (abbreviations) of any five registers found in the SIX/XE and
state their uses. (5 marks)
6. Assume the following code for the SIC machine. The Operation Code for the
Mnemonic STL is 14
0022 STL Buffer, X
2020 Buffer RESW 1
Derive machine code for the instruction at address 0022. (2 marks)
10. (a) An array MYARRY contains 10 integers (negative and positive). Write an
Intel 8085 Assembler language program that will add up all the integers of this
array and store the answer at a memory location GREATER if the answer is
greater than 100 or at a memory location LESS if the answer is less than 100.
(10 Marks)
(b) Write an equivalent program using the SIC/XE machine code for the same
problem. (10 Marks)
(vi) Study the program carefully and explain briefly what is being accomplished.
(3 Marks)
(vii) Assuming that it is to be loaded in memory from 0058H, generate the
corresponding addresses for each instruction and write the corresponding
machine code using the operation code table below. (17 Marks)
Mnemonic Opcode
LDS 6C
LDA 00
LDX 04
ADD 18
TIXR B8
STA 0C
JLT 38
S 4
12. (a) Two passes are usually needed to translate an Assembler language program to
machine code; explain briefly what is accomplished in each pass and state the
tables and the variables used in each pass. (5 marks)
(j) Some instructions in the code above will change when the program is
loaded in memory from a different memory location other than 0000.
Give the addresses of the instructions which will change and explain
why the others will not change. (3 marks)
(i) Generate the object code for the program above. (12 marks)
13. Consider the program code below written in the simple SIC format.
(a) Modify the program so that it can be assembled in one pass. (10 marks)
14. (a) (i) Briefly explain the difference between Program Blocks and Control
Sections. (2 marks)
(ii) What are the directives used to indicate a new Program Block and a
new Control section respectively in a program (2 marks)
(b) Assume that the following piece of code is in a program block called PROGA.
001C LDT NUM
002C NUMBER: RESB 1
(iii) If the beginning address of PROGA is 000A and the code at address
002C is the last directive in PROG A, what is the length of Program
Block PROGA? (2 marks)
(iv) Assume that NUM is defined at address 000E in the next Program
Block PROGB which begins at address 0000H. If the Operation Code
for the instruction LDT is 74, derive the machine instruction for the
Assembler instruction at address 001C in PROGA. (4 marks)
(ci) Explain any 5 Loader Options that can be used to modify the standard
processing of a program. (10 marks)
15. Given below are two control sections PROG1 and PROG2 both loaded in memory.
PROG1 START 0
000
0
EXTDEF
EXTREF
(ii) Loading
Bring the object program into memory for execution.
(iv) Linking
Combines two or more separate object programs and supply the information
needed to allow references between them
6. Use examples where possible to help you briefly explain the difference between
the following:
Program Blocks and Control Sections
A control Section is part of the program that maintains its identity after
assembly; each section can be loaded and relocated independently of each
other. Different control sections are most often used for subroutines or other
logical subdivisions of a program.
Control sections use External References to connect each other.
Program Blocks are segments of code that are re-arranged within a single
object unit.
The assembler rearranges these segments to gather together the pieces of each
block. These blocks are then assigned addresses in the object program with
the blocks appearing in the same order in which they were first began in the
source program.
During pass 1 a separate location counter is maintained for each block. It is
initialized to 0 when the block is first began. At the end of pass 1 the latest
value of the location counter for each block indicates the length of that block.
Control sections differ from program blocks in that they are handled
separately by the assembler
! " #
! " #
$ % &
! & '
'
% ( !
$ % & )
* %
! + , ,
&
! " #
$ % & )
"
- + , ,
)
! " # )
&
.
& ! ( & -
' / ! ( & & ! 0 &
a. (i) The Operations codes for the instructions STL, LDB, and COMP
are 14, 68, and 28 respectively, write machine code for the
instructions at addresses 0000, 0003, and 000D.
STL RETADR
Displacement = 0030 – 0003 = 02D
Format = opcode n i x b p e displacement
= 000101 1 1 0 0 1 0 02D = 17202D
LDB #LENGTH
Displacement = 0033 – 0006 = 02D
Format = opcode n i x b p e displacement
= 011010 1 0 1 0 1 0 02D = 69202D
COMP #0
Displacement = 000
Format = opcode n i x b p e displacement
= 001010 0 1 0 0 0 0 000 = 290000
b. Write all the Modification Records that may be needed in this piece of
code. Why don’t the other remaining instructions need Modification
Records?
M^000007^05
M^000014^05
M^000027^05
The other instructions in the program do not need to be modified because in
some cases the operand is not memory or the operand is specified using
program counter relative addressing or base relative addressing.
c. Assume that RDREC and WRREC are in different control sections and
that the variables LENGTH, BUFFER and BUFEND are referenced by
these other control sections:
(i) Insert some extra lines of code in the above program to reflect this
assumption.
These lines are inserted in the program after the first line.
EXTDEF BUFFER, BUFEND, LENGTH
EXTREF RDREC, WRREC
(ii) Write the machine code for the instructions at addresses 0006,
0013 and 0026. The Operation code for the instruction JSUB is 48.
Address = 00000
Format = opcode n i x b p e address
= 010010 1 1 0 0 0 1 00000 = 4B100000