Anda di halaman 1dari 6

Assignment No.

3
MCA-206: System Programming
Roll Number: _____________

Q. 1 Attempt all
a. Write a set of assembly instructions for SIC to read one byte of data from the input device and
write it to an output device. Input device code and output device code is F5 and 08 (in
hexadecimal) respectively.
b. Write functions of the pass1 of the two pass simple assembler. Also draw a flow graph for pass 1
of two pass assembler.
c. Write a program containing data and character movement operation for both SIC and SIC/XE
machine separately. The variable ALPHA must hold constant value 6 and variable ASC must hold
string 'ACK'. Given that- ASCII code of ACK is 6.
Q. 2
a. Write down machine code for a series of LDB (Format 3) instructions for SIC/XE machine. Also
write the Target address generated by each instruction and the value that is loaded into register T.
Given that (PC) = 004000; (B) = 005000; (X) = 000060; (4040) = 004560; (4560) = 104000; (5370) =
00B3; (B3) = 004040 (all values are in hex)
Sr. Addressing Machin Opco n i x b p e Disp/address Target The
No. mode e Code de Address value
(Hex) (LDT: loaded
68) into
register
T
1 PC relative 01101 0101 0110
0 0000
2 Base Relative 01101 0011 0111
0 0000
3 PC relative 01101 0000 0100
Indirect 0 0000
4 Immediate 01101 0000 0011
0 0000
5 Base relative 01101 0011 0001
index 0 0000

b. Find the addressing modes, Target Address (displacement value dependent on flags x, b, p & e)
and operand value (Target Address with flag n & i) for any three instructions of the code below
written in memory at memory location 2000 hex. Assume same memory location (i.e. PC) for all the
instructions.
Text record in object program is T0020000D08A0001E2FFA0810336D102060
{A series of instructions may include : LDL [opcode 08; L<-(m)], SUB [opcode 1C; A<-(A)-(m)], LDS
[opcode 6C; S<-(m)]}. Given that (L) = 201010; (A) = 00202F; (PC) = 02000; (B) = 03000; (X) =
00060; (02060) = 010010; (8A000) = 002000; (04040)=002010; (01033)=001B; (00FFA)=002040 (all
values are in hex)
After execution, tell which registers and memory location(s) will change and give the values of
these registers and memory locations after execution of these instructions.
Addressing Mode Target Operand After execution PC
Address Value values of registers
(L/A/S) and
memory location
Instruction 1 L
Instruction 2 A

1
Assignment No. 3
MCA-206: System Programming
Roll Number: _____________

Instruction 3 L
Instruction 4 S

Q3. Write the object code for the following assembly program, prepare symbol table with the fields
such as Symbol Name and Value.
Line Location Label Operatio Operand Opcode/For Object Code
No. n mat
5 0000 COPY START 0
10 0000 FIRST STL RETADR 14/3
13 LDB #LENGTH 68/3
14 BASE LENGTH
15 0006 CLOOP +JSUB RDREC 48/4
20 LDA LENGTH 00/3
25 COMP #0 28/3
30 JEQ ENDFIL 30/3
35 +JSUB WRREC 48/4
40 J CLOOP 3C/3
45 001A ENDFIL LDA EOF 00/3
50 STA BUFFER 0C/3
55 LDA #3 00/3
60 STA LENGTH 0C/3
65 +JSUB WRREC 48/4
70 J @RETADR 3C/3
93 LTORG
002D * =CEOF
95 RETADR RESW 1
100 LENGTH RESW 1
105 BUFFER RESB 4096
106 BUFEND EQU *
107 1000 MAXLEN EQU BUFEND-
BUFFER
: :
125 1036 RDREC CLEAR X B4/2
: :
: :
210 105D WRREC CLEAR X B4/2
:
: 1073 RSUB 4C/3
255 END FIRST
* =X05
SYMTAB:

SYMBOL VALUE
NAME

2
Assignment No. 3
MCA-206: System Programming
Roll Number: _____________

Q4. Write short notes on-


1. Dynamic linking
2. SIC/XE machine architecture
3. Bootstrap Loaders
4. Automatic Library Search
5. Conditional Macro Expansion
6. Machine independent macro processor features
7. Phases of compilations.
8. Recursive macro expansion

Q5. Compare the following


1. Compiler and interpreter
2. Linking Loader and Linkage Editor
3. Literal and Immediate Addressing

Q6. Write algorithm for pass 1 of two pass assembler. Also draw flowgraph for pass 1 and pass 2 of
two pass assembler.

Q.7 Explain the following machine independent assembler features in detail : Literals, Symbol
defining statements, Expressions.

Q. 8 Apply the logic of linking loader to perform relocation and linking operations on REF4 for
PROGA (Refere figure 1). Generate modification record for REF8. Also construct the block schematic
to illustrate the linking process via address relocation. Load addresses of PROGA and PROGC are
004000 and 0040E2 respectively.
0000 PROGA START 0
EXTDEF LISTA, ENDA
EXTREF LISTB, ENDB, LISTC, ENDC

0020 REF1 LDA LISTA 03201D
0023 REF2 +LDT LISTB+4 77100004
0027 REF3 LDX #ENDA-LISTA 050014

0040 LISTA EQU *
0054 ENDA EQU *
0054 REF4 WORD ENDA-LISTA+LISTC 000014
0057 REF5 WORD ENDC-LISTC-10 FFFFF6
005A REF6 WORD ENDC-LISTC+LISTA-1 00003F
005D REF7 WORD ENDA-LISTA-(ENDB-LISTB) 000014
3
Assignment No. 3
MCA-206: System Programming
Roll Number: _____________

0060 REF8 WORD LISTB-LISTA FFFFC0


END REF1

0000 PROGC START 0


..
..
0030 LISTC EQU *
..
Figure 1 Sample program illustrating linking and relocation

Q9. In the program (Table 1), suppose we used three program blocks: default, CDATA and CBLKS.
Describe and depict the assembly and loading process that would take place. Also populate the
working table/symbol table(for program blocks only) which is generated after pass 1. Assign the
block number and LOCCTR value to each line of code. Also, assign addresses to each instruction
and constant.
Table 1

Line Block No Addre Label Op-code Operan Structure of working Table


Block Block Addres
ss Lengt d
Nam
10 Numb s hCOPY START 0
e
20 er FIRST LDA IN
30 COMP = X42
40 JLT FIRST
50 JSUB ADIV List the entries of following tables in
60 RSUB the sequence of their insertion
70 USE CDATA c) LITTAB (Name, value, address,
80 LTORG length and type are the fields of
90 IN RESW 1 LITTAB) and []
100 USE CBLKS d) SYMTAB (Label, value and Type are
110 BUFFER RESW 4096 the fields of SYMTAB)
for each entry in the tables, specify
120 BUFEND EQU *
type of value (Relative / Absolute).
..
130 USE
140 ADIV DIVR X, A
150 STX =50
160 RSUB
170 USE CDATA
180 LTORG
190 END

Q10. When different control sections are assembled together, the references between them being
passed on to the loader. Follow the scheme to generate object program corresponding to the
program of figure 2.
Q11. Design tables and logic for a Linking Loader.Write down algorithm for pass 1 and pass2 of a
linking loader.
Q12. Expalin Macros and basic macro processor functions. Implement macro processor tables and
logic. Also write down pseudo code/algorithm for a one pass macro processor.
Q13. Illustrate recursive macro expansion with the the help of example.

4
Assignment No. 3
MCA-206: System Programming
Roll Number: _____________

Q14. Design recursive descent parser for i. READ statement, ii. an assignment statement.
Q15. Given the grammar
expexp addop term | term
addop+ | -
termterm mulop factor | factor
mulop*
factor (exp) | number
number0|1|2|3|4|5|6|7|8|9
write down leftmost derivations, and parse tree for the following expressions:
a. 3+4*5-6 b. 3*(4-5+6) c. 3-(4+5*6)
Q16. Describe top-down parsing by backtracking and recursive descent method.

5
Assignment No. 3
MCA-206: System Programming
Roll Number: _____________

Figure 2 Sample program with control section

Anda mungkin juga menyukai