Sunteți pe pagina 1din 13

Microprocessors and Microcontrollers – 11EC311

Prodecures, Macros and Interrupts


of 8086
Stack Operation


In 8086 Stack Pointer Points TOP of the stack

SS(Base Address) : SP(Offset Address)

PUSH Decrements SP once for each byte

POP Increments the SP

Last in First Out(LIFO)

Used in CALL and Interrupts

07/08/19 8086 Programming Model - MPMC


Prodecures vs Macros

Procedures Macros
Sequence of Instructions to perform Sequence of Instructions to perform
a specific task which is to be a specific task which is to be
repeatedly used in the program repeatedly used in the program
Accessed with CALL followed by Accessed with the name given to the
PROCEDURE name, Ends with RET MACRO
Loads the new CS:IP from the Set of Instructions written in a Macro
address followed by CALL executes are copied to the called location
the Set of Instructions and returns
back to the next instruction to CALL
after RET
Uses STACK Does not use STACK
Machine Code is generated once Generated each time called

07/08/19 8086 Programming Model - MPMC


Prodecures vs Macros

Procedures Macros
Uses PROC and ENDP to define Uses MACRO and ENDM to define

Procedures consumes Lot of time as Macros does not have any control
CALL is to be exectued transfer, executes sequentially
Code Footprint(Size) is less as the Large Code Footprint as the
machine code is generated only Machine code is gerenated for every
once access to Macro

Best for Larger Sub-Routines Best for Smaller Sub-Routines


Best if more Calls have to be made Best for Lesser accesses
Can be defined anywhere in Should be defined before it is called
Program

07/08/19 8086 Programming Model - MPMC


Prodecures vs Macros

Procedures Macros
Syntax: <name> PROC Syntax: <name> MACRO
.......... ..........
.......... ..........
RET ENDM
<name> ENDP
Access: ........... Access: ...........
........... ...........
CALL <name> <name>
............. .............

07/08/19 8086 Programming Model - MPMC


Interrupts in 8086

Sources of Interrupts
– Internal

Called within the Program (INT n)

Caused by an Exception Condition
– External

Generated by a peripheral (NMI, INTR)

Classification of Interrupts
–Hardware and Software
– Maskable and Non Maskable

256 Types of Software Interrupts - Type 0 – Type 255

Predefined Interrupts - Type 0 – Type 4

Reserved by INTEL - Type 5 – Type 32

User Defined Interrupts - Type 33 – Type 255
07/08/19 8086 Programming Model - MPMC
Predefined Interrupts in 8086


Type 0: Divide by Zero Interrupt

Type 1: Single Step Interrupt (Trap Interrupt)
Trap Flag must be Set


Type 2: NMI (Non- Maskable Interrupt)

Type 3: Breakpoint Interrupt (Single Byte Instruction)

Debugging Purpose

Placing INT 3 whereever debug Required

Type 4: Interrupt on Overflow

Occurs if Overflow Flag is Set

07/08/19 8086 Programming Model - MPMC


Interrupt Vector Table


Stores the Vector Address(Branching Address) of Interrupt

Each Interrupt requires 4 Bytes of Space

2 Bytes for IP

2 Bytes for CS

256 Types of Interrupts with 4 Bytes Each = 1 KB

00000h to 03FFFh is space for Vector Table

Vector Address of INT n is stored in Vector Table having
address

IP : 2 bytes at n x 4

CS: 2 bytes at (n x 4) +2

07/08/19 8086 Programming Model - MPMC


Interrupt Vector Table of 8086

07/08/19 8086 Programming Model - MPMC


Steps Involved in Execution of Interrupt


After interrupt occurs Flag, CS and IP are PUSHED to Stack

PUSH PSW

PUSH CS

PUSH IP

IP and CS of Interrupt Service Routine are loaded from the
Vector table depending on type of Interrupt from the address
Type n x 4

Executes Interrupt until IRET

POPS out IP, CS and Flag from the Stack

POP IP

POP CS

POP PSW
07/08/19 8086 Programming Model - MPMC
Steps Involved in Execution of Interrupt

07/08/19 8086 Programming Model - MPMC


References


https://www.sites.google.com/site/sripathroykoganti/my-forms

D.V.Hall “Microprocessor and Interfacing”, 2nd Edition Tata McGraw
Hill Publishing Company,2006.

A.K. Ray & K. M Bhurchandi, “Advanced Microprocessors &
peripherals”, Tata Mc Graw Hill Publishing Company 2002.

Rajkamal, “Microcontrollers - Architecture, Programming, Interfacing
& System Design”, 2 nd edition, Pearson Education.

07/08/19 8086 Programming Model - MPMC


Thank You

07/08/19 8086 Programming Model - MPMC

S-ar putea să vă placă și