100% found this document useful (1 vote)
3K views

Chapter 3 - Solution

The document provides an assembly language program and details about instruction mnemonics and codes. It asks to: 1. Show the symbol table contents after pass 1 of the assembler. 2. Generate the intermediate code for the program using Variant II representation.

Uploaded by

Ridham Vyas
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
3K views

Chapter 3 - Solution

The document provides an assembly language program and details about instruction mnemonics and codes. It asks to: 1. Show the symbol table contents after pass 1 of the assembler. 2. Generate the intermediate code for the program using Variant II representation.

Uploaded by

Ridham Vyas
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

QUESTION BANK

CHAPTER 3
ASSEMBLERS

2 Let us consider a two pass assembler and assume that each instruction isone word. 07
Given an assembly program and code for Mnemonics.

SYMBOL TABLE
No. Symbol Address length
01 A 107 1
02 B 108 1
03 D 109 1

Mnemonic Address Machine Code VARIANT – I Variant – II


START 101 (AD,01) (C,101) (AD,01) (C,101)
READ A 101 09 0 107 (IS,09) (S,01) (IS,09) A
READ B 102 09 0 108 (IS,09) (S,02) (IS,09) B
MOVER BREG, A 103 04 2 107 (IS,04) (2)(S,01) (IS,04) BREG, A
MULT BREG, B 104 03 2 108 (IS,03) (2)(S,02) (IS,03) BREG, B
MOVEM BREG, D 105 05 2 109 (IS,05) (2)(S,03) (IS,05) BREG, D
STOP 106 00 0 000 (IS,00) (IS,00)
A DS 1 107 (DL,02) (C,1) (DL,02) (C,1)
B DS 1 108 (DL,02) (C,1) (DL,02) (C,1)
D DS 1 109 (DL,02) (C,1) (DL,02) (C,1)
END (AD,02)

(i) Show content of symbol table at the end of pass-one of an assembler.


(ii) Write intermediate code representation of the assembly program. Use
Variant-II of intermediate code representation.
13 Consider following assembly program. Show (i) Contents of Symbol Table (ii) 07
intermediate codes using Variant I representation (iii) corresponding machine
codes
(Assuming Length = 1)
SYMBOL TABLE
No. Symbol Address length
01 A 110 1
02 B 111 1
03 C 112 1
04 RESULT 113 1

Mnemonic Address Machine Code VARIANT - I


START 100 (AD,01) (C,100)
READ A 100 09 0 110 (IS,09) (S,01)
READ B 101 09 0 111 (IS,09) (S,02)
READ C 102 09 0 112 (IS,09) (S,03)
MOVER AREG, A 103 04 1 110 (IS,04) (1)(S,01)
ADD AREG, B 104 01 1 11 (IS,01) (1)(S,02)
ADD AREG, C 105 01 1 112 (IS,01) (1)(S,03)
MULT AREG, C 106 03 1 112 (IS,03) (1)(S,03)
MOVEM AREG, RESULT 107 05 1 113 (IS,05) (1)(S,04)
PRINT RESULT 108 10 0 113 (IS,10) (S,04)
STOP 109 00 0 000 (IS,00)
A DS 1 110 (DL,02) (C,1)
B DS 1 111 (DL,02) (C,1)
C DS 1 112 (DL,02) (C,1)
RESULT DS 1 113 (DL,02) (C,1)
END

Instruction opcodes:
READ – 09, MOVER – 04, MOVEM – 05, ADD – 01, MULT – 03, PRINT – 10,
STOP – 00
Assembler-directive codes: START – 01, END - 02
Register code: AREG – 01
17 Given an assembly language program for finding factorial of a given number N 07
with Mnemonic code details. Write an equivalent machinelanguage program.

ANSWER:

20 Given the source program: 07


SYMBOL TABLE
No. Symbol Address length
01 A 100 1
02 L1 1
03 B 111 1
04 C 109
05 D
06 L2
07

MNEMONIC ADDRESS Variant – I


START 100 (AD,01) (C,100)
A DS 3 100 (DL,02) (S,01)
L1 MOVER AREG,B 101 (IS,04) (1)(S,02)
ADD AREG,C 102 (IS,01) (1)(S,04)
MOVEM AREG,D 103 (IS,05) (1)(S,05)
MOVER BREG,=’2’ 104 (IS,04) (2)(L,01)
MOVER CREG,=’4’ 105 (IS,04) (3)(L,02)
D EQU A+1 (AD,04) (S,01)
L2 PRINT D 106 (IS,10) (S,05)
LTROG (DL,05)
=’2’ 107
=’4’ 108
ORIGIN A-1 (AD,03)
C DC 5 109 (DL,01) (C,04)
ORIGIN L2+3 (AD,03)
STOP 110 (IS,00)
B DC ‘19’ 111 (DL,01) (C,03)
END L1
=’5’ 112

1. Show the contents of symbol table at the end of pass I.


2. Explain the significance of EQU and ORIGIN statements in the program and
explain how they are processed by the assembler.
ANS 2. ) EQU Statement Defines Label D as A+1.
ORIGIN Statement starts Next Statement From Address of A -1.
3. Show the intermediate code generated from the program.
21 Given the source program: 07
(SAME AS 20th Question)
START 200
X DS 4
L1 MOVER AREG,Y
SUB AREG,Z
MOVEM AREG,W
W EQU X+2
L2 PRINT W
ORIGIN X-5
Z DC ‘9’
ORIGIN L2+1
STOP
Y DC ‘7’
END
1. Show the contents of symbol table at the end of pass I.
2. Explain the significance of EQU and ORIGIN statements in theprogram and
explain how they are processed by the assembler.
3. Show the intermediate code generated from the program.

25 Consider the following assembly program 07


START 500
READ N
MOVER CREG, ZERO
BK READ A
MOVER AREG, A
COMP AREG, MAX
BC LE, NT
MOVEM AREG, MAX
NT ADD CREG, ONE
COMP CREG, N
BC LT, BK
PRINT MAX
STOP
N DS 1
A DS 1
ZERO DC ‘0’
ONE DC ‘1’
MAX DC ‘0’
END
Instruction opcodes:
READ-09, MOVER-04,MOVEM-05, ADD-01,COMP-06, BC-07, PRINT-10,
STOP-00
Assembler directive codes: START 01, END-02
Register code: AREG-01, CREG-03
1. Identify task performed by above program.
2. Generate symbol table
3. Show intermediate code generated by above program
29 Given the following source program and code for mnemonics 07
1. Show the content of the symbol table at the end of pass-I of a two pass
assembler.
2. Show the intermediate code generated for program using variant-I of
intermediate code representation.
Assume that each instruction is one word.

SYMBOL TABLE
No. Symbol Address length
01 A 100 1
02 L1 1
03 B 111 1
04 C 109
05 D
06 L2
07

You might also like