Generate The Complete Object Program For Each Statement
Generate The Complete Object Program For Each Statement
Generate the complete object program for each statement in the following SIC/XE program
(Jan 2006 – 14 marks)
Line No.
5
LOCCTR SOURCE STATMENTS
SUM
cks
START 0000
OBJECT CODE
---------
10 0000 FIRST LDX #0 050000
15 0003 LDA #0 010000
20 0006 +LDB #TABLE2 69101790
25 --------- BASE TABLE2 -----------
30 000A LOOP ADD TABLE, X 1BA013
35 000D ADD TABLE2, X 1BC000
40 0010 TIX COUNT 2F200A
45 0013 JLT LOOP 3B2FF4
50 0016 +STA TOTAL 0F102F20
55 001A RSUB 4F0000
60 001D COUNT RESW 1 ---------
65 0020 TABLE RESW 2000 ---------
70 1790 TABLE2 RESW 2000 ---------
75 2F00 TOTAL RESW 1 ---------
80 2F03 END FIRST ---------
The assembly of instruction with immediate addressing is to convert the immediate
operand to its internal representation and insert it into the instruction.
15 0003 LDA #0
OPCODE n
0000 00 0
i
1
cks
x
0
b
0
p
0
e
0 0000
Disp (12 bit)
0000 0000
0 1 0 0 0 0
In this case, the operand (TABLE2) is too large to fit into the 12-bit displacement
field, so the extended instruction format is called for. (If the operand were too large even
for this 20-bit address field, immediate addressing could not be used.).
Note that the program counter is advanced after each instruction is fetched and before it
is executed. While ADD is executed, PC will contain the address of the next instruction
(000D), where TABLE (line 65) is assigned the address 0020.
The displacement we need in the instruction is DISP = TA-[PC] that is
20 – 0D = 13,
Target address = (PC) + disp = 000D + 13 = 20.
Note that bits x and p are set to 1 to indicate indexed and PC relative addressing
35 000D
cks
ADD TABLE2, X
OPCODE (ADD) = 18 = 0001 1000
Target address of operand (TABLE2) is = 1790
Note that the program counter is advanced after each instruction is fetched and before it is
executed. While ADD is executed, PC will contain the address of the next instruction (0010),
where TABLE2 (line 70) is assigned the address 1790.
According to the BASE statement, register B = 1790 (the address of TABLE2) during execution.
The address TABLE2 is 1790.
Thus the displacement in the instruction must be DISP = TA - [B]
= 1790 – 1790 = 0000.
Note that bits x and b are set to 1 to indicate indexed and base relative addressing.
Note that the program counter is advanced after each instruction is fetched and before it
is executed. While TIX is executed, PC will contain the address of the next instruction
(0013), where COUNT (line 60) is assigned the address 001D.
The displacement we need in the instruction is DISP = TA - [PC] that is
= 001D – 0013
= 00A,
Target address = (PC) + disp = 0013 + 000A = 001D.
Note that the program counter is advanced after each instruction is fetched and before it
is executed. While JLT is executed, PC will contain the address of the next instruction
(0016), where LOOP (line 30) is assigned the address 000A.
The displacement we need in the instruction is DISP = TA-[PC] that is
000A – 0016 = - 00C,
In SIC/XE the negative numbers are represented using 2’s complement therefore
In this case, the operand (TOTAL) is too large to fit into the 12-bit displacement
field, so the extended instruction format is called for. (If the operand were too large even
for this 20-bit address field, immediate addressing could not be used.).
55 001A RSUB
OPCODE n
0100 11 1
4 F
i
1 cks
x
0
b
0
0
p
0
e
0 0000
0
Disp (12 bit)
0000
0
0000
0
SYMTAB
LABEL VALUE
FIRST 0000
LOOP 000A
COUNT 001D
TABLE 0020
TABLE2 1790
TOTAL 2F00
OBJECT PROGRAM
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
H ^ S U M ^ 0 0 0 0 0 0 ^ 0 0 2 F 0 2
E^000000
2. Generate the complete object program for each statement in the following SIC/XE program.
(JUNE 2010 14 MARKS)
cks
3. Generate the complete object program for each statement in the following SIC/XE program
(Jan 2005 – 14 marks)
SUM START 0
FIRST CLEAR X
LDA #0
+LDB #TOTAL
BASE TOTAL
LOOP ADD TABLE, X
TIX COUNT
JLT LOOP
STA TOTAL
COUNT RESW 1
TABLE RESW 2000
TOTAL RESW 1
END FIRST
cks