You are on page 1of 20

8086 Microprocessor

2012


1

8086 microprocessor

8086 interview questions:
1. What are the flags in 8086?
In 8086 Carry flag, Parity flag, Auxiliary carry flag, Zero flag,
Overflow flag, Trace flag, Interrupt flag, Direction flag, and Sign flag.
2. What are the various interrupts in 8086? Maskable
interrupts, Non-Maskable interrupts.

3. What is meant by Maskable interrupts?
An interrupt that can be turned off by the programmer is known as
Maskable interrupt.
4. What is Non-Maskable interrupts?
An interrupt which can be never be turned off (i.e. disabled) is known
as Non-Maskable interrupt.
5. Which interrupts are generally used for critical events?
Non-Maskable interrupts are used in critical events. Such as Power
failure, Emergency, Shut off etc.,

6. Give examples for Maskable interrupts?
RST 7.5, RST6.5, RST5.5 are Maskable interrupts.



8086 Microprocessor
2012


2
7. Give example for Non-Maskable interrupts?
Trap is known as Non-Maskable interrupts, which is used in
emergency condition.
8. What is the Maximum clock frequency in 8086?
5 Mhz is the Maximum clock frequency in 8086.

9. What are the various segment registers in 8086?
Code, Data, Stack, Extra Segment registers in 8086.
10. Which Stack is used in 8086?
FIFO (First In First Out) stack is used in 8086.In this type of Stack the
first stored information is retrieved first.
11. What are the address lines for the software interrupts?
RST 0 0000 H
RST1 0008 H
RST2 0010 H
RST3 0018 H
RST4 0020 H
RST5 0028 H
RST6 0030 H
RST7 0038 H




8086 Microprocessor
2012


3
12. What is SIM and RIM instructions?
SIM is Set Interrupt Mask. Used to mask the hardware interrupts. RIM
is Read Interrupt Mask. Used to check whether the interrupt is Masked
or not.
13. Which is the tool used to connect the user and the
computer?
Interpreter is the tool used to connect the user and the tool.
14. What is the position of the Stack Pointer after the PUSH
instruction?
The address line is 02 less than the earlier value.
15. What is the position of the Stack Pointer after the POP
instruction?
The address line is 02 greater than the earlier value.
16. Logic calculations are done in which type of registers?
Accumulator is the register in which Arithmetic and Logic
calculations are done.
17. What are the different functional units in 8086?
Bus Interface Unit and Execution unit, are the two different
functional units in 8086.


18. Give examples for Micro controller?
Z80, Intel MSC51 &96, Motorola are the best examples of
Microcontroller.



8086 Microprocessor
2012


4
19. What is meant by cross-compiler?
A program runs on one machine and executes on another is called as
cross-compiler.

20. What are the address lines for the hardware interrupts?

RST 7.5 003C H
RST 6.5 0034 H
RST 5.5 002C H
TRAP 0024 H
21. Which Segment is used to store interrupt and subroutine
return address registers?
Stack Segment in segment register is used to store interrupt and
subroutine return address registers.
22. Which Flags can be set or reset by the programmer and
also used to control the operation of the processor?
Trace Flag, Interrupt Flag, Direction Flag.
23. What does EU do?
Execution Unit receives program instruction codes and data from
BIU, executes these instructions and store the result in general
registers.



8086 Microprocessor
2012


5
24. Which microprocessor accepts the program written for
8086 without any changes?
8088 is that processor.

25. What is the difference between 8086 and 8088?
The BIU in 8088 is 8-bit data bus & 16- bit in 8086.Instruction queue
is 4 byte long in 8088and 6 byte in 8086


























8086 Microprocessor
2012


6
Exercise:

1. Write an 8086 Program to add two packed BCD
numbers entered through keyboard?
Ans:
Write an 8086 program that adds two packed BCD numbers
input from the keyboard and computes and displays the result on
the system video monitor
Data should be in the form 64+89= The answer 153 should
appear in the next line.
Program:
MOV DX, BUFFER ADDRESS
MOV AH,0A
MOV SI,DX
MOV BYTE PTR [SI], 8
INT 21
MOV AH,0EH
MOV AL,0AH
INT 10 ; BIOS SERVICE 0E LINE FEED
POSITION CURSOR
SUB BYTE PTR[SI+2], 30H
SUB BYTE PTR[SI+3], 30H
SUB BYTE PTR[SI+5], 30H
SUB BYTE PTR[SI+6], 30H
MOV CL,4
ROL BYTE PTR [SI+3],CL
ROL BYTE PTR [SI+6],CL
ROR WORD PTR [SI+2], CL
ROR WORD PTR [SI+2], CL
MOV AL, [SI+3]
ADD AL, [SI+6]
DAA
MOV BH,AL
JNC DISPLAY
MOV AL,1
CALL DISPLAY
MOV AL,BH


8086 Microprocessor
2012


7
CALL DISPLAY
INT 20
DISPLAY SUBROUTINE:
MOV BL,AL ; SAVE ORIGINAL NUMBER AND AL,F0
;FORCE BITS 0-3 LOW
MOV CL,4 ; FOUR ROTATES
ROR AL,CL ; ROTATE MSD INTO LSD
ADD AL,30 ; CONVERT TO ASCII
MOV AH,0E ; BIOS VIDEO SERVICE 0E
INT 10 ; DISPLAY CHARACTER
MOV AL,BL ; RECOVER ORIGINAL NUMBER
AND AL,0F ; FORCE BITS 4-7 LOW
ADD AL,30 ; CONVERT TO ASCII
INT 10 ; DISPLAY CHARACTER
RET ; RETURN TO CALLING PROGRAM
;
;Input buffer begins here
























8086 Microprocessor
2012


8
2. Write an 8086 Program to double digit addition,
subtraction, multiplication and division program using
8086 microprocessor?
Ans:
RIGHT EQU 1
WRONG EQU 0
STACK SEGMENT PARA STACK 'STACK'
DB 256 DUP(0)
STACK ENDS
;
DATA SEGMENT PARA PUBLIC 'DATA'
DATA ENDS
INTER SEGMENT AT 0H
ORG 100H
INT_40 DB 4 DUP(?) ;+
INT_41 DB 4 DUP(?) ;-
INT_42 DB 4 DUP(?) ;*
INT_43 DB 4 DUP(?) ;/
INTER ENDS;
CODE SEGMENT PARA PUBLIC 'CODE';
ASSUME CS:CODE,DS:DATA,ES:INTER
BEGIN: MOV AX,DATA
MOV DS,AX
MOV AX,INTER
MOV ES,AX
MOV SI,OFFSET INT_40
MOV AX,OFFSET ADD
MOV ES:[SI],AX
ADD SI,2
MOV AX,SEG ADD
MOV ES:[SI],AX
ADD SI,2
MOV SI,OFFSET INT_41
MOV AX,OFFSET SUB
MOV ES:[SI],AX


8086 Microprocessor
2012


9
ADD SI,2
MOV AX,SEG SUB
MOV ES:[SI],AX
ADD SI,2
MOV SI,OFFSET INT_42
MOV AX,OFFSET MUL
MOV ES:[SI],AX
ADD SI,2
MOV AX,SEG MUL
MOV ES:[SI],AX
ADD SI,2
MOV SI,OFFSET INT_43
MOV AX,OFFSET DIV
MOV ES:[SI],AX
ADD SI,2
MOV AX,SEG DIV
MOV ES:[SI],AX
MOV BX,0
FIRST: MOV AH,0
INT 16H
CALL JUDGE
AND AH,0FH
JZ FIRST
CALL DISCHAR
SUB AL,30H
MOV BL,AL
LOOP: MOV AH,0
INT 16H
CMP AL,"*"
JNZ JUDGE2
INT 42H
JMP LOOP
JUDGE2: CMP AL,"+"
JNZ JUDGE3
INT 40H
JMP LOOP


8086 Microprocessor
2012


10
JUDGE3: CMP AL,"-"
JNZ JUDGE4
INT 41H
JMP LOOP
JUDGE4: CMP AL,"/"
JNZ NEXT
INT 43H
JMP LOOP
NEXT: CMP AL,0DH;ENTER
JZ OUTPUT
JMP LOOP
OUTPUT:
MOV AL,3DH
CALL DISCHAR
MOV AL,BL
PUSH AX
MOV CH,AL
MOV CL,4
SHR AL,CL
OR AL,30H
CMP AL,3AH
JC L1
ADD AL,07H
L1: CALL DISCHAR
MOV AL,CH
AND AL,0FH
OR AL,30H
CMP AL,3AH
JC L2
ADD AL,07H
L2: CALL DISCHAR
MOV AL,48H
CALL DISCHAR
MOV AH,4CH
INT 21H;
MUL PROC


8086 Microprocessor
2012


11
MOV AL,2AH
CALL DISCHAR
MULL: MOV AH,0
INT 16H
CALL JUDGE
AND AH,0FH
JZ MULL
CALL DISCHAR
SUB AL,30H
MUL BL
MOV BL,AL
AND BH,0
STI
IRET
MUL ENDP
DIV PROC
MOV AL,2FH
CALL DISCHAR
DIVL: MOV AH,0
INT 16H
CALL JUDGE
AND AH,0FH
CALL DISCHAR
SUB AL,30H
PUSH BX
MOV BL,AL
POP AX
DIV BL
MOV BL,AL
AND BH,0
STI
IRET
DIV ENDP
;
ADD PROC
MOV AL,2BH


8086 Microprocessor
2012


12
CALL DISCHAR
addl: MOV AH,0
INT 16H
CALL JUDGE
AND AH,0FH
JZ ADDL
CALL DISCHAR
SUB AL,30H
ADD BL,AL
AND BH,0
STI
IRET
ADD ENDP
;
JUDGE PROC near
CMP AL,"0"
JC NT
CMP AL,"9"
JA NT
MOV AH,RIGHT
ret
NT: MOV AH,WRONG
RET
JUDGE ENDP
SUB PROC
MOV AL,2DH
CALL DISCHAR
SUBL: MOV AH,0
INT 16H
CALL DISCHAR
CALL JUDGE
AND AH,0FH
JZ SUBL
SUB AL,30H
SUB BL,AL
AND BH,0


8086 Microprocessor
2012


13
STI
IRET
SUB ENDP
DISCHAR PROC NEAR
PUSH BX
PUSH AX
MOV BX,0
MOV AH,14
INT 10H
POP AX
POP BX
RET
DISCHAR ENDP
;
CODE ENDS
END BEGIN
























8086 Microprocessor
2012


14
3. Write an 8086 Program to Program for Fibonacci
series using 8086 microprocessor assembly language?
Ans:
This code represents an example of finding Fibonacci number and sum of
Fibonacci series up to n-th number. It is written in assembly language and
simulated using emu8086 emulator. Though it is a general program, it
cannot find more than 8-bit binary number, the reason is 8086 processor
registersare8-bit.

This is a general program for finding any number in Fibonacci series
up to its limit and finding summation of two Fibonacci numbers written
in assembly code and I checked this code with emu8086 emulator. Here it
goes:

; this program calculates the n-th Fibonacci number
; and the sum of the fibonacci series upto n-th number
; the n-th number must be given in CX register


CODE SEGMENT
ASSUME CS: CODE, DS: CODE
ORG 100H

;S=F1+F2 // these 3 lines are algorithom
;F1=F2;
;F2=S;

XOR AX,AX ; clearing garbage value if any
XOR BX,BX

XOR DX,DX
XOR CX,CX

MOV AL,1 ; first number in series
MOV AH,1 ; second number in series


8086 Microprocessor
2012


15
MOV CX,6 ;calculating upto sixth number in
;fibonacci series

MOV DL,0
MOV SI,0 ; SI is used as index
MOV SRS[SI],AL ; putting first and second value in array
INC SI
MOV SRS[SI],AH
INC SI ; increment to point first calculated
;value store point
FIB: ;starting the fibonacci number
;calculating loop
PUSH AX ; AH contains second number,it will be changed
; during addition, so saving it

ADD AH,AL ; S=F1+F2, next number in series
MOV DL,AH ;saving the calculated number
MOV SRS[SI],DL ; copying to the array

INC SI ; pointing the next position in the array
POP AX ; restoring the second number


MOV AL,AH ; F1=F2
MOV AH,DL ; F2=S
LOOP FIB ; loop until all number is calculated

MOVCX,6H
MOV SI,0 ; pointing to first index in the array

ADD: ; summation loop
ADD BL,SRS[SI] ; SRS is array for number stored
INC SI
LOOP ADD

;ORG 500H , comment bcoz EMU dont support two ORG


8086 Microprocessor
2012


16

SRS DB 12 DUP(5) ; twelve position array for fib series
; now maximum 12 number can be calculated
; number should be increased to increase capacity

CODE ENDS
END



4. Write an 8086 program to right and left shift a bit of
data in 8086?
ANS:
MOV AX, 0055H
MOV DX, 0505H
MOV CL, 3
SAL AX, CL
SAR DX, CL
MOV CL, 2
ROR AX, CL
ROL DX, CL
STC
RCL AL, CL
RCR DX, CL
HLT













8086 Microprocessor
2012


17
5. Write an 8086 program to interface seven segment display
with 8086 microprocessor?

Ans
Description:
To interface with Seven Segment Display,we must be familiar with
8255A PPI, which has three ports which can be used as I/O ports. The
ports A, B and C are identified using addresses 19H, 1BH, and 1DH
respectively and control register address is 1FH. We use Seven Segment
Display structure using the following digit code:








MOV AL,10000000B
OUT 1Fh, AL
MOV AL, __ (Hex Code of Digit)
OUT 19h,AL
HLT






8086 Microprocessor
2012


18
6. Write an 8086 program to blink a digit of seven
segment display with 8086 microprocessor?
Ans
Description:
In this program we interface 8086 microprocessor with Seven Segment
Display and diaplay a digit. To interface with Seven Segment Display,we
must be familiar with 8255A PPI, which has three ports which can be
used as I/O ports. The ports A, B and C are identified using addresses
19H, 1BH, and 1DH respectively and control register address is 1FH. We
use Seven Segment Display structure using the following digit code:











MO
V
AL,10000000B
OUT 1FH, AL
STR: MOV AL, 10011001B
OUT 19H, AL
Call Delay
MOV AL, 11111111B
OUT 19H, AL
CALL Delay
JMP STR
INT 3

Delay: MOV CX, 0FFFFH


8086 Microprocessor
2012


19
DEL: NOP
NOP
NOP
LOOP DEL
RET

HLT













7. Write an 8086 program to interface a Dot Matrix Display
with 8086 microprocessor?
Description: In this program, interface 8086 microprocessor with Dot
Matrix Display and scan every row of the display from bottom to top. The
Dot Matrix Display is a 8 X 8 display, with two colors of LEDs, which
display any bitmap information. In this program we use a delay concept
to scan every line. To interface with Dot Matrix Display, we must be
familiar with 8255A PPI, which has three ports, which can also be used a
I/O ports. Ports A, B and C are identified with addresses 18H, 1AH, 1CH
respectively.





8086 Microprocessor
2012


20
Source program:
MOV AL, 80H
OUT PPI_C, AL
MOV AL, FFH
OUT PPIC, AL
MOV AL, FFH
OUT PPIB, AL
MOV AL, FEH
100E E6 18 OUT PPIA, AL
MOV CX, FFFFH
NOP
NOP
NOP
LOOP T1
STC
ROL AL,1
JC L2
JMP L1
INT 3
The Dot Matrix Display turns on rows of LEDs one by one as shown
in the following figure. The Dot Matrix Display will scan every line from
bottom to up sequences. Display changes as RED or GREEN lighting.

You might also like