MIC
MIC
22415
3 Hours / 70 Marks Seat No.
Marks
[1 of 4] P.T.O.
22415 [2 of 4]
2. Attempt any THREE of the following : 12
(a) Describe the function of the following instructions :
(i) DAA
(ii) CMP
(iii) ADC
(iv) JNC
(b) Explain Re-Entrant and Recursive Procedure with diagram.
(c) Write the function of following pins of 8086 :
(i) READY
(ii) ALE
(iii) TEST
(iv) DEN
(d) Draw and explain model of Assembly Language Programming.
_______________
22415 [4 of 4]
22232
22415
3 Hours / 70 Marks Seat No.
Marks
1. Attempt any FIVE of the following : 10
(a) State the functions of following pins of 8086 Microprocessor :
(i) ALE
––
(ii) M/IO
(b) State the function of STC and CMC Instruction of 8086.
(c) List the program development steps for Assembly Language Programming.
(d) Define MACRO with its syntax.
(e) Write an ALP to Add two 16 bit numbers.
(f) State two examples of each, Immediate and based indexed Addressing modes.
(g) State the use of OF and AF Flags in 8086.
[1 of 4] P.T.O.
22415 [2 of 4]
(d) Identify the Addressing modes for the following instructions :
(e) Explain MACRO with suitable example. List four advantages of it.
(i) DB (ii) DW (iii) EQU (iv) DUP (v) SEGMENT (vi) END
_______________
P.T.O.
22415 [4 of 4]
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.
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 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.
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
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
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)
__________________________________________________________________________________________________
(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
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.
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)
__________________________________________________________________________________________________
Ans Diagram: 2 M
Explanation:
2M
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.
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
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
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
----------------------------
2A887H
Array db 02h,04h,06h,01h,05h
Ends
.code
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
START:
MOV AX,@DATA
MOV DS,AX
ENDS
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
mov al,num1
mov bl,num2
sub al,bl
das
sub1 endp
mov ah,4ch
int 21h
ends
end start
end
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.
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
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.
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]
a) Describe how string instructions are used to compare two strings with suitable 6M
example.
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
ROL AX, CL
SHR BX, CL
MOV SS, 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)
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.
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)
Page 2 | 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Ans Correct
diagram 2M
Page 3 | 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Any 4 flag
explanation
:1/2 M each
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)
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
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
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
---------------------
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.
TEST AL, 1 ; ZF = 0.
TEST AL, 10b ; ZF = 1
Page 7 | 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
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
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
Page 13 | 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Page 14 | 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
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)
Example
LEA SI, Source
LEA DI, destination
CLD
MOV CX, 04H
REP MOVSB
Page 17 | 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Example
LEA SI, Source
LEA DI, destination
CLD
MOV CX, 100
REPE CMPSB
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
Example:
MOV AX,67D3H
Page 19 | 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Example:
MOV AX,CX
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]
Example:
MOV AX,[SI]
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]
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
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
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.
1 1 None
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
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
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
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.
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)
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)
Directives PROC & ENDP are MACRO and ENDM are used
used for defining procedure. for defining MACRO
Page No: 6 /2 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
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.
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
Page No: 7 /2 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
DW 1000
DD 4294967295
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)
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
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
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
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.
Page No: 12 /2 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Advantages of Segmentation:
Page No: 13 /2 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
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
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)
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
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
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
Page No: 20 /2 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
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)
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).
Page No: 23 /2 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
Page No: 24 /2 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
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
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.
Page No: 25 /2 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2013 Certified)
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
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