Professional Documents
Culture Documents
Ques. Max
Question
No. Marks
1-a With syntax and example explain types of assembly language statements. 04
Sol: An assembly language statement has the following format:
[Label] <Opcode> <operand specification>
Label:- It is a symbolic name. It is an optional field
Opcode:- Use Assembly mnemonics
operand specification> has following syntax:
<symbolic name> [± <displacement>] [(<index register>)]
• Example:
AGAIN MULT BREG, A
• Three types of assembly statements are:
1. Imperative statement:
An imperative statement indicates an action to be performed during the
execution of the assembled statement.
Each imperative statement converted into one machine instruction.
These are executable statements.
Examples:
MOVER BREG,X
ADD AREG,Y
PRINT RESULT
STOP
2. Declaration statement :
Declaration statements are used for reserving memory for variables.
The syntax of declaration statement is as follow:
[Label] DS <constant>
[Label] DC ‘<value>’
Where DS stands for Declare storage and DC stands for Declare constant.
3. Assembler directive
Assembler directives instruct the assembler to perform certain action
during the assembly program.
Assembler directives are not converted into machine code rather they give
instruction to assembler itself.
Example
Page 1 of 8
Pune Institute of Computer Technology, Pune-43
DEPARTMENT OF INFORMATION TECHNOLOGY
(Academic Year – 2019-20 Sem-II)
SAMPLE SOLUTION UNIT TEST - I
2. END:
Syntax:
END [<operand specification>]
This directive indicates end of the source program.
The operand specification indicates address of the instruction from where
the execution of program should begin.
Execution control should transfer to label given in operand field.
By default, execution begins with the first instruction of the assembly
program.
3. ORIGIN:
Syntax:
ORIGIN <address specification>
Where <address specification> is an <operand specification> or
<constant>.
This directive indicates that LC should be set to the address given by
<address specification>.
The ORIGIN statement is useful when the target program does not consist
of consecutive memory words.
4. EQU:
Syntax
<symbol> EQU <address specification>
Where <address specification> is either a <constant> or <symbolic name>
± <displacement>.
The EQU statement simply associates the name <symbol> with the
address specified by <address specification>.
However, the address in the location counter is not affected.
5. LTORG:
The LTORG directive, stands for 'origin for literals'.
LTORG allows a programmer to specify where literals should be placed.
Page 2 of 8
Pune Institute of Computer Technology, Pune-43
DEPARTMENT OF INFORMATION TECHNOLOGY
(Academic Year – 2019-20 Sem-II)
SAMPLE SOLUTION UNIT TEST - I
For the given assembly code generate MNT, MDT and expanded code
2-a 07
MACRO START 100
M1 &N, &A1 = ,&R=AREG READ VAR
Sol:- Macro Definition Table (MDT):
MOVEM &R, &N M2 A, OPR =SUB
Index Label, Opcode and Operands (Cards)
SUB &R, &A1 ADD AREG, VAR
1 M1 &N, &A1 = ,&R=AREG
ADD &R, &N LDA CREG, BREG
2 MOVEM BREG, #1
MEND SUB CREG, A
3 SUB BREG, #2
MACRO M1 C, R = BREG, A1 =A
4 ADD BREG, #1
M2 &P, &Q = B, &OPR = A DS 1
5 MEND
DIV VAR DC 2
6 M2 &P, &Q = B, &OPR =
MOVER AREG, &P
MOVER C AREG, #1 DS 3
7
&OPR AREG, &Q
8 #3 AREG, #2
MOVEM BREG, &P
9 MOVEM BREG, #3
MEND
10 MEND
Page 3 of 8
Pune Institute of Computer Technology, Pune-43
DEPARTMENT OF INFORMATION TECHNOLOGY
(Academic Year – 2019-20 Sem-II)
SAMPLE SOLUTION UNIT TEST - I
START 100
READ VAR
+ MOVER AREG, A
+ SUB AREG, B
+ MOVEM BREG, A
ADD AREG, VAR
LDA CREG, BREG
SUB CREG, A
+ MOVEM BREG, C
+ SUB BREG, A
+ ADD BREG, C
A DS 1
VAR DC 2
C DS 3
END
}
Sol:-
Terminal Table Identifier Table
Index Symbol Index Symbol Name
1 ( 1 main
2 ) 2 volume
3 { 3 length
4 float 4 breath
5 = 5 height
6 ,
7 ;
8 Literal Table
clrscr
9Index Symbol Name
printf
1
10 “0.0
2
11 Enter length,
scanf
breadth and
12 %
height of cube:
13
3 *%f %f %f
14
4 getch
Volume = %f
15 }
16 &
Page 5 of 8
Pune Institute of Computer Technology, Pune-43
DEPARTMENT OF INFORMATION TECHNOLOGY
(Academic Year – 2019-20 Sem-II)
SAMPLE SOLUTION UNIT TEST - I
Page 6 of 8
Pune Institute of Computer Technology, Pune-43
DEPARTMENT OF INFORMATION TECHNOLOGY
(Academic Year – 2019-20 Sem-II)
SAMPLE SOLUTION UNIT TEST - I
-----------******-----------
Page 8 of 8