Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

8086 Microprocessor Interrupts

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 27

8086 Microprocessor Interrupts

Contents

*Introduction
*Interrupts
*Types of interrupts
* Hardware Interrupts
* Maskable & Non-Maskable Interrupts
* Software Interrupts
* 256 Interrupts
Introduction
 The meaning of ‘interrupts’ is to break the sequence of operation.

 While the microprocessor is executing a program, an ‘interrupt’ breaks the


normal sequence of execution of instructions, diverts its execution to some other
program called Interrupt Service Routine (ISR).

 After execution, control is returned back again to the main program.

 Keeping moving until interrupted by the processor.

 Interrupt received then do pre-defined operation.

 After finishing the interrupt service return to normal operation i.e. keep moving
forward again.
The processor can be interrupted in the following ways

i)By an external signal generated by a peripheral devices


ii)By an internal signal generated due to an exceptional condition
which occurs while executing an instruction
Interrupts

Software Interrupt
Hardware Interrupts
(INT n)

Non-Maskable
Maskable Interrupts Interrupts 256 Types Of
Software Interrupts
Hardware Interrupts
• The interrupts initiated by external hardware by sending an appropriate signal to
the interrupt pin of the processor is called hardware interrupt.
• The 8086 processor has two interrupt pins INTR and NMI. The interrupts
initiated by applying appropriate signal to these pins are called hardware
interrupts of 8086.
Interrupts

Hardware
Interrupts

Maskable Non-
Interrupts Maskable
Interrupts
Interrupts

Hardware
Interrupts

Maskable Non-
Interrupts Maskable
Interrupts
Interrupts

Hardware
Interrupts

Maskable Non-
Maskable
Interrupts Interrupts
Hardware Interrupts

Used to handle external hardware peripherals , such as key boards ,


mouse , hard disks , floppy disks , DVD drivers, and printers.

key boards mouse hard disks floppy disks DVD drivers


Maskable & Non-Maskable Interrupts
• The processor has the facility for accepting or rejecting hardware interrupts.
• Programming the processor to reject an interrupt is referred to as masking or
programming the processor to accept an interrupt is referred to as unmasking or
enabling.
• The interrupts whose request can be either accepted or rejected by the processor are
called Maskable interrupts.
Maskable & Non-Maskable Interrupts
• The interrupts whose request has to be definitely accepted (or cannot be rejected)
by the processor are called non-maskable interrupts.
• Whenever a request is made by non-maskable interrupt, the processor has to
definitely accept that request and service that interrupt by suspending its current
program and executing an ISR.
• In 8086 processor all the hardware interrupts initiated through INTR pin are
maskable.
• The interrupt initiated through NMI pin are non-maskable.
Software Interrupts
• The software interrupts are program instructions.
• While running a program, if software interrupt instruction is encountered then the
processor initiates an interrupt.
• The 8086 processor has 256 types of software interrupts.
• The software interrupt instruction is INT n, where n is the type number in the
range 0 to 255.
• All software interrupts are non-maskable.
Input and Output Instructions
The INT Instruction
• To invoke a DOS or BIOS, the INT (interrupt) instruction is used.
INT interrupt_number
DOS Interrupts
• INT 21H, Function 09H
(INT 21h)
• Display the string on the screen
• INT 21H, Function 01H
• Get Character input with Echo
• INT 21h, function 08H
• Get Character input without Echo
• INT 21H, Function 02H
• Display a number or character on the screen.
• INT 21H, Function 04CH
• Terminate the code properly and return to the DOS Prompt.
LEA instruction and offset
Offset and LEA instruction
Offset: Holds the beginning address of a variable
Syntax:
Mov Register/Variable, offset String Name

LEA: Load Effective Address loads the specified register with the offset
of a memory location.
Syntax:
LEA register,memory variable
Dx Offset and LEA instruction
0x50 0x51 0x52 0x53 0x54 0x56 0x57 0x58 0x59 0x60 0x61
0 1 2 3 4 5 6 7 8 9 10
H e l l o W o r l d

data segment mov dx,offset str1


str1 db "Hello World ",13,10,'$' mov ah,09h Holds beginning address of str1 i.e.
Ends int 21h dx= 0x50
code segment
start: lea dx,str1 Holds beginning address of str1 and
mov ax,@data mov ah,09h it also point at that memory location
mov ds,ax int 21h dx= 0x50

mov ax, 4c00h


int 21h

ends
end start
data segment mov ax, 4c00h
str1 db "Hello World int 21h
",13,10,'$'
ends ends

end start
stack segment
dw 128 dup(0) Output:
Ends

code segment
start:
mov ax,@data
mov ds,ax
mov bx,2

mov dx,offset str1+bx


mov ah,09h
int 21h

lea dx,str1+bx
mov ah,09h
int 21h
Difference of LEA and Offset instruction

Difference of LEA and Offset instruction


Offset LEA
It is a indirect instruction in which register
Holds the beginning address of a variable points to a memory location and holds the
address of that memory location
However, the MOV instruction cannot be
indexed because OFFSET is an assembler LEA instruction can be indexed.
directive, not an instruction
Function 09 - Display a string on Screen
To display a String execute the following instruction, DX
register
must contain the starting offset Address of string that to be
displayed
data segment
mesg db "Hello World $"
ends

stack segment
dw 128 dup(0)
ends
code segment
start:
mov ax,@data
mov ds,ax

lea dx,mesg
mov ah,09h
int 21h
OR

mov dx,offset mesg


mov ah,09h
int 21h

mov ax, 4c00h


int 21h

ends
end start
Function 01 - Read a character input with Echo from
keyboard
 
Reads a character from the standard input device and echoes it to
The standard output device. If no character is ready it waits until
one is available.
mov ah, 01H ; input key function
 
INT 21H ; get ASCII code in AL
 
On entry: Ah= 01H
Returns: AL= 8 bit data input
 
When a character is pressed, AL will contain its ASCII code if any other key is pressed, such
as an arrow key or F0-F10 and so on, AL will contain 0.
Function 08 - Read a character input without Echo
from keyboard
Reads a character from the standard input device without copying it
to the display. If no character is ready it waits until one is available.
 
MOV AH, 08h ; Input key function
INT 21h ; get ASCII code in AL.
On entry: ; Ah= 01H
Returns: ; AL= 8 bit data input.
Function 02 - Display a Character on Screen
To display a character ‘A’ on screen execute the following instruction, actually DL must contain
the ASCII code of Character that is to be displayed. In this example DL will contain ASCI code of
‘A’.
 
MOV AH, 2 ; display character function
MOV DL, ‘A’ ; character is A
INT 21H ; display character

On entry:
AH = 02h
DL = 8 bit data (usually ASCII character)

Returns:
Nothing
Practice Exercise
Displaying an integer 0-9
• We can print character only
• ASCII of 0-9 is 30h-39h respectively
• First convert the digit into its ASCII by adding 30h then print it like a character

You might also like