Nothing Special   »   [go: up one dir, main page]

MIC 22415 Model Answers

Download as pdf or txt
Download as pdf or txt
You are on page 1of 147

Zeal Education Society’s

ZEAL POLYTECHNIC, PUNE.


NARHE │PUNE -41 │ INDIA

SECOND YEAR (SY)


DIPLOMA IN COMPUTER ENGINEERING
SCHEME: I SEMESTER: IV

NAME OF SUBJECT: MICROPROCESSOR


SUBJECT CODE: 22415

MSBTE QUESTION PAPERS & MODEL ANSWERS


1. MSBTE SUMMER -19 EXAMINATION
2. MSBTE WINTER -19 EXAMINATION
3. MSBTE SUMMER -22 EXAMINATION
4. MSBTE WINTER -22 EXAMINATION
5. MSBTE SUMMER -23 EXAMINATION
6. MSBTE WINTER -23 EXAMINATION
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
SUMMER – 2023 EXAMINATION
Model Answer – Only for the Use of RAC Assessors

Subject Name: Microprocessors Subject Code: 22415


Important Instructions to examiners: XXXXX
1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme.
2) The model answer and the answer written by candidate may vary but the examiner may try to assess the
understanding level of the candidate.
3) The language errors such as grammatical, spelling errors should not be given more Importance (Not applicable for
subject English and Communication Skills.
4) While assessing figures, examiner may give credit for principal components indicated in the figure. The figures drawn
by candidate and model answer may vary. The examiner may give credit for any equivalent figure drawn.
5) Credits may be given step wise for numerical problems. In some cases, the assumed constant values may vary and
there may be some difference in the candidate’s answers and model answer.
6) In case of some questions credit may be given by judgement on part of examiner of relevant answer based on
candidate’s understanding.
7) For programming language papers, credit may be given to any other program based on equivalent concept.
8) As per the policy decision of Maharashtra State Government, teaching in English/Marathi and Bilingual (English +
Marathi) medium is introduced at first year of AICTE diploma Programme from academic year 2021-2022. Hence if
the students in first year (first and second semesters) write answers in Marathi or bilingual language (English
+Marathi), the Examiner shall consider the same and assess the answer based on matching of concepts with model
answer.

Q. Sub Answer Marking


No. Q. Scheme
N.

1 Attempt any FIVE of the following: 10 M

a) State the functions of the following pins of 8086 Microprocessor : 2M


i) ALE
ii) M/IO

Ans ALE - It stands for address enable latch and is available at pin 25. A positive pulse is 1M
generated each time the processor begins any operation. This signal indicates the
availability of a valid address on the address/data lines.
M/IO - This signal is used to distinguish between memory and I/O operations. When it is 1M
high, it indicates I/O operation and when it is low indicating the memory operation. It is
available at pin 28.
b) State the function of STC and CMC Instruction of 8086. 2M

Ans STC – This instruction is used to Set Carry Flag. CF 1 1M

CMC – This instruction is used to Complement Carry Flag. CF ~ CF 1M

Page No: 1 | 25
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
c) List the program development steps for assembly language 2M
programming.

Ans Program Development steps: 2M

1. Defining the problem

2. Algorithm

3. Flowchart

4. Initialization checklist

5. Choosing instructions

6. Converting algorithms to assembly language program

d) Define MACRO with its syntax. 2M

Ans Macro: A MACRO is group of small instructions that usually performs one task. It is a 1M
reusable section of a software program. A macro can be defined anywhere in a program
using directive MACRO &ENDM.
1M
Syntax: MACRO-name MACRO [ARGUMENT 1,……….ARGUMENT N]

-----

ENDM

e) Write an ALP to Add two 16-bit numbers. 2M

Ans data segment Any correct


a dw 0202h program –
b dw 0408h 2M
c dw ?
data ends

code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov ax,a
mov bx,b
add ax,bx
mov c,ax
int 03h
code ends
end start

Page No: 2 | 25
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
f) State two examples of each, Immediate and based indexed 2M
Addressing modes.

Ans Immediate Addressing mode: 1 M for any


two valid
1. MOV AX, 2000H instructions

2. MOV CL, 0AH

3. ADD AL, 45H

4. AND AX, 0000H

1 M for any
Based indexed Addressing mode: two valid
instructions
1. ADD CX, [AX+SI]

2. MOV AX, [AX+DI]

3. MOV AL, [SI+BP+2000]

g) State the use of OF and AF flags in 8086. 2M

Ans Auxiliary Carry Flag (AF): 1M

This flag is used in BCD (Binary-coded Decimal) operations.

This flag is set to 1 if there is a CARRY from the lower nibble or BORROW for the lower
nibble in binary representation; else it is set to zero.

Overflow Flag (OF): 1M

This flag will be set (1) if the result of a signed operation is too large to fit in the number
of bits available to represent it, otherwise reset (0).

2. Attempt any THREE of the following: 12 M

a) Differentiate between NEAR and FAR CALLS. 4M

Page No: 3 | 25
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans 1 M for each
valid point

b) Explain the concept of memory segmentation in 8086. 4M

Ans Memory Segmentation: The memory in an 8086 microprocessor is organized as a Explanation-


segmented memory. The physical memory is divided into 4 segments namely, - Data 2 M,
segment, Code Segment, Stack Segment and Extra Segment. Diagram-
2M
Description:

• Data segment is used to hold data, Code segment for the executable program, Extra
segment also holds data specifically in strings and stack segment is used to store stack
data.

• Each segment is 64Kbytes & addressed by one segment register. i.e. CS, DS, ES or SS

• The 16-bit segment register holds the starting address of the segment.

• The offset address to this segment address is specified as a 16-bit displacement (offset)
between 0000 to FFFFH. Hence maximum size of any segment is 216=64K locations.

• Since the memory size of 8086 is 1Mbytes, total 16 segments are possible with each
having 64Kbytes.

• The offset address values are from 0000H to FFFFH, so the physical address range from
00000H to FFFFFH.

Page No: 4 | 25
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

c) State the Assembler Directives used in 8086 and describe the function of 4M
any two.
Ans Assembler directives: List - 2 M
1) DW
2) EQU
3) ASSUME
4) OFFSET
5) SEGMENT
6) EVEN

Function of any two:

1)DW (DEFINE WORD): Function of


The DW directive is used to tell the assembler to define a variable of type word or to each
reserve storage locations of type word in memory. The statement MULTIPLIER DW directive 1
437AH, for example, declares a variable of type word named MULTIPLIER, and M
initialized with the value 437AH when the program is loaded into memory to be run.

2)EQU (EQUATE):
EQU is used to give a name to some value or symbol. Each time the assembler finds the
given name in the program, it replaces the name with the value or symbol you equated
with that name.
Example:
Data SEGMENT
Num1 EQU 50H
Num2 EQU 66H
Data ENDS
Numeric value 50H and 66H are assigned to Num1 and Num2.
d) Identify the Addressing Modes for the following instructions: 4M

Page No: 5 | 25
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
I. MOV CL, 34H
II. MOV BX, [4100H]
III. MOV DS, AX
IV. MOV AX, [SI+BX+04]
Ans I. MOV CL, 34H: Immediate addressing mode. 1M
II. MOV BX, [4100H]: Direct addressing mode. 1M
III. MOV DS, AX: Resister addressing mode. 1M
1M
IV. MOV AX, [SI+BX+04]: Relative Base Index addressing mode.

3. Attempt any THREE of the following: 12 M

a) Explain the concept of pipelining in 8086 microprocessor with diagram. 4M

Ans • In 8086, pipelining is the technique of overlapping instruction fetch and execution Explanation-
mechanism. 3 M,
Diagram-
• To speed up program execution, the BIU fetches as many as six instruction bytes 1M
ahead of time from memory. The size of instruction prefetching queue in 8086 is
6 bytes.

• While executing one instruction other instruction can be fetched. Thus it avoids
the waiting time for execution unit to receive other instruction.

• BIU stores the fetched instructions in a 6 level deep FIFO. The BIU can be
fetching instructions bytes while the EU is decoding an instruction or executing
an instruction which does not require use of the buses

• When the EU is ready for its next instruction, it simply reads the instruction from
the queue in the BIU

• This is much faster than sending out an address to the system memory and waiting
for memory to send back the next instruction byte or bytes.

• This improves overall speed of the processor.

Page No: 6 | 25
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

OR

b) Write an alp to perform block transfer operation of 10 numbers 4M

Ans WITHOUT STRING INSTRUCTION Correct


program -
.MODEL SMALL 4M
.DATA
ARR1 DB 00H,01H,02H,03H,04H,05H,06,07H.08H.09H
ARR2 DB 10 DUP(00H)
ENDS
.CODE
START:
MOV AX, @DATA
MOV DS,AX
MOV SI, OFFSET ARR1
MOV DI, OFFSET ARR2
MOV CX ,0000A
BACK: MOV AL,[SI]
MOV [DI],AL
INC SI
INC DI

Page No: 7 | 25
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
LOOP BACK
MOV AH,4CH
INT 21H
ENDS
END START
OR
WITH STRING INSTRUCTION
.MODEL SMALL
.DATA
ARR1 DB 00H, 01H,02H,03H,04H,05H,06,07H.08H.09H
ARR2 DB 10 DUP(00H)
ENDS
.CODE
START:MOV AX,@DATA
MOV DS,AX
MOV SI,OFFSET ARR1
MOV DI, OFFSET ARR2
MOV CX,0000A
REP MOVSB
MOV AH,4CH
INT 21H
ENDS
END START

c) Write an ALP to subtract two BCD number’s. 4M

Ans .MODEL SMALL Correct


program -
.DATA 4M
NUM1 DB 86H
NUM2 DB 57H

Page No: 8 | 25
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
ENDS
.CODE
START:
MOV AX@,DATA
MOV DS,AX
MOV AL,NUM1
SUB AL,NUM2
DAS
MOV BL,AL // STORE FINAL RESULT IN BL REGISTER
MOV AH,4CH
INT 21H
ENDS
END START

d) Compare procedure and macros (4 points). 4M

Ans Sr.No. MACRO PROCEDURE One point 1


M each
1 Macro is a small sequence of Procedure is a series of
code of the same pattern, instructions is to be executed
repeated frequently at different several times in a program, and
places, which perform the same called whenever required.
operation on different data of
the same data type

2 The MACRO code is inserted Program control is transferred


into the program, wherever to the procedure, when CALL
MACRO is called, by the instruction is executed at run
assembler time.

3 Memory required is more, as Memory required is less, as the


the code is inserted at each program control is transferred
MACRO call to procedure.

4 Stack is not required at the Stack is required at Procedure


MACRO call. CALL

5. Less time required for its Extra time is required for


linkage between the calling
execution program and called procedure.

Page No: 9 | 25
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
6 Parameter passed as the part of Parameters passed in registers,
statement which calls macro. memory locations or stack.

7 RET is not used RET is required at the end of


the procedure

8 Macro is called< Macro Procedure is called using:


NAME> [argument list]
CALL< procedure name>

9 Directives used: MACRO, Directives used: PROC, ENDP


ENDM,

4. Attempt any THREE of the following: 12 M

a) Differentiate between minimum mode and maximum of 8086 microprocessor. 4M

Ans Sr.No. Minimum Mode Maximum Mode Any four


points- 4 M
1 MN/MX’ pin is connected MN/MX’ pin is connected
to Vcc. i.e. MN/MX = 1 to ground. i.e. MN/MX = 0

2 Control system M/ IO’ , Control system M/ IO’ ,


RD’ , WR’ is available on RD’ , WR’ is not available
8086 directly directly in 8086

3 Single processor in the Multiprocessor


minimum mode system configuration in maximum
mode system

4 In this mode, no separate Separate bus controller


bus controller is required (8288) is required in
maximum mode

5 Control signals such as Control signals such as


IOR’ , IOW’ , MEMW’ , MRDC’ , MWTC’ ,
MEMR’ can be generated AMWC’ , IORC’ , IOWC’
using control signals M/IO , and AIOWC’ are
, RD , WR which are generated by bus controller
available on 8086 directly. 8288.

6 HOLD and HLDA signals RQ / GTQ and RQ / GT 1


are available to interface signals are available to
another master in system interface another master in
such as DMA controller. system such as DMA

Page No: 10 | 25
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
controller and coprocessor
8087.

7 This circuit is simpler This circuit is complex

b) Write an ALP for sum of series of 05 number’s. 4M

Ans .MODEL SMALL Correct


program - 4
.DATA M
NUM1 DB 10H,20H,30H,40H,50H
RESULT DB 00H
CARRY DB 00H
ENDS
.CODE
START: MOV AX,@DATA
MOV DS, AX
MOV CL,05H
MOV SI, OFFSET NUM1
UP:MOV AL,[SI]
ADD RESULT, AL
JNC NEXT
INC CARRY
NEXT: INC SI
LOOP UP
MOV AH,4CH
INT 21H
ENDS
END START

c) Write an ALP to find largest number from array of 10 number’s. 4M

Ans .MODEL SMALL Correct


program - 4
.DATA M

Page No: 11 | 25
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
ARRAY DB 02H,04H,06H,01H,05H,09H,0AH,0CH.00H,07H
ENDS
.CODE
START: MOV AX,@DATA
MOV DS,AX
MOV CL,09H
LEA SI,ARRAY
MOV AL,[SI]
UP : INC SI
CMP AL,[SI]
JNC NEXT
MOV AL[SI]
NEXT : DEC CL
JNZ UP
MOV AH,4CH
INT 21H
ENDS
END START

d) Describe re-entrant and Recursive procedure with diagram. 4M

Ans A recursive procedure is procedure which calls itself. This results in the procedure call to Explanation
be generated from within the procedures again and again. re-entrant
and
The recursive procedures keep on executing until the termination condition is reached. Recursive-
2M each
The recursive procedures are very effective to use and to implement but they take a large
amount of stack space and the linking of the procedure within the procedure takes more
time as well as puts extra load on the processor.

Page No: 12 | 25
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

2) Re-entrant procedures:
In some situation it may happen that Procedure 1 is called from main program,
Procrdure2 is called from procedure1And procedure1 is again called from procdure2. In
this situation program execution flow re-enters in the procedure1. These types of
procedures are called re-entrant procedures.
A procedure is said to be re-entrant, if it can be interrupted, used and re-entered without
losing or writing over anything.

e) Explain MACRO with suitable example. List four advantages of it. 4M

Ans • Macro is a small sequence of code of the same pattern, repeated frequently at Macro
different places, which perform the same operation on different data of the same explanation-
data type 1 M,

• The MACRO code is inserted into the program, wherever MACRO is called, by Example-
the assembler 1 M,

• Memory required is more, as the code is inserted at each MACRO call Advantages-
2M
Syntax: Macro_name MACRO [arg1,arg2,.....argN)
.....
endM

Page No: 13 | 25
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Example: (Any Same
Type of
.MODEL SMALL Example
can be
PROG MACRO A,B
considered)
MOV AL,A
MUL AL
MOV BL,AL
MOV AL,B
MUL AL
ADD AL,BL
ENDM
.DATA
X DB 02H
Y DB 03H
P DB DUP()
ENDS
.CODE
START:
MOV AX,DATA
MOV DS,AX
PROG X, Y
MOV P,AL
MOV AH,4CH
INT 21H
END START
ENDS
Advantages of Macro:
1) Program written with macro is more readable.
2) Macro can be called just writing by its name along with parameters, hence no extra
code is required like CALL & RET.

Page No: 14 | 25
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
3) Execution time is less because of no linking and returning to main program.
4) Finding errors during debugging is easier.

5. Attempt any TWO of the following: 12 M

a) Define logical and effective address. Describe Physical address generation in 6M


8086. If CS = 2135 H and IP = 3478H, calculate Physical Address.

Ans A logical address: A logical address is the address at which an item (memory cell, storage Defination-
element) appears to reside from the perspective of an executing application program. A 3M,
logical address may be different from the physical address due to the operation of an Physical
address
address translator or mapping function.
generation-
Effective Address or Offset Address: The offset for a memory operand is called the 3M
operand's effective address or EA. It is an unassigned 16-bit number that expresses the
operand's distance in bytes from the beginning of the segment in which it resides. In 8086
we have base registers and index registers.

Procedure for Generation of 20-bit physical address in 8086: -

1. Segment registers carry 16-bit data, which is also known as base address.

2. BIU appends four 0 bits to LSB of the base address. This address becomes 20-bit
address.

3. Any base/pointer or index register carries 16 bits offset.

4. Offset address is added into 20-bit base address which finally forms 20-bit physical
address of memory location

CS=2135H and IP=3475H

Physical address = CS*10H + IP

= 2135H * 10H + 3475H

= 21350 + 3475

= 247C5H

b) Explain the following assembler directives: 6M

(i) DB (ii) DW (iii) EQU (iv) DUP (v) SEGMENT (vi) END

Ans (i) DB (Define Byte) – The DB directive is used to declare a BYTE -2-BYTE Each
variable – A BYTE is made up of 8 bits. Declaration assembler
Examples:

Page No: 15 | 25
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Byte1 DB 10h directives-
Byte2 DB 255; 0FFh, the max. possible for a BYTE 1M
CRLF DB 0Dh, 0Ah, 24h; Carriage Return, terminator BYTE

(ii) DW (Define Word): The DW directive is used to tell the assembler to define
a variable of type word or to reserve storage locations of type word in memory.
The statement MULTIPLIER DW 437AH.
Example, declares a variable of type word named MULTIPLIER, and
initialized with the value 437AH when the program is loaded into memory to
be run.

(iii) EQU (EQUATE): EQU is used to give a name to some value or symbol. Each
time the assembler finds the given name in the program, it replaces the name
with the value or symbol you equated with that name.
Example -
Data SEGMENT
Num1 EQU 50H
Num2 EQU 66H
Data ENDS

Numeric value 50H and 66H are assigned to Num1 and Num2.

(iv) DUP: - It can be used to initialize several locations to zero.


e. g. SUM DW 4 DUP(0)
- Reserves four words starting at the offset sum in DS and initializes them to
Zero.
- Also used to reserve several locations that need not be initialized. In this case
(?) is used with DUP directives.
E. g. PRICE DB 100 DUP(?)
- Reserves 100 bytes of uninitialized data space to an offset PRICE.

(v) SEGMENT: - The SEGMENT directive is used to indicate the start of a


logical segment. Preceding the SEGMENT directive is the name you want to
give the segment. For example, the statement CODE SEGMENT indicates to
the assembler the start of a logical segment called CODE. The SEGMENT
and ENDS directive are used to “bracket” a logical segment containing code
of data.

(vi) END: - An END directive ends the entire program and appears as the last
statement. –
ENDS directive ends a segment and ENDP directive ends a procedure.
END PROC-Name

Page No: 16 | 25
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
c) Explain with suitable example the Instruction given below : 6M

(i) DAA (ii) AAM

Ans (i) DAA – Decimal Adjust after BCD Addition: When two BCD numbers are Each
added, the DAA is used after ADD or ADC instruction to get correct answer in BCD. Instruction-
3M
Syntax- DAA (DAA is Decimal Adjust after BCD Addition)
Explanation: This instruction is used to make sure the result of adding two packed BCD
numbers is adjusted to be a correct BCD number. The result of the addition must be in
AL for DAA instruction to work correctly. If the lower nibble in AL after addition is > 9
or Auxiliary Carry Flag is set, then add 6 to lower nibble of AL. If the upper nibble in AL
is > 9H or Carry Flag is set, and then add 6 to upper nibble of AL.
Example: - (Any Same Type of Example)
AL=99 BCD and BL=99 BCD
Then ADD AL, BL
1001 1001 = AL= 99 BCD +
1001 1001 = BL = 99 BCD
0011 0010 = AL =32 H
and CF=1, AF=1 After the execution of DAA instruction, the result is CF = 1 0011
0010 =AL =32 H AH =1 + 0110 0110 ------------------------- 1001 1000 =AL =98 in
BCD

(ii) AAM - Adjust result of BCD Multiplication: This instruction is used after the
multiplication of two unpacked BCD.
The AAM mnemonic stands for ASCII adjust for Multiplication or BCD Adjust after
Multiply. This instruction is used in the process of multiplying two ASCII digits. The
process begins with masking the upper 4 bits of each digit, leaving an unpacked BCD in
each byte. These unpacked BCD digits are then multiplied and the AAM instruction is
subsequently used to adjust the product to two unpacked BCD digits in AX.
AAM works only after the multiplication of two unpacked BCD bytes, and it works only
on an operand in AL.
Example
Multiply 9 and 5

MOV AL, 00000101


MOV BH, 00001001

Page No: 17 | 25
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
MUL BH ;Result stored in AX
;AX = 00000000 00101101 = 2DH = 45 in decimals
AAM ;AX = 00000100 00000101 = 0405H = 45 in unpacked BCD
; If ASCII values are required an OR operation with 3030H can follow this step.

6. Attempt any TWO of the following: 12 M

a) Write an appropriate 8086 instruction to perform following operations. 6M

(i) Rotate the content of BX register towards right by 4 bits.


(ii) Rotate the content of AX towards left by 2bits.
(iii) Add 100H to the content of AX register.
(iv) Transfer 1234H to DX register.
(v) Multiply AL by 08 H.
(vi) Signed division of BL and AL
Ans 1. Rotate the content of BX register towards right by 4 bits – Each
Instruction-
MOV CL, 04H 1M
ROR BX, CL

2. Rotate the content of AX towards left by 2bits –


MOV CL, 02H
ROL AX, CL

3. Add 100H to the content of AX register –


ADD AX,0100H.

4. Transfer 1234H to DX register –


MOV DX,1234H

5. Multiply AL by 08H –

MOV BL,08h
MUL BL

6. Signed division of BL and AL

IDIV BL

Page No: 18 | 25
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
b) Explain Addressing modes of 8086 with suitable example. 6M

Ans 1. Immediate addressing mode: An instruction in which 8-bit or 16-bit operand Each
(data) is specified in the instruction, then the addressing mode of such instruction Addressing
is known as immediate addressing mode. Mode – 1M

Example: MOV AX,67D3H

2. Register addressing mode: An instruction in which an operand (data) is specified


in general purpose registers, then the addressing mode is known as register
addressing mode.

Example: MOV AX, CX

3. Direct addressing mode: An instruction in which 16-bit effective address of an


operand is specified in the instruction, then the addressing mode of such
instruction is known as direct addressing mode.

Example: MOV CL,[2000H]

4. Register Indirect addressing mode: An instruction in which address of an operand


is specified in pointer register or in index register or in BX, then the addressing
mode is known as register indirect addressing mode.

Example: MOV AX,[BX]

5 Indexed addressing mode: An instruction in which the offset address of an


operand is stored in index registers (SI or DI) then the addressing mode of such
instruction is known as indexed addressing mode. DS is the default segment for
SI and DI. For string instructions DS and ES are the default segments for SI and
DI resp. this is a special case of register indirect addressing mode.

Example: MOV AX,[SI]

6. Based Indexed addressing mode: An instruction in which the address of an


operand is obtained by adding the content of base register (BX or BP) to the
content of an index register (SI or DI) The default segment register may be DS or
ES

Example: MOV AX,[BX][SI]

7. Register relative addressing mode: An instruction in which the address of the


operand is obtained by adding the displacement (8-bit or 16 bit) with the contents
of base registers or index registers (BX, BP, SI, DI). The default segment register
is DS or ES.

Page No: 19 | 25
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Example: MOV AX,50H[BX]

8. Relative Based Indexed addressing mode: An instruction in which the address of


the operand is obtained by adding the displacement (8 bit or 16 bit) with the base
registers (BX or BP) and index registers (SI or DI) to the default segment.

Example: MOV AX,50H [BX][SI]

c) Write an ALP to transfer 10 bytes of data from one memory location to 6M


another, also draw the flow chart of the same.

Ans Data Block Transfer Using String Instruction Correct


Code-4M,
.MODEL SMALL
.DATA
BLOCK1 DB 01H,02H,03H,04H,05H,06H,07H,08H,09H,0AH Flowchart-
BLOCK2 DB 10(?) 2M
ENDS

.CODE
MOV AX, @DATA
MOV DS, AX
MOV ES, AX

LEA SI, BLOCK1


LEA DI, BLOCK2

MOV CX, 000AH ; Initialize counter for 10 data elements

CLD
REP MOVSB

MOV AH, 4CH


INT 21H
ENDS
END

Page No: 20 | 25
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

Page No: 21 | 25
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

OR

Data Block Transfer Without String Instruction

. Model small

. Data

ORG 2000H

Arr1 db 00h,01h,02h,03h,04h,05h,06h,07h,08h,09h

Count Equ 10 Dup

Org 3000H

Arr2 db 10 Dup(00h)

Ends

.code

Start: Mov ax,@data

Mov ds,ax

Mov SI,2000H

Mov DI,3000H

Mov cx, count

Back: Mov al, [SI]

Page No: 22 | 25
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Mov [DI], al

Inc SI

Inc DI

Dec cx

Jnc Back

Mov ah, 4ch


Int 21h

Ends
End

Page No: 23 | 25
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

Page No: 24 | 25
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

Page No: 25 | 25
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
WINTER – 2023 EXAMINATION
Model Answer – Only for the Use of RAC Assessors
Subject Name: Microprocessor Subject Code: 22415
Important Instructions to examiners:
1) The answers should be examined by key words and not as word-to-word as given in the model answer
scheme.
2) The model answer and the answer written by candidate may vary but the examiner may try to assess the
understanding level of the candidate.
3) The language errors such as grammatical, spelling errors should not be given more Importance (Not
applicable for subject English and Communication Skills.
4) While assessing figures, examiner may give credit for principal components indicated in the figure. The
figures drawn by candidate and model answer may vary. The examiner may give credit for any equivalent
figure drawn.
5) Credits may be given step wise for numerical problems. In some cases, the assumed constant values may
vary and there may be some difference in the candidate’s answers and model answer.
6) In case of some questions credit may be given by judgement on part of examiner of relevant answer based
on candidate’s understanding.
7) For programming language papers, credit may be given to any other program based on equivalent concept.
8) As per the policy decision of Maharashtra State Government, teaching in English/Marathi and Bilingual
(English + Marathi) medium is introduced at first year of AICTE diploma Programme from academic year
2021-2022. Hence if the students in first year (first and second semesters) write answers in Marathi or
bilingual language (English +Marathi), the Examiner shall consider the same and assess the answer based
on matching of concepts with model answer.

Q. Sub Answer Marking


No. Q. Scheme
N.

1 Attempt any FIVE of the following: 10 M

a) State the use of MN/ MX and Test signal. 2M

Ans MN/MX: - Minimum/Maximum: - This pin signal indicates what mode the processor will 1 M for
operate in. each signal
MN/MX = 1 = 8086 operates in minimum mode. In this mode the 8086 is configured to
support small single processor system using a few devices that the system bus.
MN/MX = 0 = 8086 is configured to support multiprocessor system.
Test: - It is an input pin and is only used by the wait instruction. The 8086 enter a wait state
after execution of the wait instruction until a low is seen on the test pin. If the TEST pin is
Low, execution continues otherwise the processor waits in an "idle" state. This input is
synchronized internally during each clock cycle on the leading edge of CLK.
b) List Assembly Language Programming tools. 2M

Ans 1. Editors 1/2 M for


2. Assembler each tool
3. Linker

Page No: 1 | 28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
4. Debugger.
c) Write any four-bit manipulation instructions of 8086. 2M

Ans NOT − Used to invert each bit of a byte or word. 1/2 M for
each tool
AND − Used for adding each bit in a byte/word with the corresponding bit in another
byte/word.

OR − Used to multiply each bit in a byte/word with the corresponding bit in another
byte/word.

XOR − Used to perform Exclusive-OR operation over each bit in a byte/word with the
corresponding bit in another byte/word.

d) What is the use of AAM instruction with suitable example? 2M

Ans The AAM instruction, short for "ASCII Adjust AX After Multiply," is an assembly 1 M for use
language instruction in the x86 architecture used for converting the binary result of
1 M for
multiplying two unpacked Binary-Coded Decimal (BCD) values back into a valid example
unpacked BCD format.

Example:

Let's say we want to multiply the BCD numbers 5 (0101) and 7 (0011) using the x86
architecture.

1. 1. Multiplication:
MOV AL, 5; Store 5 in AL
MOV BL, 7; Store 7 in BL
MUL BL; Multiply AL and BL, result stored in AX

2. 2. Result in AX:
AH: 0 (carry from overflow)
AL: 5 (product of lower digits)

3. 3. AAM instruction:
AAM

4. 4. Adjusted result in AX:


AH: 1 (quotient from dividing AL by 10)
AL: 5 (remainder from dividing AL by 10)
Therefore, the final result of multiplying 5 and 7 in unpacked BCD format is 35 (0011
0101).
e) Give any two advantages of pipelining in 8086. 2M

Ans 1. Increased Instruction Throughput: 1 M for


2. Improved Efficiency of the Execution Unit (EU) each

f) Draw the format of flag register of 8O86. 2M

Page No: 2 | 28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans 2 M for
format

g) Define procedure and write its syntax 2M

Ans Procedure: A procedure is group of instructions that usually performs one task. It is a 1 M for
reusable section of a software program which is stored in memory once but can be used as Definition
often as necessary. 1 M for
A procedure can be of two types. 1) Near Procedure 2) Far Procedure syntax.
Syntax :-

Procedure can be defined as

Procedure_name PROC

----

------

Procedure_name

ENDP

For Example

Addition PROC near

------

Addition ENDP

2. Attempt any THREE of the following: 12 M

Page No: 3 | 28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
a) Describe the function of the following instructions: (i) DAA (ii) CMP (iii) ADC 4M
(iv) JNC
Ans 1) DAA: Decimal adjust after addition 1 M for
This instruction is used to make sure the result of adding two packed BCD numbers is each
adjusted to be a legal BCD number. The result of the addition must be in AL for DAA to instruction
work correctly. If the lower nibble in AL after an addition is greater than 9 or AF was set (example is
by the addition, then the DAA instruction will add 6 to the lower nibble in AL. If the not
result in the upper nibble of AL in now greater than 9 or if the carry flag was set by the mandatory)
addition or correction, then the DAA instruction will add 60H to AL.

Let AL = 59 BCD, and BL = 35 BCD


ADD AL, BL AL = 8EH; lower nibble > 9, add 06H to AL
DAA AL = 94 BCD, CF = 0

Let AL = 88 BCD, and BL = 49 BCD


ADD AL, BL AL = D1H; AF = 1, add 06H to AL
DAA AL = D7H; upper nibble > 9, add 60H to AL
AL = 37 BCD, CF = 1

2) CMP: Compare
This instruction compares the source operand, which may be a register or an immediate
data or a memory location, with a destination operand that may be a register or a memory
location.
Example: -
CMP BX, 0100H
CMP AX, 0100H
CMP [5000H], 0100H
CMP BX, [SI]
CMP BX, CX

3) ADC: Add with Carry


ADC Destination, Source
This instruction performs the same operation as ADD instruction, but adds the carry flag
to the result.
Example: -
ADC 0100H
ADC AX, BX
ADC AX, [SI]
ADC AX, [5000]
ADC [5000], 0100H
4) JNC: - Stands for 'Jump if Not Carry'

Page No: 4 | 28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
It checks whether the carry flag is reset or not. If yes, then jump takes place, that is: If CF
= 0, then jump.
ADD AL, BL Add two bytes
JNC NEXT If the result within acceptable range, continue

4) JNC : Stands for 'Jump if Not Carry' It checks whether the carry flag is reset or not. If
yes, then jump takes place, that is: If CF = 0, then jump.

b) Explain Re-Entrant and Recursive Procedure with diagram. 4M

Ans 1) Re-Entrant Procedure: 1 M for


The re-entrant procedure is a very special kind of procedure. In such kind of procedure, explanation
procedure 1 is called the mainline program, then procedure 2 is called form procedure 1 1M for
and then again procedure 1 is called form procedure 2. This can be well understood from diagram
the following diagram
For each

This is called a re-entrant procedure because a procedure is re-entering into itself form
another procedure which is also present inside its own body. The re-entrant
procedure occurs in the following three conditions: when the procedure is undergoing
recursion, when multi-threading is being implemented inside a program or when some
interruption is being generated. Like the recursive procedures, it is important to have a
termination condition for the procedures in the re-entrant procedures also, else we can face
machine halts due to infinite procedure calls.

2) Recursive procedures:
A recursive procedure is a procedure which calls itself. This results in the procedure call
to be generated from within the procedures again and again. This can be understood as
follows:

Page No: 5 | 28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

The recursive procedures keep on executing until the termination condition is reached. The
recursive procedures are very effective to use and to implement but they take a large
amount of stack space and the linking of the procedure within the procedure takes more
time as well as puts extra load on the processor.

c) Write the function of following pins of 8086: 4M


(i) Ready
(ii) ALE

Ans (i) Ready: - 1 M for


This is an acknowledgment signal from the slower I/O devices or memory. When high, it each
indicates that the device is ready to transfer data, else the microprocessor is in the wait
state.
(ii) ALE:-
Address Latch Enable. ALE is provided by the microprocessor to latch the address into the
8282 or 8283 address latch. It is an active high (1) pulse during T1 of any bus cycle. ALE
signal is never floated, is always integer.

-
This is an acknowledgment signal from the slower I/O devices or memory. When high, it
indicates that the device is ready to transfer data, else the microprocessor is in the wait
state.

:
Data enable. This pin is provided as an output enable for the 8286/8287 in a minimum
system which uses transceiver. DEN is active low (0) during each memory and input-output
access and for INTA cycles.
d) Draw and explain model of Assembly Language Programming. 4M

Ans The programming model for a microprocessor shows the various internal registers that 2 M for
are accessible to the programmer. Diagram

Page No: 6 | 28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
The Following Figure is a model for the 8086. In general, each register has a special 2 M for
function. explanation

In the programming model there are

- 4 General Purpose registers(Data Registers)

- 4 Segment registers

- 2 Pointer registers

- 2 Index registers

- 1 Instruction Pointer register

- 1 Flag register

General purpose registers:

AX Register (Accumulator): This is accumulator register. It gets used in arithmetic, logic


and data transfer instructions. In manipulation and division, one of the numbers involved
must be in AX or AL.

BX Register (Base Register): This is base register. BX register is an address register. It


usually contain a data pointer used for based, based indexed or register indirect
addressing.

CX Register (Counter register): This is Count register. This serves as a loop counter.
Program loop constructions are facilitated by it. Count register can also be used as a
counter in string manipulation and shift/rotate instruction.

DX Register (Data Register): This is data register. Data register can be used as a port
number in I/O operations. It is also used in multiplication and division.

Page No: 7 | 28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Segment Registers:

There are four segment registers in Intel 8086:

1. Code Segment Register (CS),

2. Data Segment Register (DS),

3. Stack Segment Register (SS),

4. Extra Segment Register (ES).

A segment register points to the starting address of a memory segment. Maximum


capacity of a segment may be up to 64 KB.

Code segment Register (CS):- It is a 16-bit register containing the starting address of 64
KB segment. The processor uses CS segment for all accesses to instructions referenced
by instruction pointer (IP) register.

Stack segment Register (SS):- It is a 16-bit register containing address of 64KB


segment with program stack. By default, the processor assumes that all data referenced
by the stack pointer (SP) and base pointer (BP) registers is located in the stack segment.
SS register can be changed directly using POP instruction.

Data segment Register (DS):- It is a 16-bit register containing address of 64KB segment
with program data. By default, the processor assumes that all data referenced by general
registers (AX, BX, CX, DX) and index register (SI, DI) is located in the data segment.

Extra segment Register (ES):- It is a 16-bit register containing address of 64KB


segment, usually with program data. By default, the processor assumes that the DI
register references the ES segment in string manipulation instructions. It is possible to
change default segments used by general and index registers by prefixing instructions
with a CS, SS,DS or ES prefix.

Pointer Registers:

SP Register (Stack Pointer): This is stack pointer register pointing to program stack. It
is used in conjunction with SS for accessing the stack segment.

BP Register (Base Pointer): This is base pointer register pointing to data in stack
segment. Unlike SP, we can use BP to access data in the other segments.

Index Registers:

SI Register (Source Index): This is used to point to memory locations in the data
segment addressed by DS. By incrementing the contents of SI one can easily access
consecutive memory locations.

Page No: 8 | 28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
DI Register (Destination Index): This register performs the same function as SI. There
is a class of instructions called string operations, that use DI to access the memory
locations addressed by ES.

Instruction Pointer: The Instruction Pointer (IP) points to the address of the next
instruction to be executed. Its content is automatically incremented when the execution of
a program proceeds further. The contents of the IP and Code Segment Register are used
to compute the memory address of the instruction code to be fetched. This is done during
the Fetch Cycle.

Flag Register: Status Flags determines the current state of the accumulator. They are
modified automatically by CPU after mathematical operations. This allows to determine
the type of the result. 8086 has 16-bit status register. It is also called Flag Register or
Program Status Word (PSW). There are nine status flags and seven bit positions remain
unused.

8086 has 16 flag registers among which 9 are active. The purpose of the FLAGS register
is to indicate the status of the processor. It does this by setting the individual bits called
flags. There are two kinds of FLAGS;

Status FLAGS and Control FLAGS. Status FLAGS reflect the result of an operation
executed by the processor. The control FLAGS enable or disable certain operations of the
processor.

3. Attempt any THREE of the following: 12 M

a) Describe memory segmentation in 8086 and list its advantages. 4M

Ans Segmentation is the process in which the main memory of the computer is logically 1 M for
divided into different segments and each segment has its own base address. It is basically explanation
used to enhance the speed of execution of the computer system, so that the processor is 2 M for
able to fetch and execute the data from the memory easily and fast. diagram

Need for Segmentation – 1 M for


The Bus Interface Unit (BIU) contains four 16 bit special purpose registers (mentioned Advantages
below) called as Segment Registers.
• Code segment register (CS): is used for addressing memory location in the
code segment of the memory, where the executable program is stored.
• Data segment register (DS): points to the data segment of the memory
where the data is stored.
• Extra Segment Register (ES): also refers to a segment in the memory
which is another data segment in the memory.
• Stack Segment Register (SS): is used for addressing stack segment of the
memory. The stack segment is that segment of memory which is used to
store stack data.

Page No: 9 | 28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
The number of address lines in 8086 is 20, 8086 BIU will send 20bit address, so as to
access one of the 1MB memory locations. The four segment registers actually contain
the upper 16 bits of the starting addresses of the four memory segments of 64 KB each
with which the 8086 is working at that instant of time. A segment is a logical unit of
memory that may be up to 64 kilobytes long. Each segment is made up of contiguous
memory locations. It is an independent, separately addressable unit. Starting address
will always be changing. It will not be fixed.

Advantages of the Segmentation The main advantages of segmentation are as follows:


• It provides a powerful memory management mechanism.
• Data related or stack related operations can be performed in different
segments.
• Code related operation can be done in separate code segments.
• It allows to processes to easily share data.
• It allows to extend the address ability of the processor, i.e. segmentation
allows the use of 16 bit registers to give an addressing capability of 1
Megabytes. Without segmentation, it would require 20 bit registers.
• It is possible to enhance the memory size of code data or stack segments
beyond 64 KB by allotting more than one segment for each area.

Page No: 10 | 28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
b) Write an ALP to perform addition of two 16 bit BCD numbers, 4M

Ans 4 Mark for


program

c) Write an ALP to find largest number in array of 5 elements. 4M

Ans DATA SEGMENT 4 M for


ARRAY DB 10H,24H,02H,05H,17H program
LARGEST DB 00H
DATA ENDS
CODE SEGMENT
START:
ASSUME CS:CODE,DS:DATA
MOV DX,DATA
MOV DS,DX
Page No: 11 | 28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
MOV CX,04H
MOV SI ,OFFSET
ARRAY MOV AL,[SI]
UP: INC SI
CMP AL,[SI]
JNC NEXT
MOV AL,[SI]
NEXT: DEC CX
JNZ UP
MOV LARGEST,AL
MOV AX,4C00H
INT 21H
CODE ENDS
END START

d) Describe CALL and RET instructions with example. 4M

Ans 1. CALL : Unconditional Call 2 M for


The CALL instruction is used to transfer execution to a subprogram or procedure by each
storing return address on stack There are two types of calls- NEAR (Inter-segment) and explanation
FAR(Intra-segment call). Near call refers to a procedure call which is in the same code
segment as the call instruction and far call refers to a procedure call which is in different
code segment from that of
the call instruction.
Syntax: CALL procedure_name

2. RET: Return from the Procedure.


At the end of the procedure, the RET instruction must be executed. When it is executed,
the previously stored content of IP and CS along with Flags are retrieved into the CS, IP
and Flag registers from the stack and execution of the main program continues further.
Syntax :RET

4. Attempt any THREE of the following: 12 M

a) Differentiate between Procedure and Macros. 4M

Ans 1 Mark for


each point

Page No: 12 | 28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

b) Write an ALP to find length of string. 4M

Ans Data Segment 4 M for


STRG DB 'GOOD MORNING$' program
LEN DB ?
DATA ENDS
CODE SEGMENT
START:
ASSUME CS: CODE, DS : DATA
MOV DX, DATA
MOV DS,DX
Page No: 13 | 28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
LEA SI, STRG
MOV CL,00H
MOV AL,'$'
NEXT: CMP AL,[SI]
JZ EXIT
ADD CL,01H
INC SI
JMP
NEXT EXIT: MOV LEN,CL
MOV AH,4CH
INT 21H
CODE ENDS

c) Explain the following assembler directives: 4M

(i) DB (ii) SEGMENT (iii) DUP (iv) EQU

Ans (i) DB: 1 Mark for


each
The DB directive is used to declare a BYTE -2-BYTE variable – A
BYTE is made up of 8 bits.
Declaration examples:
(ii) SEGMENT:
The SEGMENT directive is used to indicate the start of a logical segment.
Preceding the SEGMENT directive is the name you want to give the
segment.
For example, the statement CODE SEGMENT indicates to the assembler
the start of a logical segment called CODE. The SEGMENT and ENDS
directive are used to “bracket” a logical segment containing code of data
(iii) DUP:
The DUP directive can be used to generate multiple bytes or words with known as well as
un-initialized values.
Example :
Table dw 100 DUP(0)
Stars db 50 dup(‘*’)
ARRAY3 DB 30 DUP(?)

Page No: 14 | 28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
(iv) EQU :
EQU is used to give a name to some value or symbol. Each time the assembler finds the
given name in the program, it replaces the name withthe value or symbol you equated
with that name.
Example
Data SEGMENT
Num1 EQU 50H
Num2 EQU 66H
Data ENDS
Numeric value 50H and 66H are assigned to Num1 and Num2.

d) Write an ALP to count number 1' in 8 bit number. 4M

Ans DATA SEGMENT 4 M for


program
N DB 12H
Z DB 0
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA, CS:CODE
START:
MOV DX,DATA
MOV DS,DX
MOV AL, N
MOV CL,04
NEXT: ROL AL,01
JNC ONE
INC Z
ONE: LOOP NEXT
HLT
CODE ENDS
END START

Page No: 15 | 28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
e) Explain any four Addressing Modes of 8086.

Ans 1. Immediate addressing mode: 1 Mark for


each
An instruction in which 8-bit or 16-bit operand (data) is specified in the
instruction, then the addressing mode of such instruction is known as
Immediate addressing mode.
Example:
MOV AX,67D3H
2. Register addressing mode
An instruction in which an operand (data) is specified in general purpose
registers, then the addressing mode is known as register addressing mode.
Example:
MOV AX,CX
3. Direct addressing mode
An instruction in which 16 bit effective address of an operand is specified in
the instruction, then the addressing mode of such instruction is known as
direct addressing mode.
Example:
MOV CL,[2000H]
4. Register Indirect addressing mode
An instruction in which address of an operand is specified in pointer register
or in index register or in BX, then the addressing mode is known as register
indirect addressing mode.
Example:
MOV AX, [BX]
5. Indexed addressing mode
An instruction in which the offset address of an operand is stored in index
registers (SI or DI) then the addressing mode of such instruction is known as
indexed addressing mode.

Page No: 16 | 28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
DS is the default segment for SI and DI.
For string instructions DS and ES are the default segments for SI and DI resp.
this is a special case of register indirect addressing mode.
Example:
MOV AX,[SI]
6. Based Indexed addressing mode:
An instruction in which the address of an operand is obtained by adding the
content of base register (BX or BP) to the content of an index register (SI or
DI) The default segment register may be DS or ES
Example:
MOV AX, [BX][SI]
7. Register relative addressing mode:
An instruction in which the address
of the operand is obtained by adding the displacement (8-bit or 16 bit) with the contents of
base registers or index registers (BX, BP, SI, DI). The default segment register is DS or
ES.
Example:
MOV AX, 50H[BX]
8. Relative Based Indexed addressing mode
An instruction in which the address of the operand is obtained by adding the
displacement (8 bit or 16 bit) with the base registers (BX or BP) and index
registers (SI or DI) to the default segment.
Example:
MOV AX, 50H [BX][SI]

5. Attempt any TWO of the following: 12 M

a) Define Logical and Effective address. Describe how 20 bit Physical address is 6M
generated in 8086. If CS = 348AH and IP = 4214H, calculate the Physical
Address.

Ans Logical Address:

Page No: 17 | 28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
• Logical address are also known as virtual address. It is generated by CPU during Definition
program execution.
2M
• Logical addresses provide a way for the CPU to access different locations in
memory without needing to know the physical organization of the memory. Explanation
of
Effective Address or Offset Address: generation
of Physical
The offset for a memory operand is called the operand's effective address or EA. It is an address :
unassigned 16 bit number that expresses the operand's distance in bytes from the beginning
of the segment in which it resides. 2M

Generation of 20 bit physical address in 8086:- Calculation


of Physical
1. Segment registers carry 16 bit data, which is also known as base address. addresss :
2. BIU appends four 0 bits to LSB of the base address. This address becomes 20- 2M
bit Address.
3. Any base/pointer or index register carries 16 bit offset.
4. Offset address is added into 20-bit base address which finally forms 20 bit
physical address of memory location

if CS 348AH and IP = 4214H,


Physical address=Segment base address*10+Offset (Effective) address
=CS*10 + IP
=348AH*10H+4214H
= 38AB4 H

b) Select the instructions for each of the following : 6M

(i) Multiply AL by 05H

Page No: 18 | 28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
(ii) Move 1234H in DS register

(iii) Add AX with BX

(iv) Signed Division of AX by BL

(v) Rotate the contents of AX towards left by 4 bits through carry

(vi) Load SP register with FF00H.

Ans : i)Multiply AL by 05H. 1 M for


each
MOV BL,05H instruction
MUL BL
ii)Move 1234H in DS register
MOV AX,1234H
MOV DS,AX
iii) Add AX with BX
ADD AX,BX
iv) Signed Division of AX by BL
IDIV BL
v)Rotate the contents of AX towards left by 4 bits through carry
MOV CL,04
RCL AX,CL
vi) Load SP register with FF00H.
MOV SP,FFOOH

c) Write an ALP for concatenation of two strings. Draw flow chart and assume 6M
suitable data.

Ans .MODEL SMALL


.DATA
STR_S DB ‘Hello $’
STR_D DB ‘World $’ Correct
program :
.CODE 4M
MOV AX, @DATA Flowchart:

Page No: 19 | 28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
MOV DS, AX 2M
MOV SI, OFFSET STR_S
NEXT:
MOV AL, [SI]
CMP AL, ’$’
JE EXIT
INC SI
JMP NEXT
EXIT:
MOV DI, OFFSET STR_D
UP: MOV AL, [DI]
CMP AL, ’$’
JE EXIT1
MOV [SI], AL
INC SI
INC DI
JMP UP
EXIT1:
MOV AL, ’$’
MOV [SI], AL
MOV AH, 4CH
INT 21H
ENDS
END

Page No: 20 | 28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

6. Attempt any TWO of the following: 12 M

a) Draw the functional block diagram of 8086 with all labels. 6M

Page No: 21 | 28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans Correct
Diagram: 6
M

b) Explain with example any three Shift and any three Rotate instructions. 6M

Ans 1.SAL/SHL Destination , Count: Rotate


Instructions
Left shifts the bits of destination. :3 M
MSB is shifted into CARRY Shift
instructions
LSB gets 0
:3 M
Bits are shifted count no.of times.
IF count =1 ,it is directly specified in instruction
If count > 1, it has to be loaded in CL register
e.g. SAL BL,1 : Left shift BL bits once

Page No: 22 | 28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

More examples:

MOV CL,05H: Load no of shifts in CL register


SHL BL,CL: left shift BL bits CL(5) number of times
2. SHR Destination , Count:
Right shifts the bits of destination.
LSB is shifted into CARRY
MSB gets 0
Bits are shifted count no.of times.
IF count =1 ,it is directly specified in instruction
If count > 1, it has to be loaded in CL register
e.g. SHR BL,1 right shift BL bits once

More examples:

MOV CL,05H: Load no of shifts in CL register


SHR BL,CL: right shift BL bits CL(5) number of times
3. SAR Destination , Count:
Right shifts the bits of destination.
LSB is shifted into CARRY
MSB placed in MSB itself

Page No: 23 | 28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Bits are shifted count no.of times.
IF count =1 ,it is directly specified in instruction
If count > 1, it has to be loaded in CL register

Rotate Instructions
1.ROL Destination , Count:
Left shifts the bits of destination.
MSB is shifted into CARRY
MSB also goes to LSB
Bits are shifted count no.of times.
IF count =1 ,it is directly specified in instruction
If count > 1, it has to be loaded in CL register
e.g ROL BL,1 : Left shift BL bits once

2. ROR Destination , Count:


Right shifts the bits of destination.
LSB is shifted into CARRY

Page No: 24 | 28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
LSB also goes to MSB
Bits are shifted count no.of times.
IF count =1 ,it is directly specified in instruction
If count > 1, it has to be loaded in CL register
e.g. ROR BL,1 : Left shift BL bits once

3.RCL Destination , Count:


Left shifts the bits of destination.
MSB is shifted into CARRY
Carry goes to LSB
Bits are shifted count no.of times.
IF count =1 ,it is directly specified in instruction
If count > 1, it has to be loaded in CL register

e.G RCL BL,1 : Left shift BL bits once

c) Write an ALP for Z = (P + Q) * (R+ S) using MACRO. Draw flow chart of the 6M
same.

Page No: 25 | 28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans MODEL SMALL Correct
Program :
ADD_NO1 MACRO P,Q,RES_ADD1 :MACRO DECLARATION (P+Q) 4M
MOV AL,P
ADD AL,Q Flowchart:
2M
MOV RES_ADD1,AL
ENDM
ADD_NO2 MACRO R, S,RES_ADD2 :MACRO DECLARATION (R+S)

MOV AL,R
ADD AL,S
MOV RES_ADD2,AL
ENDM
MULTIPLY_NUM MACRO RES_ADD1,RES_ADD2,Z
MOV AL,RES_ADD1
MUL RES_ADD2
ENDM
.DATA
P DB 02H
Q DB 03H
R DB 04H
S DB 05H
RES_ADD1 DB ? :RESULT OF P+Q
RES_ADD2 DB ? : RESULT OF R+S

Z DW? : RESULT OF ( P+Q)* (R+S)


ENDS
.CODE
START:

Page No: 26 | 28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
MOV AX,@DATA
MOV DS,AX
ADD_NO1 MACRO P,Q,RES_ADD1 : CALL MACRO TO ADD
ADD_NO2 MACRO R,S,RES_ADD2 : CALL MACRO TO ADD

MULTIPLY_NUM MACRO RES_ADD1,RES_ADD2,Z : CALL MACRO


TO MULTIPLY

MOV AX,4C00H
INT 21H
ENDS
END START

Page No: 27 | 28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

Page No: 28 | 28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
SUMMER – 2022 EXAMINATION
Subject Name: Microprocessor Model Answer Subject Code: 22415
Important Instructions to examiners: XXXXX
1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme.
2) The model answer and the answer written by candidate may vary but the examiner may try to assess the
understanding level of the candidate.
3) The language errors such as grammatical, spelling errors should not be given more Importance (Not applicable for
subject English and Communication Skills.
4) While assessing figures, examiner may give credit for principal components indicated in the figure. The figures
drawn by candidate and model answer may vary. The examiner may give credit for any equivalent figure drawn.
5) Credits may be given step wise for numerical problems. In some cases, the assumed constant values may vary and
there may be some difference in the candidate’s answers and model answer.
6) In case of some questions credit may be given by judgement on part of examiner of relevant answer based on
candidate’s understanding.
7) For programming language papers, credit may be given to any other program based on equivalent concept.
8) As per the policy decision of Maharashtra State Government, teaching in English/Marathi and Bilingual (English +
Marathi) medium is introduced at first year of AICTE diploma Programme from academic year 2021-2022. Hence if
the students in first year (first and second semesters) write answers in Marathi or bilingual language (English
+Marathi), the Examiner shall consider the same and assess the answer based on matching of concepts with
model answer.

Q. Sub Answer Marking


No. Q. Scheme
N.

1 Attempt any FIVE of the following: 10 M

a) Draw the labeled format of 8086 flag register 2M

Ans Correct
diagram: 2 M

Page No: 1 | 16
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
b) State any two difference between TEST and AND instructions. 2M

Ans 1 M for each


point of
TEST AND comparison
This instruction logically ANDs the This instruction logically ANDs the
source with the destination but the result source with the destination and stores the
is not stored anywhere. result in destination.
.

e. g .TEST BL ,CL e.g. AND BL , CL


The result is not saved anywhere. The result is saved in BL register

c) State the function of editor and assembler. 2M

Ans Editor: The editor is a program which allows the user to enter and modify as well as store 1 M for each
a group of instructions or text under a file name. function
Assembler: The assembler is used to convert assembly language written by a user or a
program into a machine recognizable format.

d) Write any two difference between NEAR and FAR procedure. 2M

Ans 1 M for each


point of
comparison

e) Write an ALP to add two 8 bit numbers. 2M

Ans .model small Correct


.data
Page No: 2 | 16
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
a db 06h program: 2 M
b db 12h
ends
.code
start:
mov ax,@data
mov ds,ax
mov al,a
mov bl,b
add al,bl
int 3
ends
end start

f) Define immediate addressing mode with suitable example 2M

Ans An instruction in which 8 bit or 16 bit operand (data) is specified in instruction itself then Definition :1M
the addressing mode of such instruction is called as immediate addressing mode.
Example:1M
Eg.
MOV AX,7120H

g) State the use of DAA instruction in BCD addition. 2M

Ans The DAA (Decimal Adjust after Addition) instruction makes the result in Packed BCD Explanation: 2
from after BCD addition is performed. It works only on AL register. M

2. Attempt any THREE of the following: 12 M

a) Describe the directives used to define the procedure with suitable example 4M

Ans Directives used for procedure: PROC directive: The PROC directive is used to identify Description: 2
the start of a procedure. The PROC directive follows a name given to the procedure. M
After that the term FAR and NEAR is used to specify the type of the procedure.
Example: 2 M
ENDP Directive: This directive is used along with the name of the procedure to indicate
the end of a procedure to the assembler. The PROC and ENDP directive are used in
procedure.
Example:

Page No: 3 | 16
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

b) Write the function of following pins of 8086: 4M

(i)
(ii) ALE
(iii) READY
(iv) RESET
Ans Each pin
(i) : BHE stands for Bus High Enable. It is available at pin 34 and used function 1 M
to indicate the transfer of data using data bus D8-D15. This signal is low
during the first clock cycle, thereafter it is active.
(ii) ALE: ALE stands for address Latch Enable, as address and data bus are
multiplexed; ALE is used to lock either Address or Data.
(iii) READY: It is used as acknowledgement from slower I/O device or memory.
It is Active high signal, when high; it indicates that the peripheral device is
ready to transfer data.
(iv) RESET: This pin requires the microprocessor to terminate its present activity
immediately

c) Describe any four assembler directives with suitable example. 4M

Ans 1. DB – The DB directive is used to declare a BYTE type variable – A BYTE is Each assembler
made up of 8 bits. directive 1 M
Declaration examples:
Num1 DB 10h

Page No: 4 | 16
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Num2 DB 37H
2. DW – The DW directive is used to declare a WORD type variable – A WORD
occupies 16 bits or (2 BYTE).
Declaration examples:
TEMP DW 1234h
3. DD – The DD directive is used to declare a double word which is made up of 32
bits =2 Word’s or 4 BYTE.
Declaration examples:
Dword1 DW 12345678h
4. EQU - This is used to declare symbols to which some constant value is assigned
each time the assembler finds the given names in the program, it will replace the
name with the value or a symbol. The value can be in the range 0 through 65535
and it can be another Equate declared anywhere above or below.
.Num EQU 100
5. SEGMENT: It is used to indicate the start of a logical segment. It is the name
given to the segment. Example: the code segment is used to indicate to the
assembler the start of logical segment.
6. PROC: (PROCEDURE) It is used to identify the start of a procedure. It follows a
name we give the procedure
After the procedure the term NEAR and FAR is used to specify the procedure
Example: SMART-DIVIDE PROC FAR identifies the start of procedure named
SMART-DIVIDE and tells the assembler that the procedure is far.

d) Describe DAS instruction with suitable example. 4M

Ans DAS: Decimal Adjust after Subtraction: - This instruction converts the result of the Description 2
subtraction operation of 2 packed BCD numbers to a valid BCD number. The subtraction M
operation has to be only in the AL. If the lower nibble of AL is higher than the value 9,
this instruction will subtract 06 from the lower nibble of the AL. If the output of the Example 2 M
subtraction operation sets the carry flag or if the upper nibble is higher than value 9, it
subtracts 60H from the AL. This instruction modifies the CF, AF, PF, SF, and ZF flags.
The OF is not defined after DAS instruction. The instance is following:

Example:

Page No: 5 | 16
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

3. Attempt any THREE of the following: 12 M

a) Describe memory segmentation in 8086 with suitable diagram. 4M

Ans Diagram: 2 M
Explanation:
2M

Memory Segmentation: The memory in 8086 based system is organized as segmented


memory. 8086 can access 1Mbyte memory which is divided into number of logical
segments. Each segment is 64KB in size and addressed by one of the segment register.
The 4 segment register in BIU hold the 16-bit starting address of 4 segments. CS holds
program instruction code. Stack segment stores interrupt & subroutine address. Data
segment stores data for program. Extra segment is used for string data.

 The number of address lines in 8086 is 20, 8086 BIU will send 20bit address, so
as to access one of the 1MB memory locations.
 The four segment registers actually contain the upper 16 bits of the starting
addresses of the four memory segments of 64 KB each with which the 8086 is
working at that instant of time
 A segment is a logical unit of memory that may be up to 64 kilobytes. Starting
address will always be changing. It will not be fixed.
Note that the 8086 does not work the whole 1MB memory at any given time. However, it
works only with four 64KB segments within the whole 1MB memory.

b) Write an ALP to multiply two 16 bit signed numbers. 4M

Ans .model small Program Code:


4M
.data

A db 2222h
B db 1111h

Page No: 6 | 16
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ends
.code
Mov ax,@data
Mov ds,ax
Mov AX,a
Mov BX,b
IMul BX
Int 03h
Ends
End

c) Write an ALP to count odd numbers in the array of 10 numbers 4M

Ans . Model Small Program Code:


4M
.data

BLK DB 10h,40h,30h,60h
e db ?h
o db ?h
ends
.code
mov ax, @data
mov ds, ax
lea si, BLK
mov bl, 00h
mov bh, 00h
mov cl, 04h
up: mov al, [si]
ror al, 1
jc go
inc bl
jmp next
go: inc bh
next: inc si
dec cl
jnz up
mov e,bl
mov o,bh
int 3
ends
end
d) Write a MACRO to perform 32 bit by 16 bit division of unsigned 4M
numbers.
Ans .model small Program Code:
4M
Div1 macro no1,no2

Page No: 7 | 16
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
mov ax,no1

div no2

endm

.data

num1 dw 12346666h

num2 dw 2222h

.code

mov ax,@data

mov ds,ax

div1 num1,num2

ends

end

4. Attempt any THREE of the following: 12 M

a) Describe how 20 bit Physical address is generated in 8086 microprocessor 4M


with suitable example.

Ans Formation of a physical address:- Segment registers carry 16 bit data, which is also Describition:
known as base address. BIU attaches 0 as LSB of the base address. So now this address 2M
becomes 20-bit address. Any base/pointer or index register carry 16 bit offset. Offset
address is added into 20-bit base address which finally forms 20 bit physical address of Example: 2 M
memory location.

Page No: 8 | 16
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Example
Assume DS= 2632H, SI=4567H

DS : 26320H ……...0 added by BIU(or Hardwired 0)


+ SI : 4567H

----------------------------

2A887H

b) Write an ALP to find largest number in the array. 4M

Ans .model small Program Code:


4M
.data

Array db 02h,04h,06h,01h,05h

Ends

.code

Start: Mov ax,@data

Mov ds,ax

Mov cl,04h

Lea si,array

Mov al,[si]

Up : inc si

Cmp al,[si]

Jnc next

Mov al,[si]

Next : dec cl

Jnz up

Int 03h

Ends

Page No: 9 | 16
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
End start

c) Write an ALP to count number of 0' in 8 bit number. 4M

Ans .MODEL SMALL Program Code:


4M
.DATA
NUM DB 08H
ZEROS DB 00H
.CODE

START:

MOV AX,@DATA

MOV DS,AX

MOV CX, 08H ; initialize rotation counter by 8


MOV BX, NUM ;load number in BX
UP: ROR BX, 1 ; rotate number by 1 bit right
JC DN ; if bit not equal to 1 then go to DN
INC ZEROS ; else increment ZEROS by one
DN: LOOP UP
;decrement rotation counter by 1 and if not zero then go
to up
MOV CX, ZEROS ;move result in cx register.

MOV AH, 4CH


INT 21H

ENDS

END ; end of program.

d) Write an ALP to subtract two BCD number using procedure. 4M

Ans .model small Program Code:


4M
.data

num1 db 13h

num2 db 12h

Page No: 10 | 16
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
ends

.code

start:

mov ax,@data

mov ds,ax

call sub1

sub1 proc near

mov al,num1

mov bl,num2

sub al,bl

das

sub1 endp

mov ah,4ch

int 21h

ends

end start

end

e) Describe re-entrant and recursive procedure with suitable diagram. 4M

Ans 1)Recursive procedure: Recursive


procedure: 2 M
A recursive procedure is procedure which calls itself. This results in the procedure call
to be generated from within the procedures again and again. Re-entrant
procedures:
The recursive procedures keep on executing until the termination condition is reached. 2M

The recursive procedures are very effective to use and to implement but they take a large
amount of stack space and the linking of the procedure within the procedure takes more
time as well as puts extra load on the processor.

Page No: 11 | 16
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

2) Re-entrant procedures:

In some situation it may happen that Procedure 1 is called from main program
Procrdure2 is called from procedure1And procedure1 is again called from procdure2. In
this situation program execution flow re enters in the procedure1. These types of
procedures are called re-entrant procedures.

A procedure is said to be re-entrant, if it can be interrupted, used and re-entered without


losing or writing over anything.

5. Attempt any TWO of the following: 12 M

a) (a) Calculate the physical address if: 6M


(i) CS 1200H and IP = DE00OH
(ii) SS = FFOOH and SP = 0123H
(iii) DS 1IFOOH and BX= IA00H for MOV AX, [BX]
Ans Physical address = segment address x 10H + offset address Each correct
answer 2 M
(i) Physical address = CS X 10H + IP
= 1200H X 10H + DE00H
= 12000H + DE00H

Page No: 12 | 16
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
= 1FE00H
(ii) Physical address = SS X 10H + SP
= FF00H X 10H + 0123H

= FF000H + 0123H

= FF123H

(iii) Physical address = DS X 10H + BX


= 1F00H X 10H + 1A00H
= 1F000H + 1A00H
= 20A00H

b) Describe how an assembly language program is developed and debugging 6M


using program developments tools.
Ans Assembly language development tools: Each
development
EDITOR: tool 1.5 M

It is a program which helps to construct assembly language program with a file


extension .asm, in right format so that the assembler will translate it to machine
language. It enables one to create, edit, save, copy and make modification in source file.

Assembler:

Assembler is a program that translates assembly language program to the correct binary
code. It also generates the file called as object file with extension .obj. It also displays
syntax errors in the program, if any.

Linker:

It is a programming tool used to convert Object code (.OBJ) into executable (.EXE)
program. It combines, if requested, more than one separated assembled modules into one
executable module such as two or more assembly programs or an assembly language
with C program.

Debugger:

Debugger is a program that allows the execution of program in single step mode under
the control
of the user. The errors in program can be located and corrected using a debugger.
Debugger generates .exe file.

c) State the addressing mode of following instructions: 6M

(i) MOV AX, 3456H


(ii) ADD BX, [2000H]

Page No: 13 | 16
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
(iii) DAA
(iv) MOV AX, [Si]
(v) MOV AX, BX
(vi) SUB AX, [BX +SI +80H]

Ans (i) MOV AX , 3456H ------- IMMEDIATE ADDRESSING MODE


(ii) ADD BX , [2000H] ------- DIRECT ADDRESSING MODE
Each correct
(iii) DAA ------ IMPLIED ADDRESSING MODE
answer 1 M
(iv) MOV AX , [SI] ------- INDEXED ADDRESSING MODE
(v) MOV AX , BX ------- REGISTER ADDRESSING MODE
(vi) SUB AX , [BX+SI+80H] ----- BASE RELATIVE INDEX
ADDRESSING MODE

6. Attempt any TWO of the following: 12 M

a) Describe how string instructions are used to compare two strings with suitable 6M
example.

Ans CMPS /CMPSB/CMPSW: Compare string byte or Words.

Syntax: Explanation of
CMPS destination, source string compare
instruction 4 M
CMPSB destination, source
CMPSW destination, source And
Operation: Flags affected < ----- DS:[SI]- ES:[DI]
Example 2 M
It compares a byte or word in one string with a byte or word in another string. SI holds
the offset of source and DI holds offset of destination strings. CX contains counter and
DF=0 or 1 to auto increment or auto decrement pointer after comparing one byte/word.
e.g.

Example Explanation
CMPS m8, m8 Compares byte at address DS: SI with byte at address ES: DI
and sets the status flags accordingly.
CMPS m16, m16 Compares word at address DS:SI with word at address ES:DI
and sets the status flags accordingly.
CMPSB Compares byte at address DS:SI with byte at address ES:DI
accordingly.
CMPSW Compares word at address DS:SI with word at address ES:DI
and sets the status flags accordingly.

Page No: 14 | 16
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
b) Write an instructión to perform following operations: 6M
(i) Multiply BL by 88H
(ii) Signed division of AL by BL
(iii) Move 4000H to DS register
(iv) Rotate content of AX register to left 4 times.
(v) Shift the content of BX register to right 3 times.
(vi) Load SS with FF0OH.
Ans (1) Multiply BL by 88h
MOV AL, 88H Each correct
answer 1 M
MUL BL

(2) Signed division of AL by BL


IDIV BL

(3) Move 4000H to DS register


MOV DS, 4000H

(4) Rotate content of AX register to left 4 times


MOV CL,04

ROL AX, CL

(5) Shift the content of BX register to right 3 times


MOV CL,03H

SHR BX, CL

(6) Load SS with FF00H


MOV AX, FF00H

MOV SS, AX

c) Write an ALP to concatenate two strings. 6M

Ans DATA SEGMENT Correct


STR1 DB "hello$" program 6 M
STR2 DB "world$"
DATA ENDS
CODE SEGMENT
START: ASSUME CS: CODE, DS:DATA
MOV AX,@ DATA
MOV DS, AX

Page No: 15 | 16
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
MOV SI, OFFSET STR1
NEXT: MOV AL, [SI]
CMP AL,’$’
JE EXIT
INC SI
JMP NEXT
EXIT: MOV DI, OFFSET STR2
UP: MOV AL, [DI]
CMP AL, "$"
JE EXIT1
MOV [SI], AL
INC SI
INC DI
JMP UP
EXIT1: MOV AL,’$’
MOV [SI], AL
MOV AH, 4CH
INT 21H
CODE ENDS
END START

Page No: 16 | 16
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
WINTER – 2022 EXAMINATION
Subject Name: Microprocessor Model Answer Subject Code: 22415
Important Instructions to examiners: XXXXX
1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme.
2) The model answer and the answer written by candidate may vary but the examiner may try to assess the
understanding level of the candidate.
3) The language errors such as grammatical, spelling errors should not be given more Importance (Not applicable for
subject English and Communication Skills.
4) While assessing figures, examiner may give credit for principal components indicated in the figure. The figures
drawn by candidate and model answer may vary. The examiner may give credit for any equivalent figure drawn.
5) Credits may be given step wise for numerical problems. In some cases, the assumed constant values may vary and
there may be some difference in the candidate’s answers and model answer.
6) In case of some questions credit may be given by judgement on part of examiner of relevant answer based on
candidate’s understanding.
7) For programming language papers, credit may be given to any other program based on equivalent concept.
8) As per the policy decision of Maharashtra State Government, teaching in English/Marathi and Bilingual (English +
Marathi) medium is introduced at first year of AICTE diploma Programme from academic year 2021-2022. Hence if
the students in first year (first and second semesters) write answers in Marathi or bilingual language (English
+Marathi), the Examiner shall consider the same and assess the answer based on matching of concepts with
model answer.

Q. Sub Answer Marking


No. Q. Scheme
N.

1 Attempt any FIVE of the following: 10 M

a) State the function of the following pins of 8086 microprocessor. 2M


(i) ALE (ii) DT/𝐑̅
Ans (i)ALE (Pin number 25) – ALE is an abbreviation for address latch enable. Whenever Each 1 M
an address is present in the multiplexed address and data bus, then the microprocessor
enables this pin.
This is done to inform the peripherals and memory devices about fetching of the data or
instruction at that memory location.

(ii) DT/𝐑̅ (Pin number 27) – This pin is used to show whether the data is getting
transmitted or is received. A high signal at this pin provides the information regarding
the transmission of data. While a low indicates reception of data.

b) Write an assembly language instruction of 8086 microprocessor to 2M


i) Divide the content of AX register by 50H.
ii) Rotate the content of BX register by 4-bit towards left.
Ans (i) Divide the content of AX register by 50H: Correct
MOV BL,50H Instruction: 1 M
DIV BL each
(ii) Rotate the content of BX register by 4 bits towards left:
MOV CL,04H

Page No: 1 | 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
ROL BX, CL
OR
MOV CL,04H
RCL BX, CL
c) List directives used for procedure. 2M

Ans The assembler directive that are used for defining a procedure in the 8086 Each 1 M
microprocessors are: PROC and ENDP

d) State any two differences between FAR and NEAR procedure. 2M

Ans Any 2 Valid


points: each 1 M

e) Write algorithm to find sum of a series of numbers. 2M

Ans 1) Load the count in CX and clear AX and BX. Any other
2) Store the starting address in SI. correct relevant
3) Move data stored at address pointed by SI in DX. algorithm 2 M
4) Add AX=AX+DX.
5) If carry exists, increment BX.
6) Increment SI twice. Decrement CX.
7) If CX is not zero, return to step 3.
8) Store the sum (AX) and carry (BX) in memory.
9) Terminate the program.
f) What is the use of REP in string related instruction? Explain. 2M

Ans REP: 1M- Definition,


REP is a prefix which is written before one of the string instructions. It will cause
During length counter CX to be decremented and the string instruction to be repeated 1M-Explanation
until CX becomes 0.

Page No: 2 | 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Two more prefix.
REPE/REPZ: Repeat if Equal /Repeat if Zero.
It will cause string instructions to be repeated as long as the compared by words Are
equal and CX≠0.
REPNE/REPNZ: Repeat if not equal/Repeat if not zero.
It repeats the strings instructions as long as compared bytes or words are not equal
And CX≠0.
Example: REP MOVSB

g) Differentiate between ROL and RCL. 2M

Ans 1M- For Each


Point
ROL RCL

 Rotate left byte or  Rotate through carry left byte or word


word
 Syntax: ROL  Syntax: RCL Destination, Count
Destination, Count Can be used to Swap the nibbles Cannot be used to
swap the nibbles

2. Attempt any THREE of the following: 12 M

a) What do you mean by procedure? Explain re-centrant and re-entrant 4M


procedure.
Ans Definition 2 M
A procedure is a set of code to be executed several times in a program, and called whenever
required. A repeated group of instruction in a program can be organized as subprogram. The Explanation 2 M
subprograms are called as subroutine or procedures in assembly language programming
which allows reuse of program code. A procedure is a set of the program statements that can be
processed independently.

Re-entrant Procedures:

 A procedure is said to be re-entrant, if it can be interrupted, used and re-entered


without losing or writing over anything. To be a re-entrant,
 Procedure must first push all the flags and registers used in the procedure.
 It should also use only registers or stack to pass parameters.
 The flow of re-entrant procedure for a multiply procedure when interrupt
procedure is executed, as shown below.

Page No: 3 | 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

b) What is memory segmentation? Explain it with reference to 8086 4M


microprocessor.
Ans Memory Segmentation: Segmentation is the process in which the main memory of the 2M
computer is logically divided into different segments and each segment has its own
base address. It is basically used to enhance the speed of execution of the computer -Explanation
system, so that the processor is able to fetch and execute the data from the memory
easily and fast.
2M -Diagram
The memory in an 8086 microprocessor is organized as a segmented memory. The
physical memory is divided into 4 segments namely, - Data segment, Code Segment,
Stack Segment and Extra Segment.

Description:

 Data segment is used to hold data, Code segment for the executable program,
Extra segment also holds data specifically in strings and stack segment is used
to store stack data.
 Each segment is 64Kbytes & addressed by one segment register. i.e CS,DS,ES
or SS
 The 16 bit segment register holds the starting address of the segment.
 The offset address to this segment address is specified as a 16-bit displacement
(offset) between 0000 to FFFFH. Hence maximum size of any segment is
216=64K
locations.
 Since the memory size of 8086 is 1Mbytes, total 16 segments are possible with
each having 64Kbytes.
 The offset address values are from 0000H to FFFFH so the physical address
range
from 00000H to FFFFFH.

Page No: 4 | 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

c) Describe following assembler directives: 4M

(i) DB (i) EQU (ii) Segment (iv) Assume

Ans 1) DB: Define Byte 1M – For Each


The DB directive is used to declare a BYTE -2-BYTE variable – A BYTE is made up
of 8 bits.
Declaration examples
Byte1 DB 10h.

2) EQU: Equate to
The EQU directive is used to declare the micro symbols to which some constant value
is assigned.
Micro assembler will replace every occurrence of the symbol in a program by its value.
Syntax: Symbol name EQU expression
Example: CORRECTION_FACTOR EQU 100

3) SEGMENT:
The SEGMENT directive is used to indicate the start of a logical segment. Preceding
the SEGMENT directive is the name you want to give the segment.
For example, the statement CODE SEGMENT indicates to the assembler the start of a
logical segment called CODE. The SEGMENT and ENDS directive are used to
“bracket” a logical segment containing code of data

4) ASSUME: Assume directive is used to tell Assembler the name of the logical
segment it should use for the specified segment.
Example: Assume CS: MAP_CODE, DS: MAP_DATA
d) What are the functions of CALL and RET instructions? Describe in brief. 4M

Page No: 5 | 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans CALL Instruction: It is used to transfer program control to the sub-program or 2M-For Each
subroutine. The CALL can be NEAR, where the procedure is in the same segment Instruction
whereas in FAR CALL, procedure is in a different segment.
Syntax: CALL procedure name (direct/indirect)
Operation: Steps executed during CALL
Example:
1) For Near CALL
SP ←SP - 2
Save IP on stack
IP address of procedure
2) For Far call
SP ← SP-2
Save CS on stack
CS New segment base containing procedure
SP←SP-2
Save IP on stack
IP Starting address of called procedure

RET instruction: it is used to transfer program execution control from a procedure to


the next instruction immediate after the CALL instruction in the calling program.
Syntax: RET
Operation: Steps executed during RET
Example:
1) For Near Return
IP Content from top of stack
SP ←SP + 2
2) For Far Return
IP Contents from top of stack
SP ←SP+2
CS Contents of top of stack
SP←SP+2
3. Attempt any THREE of the following: 12 M

a) Describe register organization of 8086 microprocessor. 4M

Ans Register Organization of 8086 2M-For


Diagram,2M-
1. AX (Accumulator) - Accumulator register consists of two 8-bit registers AL and AH, For Explanation
which can be combined together and used as a 16- bit register AX. AL in this case
contains the low-order byte of the word, and AH contains the high-order byte.
Accumulator can be used for I/O operations, rotate and string manipulation.
2. BX –This register is mainly used as a base register. It holds the starting base
location of a memory region within a data segment. It is used as offset storage for
forming physical address in case of certain addressing mode.
3. CX – It is used as default counter or count register in case of string and loop
instructions.

Page No: 6 | 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

4. DX – Data register can be used as a port number in I/O operations and implicit
operand or destination in case of few instructions. In integer 32-bit multiply and divide
instruction the DX register contains high-order word of the initial or resulting number.
5. CS – Code Segment – holds base address for all executable instructions in a program

Segment registers:
To complete 1Mbyte memory is divided into 16 logical segments. The complete
1Mbyte memory segmentation is as shown in above figure. Each segment contains
64Kbyte of memory. There are four segment registers.
1.Code segment (CS) is a 16-bit register containing address of 64 KB segment with
Processor instructions. The processor uses CS segment for all accesses to instructions
Referenced by instruction pointer (IP) register.

2.Stack segment (SS) is a 16-bit register containing address of 64KB segment with
Program stack. By default, the processor assumes that all data referenced by the stack
Pointer (SP) and base pointer (BP) registers is located in the stack segment.
3.Data segment (DS) is a 16-bit register containing address of 64KB segment with
Program data. By default, the processor assumes that all data referenced by general
Registers (AX, BX, CX, DX) and index register (SI, DI) is located in the data segment.

4.Extra segment (ES) is a 16-bit register containing address of 64KB segment, usually
with program data.

Page No: 7 | 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Pointers and index registers.
The pointers contain within the particular segments. The pointers IP, BP, SP
usually contain offsets within the code, data and stack segments respectively.
Stack Pointer (SP) is a 16-bit register pointing to program stack in stack segment.
Base Pointer (BP) is a 16-bit register pointing to data in stack segment.
Source Index (SI) is a 16-bit register. SI is used for indexed, based indexed and
register
Indirect addressing, as well as a source data addresses in string manipulation
instructions.
Destination Index (DI) is a 16-bit register. DI is used for indexed, based indexed and
register indirect addressing, as well as a destination data address in string manipulation
Instructions.

b) Write an assembly language program to add BCD numbers in an array of 10 4M


numbers. Assume suitable array. Store the result at the end of the array.

Ans Addition of 10 BCD numbers in Series 4M- For Correct


.MODEL SMALL Program
.STACK 100
.DATA
ARRAY DB 1,2,3,4,5,6,7,8,9,10
SUM_LSB DB 0
SUM_MSB DB 0
.CODE
MOV AX , @DATA ; Intializing data segment
MOV DS , AX

MOV CX , 10 ; Initialize byte counter


MOV SI , OFFSET ARRAY ; Initialize memory pointer

UP:
MOV AL , [SI] ; Read byte from memory
ADD SUM_LSB , AL ; Add with sum
DAA
JNC NEXT
INC SUM_MSB
NEXT:
INC SI ; Increment memory pointer
LOOP UP ; Decrement byte counter
; If byte counter==0 then exit
; else read next number
MOV DL , SUM_MSB
MOV AH , 2
Page No: 8 | 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
INT 21H

MOV DL , SUM_LSB
MOV AH , 2
INT 21H

MOV AH , 4CH
INT 21H
END

c) Write a procedure to find factorial of given number. 4M

Ans Procedure to find the factorial. 4M- For Correct


DATA SEGMENT Program
NUM DB 04H
DATA ENDS
CODE SEGMENT
START: ASSUME CS:CODE, DS:DATA
MOV AX,DATA
MOV DS,AX
CALL FACTORIAL
MOV AH,4CH
INT 21H
PROC FACTORIAL
MOV BL,NUM ; TAKE NO IN BL REGISTER
MOV CL,BL ;TAKE CL AS COUNTER
DEC CL ;DECREMENT CL BY 1
MOV AL,BL
UP: DEC BL ;DECREMENT BL TO GET N-1
MUL BL ;MULTIPLY CONTENT OF N BY N-1
DEC CL ;DECREMENT COUNTER
JNZ UP ;REPEAT TILL ZERO
RET
FACTORIAL ENDP
CODE ENDS
END START
(OR)
DATA SEGMENT
A DW 0005H
FACT_LSB DW?
FACT_MSB DW?
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA,CS:CODE

Page No: 9 | 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
START:MOV AX,DATA
MOV DS,AX
CALL FACTORIAL
MOV AH,4CH
INT 21H
FACTORIAL PROC
MOV AX,A
MOV BX,AX
DEC BX
UP: MUL BX ; MULTIPLY AX * BX
MOV FACT_LSB,AX ;ANS DX:AX PAIR
MOV FACT_MSB,DX
DEC BX
CMP BX,0
JNZ UP
RET
FACTORIAL ENDP
CODE ENDS
END START
d) Write an assembly language program for conversion of BCD to Hexe 4M
number.
Ans 4M- For Correct
Program

Page No: 10 | 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

4. Attempt any THREE of the following: 12 M

a) Draw functional block diagram of 8086 microprocessor. 4M

Ans 4M-For Block


Diagram

Page No: 11 | 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

b) Write an assembly language program to arrange the numbers in ascending 4M


order (Assume suitable data).

Ans 4M- For Correct


DATA SEGMENT Program
ARRAY DB 15h,05h,08h,78h,56h, 60h, 54h, 35h, 24h, 67h
DATA ENDS
CODE SEGMENT
START: ASSUME CS: CODE, DS:DATA
MOV DX, DATA
MOV DS, DX
MOV BL,0AH
step1: MOV SI,OFFSET ARRAY
MOV CL,09H
step: MOV AL,[SI]
CMP AL,[SI+1]
JC Down
XCHG AL,[SI+1]
XCHG AL,[SI]
Down : ADD SI,1
LOOP step
DEC BL
JNZ step1
MOV AH,4CH
INT 21H

CODE ENDS
END START
1.
c) Write an assembly language program to Count No. of 1's in a 16-bit 4M
number.
Ans Assume the number to be stored in BX register. Store the result in CX register. 4M- For Correct
MODEL SMALL Program
.DATA
NUM DW 0008H
ONES DB 00H
.CODE
START:
MOV AX,@DATA
MOV DS,AX
MOV CX, 10H ; initialize rotation counter by 16
MOV BX, NUM ; load number in BX
UP: ROR BX, 1 ; rotate number by 1 bit right
JNC DN ; if bit not equal to 1 then go to DN
INC ONES ; else increment ones by one
DN: LOOP UP ; decrement rotation counter by 1 and if not zero
then go to up
Page No: 12 | 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

MOV CX, ONES ; move result in cx register.


MOV AH, 4CH
INT 21H
ENDS
END ; end of program.
d) Write an assembly language program using MACRO to perform following 4M
operation.

X = (A +B) * (C +D)

Ans .Model small 4M- For Correct


add_no1 macro a,b,res_add1 Program
mov al,a
add al,b
mov res_add1,al
endm
add_no2 macro c,d,res_add2
mov al,c
add al,d
mov res_add2,al
endm

multiply_num macro res_add1,res_add2


mov al,res_add1
mul res_add2
endm
.Data
a db 02h
b db 03h
c db 04h
d db 05h
res_add1 db ?
res_add2 db ?
ends
.Code
start :
mov ax,@data
mov ds,ax
mov al,a
mov bl,b
mov cl,c
mov dl,d
add al,bl
add cl,dl
Page No: 13 | 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
mov res_add1,al
mov res_add2,cl
multiply_num res_add1,res_add2
mov ah,4ch
int 21h
ends
end
e) Describe with suitable example how parameter is passed on the stack in 4M
8086 assembly language procedure.
Ans In order to pass the parameters using stack we push them on the stack before the call for 2M-For
the procedure in the main program. The instructions used in the procedure read these Explanation,2M-
parameters from the stack. Whenever stack is used to pass parameters, it is important to For Example
keep a track of what is pushed on the stack and what is popped off the stack in the main
program.\
Example:
.model small
.data
MULTIPLICAND DW 1234H
MULTIPLIER DW 4232H
.code
MOV AX, @data
MOV DS, AX
:
:
PUSH MULTIPLICAND
PUSH MULTIPLIER
CALL MULTI
:
:
MULTI PROC NEAR
PUSH BP
MOV BP, SP ; Copies offset of SP into BP
MOV AX, [BP + 6] ; MULTIPLICAND value is available at
; [BP + 6] and is passed to AX
MUL WORD PTR [BP + 4] ; MULTIPLIER value is passed
POP BP
RET ; Increments SP by 4 to return address
MULTI ENDP ; End procedure
END

5. Attempt any TWO of the following: 12 M

Page No: 14 | 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
a) Define logical and effective address, Describe physical address generation process 6M
in S086 microprocessor. Calculate physical address by taking suitable DS, CS and
IP.
Ans Logical Address: It is generated by CPU in perspective of program. A logical address Definition-2 M
may be different from the physical address due to the operation of an address translator
or mapping function. Description-2 M
Effective Address or Offset Address: The offset for a memory operand is called the
Calculation
operand's effective address or EA. It is an unassigned 16 bit number that expresses the Example-2 M
operand's distance in bytes from the beginning of the segment in which it resides. In
8086 we have base registers and index registers.
Generation of 20 bit physical address in 8086:-
1. Segment registers carry 16 bit data, which is also known as base address.
2. BIU appends four 0 bits to LSB of the base address. This address becomes 20-bit
address.
3. Any base/pointer or index register carries 16 bit offset.
4. Offset address is added into 20-bit base address which finally forms 20 bit physical
address of memory location

For example if CS = 1000H and IP = 1100H, the


microprocessor fetches its next instruction from
Physical address=Segment base address*10+Offset (Effective) address
=CS*10+IP
=1000H*10+1100H
=11100H.
b) State the function of following assembly language programing tools: 6M
(i) Assembler (ii) Linker (ii) Debugger
Ans (i)Assembler 2 M each
a) Assembler is a program that translates assembly language program to the correct
binary code for each instruction i.e. machine code and generate the file called as object
file with extension .obj.
b) It also displays syntax errors in the program, if any.
c) It can also be used to produce list (.lst) which contains assembly language
statements, binary codes, and offset address for each instruction.
Example; TASM, MASM.
(ii)Linker
a) It is a programming tool used to convert Object code into executable program.
b) It combines ,if requested ,more than one separated assembled modules into one executable
Page No: 15 | 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Module such as two or more assembly programs.
c) It generates .EXE module
Example; TLINK.
(iii)Debugger
a) Debugger is a program that allows the execution of program in single step mode
under the control of the user.
b) The errors in program can be located and corrected using a debugger.
Example; TD.
c) Describe different addressing modes of 8086 with one suitable example 6M
each.

Ans 1. Immediate addressing mode: Any 6 mode


An instruction in which 8-bit or 16-bit operand (data) is specified in the instruction, with example 1
then the addressing mode of such instruction is known as M each
Immediate addressing mode.
Example:
MOV AX, 3040H

2. Register addressing mode


An instruction in which an operand (data) is specified in general purpose registers, then
the addressing mode is known as register addressing mode.
Example: MOV AX,BX

3. Direct addressing mode


An instruction in which 16 bit effective address of an operand is specified in the
instruction, and then the addressing mode of such instruction is known as direct
addressing mode.
Example: MOV BL,[3000H]

4. Register Indirect addressing mode


An instruction in which address of an operand is specified in pointer register or in index
register or in BX, then the addressing mode is known as register indirect addressing
mode.
Example: MOV AX, [BX]

5. Indexed addressing mode


An instruction in which the offset address of an operand is stored in index registers (SI
or DI) then the addressing mode of such instruction is known as indexed addressing
mode.
DS is the default segment for SI and DI.
For string instructions DS and ES are the default segments for SI and DI resp. this is a
special case of register indirect addressing mode.
Example: MOV AX,[SI]

6. Based Indexed addressing mode:


An instruction in which the address of an operand is obtained by adding the content of
base register (BX or BP) to the content of an index register (SI or (DI) The default
segment register may be DS or ES

Page No: 16 | 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Example: MOV AX, [BX+SI]
7. Register relative addressing mode: An instruction in which the address
of the operand is obtained by adding the displacement (8-bit or 16 bit) with the contents
of base registers or index registers (BX, BP, SI, DI). The default segment register is DS
or ES.
Example: MOV AX, [BX+50H]
8. Relative Based Indexed addressing mode
An instruction in which the address of the operand is obtained by adding the
displacement (8 bit or 16 bit) with the base registers (BX or BP) and index Registers
(SI or DI) to the default segment.
Example: MOV AX, [BX+SI+50H]

6. Attempt any TWO of the following: 12 M

a) Describe different branching instructions used in 8086 microprocessor in 6M


brief.

Ans Branch instruction transfers the flow of execution of the program to a new address Any 3 branch
specified in the instruction directly or indirectly. When this type of instruction is instructions: 2
executed, the CS and IP registers get loaded with new values of CS and IP M each
corresponding to the location to be transferred
Unconditional Branch Instructions:

1. CALL: Unconditional Call The CALL instruction is used to transfer execution to a


subprogram or procedure by storing return address on stack There are two types of
calls.
NEAR (Inter-segment) and FAR(Intra-segment call). Near call refers to a procedure
call which is in the same code segment as the call instruction and far call refers to a
procedure call which is in different code segment from that of the call instruction.
Syntax: CALL procedure name
2. RET: Return from the Procedure. At the end of the procedure, the RET instruction
must be executed. When it is executed, the previously stored content of IP and CS
along with Flags are retrieved into the CS, IP and Flag registers from the stack and
execution of the main program continues further.
Syntax :RET
3. JMP: Unconditional Jump This instruction unconditionally transfers the control of
execution to the specified address using an 8-bit or 16-bit displacement. No Flags are
affected by this instruction.
Syntax : JMP Label
4. IRET: Return from ISR When it is executed, the values of IP, CS and Flags are
retrieved from the stack to continue the execution of the main program.

Page No: 17 | 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Syntax: IRET
Conditional Branch Instructions When this instruction is executed, execution control is
transferred to the address specified relatively in the instruction
1. JZ/JE Label :

Transfer execution control to address ‘Label’, if ZF=1.


2. JNZ/JNE Label :
Transfer execution control to address ‘Label’, if ZF=0
3. JS Label :
Transfer execution control to address ‘Label’, if SF=1
4. JNS Label

Transfer execution control to address ‘Label’, if SF=0.


5.JO Label
Transfer execution control to address ‘Label’, if OF=1.
6. JNO Label
Transfer execution control to address ‘Label’, if OF=0.
7. JNP Label
Transfer execution control to address ‘Label’, if PF=0.

8. JP Label
Transfer execution control to address ‘Label’, if PF=1.
9. JB Label
Transfer execution control to address ‘Label’, if CF=1.
10. JNB Label
Transfer execution control to address ‘Label’, if CF=0.

11. JCXZ Label


Transfer execution control to address ‘Label’, if CX=0

b) Explain the following instructions of 8086: 6M


i) DAA (ii) ADC (ii) XCHG
Ans i) DAA − Used to adjust the decimal after the addition operation. 2 M for each
It makes the result in Packed BCD from after BCD addition is performed. instruction
It works only on AL register.

Page No: 18 | 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
All flags are updated; OF becomes Undefined after this instruction.
For AL register ONLY
If D3 – D0 ˃ 9 OR Auxiliary Carry Flag is Set, ADD 06H to AL.
If D7 – D4 ˃ 9 OR Carry Flag is Set, ADD 60 H to AL.
Assume : AL = 14H,
CL = 28H
Then ADD AL,CL gives
AL = 3CH
Now DAA gives
AL = 42(06 is added to AL as C> 9)

ii) ADC − Used to add with carry.


ADDs the source to destination with carry and stores the result back into destination
e.g.
ADC BX,CX will give
BX= BX+ CX+ Carry flag

iii) XCHG- Used to exchange the data from two locations.


This instruction exchanges the contents of a register with the contents of another
register or memory location.
Example:
XCHG AX, BX; Exchange the word in AX with word in BX.
c) Draw flow chart and write assembly language program to reverse the word in 6M
string.
Ans DATA SEGMENT Correct
STRB DB ‘COMPUTER$' program-3 M
REV DB 0FH DUP(?)
DATA ENDS
CODE SEGMENT
Flowchart- 3 M
START:ASSUME CS:CODE,DS:DATA
MOV DX,DATA
MOV DS,DX
LEA SI,STRB
MOV CL,0FH
LEA DI,REV
ADD DI,0FH
UP:MOV AL,[SI]
MOV [DI],AL
INC SI
DEC DI
LOOP UP
MOV AH,4CH
INT 21H
CODE ENDS
END START

Page No: 19 | 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________
Ans

Start

Read the input string

Load CX with length of string

Load SI register with address of


input string

Load DI register with address of


reverse string

Add Contents of CX (length of string)


to DI

Copy character of input string to AL

AL = [SI]

Copy Character in AL to DI

[DI]= AL

]
Increment SI and Decrement DI

Decrement CX

N
Is CX= 0

Stop

Page No: 20 | 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
__________________________________________________________________________________________________

Page No: 21 | 21
21819
22415
3 Hours / 70 Marks Seat No.

Instructions : (1) All Questions are compulsory.


(2) Illustrate your answers with neat sketches wherever necessary.
(3) Figures to the right indicate full marks.
(4) Assume suitable data, if necessary.

Marks
1. Attempt any FIVE : 10

(a) State the function of ––––


BHE and Ao pins of 8086.
(b) How single stepping or tracing is implemented in 8086 ?
(c) State the role of Debugger in assembly language programming.
(d) Define Macro & Procedure.
(e) Write ALP for addition of two 8 bit numbers. Assume suitable data.
(f) List any four instructions from the Bit manipulation instructions of 8086.
(g) State the use of REP in string related instructions.

2. Attempt any THREE of the following : 12


(a) Explain the concept of pipelining in 8086. State the advantages of pipelining
(any two).
(b) Compare Procedure and Macros. (4 points).
(c) Explain any two assembler directives of 8086.
(d) Write classification of instruction set of 8086. Explain any one type out of
them.

[1 of 2] P.T.O.
22415 [2 of 2]
3. Attempt any THREE : 12
(a) Explain memory segmentation in 8086 and list its advantages. (any two)
(b) Write on ALP to count the number of positive and negative numbers in array.
(c) Write ALP to find the sum of series. Assume series of 10 numbers.
(d) With the neat sketches demonstrate the use of re-entrant and recursive
procedure.

4. Attempt any THREE : 12


(a) Describe the mechanism for generation of physical address in 8086 with
suitable example.
(b) Write an ALP to count ODD and EVEN numbers in array.
(c) Write an ALP to perform block transfer operation of 10 numbers.
(d) Write an ALP using procedure to solve equation such as Z = (A + B) * (C + D)
(e) Write an ALP using macro to perform multiplication of two 8 bit unsigned
numbers.

5. Attempt any TWO : 12


(a) Draw architectural block diagram of 8086 and describe its register
organization.
(b) Demonstrate in detail the program development steps in assembly language
programming.
(c) Illustrate the use of any three Branching instructions.

6. Attempt any TWO : 12


(a) Describe any six addressing modes of 8086 with suitable diagram.
(b) Select an appropriate instruction for each of the following & write :
(i) Rotate the contents of Dx to write 2 times without carry.
(ii) Multiply contents of Ax by 06H.
(iii) Load 4000 H in SP register.
(iv) Copy the contents of Bx register to CS.
(v) Signed division of BL and AL.
(vi) Rotate Ax register to right through carry 3 times.
(c) Write an ALP to arrange numbers in array in descending order.
_______________
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

SUMMER – 19 EXAMINATION
Subject Name: Microprocessor Model Answer Subject Code: 22415
Important Instructions to examiners:
1) The answers should be examined by key words and not as word-to-word as given in the
model answer scheme.
2) The model answer and the answer written by candidate may vary but the examiner may
try to assess the understanding level of the candidate.
3) The language errors such as grammatical, spelling errors should not be given more
Importance (Not applicable for subject English and Communication Skills.
4) While assessing figures, examiner may give credit for principal components indicated in
the figure. The figures drawn by candidate and model answer may vary. The examiner
may give credit for any equivalent figure drawn.
5) Credits may be given step wise for numerical problems. In some cases, the assumed
constant values may vary and there may be some difference in the candidate’s answers
and model answer.
6) In case of some questions credit may be given by judgement on part of examiner of
relevant answer based on candidate’s understanding.
7) For programming language papers, credit may be given to any other program based on
equivalent concept.

Q. Sub Answer Marking


No. Q. Scheme
N.
1 Attempt any FIVE : 10 M
a State the function of BHE and A0 pins of 8086. 2M
Ans BHE: BHE stands for Bus High Enable. It is available at pin 34 and used to Explanation:
indicate the transfer of data using data bus D8-D15. This signal is low during 1 M each
the first clock cycle, thereafter it is active.
A0: A0 is analogous to BHE for the lower byte of the data bus, pinsD0-D7. A0 bit
is Low during T1 state when a byte is to be transferred on the lower portion of
the bus in memory or I/O operations.

BHE A0 Word / Byte access

0 0 Whole word from even address

0 1 Upper byte from / to odd address

1 0 Lower byte from / to even address

1 1 None

b How single stepping or tracing is implemented in 8086? 2M


Ans By setting the Trap Flag (TF) the 8086 goes to single-step mode. In this mode, Explanation:
after the implementation of every instruction s 8086 generates an internal 2M

Page No: 1 /2 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

interrupt and by writing some interrupt service routine we can show the content
of desired registers and memory locations. So it is useful for debugging the
program.

OR
If the trap flag is set, the 8086 will automatically do a type-1 interrupt after
each instruction executes. When the 8086 does a type-1 interrupt, it pushes the
flag register on the stack.

OR
The instructions to set the trap flag are:
PUSHF ; Push flags on stack
MOV BP,SP ; Copy SP to BP for use as index
OR WORD PTR[BP+0],0100H ; Set TF flag
POPF ; Restore flag Register

c State the role Debugger in assembly language programming. 2M


Ans Debugger: Debugger is the program that allows the extension of program in Explanation:
single step mode under the control of the user. 2M
The process of locating & correcting errors using a debugger is known as
Debugger.
Some examples of debugger are DOS debug command Borland turbo debugger
TD, Microsoft debugger known as code view cv, etc…
d Define Macro & Procedure. 2M
Ans Macro: A MACRO is group of small instructions that usually performs one Definition: 1
task. It is a reusable section of a software program. A macro can be defined M each
anywhere in a program using directive MACRO &ENDM.
General Form :
MACRO-name MACRO [ARGUMENT 1,……….ARGUMENT N]
-----
MACRO CODIN GOES HERE
ENDM
E.G DISPLAY MACRO 12,13
---------------------

Page No: 2 /2 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

MACRO STATEMENTS
-----------------------
ENDM
Procedure: A procedure is group of instructions that usually performs one
task. It is a reusable section of a software program which is stored in memory
once but can be used as often as necessary. A procedure can be of two types. 1)
Near Procedure 2) Far Procedure

Procedure can be defined as


Procedure_name PROC
----
------
Procedure_name
ENDP

For Example
Addition PROC near
------
Addition ENDP

e Write ALP for addition of two 8bit numbers. Assume suitable data. 2M
Ans .Model small Correct
Program:2 M
.Data
NUM DB 12H
.Code
START:
MOV AX, @DATA
MOV DS,AX
MOV AL, NUM
MOV AH,13H

Page No: 3 /2 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

ADD AL,AH
MOV AH, 4CH
INT 21H
ENDS
END

f List any four instructions from the bit manipulation instructions of 8086. 2M
Ans Bit Manipulation Instructions For Each
These instructions are used to perform operations where data bits are involved, instruction ½
i.e. operations like logical, shift, etc. M

Following is the list of instructions under this group −


Instructions to perform logical operation
 NOT − Used to invert each bit of a byte or word.

 AND − Used for adding each bit in a byte/word with the corresponding
bit in another byte/word.
 OR − Used to multiply each bit in a byte/word with the corresponding
bit in another byte/word.
 XOR − Used to perform Exclusive-OR operation over each bit in a
byte/word with the corresponding bit in another byte/word.

g State the use of REP in string related instructions. 2M


Ans  This is an instruction prefix which can be used in string instructions. Explanation:
 It causes the instruction to be repeated CX number of times. 2M
 After each execution, the SI and DI registers are
incremented/decremented based on the DF (Direction Flag) in the flag
register and CX is decremented i.e. DF = 1; SI, DI decrements.
E.g. MOV CX, 0023H

CLD
REP MOVSB
The above section of a program will cause the following string
operation
ES: [DI] ← DS: [SI]
SI ← SI + I

Page No: 4 /2 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

DI ← DI + I
CX ← CX – 1
to be executed 23H times (as CX = 23H) in auto incrementing mode (as
DF is cleared).
REPZ/REPE (Repeat while zero/Repeat while equal)

 It is a conditional repeat instruction prefix.


 It behaves the same as a REP instruction provided the Zero Flag is set
(i.e. ZF = 1).
 It is used with CMPS instruction.

REPNZ/REPNE (Repeat while not zero/Repeat while not equal)

 It is a conditional repeat instruction prefix.


 It behaves the same as a REP instruction provided the Zero Flag is reset
(i.e. ZF = 0).
 It is used with SCAS instruction.

2 Attempt any THREE of the following : 12 M


a Explain the concept of pipelining in 8086. State the advantages of 4M
pipelining (any two).
Ans Pipelining:
Explanation:
1. The process of fetching the next instruction when the present instruction 2 M,
is being executed is called as pipelining.
2. Pipelining has become possible due to the use of queue.
3. BIU (Bus Interfacing Unit) fills in the queue until the entire queue is For any two
full. Advantages: 2
4. BIU restarts filling in the queue when at least two locations of queue are M
vacant.

Advantages of pipelining:

 The execution unit always reads the next instruction byte from the
queue in BIU. This is faster than sending out an address to the memory
and waiting for the next instruction byte to come.
 More efficient use of processor.
 Quicker time of execution of large number of instruction.
 In short pipelining eliminates the waiting time of EU and speeds up the
processing. -The 8086 BIU will not initiate a fetch unless and until there
are two empty bytes in its queue. 8086 BIU normally obtains two

Page No: 5 /2 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

instruction bytes per fetch.

b Compare Procedure and Macros. (4 points). 4M


Ans Procedure Macro Each Point: 1
M (any 4
Procedures are used for large Procedures are used for small Points)
group of instructions to be group of instructions to be
repeated repeated.

Object code is generated only Object code is generated every


once in memory. time the macro is called.

CALL & RET instructions are Macro can be called just by


used to call procedure and return writing its name.
from procedure.

Length of the object file is less Object file becomes lengthy.

Directives PROC & ENDP are MACRO and ENDM are used
used for defining procedure. for defining MACRO

Directives More time is required Less time is required for it’s


for its execution execution

Procedure can be defined as Macro can be defined as


Procedure_name PROC MACRO-name MACRO
[ARGUMENT,……….
---- ARGUMENT N]
------ ------
Procedure_name -------
ENDP ENDM

For Example For Example


Addition PROC near Display MACRO msg
------ ------
Addition ENDP ENDM

c Explain any two assembler directives of 8086. 4M


Ans 1. DB – The DB directive is used to declare a BYTE -2-BYTE variable – A Explanation
BYTE is made up of 8 bits. for each for
Declaration examples: any two
assembler

Page No: 6 /2 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

Byte1 DB 10h directives: 2


M
Byte2 DB 255; 0FFh, the max. possible for a BYTE

CRLF DB 0Dh, 0Ah, 24h ;Carriage Return, terminator BYTE

2. DW – The DW directive is used to declare a WORD type variable – A


WORD occupies 16 bits or (2 BYTE).
Declaration examples:
Word DW 1234h

Word2 DW 65535; 0FFFFh, (the max. possible for a WORD)

3. DD – The DD directive is used to declare a DWORD – A DWORD double


word is made up of 32 bits =2 Word’s or 4 BYTE.
Declaration examples:
Dword1 DW 12345678h

Dword2 DW 4294967295 ;0FFFFFFFFh.

4. EQU -
The EQU directive is used to give name to some value or symbol. Each time the
assembler finds the given names in the program, it will replace the name with
the value or a symbol. The value can be in the range 0 through 65535 and it can
be another Equate declared anywhere above or below.

The following operators can also be used to declare an Equate:


THIS BYTE

THIS WORD

THIS DWORD

A variable – declared with a DB, DW, or DD directive – has an address and has
space reserved at that address for it in the .COM file. But an Equate does not
have an address or space reserved for it in the .COM file.

Example:
A – Byte EQU THIS BYTE

DB 10

A_ word EQU THIS WORD

Page No: 7 /2 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

DW 1000

A_ dword EQU THIS DWORD

DD 4294967295

Buffer Size EQU 1024

Buffer DB 1024 DUP (0)

Buffed_ ptr EQU $ ; actually points to the next byte after the; 1024th byte in
buffer.

5. SEGMENT:
It is used to indicate the start of a logical segment. It is the name given to the
segment. Example: the code segment is used to indicate to the assembler the
start of logical segment.

6. PROC: (PROCEDURE)
It is used to identify the start of a procedure. It follows a name we give the
procedure.

After the procedure the term NEAR and FAR is used to specify the procedure
Example: SMART-DIVIDE PROC FAR identifies the start of procedure named
SMART-DIVIDE and tells the assembler that the procedure is far.
d Write classification of instruction set of 8086. Explain any one type out of 4M
them.
Ans classification of instruction set of 8086 Classification:
2 M,
 Data Transfer Instructions
 Arithmetic Instructions
 Bit Manipulation Instructions Explanation
 String Instructions any one type:
 Program Execution Transfer Instructions (Branch & Loop Instructions) 2M
 Processor Control Instructions
 Iteration Control Instructions
 Interrupt Instructions

1) Arithmetic Instructions:
These instructions are used to perform arithmetic operations like addition,
subtraction, multiplication, division, etc.
ADD:
The add instruction adds the contents of the source operand to the destination
operand.

Page No: 8 /2 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

Eg. ADD AX, 0100H


ADD AX, BX
ADD AX, [SI]
ADD AX, [5000H]
ADD [5000H], 0100H
ADD 0100H

ADC: Add with Carry


This instruction performs the same operation as ADD instruction, but adds the
carry
flag to the result.
Eg. ADC 0100H
ADC AX, BX
ADC AX, [SI]
ADC AX, [5000]
ADC [5000], 0100H

SUB: Subtract
The subtract instruction subtracts the source operand from the destination
operand
and the result is left in the destination operand.
Eg. SUB AX, 0100H
SUB AX, BX
SUB AX, [5000H]
SUB [5000H], 0100H

SBB: Subtract with Borrow


The subtract with borrow instruction subtracts the source operand and the
borrow flag
(CF) which may reflect the result of the previous calculations, from the
destination
operand
Eg. SBB AX, 0100H
SBB AX, BX
SBB AX, [5000H]
SBB [5000H], 0100H

INC: Increment
This instruction increases the contents of the specified Register or memory
location
by 1. Immediate data cannot be operand of this instruction.
Eg. INC AX
INC [BX]
INC [5000H]

Page No: 9 /2 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

DEC: Decrement
The decrement instruction subtracts 1 from the contents of the specified register
or
memory location.
Eg. DEC AX
DEC [5000H]

NEG: Negate
The negate instruction forms 2’s complement of the specified destination in the
instruction. The destination can be a register or a memory location. This
instruction can
be implemented by inverting each bit and adding 1 to it.
Eg. NEG AL
AL = 0011 0101 35H Replace number in AL with its 2’s complement
AL = 1100 1011 = CBH

CMP: Compare
This instruction compares the source operand, which may be a register or an
immediate data or a memory location, with a destination operand that may be a
register or a memory location
Eg. CMP BX, 0100H
CMP AX, 0100H
CMP [5000H], 0100H
CMP BX, [SI]
CMP BX, CX

MUL: Unsigned Multiplication Byte or Word


This instruction multiplies an unsigned byte or word by the contents of AL.
Eg.
MUL BH ; (AX) (AL) x (BH)
MUL CX ; (DX)(AX) (AX) x (CX)
MUL WORD PTR [SI] ; (DX)(AX) (AX) x ([SI])

IMUL: Signed Multiplication


This instruction multiplies a signed byte in source operand by a signed byte in
AL or
a signed word in source operand by a signed word in AX.
Eg. IMUL BH
IMUL CX
IMUL [SI]

CBW: Convert Signed Byte to Word


This instruction copies the sign of a byte in AL to all the bits in AH. AH is then
said
to be sign extension of AL.

Page No: 10 /2 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

Eg. CBW
AX= 0000 0000 1001 1000 Convert signed byte in AL signed word in AX.
Result in AX = 1111 1111 1001 1000

CWD: Convert Signed Word to Double Word


This instruction copies the sign of a byte in AL to all the bits in AH. AH is then
said
to be sign extension of AL.
Eg. CWD
Convert signed word in AX to signed double word in DX : AX
DX= 1111 1111 1111 1111
Result in AX = 1111 0000 1100 0001

DIV: Unsigned division


This instruction is used to divide an unsigned word by a byte or to divide an
unsigned
double word by a word.
Eg.
DIV CL ; Word in AX / byte in CL
; Quotient in AL, remainder in AH
DIV CX ; Double word in DX and AX / word
; in CX, and Quotient in AX,
; remainder in DX

2) Processor Control Instructions


These instructions are used to control the processor action by
setting/resetting the flag values.

STC:
It sets the carry flag to 1.

CLC:
It clears the carry flag to 0.

CMC:
It complements the carry flag.

STD:
It sets the direction flag to 1.
If it is set, string bytes are accessed from higher memory address to lower
memory address.

CLD:
It clears the direction flag to 0.
If it is reset, the string bytes are accessed from lower memory address to higher

Page No: 11 /2 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

memory address.

3 Attempt any THREE : 12 M


a Explain memory segmentation in 8086 and list its advantages.(any two) 4M
Ans Memory Segmentation: Explanation
2M
 In 8086 available memory space is 1MByte.
 This memory is divided into different logical segments and each Any two
segment has its own base address and size of 64 KB. Advantages
 It can be addressed by one of the segment registers. 2M
 There are four segments.

Page No: 12 /2 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

Advantages of Segmentation:

 The size of address bus of 8086 is 20 and is able to address 1 Mbytes


( ) of physical memory.
 The compete 1 Mbytes memory can be divided into 16 segments,
each of 64 Kbytes size.
 It allows memory addressing capability to be 1 MB.
 It gives separate space for Data, Code, Stack and Additional Data
segment as Extra segment size.
 The addresses of the segment may be assigned as 0000H to F000H
respectively.
 The offset values are from 00000H to FFFFFH
 Segmentation is used to increase the execution speed of computer
system so that processor can able to fetch and execute the data from
memory easily and fast.

b Write an ALP to count the number of positive and negative numbers in 4M


array.
Ans ;Count Positive No. And Negative No.S In Given ;Array Of 16 Bit No. Correct
;Assume array of 6 no.s program: 4 M

Page No: 13 /2 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

CODE SEGMENT For basic


ASSUME CS:CODE,DS:DATA logic may
START: MOV AX,DATA give 1-2 M
MOV DS,AX
MOV DX,0000H
MOV CX,COUNT
MOV SI, OFFSET ARRAY
NEXT: MOV AX,[SI]
ROR AX,01H
JC NEGATIVE
INC DL
JMP COUNT_IT
NEGATIVE: INC DH
COUNT_IT: INC SI
INC SI
LOOP NEXT
MOV NEG_COUNT,DL
MOV POS_COUNT,DH
MOV AH,4CH
INT 21H
CODE ENDS

DATA SEGMENT
ARRAY DW F423H,6523H,B658H,7612H, 2300H,1559H
COUNT DW 06H
POS_COUNT DB ?
NEG_COUNT DB ?
DATA ENDS
END START
c Write an ALP to find the sum of series. Assume series of 10 numbers. 4M
Ans ; Assume TEN , 8 bit HEX numbers Correct
CODE SEGMENT program: 4 M
For basic
ASSUME CS:CODE,DS:DATA logic may
give 1-2 M
START: MOV AX,DATA
MOV DS,AX
LEA SI,DATABLOCK
MOV CL,0AH
UP:MOV AL,[SI]
ADD RESULT_LSB,[SI]

Page No: 14 /2 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

JNC DOWN
INC REULT_MSB
DOWN:INC SI
LOOP UP
CODE ENDS

DATA SEGMENT
DATABLOCK DB 45H,02H,88H,29H,05H,45H,78H,
95H,62H,30H
RESULT_LSB DB 0
RESULT_MSB DB 0
DATA ENDS

END

d With neat sketches demonstrate the use of re-entrant and recursive 4M


procedure.
Ans Reentrant Procedure: Reentrant: 2
M and
A reentrant procedure is one in which a single copy of the program code can be recursive
shared by multiple users during the same period of time. Re-entrance has two procedure
key aspects: The program code cannot modify itself and the local data for each explanation
user must be stored separately. With both
diagram :2M

Recursive procedures:
An active procedure that is invoked from within itself or from within another

Page No: 15 /2 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

active procedure is a recursive procedure. Such an invocation is


called recursion. A procedure that is invoked recursively must have the
RECURSIVE attribute specified in the PROCEDURE statement.

4 Attempt any THREE : 12 M


a Describe mechanism for generation of physical address in 8086 with 4M
suitable example.
Ans For diagram
or
computation
shown 1M ,
Explanation 2
M , and for
example 1 M

Fig.: Mechanism used to calculate physical address in 8086


As all registers in 8086 are of 16 bit and the physical address will be in 20 bits.
For this reason the above mechanism is helpful.
Logical Address is specified as segment: offset
Physical address is obtained by shifting the segment address 4 bits to the left
and adding the offset address.
Thus the physical address of the logical address A4FB:4872 is:

A4FB0
+ 4872
---------------

Page No: 16 /2 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

A9822
OR
• i.e. Calculate physical Address for the given
CS= 3525H, IP= 2450H.

CS 3 5 2 5 0 Implied Zero

IP + - 2 4 5 5

Physical Address
3 7 6 A 5
i.e. 376A5H

b Write ALP to count ODD and EVEN numbers in an array. 4M


Ans ;Count ODD and EVEN No.S In Given ;Array Of 16 Bit No. Correct
;Assume array of 10 no.s program: 4 M
For basic
CODE SEGMENT logic may
ASSUME CS:CODE,DS:DATA give 1-2 M
START: MOV AX,DATA
MOV DS,AX
MOV DX,0000H
MOV CX,COUNT
MOV SI, OFFSET ARRAY1
NEXT: MOV AX,[SI]
ROR AX,01H
JC ODD_1
INC DL
JMP COUNT_IT
ODD_1 : INC DH
COUNT_IT: INC SI
INC SI
LOOP NEXT
MOV ODD_COUNT,DH
MOV EVENCNT,DL
MOV AH,4CH
INT 21H
CODE ENDS

DATA SEGMENT
ARRAY1 DW F423H, 6523H, B658H, 7612H, 9875H,
2300H, 1559H, 1000H, 4357H, 2981H
COUNT DW 0AH
ODD_COUNT DB ?
EVENCNT DB ?
Page No: 17 /2 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

DATA ENDS
END START
c Write ALP to perform block transfer operation of 10 numbers. 4M
Ans ;Assume block of TEN 16 bit no.s Correct
;Data Block Transfer Using String Instruction program: 4 M
CODE SEGMENT For basic
ASSUME CS:CODE,DS:DATA,ES:EXTRA logic may
MOV AX,DATA give 1-2 M
MOV DS,AX
MOV AX,EXTRA
MOV ES,AX
MOV CX,000AH
LEA SI,BLOCK1
LEA DI,ES:BLOCK2
CLD
REPNZ MOVSW
MOV AX,4C00H
INT 21H
CODE ENDS
DATA SEGMENT
BLOCK1 DW 1001H,4003H,6005H,2307H,4569H, 6123H,
1865H, 2345H,4000H,8888H
DATA ENDS
EXTRA SEGMENT
BLOCK2 DW ?
EXTRA ENDS
END
d Write ALP using procedure to solve equation such as 4M
Z= (A+B)*(C+D)
Ans ; Procedure For Addition Correct
SUM PROC NEAR program: 4 M
ADD AL,BL For basic
RET logic may
SUM ENDP give 1-2 M

DATA SEGMENT
NUM1 DB 10H
NUM2 DB 20H
NUM3 DB 30H
NUM4 DB 40H
RESULT DB?
DATA ENDS

CODE SEGMENT
ASSUME CS: CODE,DS:DATA

Page No: 18 /2 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

START:MOV AX,DATA
MOV DS,AX
MOV AL,NUM1
MOV BL,NUM2
CALL SUM
MOV CL,AL
MOV AL, NUM3
MOV BL,NUM4
CALL SUM
MUL CL
MOV RESULT,AX
MOV AH,4CH
INT 21H
CODE ENDS
END
e Write ALP using macro to perform multiplication of two 8 Bit Unsigned 4M
numbers.
Ans ; Macro For Multiplication Correct
program: 4 M
PRODUCT MACRO FIRST,SECOND For basic
MOV AL,FIRST logic may
MOV BL,SECOND give 1-2 M
MUL BL
PRODUCT ENDM

DATA SEGMENT
NO1 DB 05H
NO2 DB 04H
MULTIPLE DW ?
DATA ENDS

CODE SEGMENT
ASSUME CS: CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
PRODUCT NO1,NO2
MOV MULTIPLE, AX
MOV AH,4CH
INT 21H
CODE ENDS
END

5 Attempt any TWO : 12 M


a Draw architectural block diagram of 8086 and describe its register 6M
organization.

Page No: 19 /2 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

Ans Diagram : 3M

List of
Register :1M,

Any 4
registers
explanation :
½ M each

Register Organization of 8086


1. AX (Accumulator) – Used to store the result for arithmetic / logical
operations
2. BX – Base – used to hold the offset address or data
3. CX – acts as a counter for repeating or looping instructions.
4. DX – holds the high 16 bits of the product in multiply (also handles
divide operations)
5. CS – Code Segment – holds base address for all executable instructions
in a program
6. SS - Base address of the stack
7. DS – Data Segment – default base address for variables
8. ES – Extra Segment – additional base address for memory variables in
extra segment.
9. BP – Base Pointer – contains an assumed offset from the SS register.
10. SP – Stack Pointer – Contains the offset of the top of the stack.

Page No: 20 /2 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

11. SI – Source Index – Used in string movement instructions. The source


string is pointed to by the SI register.
12. DI – Destination Index – acts as the destination for string movement
instructions
13. IP – Instruction Pointer – contains the offset of the next instruction to be
executed.
14. Flag Register – individual bit positions within register show status of
CPU or results of arithmetic operations.

b Demonstrate in detail the program development steps in assembly 6M


language programming.
Ans Program Development steps Each step :
1M
1. Defining the problem
The first step in writing program is to think very carefully about the (Flowchart
problem that you want the program to solve. symbols are
2. Algorithm optional)
The formula or sequence of operations or task need to perform by your
program can be specified as a step in general English is called
algorithm.
3. Flowchart
The flowchart is a graphically representation of the program operation
or task.

4. Initialization checklist
Initialization task is to make the checklist of entire variables, constants,
all the registers, flags and programmable ports.
5. Choosing instructions
We should choose those instructions that make program smaller in size
and more importantly efficient in execution.
6. Converting algorithms to assembly language program
Every step in the algorithm is converted into program statement using
correct and efficient instructions or group of instructions.

Page No: 21 /2 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

c Illustrate the use of any three branching instructions. 6M


Ans BRANCH INSTRUCTIONS Any 3 branch
Branch instruction transfers the flow of execution of the program to a new instructions:
address specified in the instruction directly or indirectly. When this type 2M each
of instruction is executed, the CS and IP registers get loaded with new
values of CS and IP corresponding to the location to be transferred.
Unconditional Branch Instructions :
1. CALL : Unconditional Call
The CALL instruction is used to transfer execution to a subprogram or
procedure by storing return address on stack There are two types of calls-
NEAR (Inter-segment) and FAR(Intra-segment call). Near call refers to a
procedure call which is in the same code segment as the call instruction and far
call refers to a procedure call which is in different code segment from that of
the call instruction.
Syntax: CALL procedure_name
2. RET: Return from the Procedure.
At the end of the procedure, the RET instruction must be executed. When it is
executed, the previously stored content of IP and CS along with Flags are
retrieved into the CS, IP and Flag registers from the stack and execution of the
main program continues further.
Syntax :RET

3. JMP: Unconditional Jump


This instruction unconditionally transfers the control of execution to the
specified address using an 8-bit or 16-bit displacement. No Flags are affected
by this instruction.
Syntax : JMP Label

4. IRET: Return from ISR


When it is executed, the values of IP, CS and Flags are retrieved from the stack
to continue the execution of the main program.
Syntax: IRET

Conditional Branch Instructions


When this instruction is executed, execution control is transferred to the address
specified relatively in the instruction

1. JZ/JE Label
Transfer execution control to address ‘Label’, if ZF=1.
2. JNZ/JNE Label
Transfer execution control to address ‘Label’, if ZF=0
3. JS Label
Transfer execution control to address ‘Label’, if SF=1.

Page No: 22 /2 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

4. JNS Label
Transfer execution control to address ‘Label’, if SF=0.
5. JO Label
Transfer execution control to address ‘Label’, if OF=1.
6. JNO Label
Transfer execution control to address ‘Label’, if OF=0.
7. JNP Label
Transfer execution control to address ‘Label’, if PF=0.
8. JP Label
Transfer execution control to address ‘Label’, if PF=1.
9. JB Label
Transfer execution control to address ‘Label’, if CF=1.
10. JNB Label
Transfer execution control to address ‘Label’, if CF=0.
11. JCXZ Label
Transfer execution control to address ‘Label’, if CX=0
Conditional LOOP Instructions.
12. LOOP Label :
Decrease CX, jump to label if CX not zero.

13.LOOPE label
Decrease CX, jump to label if CX not zero and
Equal (ZF = 1).

14.LOOPZ label
Decrease CX, jump to label if CX not zero and ZF= 1.

15.LOOPNE label
Decrease CX, jump to label if CX not zero and Not Equal (ZF = 0).

16. LOOPNZ label


Decrease CX, jump to label if CX not zero and ZF=0

6 Attempt any TWO : 12 M


a Describe any six addressing modes of 8086 with suitable diagram. 6M

Page No: 23 /2 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

Ans Different addressing modes of 8086 : Any 6


addressing
modes correct
description:
1M each

1. Immediate: In this addressing mode, immediate data is a part of instruction,


and appears in the form of successive byte or bytes.
ex. MOV AX, 0050H

2. Direct: In the direct addressing mode, a 16 bit address (offset) is directly


specified in the instruction as a part of it.
ex. MOV AX ,[1 0 0 0 H]

3. Register: In register addressing mode, the data is stored in a register and it is


referred using the particular register. All the registers except IP may be used in
this mode.
ex. 1)MOV AX,BX

Page No: 24 /2 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

4. Register Indirect: In this addressing mode, the address of the memory


location which contains data or operand is determined in an indirect way using
offset registers. The offset address of data is in either BX or SI or DI register.
The default segment register is either DS or ES.

e.g. MOV AX,  BX 

5. Indexed: In this addressing mode offset of the operand is stored in one of the
index register. DS and ES are the default segments for index registers SI and DI
respectively

e.g. MOV AX,  SI 

6. Register Relative: In this addressing mode the data is available at an


effective address formed by adding an 8-bit or 16-bit displacement with the
content of any one of the registers BX, BP, SI and DI in the default either DS or
ES segment.

e.g. MOV AX, 50H  BX 

7. Based Indexed: In this addressing mode the effective address of the data is
formed by adding the content of a base register (any one of BX or BP) to the
content of an index register (any one of SI or DI). The default segment register
may be ES or DS.

e.g MOV AX,  BX   SI 

8. Relative Based Indexed: The effective address is formed by adding an 8-bit


or 16-bit displacement with the sum of contents of any one of the base register
(BX or BP) and any one of the index registers in a default segment.

e.g. MOV AX, 50H  BX  SI 

9 .Implied addressing mode:

Page No: 25 /2 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

No address is required because the address is implied in the instruction itself.


e.g NOP,STC,CLI,CLD,STD

b Select an appropriate instruction for each of the following & write : 6M


i)Rotate the content of DX to write 2 times without carry
ii)Multiply content of AX by 06H
iii)Load 4000H in SP register
iv)Copy the contents of BX register to CS
v)Signed division of BL and AL
vi) Rotate AX register to right through carry 3 times.
Ans i) Each correct
answer : 1 M
MOV CL,02H each
ROR DX,CL
(OR)
ROR DX,03H

ii)
MOV BX,06h
MUL BX

iii)
MOV SP,4000H

iv)
The contents if CS register cannot be modified directly , Hence no
instructions are used However examiner can give marks if question is
attempted.
v)

Page No: 26 /2 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

IDIV BL

vi)
MOV CL,03H
RCR AX,CL

(OR)
RCR AX,03H

c Write an ALP to arrange numbers in array in descending order. 6M


Ans DATA SEGMENT Correct
ARRAY DB 15H,05H,08H,78H,56H Program: 6M
DATA ENDS (For basic
CODE SEGMENT logic may
START:ASSUME CS:CODE,DS:DATA give 2-4 M)
MOV DX,DATA
MOV DS,DX
MOV BL,05H

STEP1: MOV SI,OFFSET ARRAY


MOV CL,04H
STEP: MOV AL,[SI]
CMP AL,[SI+1]
JNC DOWN

XCHG AL,[SI+1]
XCHG AL,[SI]

DOWN:ADD SI,1
LOOP STEP
DEC BL
JNZ STEP1
MOV AH,4CH
INT 21H
CODE ENDS
END START

Page No: 27 /2 7
11920
22415
3 Hours / 70 Marks Seat No.

Instructions : (1) All Questions are compulsory.


(2) Illustrate your answers with neat sketches wherever necessary.
(3) Figures to the right indicate full marks.
(4) Assume suitable data, if necessary.

Marks

1. Attempt any FIVE of the following : 10

(a) State the function of READY & INTR pin of 8086.

(b) What is role of XCHG instruction in assembly language program ? Give


example.

(c) List assembly language programming tools.

(d) Define Macro. Give syntax.

(e) Draw flowchart for multiplication of two 16 bit numbers.

(f) Draw Machine language instruction format for Register-to-Register transfer.

(g) State the use of STC and CMC instructions of 8086.

2. Attempt any THREE of the following : 12

(a) Give the difference between intersegment and intrasegment CALL.

(b) Draw flag register of 8086 and explain any four flags.

(c) Explain assembly language program development steps.

(d) Explain logical instructions of 8086. (Any Four)

[1 of 4] P.T.O.
22415 [2 of 4]
3. Attempt any THREE of the following : 12

(a) Draw functional block diagram of 8086 microprocessor.

(b) Write an ALP to add two 16-bit numbers.

(c) Write an ALP to find length of string.

(d) Write an assembly language program to solve p = x2 + y2 using macro.


(x and y are 8-bit numbers)

4. Attempt any THREE of the following : 12

(a) What is pipelining ? How it improves the processing speed ?

(b) Write an ALP to count no. of 0’s in 16 bit number.

(c) Write an ALP to find largest number in array of elements 10 H, 24 H, 02 H,


05 H, 17 H.

(d) Write an ALP for addition of series of 8-bit number using procedure.

(e) Describe reentrant and recursive procedure with schematic diagram.

5. Attempt any TWO of the following : 12

(a) Define logical and effective address. Describe physical address generation
process in 8086. If DS = 345A H and SI = 13DC H. Calculate physical address.

(b) Explain the use of assembler directives :

(i) DW

(ii) EQU

(iii) ASSUME

(iv) OFFSET

(v) SEGMENT

(vi) EVEN

(c) Describe any four string instructions of 8086 assembly language.


22415 [3 of 4]
6. Attempt any TWO of the following : 12

(a) Describe any 6 addressing modes of 8086 with one example of each,

(b) Select assembly language for each of the following :

(i) Rotate register BL right 4 times.

(ii) Multiply AL by 04 H

(iii) Signed division of AX by BL.

(iv) Move 2000 H in BX register.

(v) Increment the content of AX by 1.

(vi) Compare AX with BX.

(c) Write an ALP to reverse a string. Also draw flowchart for same.

_______________

P.T.O.
22415 [4 of 4]
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

SUMMER – 19 EXAMINATION
Subject Name: MICROPROCESSOR Model Answer Subject Code: 22415
Important Instructions to examiners:
1) The answers should be examined by key words and not as word-to-word as given in the
model answer scheme.
2) The model answer and the answer written by candidate may vary but the examiner may try
to assess the understanding level of the candidate.
3) The language errors such as grammatical, spelling errors should not be given more
Importance (Not applicable for subject English and Communication Skills.
4) While assessing figures, examiner may give credit for principal components indicated in the
figure. The figures drawn by candidate and model answer may vary. The examiner may give
credit for any equivalent figure drawn.
5) Credits may be given step wise for numerical problems. In some cases, the assumed
constant values may vary and there may be some difference in the candidate’s answers and
model answer.
6) In case of some questions credit may be given by judgement on part of examiner of relevant
answer based on candidate’s understanding.
7) For programming language papers, credit may be given to any other program based on
equivalent concept.

Q. Sub Answer Marking


No. Q. Scheme
N.
1. Attempt any Five of the following: 10M
a State the function of READY and INTR pin of 8086 2M
Ans Ready: Each correct
It is used as acknowledgement from slower I/O device or memory. function 1M
It is Active high signal, when high; it indicates that the peripheral device is
ready to transfer data.
INTR
This is a level triggered interrupt request input, checked during last clock
cycle of each instruction to determine the availability of request. If any
interrupt request is occurred, the processor enters the interrupt acknowledge
cycle.
b What is role of XCHG instruction in assembly language program? 2M
Give example
Ans Role of XCHG: Correct
role:1M
This instruction exchanges the contents of a register with the contents of
another register or memory location. Correct
example : 1M
Example:

XCHG AX, BX ; Exchange the word in AX with word in BX.

Page 1 | 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

(any other
example
allowed)
c List assembly language programming tools. 2M
Ans 1. Editors Each ½ M
2. Assembler
3. Linker
4. Debugger.
d Define Macro.Give syntax. 2M
Ans Macro: Small sequence of the codes of the same pattern are repeated Definition1M
frequently at different places which perform the same operation on the
different data of same data type, such repeated code can be written separately Syntax 1M
called as Macro.

Syntax:
Macro_name MACRO[arg1,arg2,…..argN)
…..
End
e Draw flowchart for multiplication of two 16 bit numbers. 2M
Ans Correct
flowchart:
2M(consider
any relevant
flowchart
also)

f Draw machine language instruction format for Register-to-Register 2M


transfer.

Page 2 | 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

Ans Correct
diagram 2M

g State the use of STC and CMC instruction of 8086. 2M


Ans STC – This instruction is used to Set Carry Flag. CF1 Each correct
use 1M
CMC – This instruction is used to Complement Carry Flag.
CF ~ CF

2. Attempt any Three of the following: 12M


a Give the difference between intersegment and intrasegment CALL 4M
Ans Any 4 points
Sr.no Intersegment Call Intrasegment Call 1M each

1. It is also called Far It is also called Near


procedure call procedure call.

2. A far procedure refers to a A near procedure refers to a


procedure which is in the procedure which is in the
different code segment same code segment from
from that of the call that of the call instruction
instruction.

3 This procedure call This procedure call replaces


replaces the old CS:IP pairs the old IP with new IP.
with new CS:IP pairs

4. The value of the old CS:IP The value of old IP is


pairs are pushed on to the pushed on to the stack.
stack
SP=SP-2 ;Save IP on
SP=SP-2 ;Save CS on stack(address of procedure)
stack

SP=SP-2 ;Save IP (new


offset address of called
procedure)

5. More stack locations are Less stack locations are


required required

Page 3 | 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

6. Example :- Call FAR PTR Example :- Call Delay


Delay

b Draw flag register of 8086 and explain any four flags. 4M


Ans Flag Register of 8086 Correct
diagram 2M

Any 4 flag
explanation
:1/2 M each

Conditional /Status Flags


C-Carry Flag : It is set when carry/borrow is generated out of MSB of
result. (i.e D7 bit for 8-bit operation, D15 bit for a 16 bit operation).

P-Parity Flag This flag is set to 1 if the lower byte of the result contains even
number of 1’s otherwise it is reset.
AC-Auxiliary Carry Flag This is set if a carry is generated out of the lower
nibble, (i.e. From D3 to D4 bit)to the higher nibble
Z-Zero Flag This flag is set if the result is zero after performing ALU
operations. Otherwise it is reset.
S-Sign Flag This flag is set if the MSB of the result is equal to 1 after
performing ALU operation , otherwise it is reset.
O-Overflow Flag This flag is set if an overflow occurs, i.e. if the result of
a signed operation is large enough to be accommodated in destination
register.

Control Flags
T-Trap Flag If this flag is set ,the processor enters the single step execution
mode.
I-Interrupt Flag it is used to mask(disable) or unmask(enable)the INTR
interrupt. When this flag is set,8086 recognizes interrupt INTR. When it
is reset INTR is masked.

Page 4 | 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

D-Direction Flag It selects either increment or decrement mode for DI &/or


SI register during string instructions.
c Explain assembly language program development steps. 4M
Ans 1. Defining the problem: The first step in writing program is to think very Correct steps
carefully about the problem that the program must solve. 4M
2. Algorithm: The formula or sequence of operations to be performed by the
program can be specified as a step in general English is called algorithm.
3. Flowchart: The flowchart is a graphically representation of the program
operation or task.
4. Initialization checklist: Initialization task is to make the checklist of
entire variables, constants, all the registers, flags and programmable ports
5. Choosing instructions: Choose those instructions that make program
smaller in size and more importantly efficient in execution.
6. Converting algorithms to assembly language program: Every step in
the algorithm is converted into program statement using correct and efficient
instructions or group of instructions.
d Explain logical instructions of 8086.(Any Four) 4M
Ans Logical instructions. Any 4
instruction
1) AND- Logical AND correct
explanation
Syntax : AND destination, source
1M each
Operation
Destination ←destination AND source
Flags Affected :CF=0,OF=0,PF,SF,ZF
This instruction AND’s each bit in a source byte or word with the
same number bit in a destination byte or word. The result is put in
destination.

Example: AND AX, BX


• AND AL,BL
• AL 1111 1100
• BL 0000 0011
---------------------
• AL0000 0000 (AND AL,BL)

2) OR – Logical OR
Syntax :OR destination, source

Page 5 | 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

Operation
Destination OR source

Flags Affected :CF=0,OF=0,PF,SF,ZF


This instruction OR’s each bit in a source byte or word with the
corresponding bit in a destination byte or word. The result is put in a
specified destination.
Example :
• OR AL,BL
• AL 1111 1100
• BL 0000 0011
---------------------
• AL1111 1111

3) NOT – Logical Invert


Syntax : NOT destination
Operation: Destination NOT destination

Flags Affected :None


The NOT instruction inverts each bit of the byte or words at the
specified destination.

Example
NOT BL

BL = 0000 0011
NOT BL gives 1111 1100
4) XOR – Logical Exclusive OR
Syntax : XOR destination, source
Operation : Destination Destination XOR source

Flags Affected :CF=0,OF=0,PF,SF,ZF


This instruction exclusive, OR’s each bit in a source byte or word
with the same number bit in a destination byte or word.

Page 6 | 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

Example(optional)
XOR AL,BL
• AL 1111 1100
• BL 0000 0011
---------------------

• AL1111 1111 (XOR AL,BL)

5)TEST
Syntax : TEST Destination, Source
This instruction AND’s the contents of a source byte or word with the
contents of specified destination byte or word and flags are updated, ,
flags are updated as result ,but neither operands are changed.
Operation performed:
Flags set for result of (destination AND source)

Example: (Any 1)
TEST AL, BL ; AND byte in BL with byte in AL, no result, Update PF,
SF, ZF.

e.g MOV AL, 00000101

TEST AL, 1 ; ZF = 0.
TEST AL, 10b ; ZF = 1

3. Attempt any Four of the following:


a Draw functional block diagram of 8086 microprocessor. 4M
Ans Block
diagram 4M

Page 7 | 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

b Write an ALP to add two 16-bit numbers. 4M


Ans DATA SEGMENT Data segment
initialization
NUMBER1 DW 6753H 1M, Code
segment 3M
NUMBER2 DW 5856H
SUM DW 0
DATA ENDS
CODE SEGMENT
ASSUME CS: CODE, DS: DATA
START: MOV AX, DATA

Page 8 | 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

MOV DS, AX
MOV AX, NUMBER1
MOV BX, NUMBER2
ADD AX, BX
MOV SUM, AX
MOV AH, 4CH
INT 21H
CODE ENDS
END START
c Write an ALP to find length of string. 4M
Ans Data Segment program - 4
M
STRG DB 'GOOD MORNING$'
LEN DB ?
DATA ENDS
CODE SEGMENT
START:
ASSUME CS: CODE, DS : DATA
MOV DX, DATA
MOV DS,DX
LEA SI, STRG
MOV CL,00H
MOV AL,'$'
NEXT: CMP AL,[SI]
JZ EXIT
ADD CL,01H
INC SI

Page 9 | 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

JMP
NEXT EXIT: MOV LEN,CL
MOV AH,4CH
INT 21H
CODE ENDS
d Write an assembly language program to solve p= x2+y2 using Macro.(x 4M
and y are 8 bit numbers.
Ans .MODEL SMALL program - 4
M
PROG MACRO a,b

MOV al,a

MUL al

MOV bl,al

MOV al,b

MUL al

ADD al,bl

ENDM

.DATA

x DB 02H

y DB 03H

p DB DUP()

.CODE

START:

MOV ax,data

MOV ds,ax

PROG x, y

Page 10 | 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

MOV p,al

MOV ah,4Ch

Int 21H

END

4. Attempt any Three of the following:


a What is pipelining? How it improves the processing speed.
Ans  In 8086, pipelining is the technique of overlapping instruction fetch Explanation 3
and execution mechanism. M, Diagram
 To speed up program execution, the BIU fetches as many as six 1M
instruction bytes ahead of time from memory. The size of
instruction prefetching queue in 8086 is 6 bytes.
 While executing one instruction other instruction can be fetched.
Thus it avoids the waiting time for execution unit to receive other
instruction.
 BIU stores the fetched instructions in a 6 level deep FIFO . The
BIU can be fetching instructions bytes while the EU is decoding an
instruction or executing an instruction which does not require use of
the buses.
 When the EU is ready for its next instruction, it simply reads the
instruction from the queue in the BIU.
 This is much faster than sending out an address to the system
memory and waiting for memory to send back the next instruction
byte or bytes.
 This improves overall speed of the processor

b Write an ALP to count no.of 0’s in 16 bit number. 4M


Ans DATA SEGMENT Program 4 M
N DB 1237H
Z DB 0
Page 11 | 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

DATA ENDS
CODE SEGMENT
ASSUME DS:DATA, CS:CODE
START:
MOV DX,DATA
MOV DS,DX
MOV AX, N
MOV CL,08
NEXT: ROL AX,01
JC ONE
INC Z
ONE: LOOP NEXT
HLT
CODE ENDS
END START
c Write an ALP to find largest number in array of elements 10H, 24H, 4M
02H, 05H, 17H.
Ans DATA SEGMENT Program - 4
ARRAY DB 10H,24H,02H,05H,17H M
LARGEST DB 00H
DATA ENDS
CODE SEGMENT
START:
ASSUME CS:CODE,DS:DATA
MOV DX,DATA
MOV DS,DX
MOV CX,04H
MOV SI ,OFFSET
ARRAY MOV AL,[SI]
UP: INC SI
CMP AL,[SI]
JNC NEXT
MOV AL,[SI]
NEXT: DEC CX
JNZ UP
MOV LARGEST,AL
MOV AX,4C00H
INT 21H
CODE ENDS
END START
d Write an ALP for addition of series of 8-bit number using procedure. 4M
Ans DATA SEGMENT Program - 4
NUM1 DB 10H,20H,30H,40H,50H M
RESULT DB 0H
CARRY DB 0H

Page 12 | 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START: MOV DX,DATA
MOV DS, DX
MOV CL,05H
MOV SI, OFFSET NUM1
UP: CALL SUM
INC SI
LOOP UP
MOV AH,4CH
INT 21H

SUM PROC; Procedure to add two 8 bit numbers


MOV AL,[SI]
ADD RESULT, AL
JNC NEXT
INC CARRY
NEXT: RET
SUM ENDP
CODE ENDS
END START

e Describe re-entrant and recursive procedure with schematic diagram. 4M


Ans In some situation it may happen that Procedure 1is called from main program Re-entrant 2
Procrdure2 is called from procedure1And procrdure1 is again called from M, recursive
procdure2. In this situation program execution flow reenters in the 2 M
procedure1. These types of procedures are called re enterant procedures. The
RET instruction at the end of procrdure1 returns to procedure2. The RET
instruction at the end of procedure2 will return the execution to
procedure1.Procedure1 will again executed from where it had stopped at the
time of calling procrdure2 and the RET instruction at the end of this will
return the program execution to main program.
The flow of program execution for re-entrant procedure is as shown in FIG.

Page 13 | 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

5. Attempt any Two of the following: 12 M


a Define logical and effective address. Describe physical address 6M
generation process in 8086. If DS=345AH and SI=13DCH. Calculate
physical address.
Ans A logical address is the address at which an item (memory cell, storage Define each
element) appears to reside from the perspective of an executing application Term :1M.
program. A logical address may be different from the physical address due
to the operation of an address translator or mapping function. Physical
Address
Effective Address or Offset Address: The offset for a memory operand is Generation.
called the operand's effective address or EA. It is an unassigned 16 bit Description :
number that expresses the operand's distance in bytes from the beginning of 2 M
the segment in which it resides. In 8086 we have base registers and index &
registers. Calculation 2
M

Page 14 | 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

Generation of 20 bit physical address in 8086:-


1. Segment registers carry 16 bit data, which is also known as base address.
2. BIU appends four 0 bits to LSB of the base address. This address becomes
20-bit address.
3. Any base/pointer or index register carries 16 bit offset.
4. Offset address is added into 20-bit base address which finally forms 20 bit
physical address of memory location

DS=345AH and SI=13DCH


Physical adress = DS*10H + SI
= 345AH * 10H + 13DCH
= 345A0+13DC
= 3597CH
b Explain the use of assembler directives. 1) DW 2) EQU 3) ASSUME 4) 2M
OFFSET 5) SEGMENT 6) EVEN
Ans DW (DEFINE WORD) Each
The DW directive is used to tell the assembler to define a variable of type Directive
word or to reserve storage locations of type word in memory. The statement Use : 1M
MULTIPLIER DW 437AH, for example, declares a variable of type word each
named MULTIPLIER, and initialized with the value 437AH when the
program is loaded into memory to be run.
EQU (EQUATE)
EQU is used to give a name to some value or symbol. Each time the
assembler finds the given name in the program, it replaces the name with
the value or symbol you equated with that name.

Page 15 | 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

Example
Data SEGMENT
Num1 EQU 50H
Num2 EQU 66H
Data ENDS
Numeric value 50H and 66H are assigned to Num1 and Num2.
ASSUME
ASSUME tells the assembler what names have been chosen for Code, Data
Extra and Stack segments. Informs the assembler that the register CS is to be
initialized with the address allotted by the loader to the label CODE and DS
is similarly initialized with the address of label DATA.

OFFSET
OFFSET is an operator, which tells the assembler to determine the offset or
displacement of a named data item (variable), a procedure from the start of
the segment, which contains it.
Example
MOV BX;
OFFSET PRICES;
It will determine the offset of the variable PRICES from the start of the
segment in which PRICES is defined and will load this value into BX.
SEGMENT
The SEGMENT directive is used to indicate the start of a logical segment.
Preceding the SEGMENT directive is the name you want to give the
segment.
For example, the statement CODE SEGMENT indicates to the assembler
the start of a logical segment called CODE. The SEGMENT and ENDS
directive are used to “bracket” a logical segment containing code of data
EVEN (ALIGN ON EVEN MEMORY ADDRESS)
As an assembler assembles a section of data declaration or instruction
statements, it uses a location counter to keep track of how many bytes it is
from the start of a segment at any time. The EVEN directive tells the
assembler to increment the location counter to the next even address, if it is
not already at an even address. A NOP instruction will be inserted in the
location incremented over.
c Describe any four string instructions of 8086 assembly language. 2M
Ans 1] REP: each correct
instruction
REP is a prefix which is written before one of the string instructions. It will 1½ M each
cause During length counter CX to be decremented and the string instruction
to be repeated until CX becomes 0.

Page 16 | 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

Two more prefix.


REPE/REPZ: Repeat if Equal /Repeat if Zero.
It will cause string instructions to be repeated as long as the compared bytes
or words Are equal and CX≠0.
REPNE/REPNZ: Repeat if not equal/Repeat if not zero.
It repeats the strings instructions as long as compared bytes or words are not
equal
And CX≠0.
Example: REP MOVSB

2] MOVS/ MOVSB/ MOVSW - Move String byte or word.


Syntax:
MOVS destination, source
MOVSB destination, source
MOVSW destination, source
Operation: ES:[DI]<----- DS:[SI]
It copies a byte or word a location in data segment to a location in extra
segment. The offset of source is pointed by SI and offset of destination is
pointed by DI.CX register contain counter and direction flag (DE) will be set
or reset to auto increment or auto decrement pointers after one move.

Example
LEA SI, Source
LEA DI, destination
CLD
MOV CX, 04H
REP MOVSB

3] CMPS /CMPSB/CMPSW: Compare string byte or Words.


Syntax:
CMPS destination, source

Page 17 | 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

CMPSB destination, source


CMPSW destination, source
Operation: Flags affected < ----- DS:[SI]- ES:[DI]
It compares a byte or word in one string with a byte or word in another string.
SI Holds the offset of source and DI holds offset of destination strings. CS
contains counter and DF=0 or 1 to auto increment or auto decrement pointer
after comparing one byte/word.

Example
LEA SI, Source
LEA DI, destination
CLD
MOV CX, 100
REPE CMPSB

4] SCAS/SCASB/SCASW: Scan a string byte or word.


Syntax:
SCAS/SCASB/SCASW
Operation: Flags affected < ----- AL/AX-ES: [DI]
It compares a byte or word in AL/AX with a byte /word pointed by ES: DI.
The string to be scanned must be in the extra segment and pointed by DI. CX
contains counter and DF may be 0 or 1.
When the match is found in the string execution stops and ZF=1 otherwise
ZF=0.

Example
LEA DI, destination
MOV Al, 0DH
MOV CX, 80H
CLD
REPNE SCASB

Page 18 | 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

5] LODS/LODSB/LODSW:
Load String byte into AL or Load String word into AX.
Syntax:
LODS/LODSB/LODSW
Operation: AL/AX < ----- DS: [SI]
IT copies a byte or word from string pointed by SI in data segment into AL
or AX.CX
may contain the counter and DF may be either 0 or 1

Example
LEA SI, destination
CLD
LODSB

6] STOS/STOSB/STOSW (Store Byte or Word in AL/AX)


Syntax STOS/STOSB/STOSW
Operation: ES:[DI] < ----- AL/AX
It copies a byte or word from AL or AX to a memory location pointed by DI
in extra
segment CX may contain the counter and DF may either set or reset

6. Attempt any Two of the following: 12M


a Describe any 6 addressing modes of 8086 with one example each. 6M
Ans 1. Immediate addressing mode: Any 6 mode
with example
An instruction in which 8-bit or 16-bit operand (data) is specified in the 1 M each
instruction, then the addressing mode of such instruction is known as
Immediate addressing mode.

Example:
MOV AX,67D3H

2. Register addressing mode


An instruction in which an operand (data) is specified in general purpose
registers, then the addressing mode is known as register addressing mode.

Page 19 | 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

Example:
MOV AX,CX

3. Direct addressing mode


An instruction in which 16 bit effective address of an operand is specified in
the instruction, then the addressing mode of such instruction is known as
direct addressing mode.

Example:
MOV CL,[2000H]
4. Register Indirect addressing mode
An instruction in which address of an operand is specified in pointer register
or in index register or in BX, then the addressing mode is known as register
indirect addressing mode.
Example:
MOV AX, [BX]

5. Indexed addressing mode


An instruction in which the offset address of an operand is stored in index
registers (SI or DI) then the addressing mode of such instruction is known as
indexed addressing mode.
DS is the default segment for SI and DI.
For string instructions DS and ES are the default segments for SI and DI resp.
this is a special case of register indirect addressing mode.

Example:
MOV AX,[SI]

6. Based Indexed addressing mode:


An instruction in which the address of an operand is obtained by adding the
content of base register (BX or BP) to the content of an index register (SI or
DI) The default segment register may be DS or ES

Example:
MOV AX, [BX][SI]
7. Register relative addressing mode: An instruction in which the address
of the operand is obtained by adding the displacement (8-bit or 16 bit) with

Page 20 | 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

the contents of base registers or index registers (BX, BP, SI, DI). The default
segment register is DS or ES.

Example:
MOV AX, 50H[BX]

8. Relative Based Indexed addressing mode


An instruction in which the address of the operand is obtained by adding the
displacement (8 bit or 16 bit) with the base registers (BX or BP) and index
registers (SI or DI) to the default segment.

Example:
MOV AX, 50H [BX][SI]
b Select assembly language for each of the following 6M
i) rotate register BL right 4 times
ii) multiply AL by 04H
iii) Signed division of AX by BL
iv) Move 2000h in BX register
v) increment the counter of AX by 1
vi) compare AX with BX
Ans i) MOV CL, 04H Each correct
instruction
RCL AX, CL1 1M

Or
MOV CL, 04H
ROL AX, CL

Or
MOV CL, 04H
RCR AX, CL1

Page 21 | 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

Or
MOV CL, 04H
ROR AX, CL

ii) MOV BL,04h


MUL BL

iii) IDIV BL
iv) MOV BX,2000h
v) INC AX
vi) CMP AX,BX
c Write an ALP to reverse a string. Also draw flowchart for same.
Ans Program: Program 4 M
flowchart 2
DATA SEGMENT M
STRB DB 'GOOD MORNING$'
REV DB 0FH DUP(?)
DATA ENDS
CODE SEGMENT
START:ASSUME CS:CODE,DS:DATA
MOV DX,DATA
MOV DS,DX
LEA SI,STRB
MOV CL,0FH
LEA DI,REV
ADD DI,0FH
UP:MOV AL,[SI]

Page 22 | 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)

MOV [DI],AL
INC SI
DEC DI
LOOP UP
MOV AH,4CH
INT 21H
CODE ENDS
END START

Flowchart:

Page 23 | 23

You might also like