2017 Summer Model Answer Paper
2017 Summer Model Answer Paper
2017 Summer Model Answer Paper
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER– 17 EXAMINATION
Subject Title: Microprocessor and Programming.
Important Instructions to examiners:
Subject Code: 17431
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 anyequivalent
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.
Ans: INTR: - It is level triggered, non-vectored interrupt. When INTR occurs the (1M each)
microprocessor generates interrupt acknowledgement signal INTA
INTA
It is an active low acknowledgement signal for INTR.
This signal is used to get OPCODE & hence ISR address from external hardware.
b) List any four features of 8086 microprocessor. 2M
Page1
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
c) Define immediate and direct addressing mode. Also give one example of each 2M
Ans: 1.Immediate addressing mode:In this addressing mode, immediate data is a part of (Each
instruction, and appears in the form of successive byte or bytes Description
Example: MOV AX,56D3H ½ M and
Each
2. Direct addressing mode:In the direct addressing mode, a 16 bit address (offset) is Example: ½
M)
directly specified in the instruction as a part of it.
(Any
Example: MOV CL,[1000H] example can
be
considered)
d) List the program development steps for assembly language programming. 2M
Ans: (Correct
Format of
flag register:
2 M)
Page2
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Or
MOV CL, 04H
ROL BL, CL
B) Attempt any TWO of the following : 8M
Debugger: -
1. Debugger is a program that allows the execution of program in single step mode under
the control of the user.
2. The errors in program can be located and corrected using a debugger.
3. Debugger generates .exe file.
b) Explain following assembler directives: 4M
(i) DB (ii) DW (iii) DD (iv) DQ
Ans: DB (Define Byte) (Correct
• This is used to define a byte type variable. Explanation
:1M each)
• The range of values : 0 – 255 for unsigned numbers -128 to 127 for signed numbers
• This can be used to define a single byte or multiple bytes
DW (Define Word)
• This is used to define a word (16-bit) type variable.
• The range of values : 0 – 65535 for unsigned numbers -32768 to 32767 for signed
numbers
• This can be used to define a single word or multiple words
DD (Define Double Word)
• This is used to define a double word (32-bit) type variable.
• This can be used to define a single double word or multiple double word
DQ : Define Quad Word
Page3
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
4. Example Example
Page4
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Ans: (Correct
Diagram:4
M)
Ans: (Correct
MN/ MX: The MN/MX pin is used to select either the minimum mode or maximum Function of
mode operation of the 8086. This is achieved by connecting this pin to either +5V each :1M
directly (for minimum mode) or to the ground (for maximum mode). each)
READY: This input is used to insert wait state into the timing cycle of the 8086. If the
ready pin is at logic 1, it has no effect on the operation of the microprocessor. If it is logic
0, the 8086 enters the waits state and remains the idle. This pin is used to interface the
operating peripherals with the 8086.
ALE :This active high ,output signal used to indicate availability of valid address on
address/data lines and is connected to latch enable input of latches (8282 or 74LS373) .
DT/R- This output line is used to decide the direction of data flow through the
transceivers(bidirectional buffer). When the processor sends the data, this signal is high
and when the processor is receiving data, this signal is low.
Page5
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Ans: (Description
Description: Process of fetching the next instruction while the current instruction is :2M,
executing is called pipelining which will reduce the execution time. The technique used Diagram:2
to enable an instruction to complete with each clock cycle. Normally, on a non – M)
pipelined processor, nine clock cycles are required for fetch, decode and execute cycles
for the three instructions as shown in Fig (a).
This takes longer time when compared to pipelined processor. In this ,the fetch, decode
and execute operations are performed in parallel, so only five clock cycles are required to
execute the same three instructions as shown Fig(b).
Page6
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
accessed.
8. Requires a single +5 volt supply
9. Requires 2 phase, 50% duty cycle TTL clock
10. Provide 2 serial I/O lines, so peripheral can be interfaced with 8085 μp
Limitation of 8085Microprocessor
1.In 8085 microprocessor, microprocessor can perform any arithmetic and logical Any Four
operation only on 8 bit data at a time. Limitation
o 2. In 8085 microprocessor, only 16 bit address lines, we can address only up to 64 KB of [½ M each]
memory.
o 3.8085 microprocessor has multiplexed address and data bus, so extra hardware is
required to separate address signals from the data signals.
o 4. Flags register has limited flags.
o 5. Interrupts are very limited in 8085.
o 6. Operating frequency is less in 8085 microprocessor, so the speed of execution is slow.
o 7. In 8085 microprocessor, we cannot design multi-processor system.
o 8.In 8085 microprocessor due to limited 8 bit size of the all registers, we can store
limited data bytes in the microprocessor memory.
e) What will be the content of register AL after the execution of last instruction? 4M
MOV AL, 02H
MOV BL, 02H
SUB AL, BL
MUL 08H
Ans: [Note: If the student corrects MUL instructions and writes the output, marks can be (Correct
given, Answer : 4
M)
The above program segment gives an error at MUL 08H instructions
hence it gives no output.
After correction;
MUL instruction will be MUL BL or MUL AL
Page7
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
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
Page8
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
ADD_PROC PROC
MOV AL, NUM1
MOV BL,NUM2
ADD AL,BL
RET
ADD_PROC ENDP
CODE ENDS
END START
Page9
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page10
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
d) List and explain any four process control instruction with their function. 4M
Ans: List of process control instructions: (List any 4
1. CLC – Clear carry flag instructions
2. CMC- Complement carry flag :
3. STC- Set carry flag 2M,
4. CLD- Clear direction flag Explanation
5. STD- Set direction flag of any 4
6. CLI- Clear interrupt flag instructions
7. STI- Set Interrupt flag : 2M)
8. WAIT- wait for test input pin to go low
9. HLT- Halt the processor
10. NOP- No operation
11. ESC- Escape to external device like NDP (numeric co-processor)
12. LOCK- Bus lock instruction prefix.
Explanation:
1. CLC – This instruction Clear Carry Flag. CF 0
2. CMC – This instruction Complement Carry Flag. CF~CF
3. STC – This instruction Set Carry Flag. CF1
4. CLD – This instruction Clear Direction Flag. DF0
Page11
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
8)HLT
This instruction causes processor to enter the halt state.
CPU stop fetching and executing instructions.
9)NOP
Used to add wait state of three clock cycles and during these clock cycles CPU does
not perform any operation. .
This instruction is Used to add delay loop in program
10)WAIT
It causes processor to enter into an idle state or a wait state and continue to remain in
that the processor receives state until one of the following signal.
o Signal on processor TEST pin
o Valid interrupt on INTR
o Valid interrupt on NMI
Used to synchronize other external hardware such as math co-processor.
11)LOCK
Prevent other processor to take the control of shared resources.
Lock the bus attached to lock pin of device while a multicycle instruction completes.
The lock prefix this allows a microprocessor to make sure that another processor does
not take control of system bus while it is in the middle of a critical instruction.
12)ESC:
This instruction is used to pass instructions to a coprocessor, such as the 8087 Math
coprocessor, which shares the address and data bus with 8086. Instructions for the
coprocessor are represented by a 6-bit code embedded in the ESC instruction.
Page12
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
(OR)
.MODEL SMALL
.DATA
NUM1 DB 84H
NUM2 DB 28H
RES_LSB DB ?
RES_MSB DB ?
.CODE
MOV AX,@DATA
MOV DS,AX
MOV AL,NUM1 ;
MOV BL,NUM2
ADD AL,BL ;Ans ACH
DAA
JNC DN
INC RES_MSB
DN:MOV RES_LSB,AL
MOV AH,4CH
INT 21H
END
f) Explain concept of segmentation with diagram. 4M
Page13
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Example :
data segment
Table db „0123456789ABCDEF‟
CODE DB 11
data ends
Code segment
- --
MOV BX,offset Table
Page14
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MOV al,CODE
XLAT ;AL will output code 0BH
Code ends
Destination Source
None of flag affected
Example:
XCHG BL, CL ; Exchange the byte in BL with byte in CL.
MOV AL,NUM1
Page15
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MOV BL,NUM2
SUB AL,BL
MOV DIFF,AL
MOV AH,4CH
INT 21H
CODE ENDS
END START
(OR)
DATA SEGMENT
NUM1 DB 85H
NUM2 DB 92H
DIFFERENCE DB 1 DUP(0)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV DX,DATA
MOV DS,DX
MOV AL,NUM1
MOV BL,NUM2
SUB AL,BL
MOV DIFFERENCE,AL
JNC EXIT
MOV DIFFERENCE+1,01
EXIT:MOV AH,4CH
INT 21H
CODE ENDS
END START
e) Write an ALP to add two 16 bit numbers. 4M
Ans: DATA SEGMENT Correct
NUMBER1 DW 5522 H Program
NUMBER2 DW 3311H :4M
SUM DW 2 DUP(0) (Any other
DATA ENDS logic also
CODE SEGMENT considered)
ASSUME CS:CODE,DS:DATA
START:
MOV DX,DATA
MOV DS,DX
MOV AX,NUMBER1
MOV BX,NUMBER2
ADD AX,BX
MOV SUM,AX
MOV AH,4CH
Page16
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
INT 21H
CODE ENDS
END START
(OR)
DATA SEGMENT
NUMBER1 DW 5522 H
NUMBER2 DW 8311H
SUM DW 2 DUP(0)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV DX,DATA
MOV DS,DX
MOV AX,NUMBER1
MOV BX,NUMBER2
ADD AX,BX
MOV SUM,AX
JNC EXIT ;EXIT IF CARRY
MOV SUM+2,01 ;STORE CARRY BIT IN MS DIGIT
EXIT:MOV AH,4CH
INT 21H
CODE ENDS
END START
f) Define MACRO with its syntax. Also give two advantages of it. 4M
Ans: Macro (Definition :
• Small sequence of the codes of the same pattern are repeated frequently at different 1M)
places which perform the same operation on the different data of same data type, such
repeated code can be written separately called as macro.
(Syntax :1
1) Macro Syntax:
M)
Macro_name MACRO[arg1,arg2,…..argN)
……
……
ENDM
Advantages of Macro:
• The speed of the execution of the program is increased.
(Any 2
• It saves a lot of time that is spent by the compiler for invoking / calling the functions. advantages :
• It reduces the length of the program. 2M)
Page17
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
Page18
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
3 A near procedure call replaces the A far procedure call replaces the
old IP with new IP. old CS:IP pairs with new CS:IP
pairs
Page19
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
4. The value of old IP is pushed on to The value of the old CS:IP pairs
the stack. are pushed on to the stack
SP=SP-2 ;Save IP on stack(address SP=SP-2 ;Save CS on stack
of procedure) SP=SP-2 ;Save IP (new offset
address of called procedure)
5. Less stack locations are required More stack locations are required
3)LOCAL
Macros are expanded directly in code, therefore if there are labels inside the macro
definition you may get "Duplicate declaration" error when macro is used for twice or
more. To avoid such problem, use LOCAL directive followed by names of variables,
labels or procedure names.
Syntax: LOCAL <label>
MyMacro2 MACRO
LOCAL label1, label2
CMP AX, 2
JE label1
CMP AX, 3
JE label2
label1:
INC AX
label2:
ADD AX, 2
ENDM
data segment
data ends
code segment
start: assume cs:code,ds:data
mov ax,data
Page20
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
mov ds,ax
mov ax,02h
MyMacro2
MyMacro2
mov ah,4ch
int 21h
code ends
end start
Q.6 Attempt any two of the following 16M
a) Draw and explain the working of 8086 in maximum mode. 8M
Ans: (Diagram :
4M,
Explanatio
n : 4M)
Maximum
mode pin
description
optional
1.In the maximum mode, the 8086 is operated by strapping the MN/MX pin to ground.
2.In this mode, the processor derives the status signal S2, S1, S0.
3.Another chip called bus controller derives the control signal using this status
information
4.In the maximum mode, there may be more than one microprocessor in the system
configuration. The components in the system are same as in the minimum mode system.
5.The basic function of the bus controller chip IC8288, is to derive control signals like
RD and WR ( for memory and I/O devices), DEN, DT/R, ALE etc. using the information
by the processor on the status lines.
6.The bus controller chip has input lines S2, S1, S0 and CLK. These inputs to 8288 are
driven by CPU.
It derives the outputs ALE, DEN, DT/R, MRDC, MWTC, AMWC, IORC, IOWC and
AIOWC. The AEN, IOB and CEN pins are specially useful for multiprocessor systems.
AEN and IOB are generally grounded. CEN pin is usually tied to +5V.
7.The significance of the MCE/PDEN output depends upon the status of the IOB pin.
8.INTA pin used to issue two interrupt acknowledge pulses to the interrupt controller or
to an interrupting device.
9.IORC, IOWC are I/O read command and I/O write command signals respectively .
These signals enable an IO interface to read or write the data from or to the address port.
10.The MRDC, MWTC are memory read command and memory write command signals
respectively and may be used as memory read or write signals.
Page21
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
11.All these command signals instructs the memory to accept or send data from or to the
bus.
Pin Discription:
AD15-AD0:-These pins acts as multiplexed address and data bus of the
microprocessor. Whenever the ALE pin is high these pins carry the
address, when the ALE pin is low it carry the data.
A19/S6-A16/S3:- These pins are multiplexed to provide the address signals A19-A16
and the status bits S6-S3. When ALE=1 these pins carry the
address and when ALE=0, they carry the status lines.
S4 S3 Segment Accessed
0 0 Extra Segment
0 1 Stack Segment
1 0 Code Segment
1 1 Data Segment
Page22
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
S2 S1 S0 Function
0 0 0 INTR
0 0 1 I/O Read
0 1 0 I/O Write
0 1 1 Halt
1 0 0 Op-code Fetch
1 0 1 Memory Read
1 1 0 Memory Write
1 1 1 Passive
b) Write an ALP to transfer 10 bytes of data from one memory location to another 8M
Also draw the flow chart for the same.
Ans: DATA SEGMENT (Correct
block1 db 10 dup(10h) Program :
block2 db 10 dup(0) 5M,
DATA ENDS Flowchart :
CODE SEGMENT 3M)
ASSUME CS:CODE,DS:DATA ,ES: EXTRA
START:MOV DX,DATA ;initialize data seg
MOV DS,DX
MOV DX, EXTRA
MOV ES,DX
LEA SI,BLOCK1
LEA DI,BLOCK2
MOV CX,000AH
CLD
REP MOVSB
MOV AH,4CH
INT 21H
CODE ENDS
END START
(OR)
DATA SEGMENT
block1 db 10 dup(10h)
block2 db 10 dup(0)
DATA ENDS
Page23
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV DX,DATA ;initialize data seg
MOV DS,DX
MOV ES,DX
LEA SI,BLOCK1
LEA DI,BLOCK2
MOV CX,000AH
CLD
BACK:MOV AL,[SI] ; REP MOVSB
MOV [DI],AL
INC SI
INC DI
DEC CX
JNZ BACK
MOV AH,4CH
INT 21H
CODE ENDS
END START
Page24
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
CALL SMALLEST_NO
MOV AX,4C00H
INT 21H
Page25
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
SMALLEST_NO PROC
MOV CX,04H
MOV SI ,OFFSET ARRAY
MOV AL,[SI]
UP:INC SI
CMP AL,[SI]
JC NEXT
MOV AL,[SI]
NEXT:DEC CX
JNZ UP
MOV SMALLEST,AL ;AL=08H
RET
SMALLEST_NO ENDP
CODE ENDS
END START
DATA SEGMENT
NUM DB 04H (Correct
DATA ENDS Program :
4M)
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
Page26
MAHARASHTRASTATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
A DW 0005H
FACT_LSB DW ?
FACT_MSB DW ?
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA,CS:CODE
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
Page27