CC372 Spring 2025 Tutorial 08-Part-02
CC372 Spring 2025 Tutorial 08-Part-02
2
Solution
3
Exercise(1)
b) Give some examples of System Software. Describe each briefly.
4
Solution
5
Exercise(1)
c) Describe in details why do we need a system software.
6
Solution
7
Exercise(1)
d) State two common categories of languages with examples for each
that are used for Systems Programming.
8
Solution
Example: SIC/XE
Assembly Langyage
9
Exercise(1)
e) Describe in details the difference between literal and immediate
operand.
10
Solution
11
Exercise(1)
f) Describe the need for a LTORG (Literal Origin) statement in SIC/XE
assembly programming.
12
Solution
13
Exercise(1)
g) Describe the need for an ORG (Origin) statement in SIC/XE assembly
programming.
14
Solution
15
Exercise(1)
h) Differentiate between Systems Programming and Applications
Programming.
16
Solution
17
Exercise(1)
i) What are the advantages of using relocatable code?
18
Solution
19
Exercise(2)
2. Indicate whether each of the following statements is TRUE or FALSE.
20
Solution
True
False
False
False
False
False
False
21
Exercise(3)
3. What is wrong with the following pieces of code:
22
Solution(a)
The value of location counter should be loaded in base register and should be done after the base
directive
23
Solution(b)
24
Solution(c)
Literals can be used only in place of operand as source but not as destination field
of an instruction (operand used to retrieve a value).
25
Solution(d)
ORG operand must be defined using previously defined constants and/or symbols
EQU operand (expression) must be defined using previously defined constants
and/or symbols.
26
Solution(e)
27
Solution(f)
The operand for START directive should not exceed 4 hexadecimal digits.
28
Exercise(4)
4. A SIC/XE instruction is stored at location 700 and spans 3 bytes (format-
3). The address field has the value 150. The location 150 contains the
value 20. The registers X and B contain the value 120 and 180,
respectively. Assuming that all the values given are in decimal and that
the value of the program counter contains the address of the current
instruction while evaluating the target address of the current
instruction, what is the target address (in decimal) of the instruction
operand for each of the following addressing modes:
a) Direct
b) Indirect
c) Immediate
d) PC-relative
e) Base-relative with B as base register
f) Indexed with X as index register
29
Solution
Hint: We ignore the relative possibilities in our solution while evaluating
the addresses for (Direct, Indirect, Immediate, and indexing).
a) Direct TA = 150 Operand = (TA) = (150)
b) Indirect TA = 150 Operand = ((TA)) = ((150)) = (20)
c) Immediate TA = 150 Operand = TA = 150
d) PC-relative TA = (PC) + 150 = 700 + 150 = 850 Operand = (TA) = (850)
e) Base-relative TA = (B) + 150 = 180 + 150 = 330 Operand = (TA) = (330)
f) Indexed TA = 150 + (x) = 150 + 120 = 270 Operand = (TA) = (270)
30
Exercise(5)
5. Consider the SIC/XE assembler, explain using examples each of the
following:
a) How could the assembler decide whether to use PC-relative or Base-
relative addressing in assembling format-3 instructions.
b) How could the assembler decide whether to encode an instruction as
format-3 or format-4.
31
Solution(a)
• Using Base and NOBASE directives
32
Solution(b)
• All format-3 instructions can be used as format-4.
• The programmer can specify use of format-4 by adding prefix ‘+’ to
the operation code (mnemonic).
• Example
LDA ALPHA (format-3)
+LDA ALPHA (format-4)
33
Exercise(6)
6. Assume the following code (the address in leftmost cell is in
hexadecimal):
0080 NUM RESW 100
TNUM EQU *
a) What is the value of TNUM (in hexadecimal)?
b) If we replaced the directive RESW with ORG, what is the new value of
TNUM?
34
Solution(a)
• TNUM = 0080 + 012C = 01AC (hexadecimal)
35
Solution(b)
• TNUM = 0064 (hexadecimal)
36
Exercise(7)
7. Consider the following sequence of SIC/XE assembly instructions starting
at location 30 (hexadecimal):
37
Solution
0033
081B
07E8
07F2
Symbol Type Value(Hexadecimal)
XXX Relocatable (relative) 0030
YYY Relocatable (relative) 0033
WWW Relocatable (relative) 081B
ZZZZ Absolute 07E8
QQQ Absolute 07F2
38