You are on page 1of 8

Interrupts in 8086 microprocessor



An interrupt is a condition that halts the microprocessor temporarily to work on a different task
and then returns to its previous task. An interrupt is an event or signal that requests the CPU’s
attention. This halt allows peripheral devices to access the microprocessor. Whenever an
interrupt occurs, the processor completes the current instruction and starts the implementation of
an Interrupt Service Routine (ISR) or Interrupt Handler. ISR is a program that tells the processor
what to do when the interrupt occurs. After the ISR execution, control returns to the main routine
where it was interrupted. In the 8086 microprocessor following tasks are performed when the
microprocessor encounters an interrupt:

1. The value of the flag register is pushed into the stack. It means that first, the value of SP
(Stack Pointer) is decremented by two then the value of the flag register is pushed to the
memory address of the stack segment.
2. The value of starting memory address of CS (Code Segment) is pushed into the stack.
3. The value of IP (Instruction Pointer) is pushed into the stack.
4. IP is loaded from word location (Interrupt type) * 04.
5. CS is loaded from the following word location.
6. Interrupt, and Trap flags are reset to 0.

The different types of interrupts present in the 8086 microprocessor are given by:

1. Hardware Interrupts – Hardware interrupts are those interrupts that are caused by any
peripheral device by sending a signal through a specified pin to the microprocessor.
There are two hardware interrupts in the 8086 microprocessor. They are:
o NMI (Non-Maskable Interrupt): It is a single pin non-maskable hardware interrupt
that cannot be disabled. It is the highest priority interrupt in the 8086
microprocessor. After its execution, this interrupt generates a TYPE 2 interrupt.
IP is loaded from word location 00008 H, and CS is loaded from the word
location 0000A H.
o INTR (Interrupt Request): It provides a single interrupt request and is activated by
the I/O port. This interrupt can be masked or delayed. It is a level-triggered
interrupt. It can receive any interrupt type, so the value of IP and CS will change
on the interrupt type received.
2. Software Interrupts – These are instructions inserted within the program to generate
interrupts. There are 256 software interrupts in the 8086 microprocessor. The instructions
are of the format INT type, where the type ranges from 00 to FF. The starting address
ranges from 00000 H to 003FF H. These are 2-byte instructions. IP is loaded from type *
04 H, and CS is loaded from the following address given by (type * 04) + 02 H. Some
important software interrupts are:
o TYPE 0 corresponds to division by zero(0).
o TYPE 1 is used for single-step execution for debugging the program.
o TYPE 2 represents NMI and is used in power failure conditions.
o TYPE 3 represents a break-point interrupt.
o TYPE 4 is the overflow interrupt

2.7 An Introduction to the Intel 80x86 CPU Family

Thus far, you've seen a couple of HLA programs that will actually compile and run. However, all
the statements utilized to this point have been either data declarations or calls to HLA Standard
Library routines. There hasn't been any real assembly language up to this point. Before we can
progress any farther and learn some real assembly language, a detour is necessary. For unless
you understand the basic structure of the Intel 80x86 CPU family, the machine instructions will
seem mysterious indeed.

The Intel CPU family is generally classified as a Von Neumann Architecture Machine. Von
Neumann computer systems contain three main building blocks: the central processing unit
(CPU), memory, and input/output devices (I/O). These three components are connected together
using the system bus. The following block diagram shows this relationship:

Figure 2.4 Von Neumann Computer System Block Diagram


Memory and I/O devices will be the subjects of later chapters; for now, let's take a look inside
the CPU portion of the computer system, at least at the components that are visible to the
assembly language programmer.

The most prominent items within the CPU are the registers. The Intel CPU registers can be
broken down into four categories: general purpose registers, special purpose application
accessible registers, segment registers, and special purpose kernel mode registers. This text will
not consider the last two sets of registers. The segment registers are not used much in modern 32-
bit operating systems (e.g., Windows, BeOS, and Linux); since this text is geared around
programs written for 32-bit operating systems, there is little need to discuss the segment
registers. The special purpose kernel mode registers are intended for use by people who write
operating systems, debuggers, and other system level tools. Such software construction is well
beyond the scope of this text, so once again there is little need to discuss the special purpose
kernel mode registers.

The 80x86 (Intel family) CPUs provide several general purpose registers for application use.
These include eight 32-bit registers that have the following names:

EAX, EBX, ECX, EDX, ESI, EDI, EBP, and ESP

The "E" prefix on each name stands for extended. This prefix differentiates the 32-bit registers
from the eight 16-bit registers that have the following names:

AX, BX, CX, DX, SI, DI, BP, and SP

Finally, the 80x86 CPUs provide eight 8-bit registers that have the following names:

AL, AH, BL, BH, CL, CH, DL, and DH

Unfortunately, these are not all separate registers. That is, the 80x86 does not provide 24
independent registers. Instead, the 80x86 overlays the 32-bit registers with the 16-bit registers
and it overlays the 16-bit registers with the 8-bit registers. The following diagram shows this
relationship:
Figure 2.5 80x86 (Intel CPU) General Purpose Registers

The most important thing to note about the general purpose registers is that they are not
independent. Modifying one register will modify at least one other register and may modify as
many as three other registers. For example, modification of the EAX register may very well
modify the AL, AH, and AX registers as well. This fact cannot be overemphasized here. A very
common mistake in programs written by beginning assembly language programmers is register
value corruption because the programmer did not fully understand the ramifications of the above
diagram.

The EFLAGS register is a 32-bit register that encapsulates several single-bit boolean (true/false)
values. Most of the bits in the EFLAGs register are either reserved for kernel mode (operating
system) functions, or are of little interest to the application programmer. Eight of these bits (or
flags) are of interest to application programmers writing assembly language programs. These are
the overflow, direction, interrupt disable1, sign, zero, auxiliary carry, parity, and carry flags. The
following diagram shows their layout within the lower 16-bits of the EFLAGS register.
The 80x86 CPUs provide special machine instructions that let you test the flags, alone or in various
combinations. The last register of interest is the EIP (instruction pointer) register. This 32-bit register
contains the memory address of the next machine instruction to execute.

register (processor register, CPU register)


A processor register (CPU register) is one of a small set of data holding places that are part of the
computer processor.

A register may hold an instruction, a storage address, or any kind of data (such as a bit sequence
or individual characters). Some instructions specify registers as part of the instruction. For
example, an instruction may specify that the contents of two defined registers be added together
and then placed in a specified register.

A register must be large enough to hold an instruction - for example, in a 64-bit computer, a
register must be 64 bits in length. In some computer designs, there are smaller registers - for
example, half-registers - for shorter instructions. Depending on the processor design and
language rules, registers may be numbered or have arbitrary names.

A processor typically contains multiple index registers, also known as address registers or
registers of modification. The effective address of any entity in a computer includes the base,
index, and relative addresses, all of which are stored in the index register. A shift register is
another type. Bits enter the shift register at one end and emerge from the other end. flip flops,
also known as bistable gates, store and process the data.

What is a CPU and where do you find it in a computer?

CPU is short for Central Processing Unit. It is also known as a processor or microporcessor.

It's one of the most important pieces of hardware in any digital computing system – if not the
most important.

Inside a CPU there are thousands of microscopic transistors, which are tiny switches that control
the flow of electricity through the integrated circuits.

You'll find the CPU located on a computer's motherboard.


A computer's motherboard is the main circuit board inside a computer. Its job is to connect all
hardware components together.

Often referred to as the brain and heart of all digital systems, a CPU is responsible for doing all
the work. It performs every single action a computer does and executes programs.

What are computer programs and where are they stored?

There is a program for everything a CPU does.

You have a program that lets you use your web browser or a word processor. You have one that
performs mathematical operations on a calculator or lets you type letters and characters on a
keyboard. And there are programs that manage clicking and selecting elements with a computer
mouse and pressing down on your laptop's touchpad.

Whatever it may be, there is a program for all computer activities.

Programs are sets of instructions that need to be executed in sequential, logical order and be
followed precisely step-by-step.

They are written in a human-readable language – a programming language – by a programmer.

Computers don't understand programming languages directly, so they need to be translated to a


form that is easier understood.

That form is called machine language or binary.

Binary is a base two numerical system. It's comprised of only two numbers: 0 and 1.

This reflects and ties in well with the only two possible states transistors have to control the ebb
and flow of electricity – they are either on (1) or off (0).

So, under the hood, programs are stored as sequences of bits. Bits are another name for binary
digits (sequences of 1s and 0s).

Programs are stored permanently and long term in a storage device, whether it's a HDD (Hard
Disk Drive) or SSD (Solid State Drive).

These are non-volatile types of memory, meaning they store data even when the power is off.

While a program is up and running and currently being used, though, all of its data is stored in
the main, primary, memory or RAM (Random Access Memory).

This type of memory is volatile, and all data is lost when the power shuts off.
What is a CPU and where do you find it in a computer?

CPU is short for Central Processing Unit. It is also known as a processor or microporcessor.

It's one of the most important pieces of hardware in any digital computing system – if not the
most important.

Inside a CPU there are thousands of microscopic transistors, which are tiny switches that control
the flow of electricity through the integrated circuits.

You'll find the CPU located on a computer's motherboard.

A computer's motherboard is the main circuit board inside a computer. Its job is to connect all
hardware components together.

Often referred to as the brain and heart of all digital systems, a CPU is responsible for doing all
the work. It performs every single action a computer does and executes programs.

What are computer programs and where are they stored?

There is a program for everything a CPU does.

You have a program that lets you use your web browser or a word processor. You have one that
performs mathematical operations on a calculator or lets you type letters and characters on a
keyboard. And there are programs that manage clicking and selecting elements with a computer
mouse and pressing down on your laptop's touchpad.

Whatever it may be, there is a program for all computer activities.

Programs are sets of instructions that need to be executed in sequential, logical order and be
followed precisely step-by-step.

They are written in a human-readable language – a programming language – by a programmer.

Computers don't understand programming languages directly, so they need to be translated to a


form that is easier understood.

That form is called machine language or binary.

Binary is a base two numerical system. It's comprised of only two numbers: 0 and 1.

This reflects and ties in well with the only two possible states transistors have to control the ebb
and flow of electricity – they are either on (1) or off (0).

So, under the hood, programs are stored as sequences of bits. Bits are another name for binary
digits (sequences of 1s and 0s).
Programs are stored permanently and long term in a storage device, whether it's a HDD (Hard
Disk Drive) or SSD (Solid State Drive).

These are non-volatile types of memory, meaning they store data even when the power is off.

While a program is up and running and currently being used, though, all of its data is stored in
the main, primary, memory or RAM (Random Access Memory).

This type of memory is volatile, and all data is lost when the power shuts off.

You might also like