You are on page 1of 3

SCHOOL OF COMPUTING AND INFORMATICS TECHNOLOGY

SYSTEMS PROGRAMMING CSC 2209


TEST 2
Answer all questions
Time allowed: 1 Hour
1. (a) Explain the following:
(i) Loading
Bringing the object program into memory for execution.

(ii) Linking:
Combining two or more separate object programs and supply the information needed to
allow references between them.

(iii) Program Relocation:


Modifying the object program so that it can be loaded at an address different from the
location originally specified.

(iv) A Relocation bit


A bit indicating whether an instruction will need relocating (1) or not (0).

0000 NEWPRG START 0


0000 FIRST STL RETADR 17202D
0003 LDB #LENGTH 69202D
0006 CLEAR X B410
0008 CLEAR A B400
000A CLEAR S B440
001C +LDT #4096 75101000
0020 CLOOP +JSUB RDREC 4B101036
0024 LDA LENGTH 032026
0027 COMP #0 290000
002A JEQ ENDFIL 332007
002D +JSUB WRREC 4B10105D
0031 J CLOOP 3F2FEC
0034 ENDFIL LDA =C’EOF’ 032010
0037 STA BUFFER 0F2016
003A LDA #3 010003
003D STA LENGTH 0F200D
0040 +JSUB WRREC 4B10105D
0044 * =C’EOF’ 454F46
0047 RETADR RESW 1
004A LENGTH RESW 1
004D BUFFER RESW 2

(b) (i) Write the Modification Records for the instructions in this program that will need to be
relocated.
M^000021^05+NEWPRG
M^00002E^05+NEWPRG
M^000041^05+NEWPRG

(v) Why don’t the other instructions need Relocating?


It is because their new locations when moved from the first location will not affect them.

(c) Write the object listing for this program assuming that Relocation will be done by using Relocation Bits.

H^NEWPRG^000000^000053
Saturday 2nd May, 2015
T^000000^2D ^020^17202D^69202D^----332007
T^00002D^1A^820^4B10105D^3F2FEC^03010 – 454F46
END

2. (a) Write in full and explain the use of the following:


(i) PROGADDR
The beginning address in memory where the linked program is loaded

(ii) CSADDR
The starting address assigned to the control section currently being scanned by the loader

(iii) CSLTH
Length of a Control Section

(iv) ESTAB
External Symbol Table: Stores names and addresses of each external symbol in the set of
control sections being loaded. It also indicates in which control section the symbol is
defined.

(b) Assume that the three programs MAK, MUBS AND KLA shown here below are to be linked together and
that the beginning linking address in memory will be 5000. Construct an External Symbol Table for these
programs and hence calculate the value of MAK1 + MUBS2 – KLA1

0000 MAK START 0 0000 MUBS START 0 0000 KLA START 0


0010 MAK1 0035 MUB1 0020 KLA1

0025 MAK2 RESW 1 0045 MUB2 RESW 1 0035 KLA2 RESW 1

Control Section Symbol Name Address Length


MAK 5000 0028
MAK1 5010
MAK2 5025
MUBS 5028 0048
MUB1 505D
MUB2 506D
KLA 5070 0038
KLA1 5090
KLA2 50A5

MAK1 + MUBS2 – KLA1 = 4FED

(c) Use examples to explain when you may need to use the following Loader Options
(i) INCLUDE
To allow selection of an alternative source of input e.g. INCLUDE program_name
(library_name) directs the loader to read the designated object program from a library.

(ii) CHANGE
To change the name of an external symbols e.g. CHANGE name1, name2 causes the
external symbol name1 to be changed to name2 wherever it appears in the object
programs

Saturday 2nd May, 2015


(iii) NOCALL
Excludes some functions that come with the library search e.g. NOCALL STDEV

3. (a) What are the main functions of a compiler?


To detect errors within the source program and then to generate machine code which can n be
executed.

(b) Assume the following grammar for the PASCAL compiler and construct a Top Down parse tree for the
expression X := Y DIV 50.

<assign>

<exp>

<term>

<term>

<factor> <factor>

id := id DIV int
{X} {Y} {50}

PART OF THE PASCAL GRAMMAR


1. <prog> ::= PROGRAM <prog-name> VAR <dec-list> BEGIN <stmt-list> END
2. <prog-name>::= id
3. <dec-list> ::= <dec> | <dec-list> ; <dec>
4. <dec> ::= <id-list> : <type>
5. <type> ::= INTEGER
6. <id-list> ::= id | <id-list> , id
7. <stmt-list>::= <stmt> | <stmt-list> ; <stmt>
8. <stmt> ::= <assign> | <read> | <write> | for
9. <assign> ::= id := <exp>
10. <exp> ::= <term> | <exp> + <term> | <exp> - <term>
11. <term> ::= <factor> | <term * <factor> | <term> DIV <factor>
12. <factor> ::= id | int | ( <exp>)
13. <read> ::= READ ( <id-list> )
14. <write> ::= WRITE ( <id-list> )
15. <for> ::= FOR <index-exp> DO <body>
16. <index-exp> ::= id := <exp> TO <exp>
17. <body> ::= <stmt> | BEGIN <stmt-list> END

Saturday 2nd May, 2015

You might also like