Unit2 MP PDF
Unit2 MP PDF
Unit2 MP PDF
16-bit Microprocessors
Why Transition :- Transition
S.No. 8085 Microprocessor 8086 Microprocessor
1. 8085 has 16 address line with 8 to 20 address with 16 to these lines also
these line also being used for data being used for data
2. 8 bit accumulator & six 8 bit All register 16 bit wide
general purpose register which
can be combined to form 16 bit
register for addressing
3. A program counter & stack 5 pointer register
pointer
4. Address 64 KB of memory 16 segments each with a length of 64 K
these memory segments are addressed
through four segment register
- Code Segment
- Stack Segment
- Data Segment
- Extra Segment
5. Single processing capability Multiprocessing capability
6. Only 256 instructions 64 K or 65536 instructions more than one
opcode can be used for the same
instruction
8086 Registers and Internal Architecture
• There are two main functional logic
blocks in the 8086/88 processors:
– EU Execution Unit - execution of program
instructions
– BIU Bus Interface Unit - provides interface
to memory and I/O
1. controls the address, data, and control busses.
2. handles instruction fetch and data read/write
functions
Bus Interface Unit
• BIU is the 8086’s interface to the outside world.
• It is responsible for performing all external bus
operations.
• BIU contains the segment registers, Instruction
pointer and bus control logic
• BIU has a mechanism called Instruction Stream
Queue to implement a Pipeline Architecture that
permits pre-fetch of up to 6 bytes of code.
Control Unit
• Responsible for decoding and executing all
instructions
• Generates operand addresses
• Requests BIU to perform RD or WR cycles
to Memory or I/O
• After execution the EU tests and updates the
status flags
• Handles Jumps
Execution Unit – Multipurpose Registers
• EAX Accumulator: AX is good at collecting the results of arithmetic and logic
operations. It is very strongly tied to the ALU (arithmetic and logic unit) and
can serve as the source and destination of instructions that use the ALU Thus when
you operate on a program variable over and over,AX can be used to hold the variable
during the long chain of instructions being executed and accumulate the end
result. So AX is called the accumulator.
C-Carry Flag This flag is set, when there is a carry out of MSB in case of
addition or a borrow in case of subtraction. For example, when two numbers
are added, a carry may be generated out of the most significant bit position.
The carry flag, in this case, will be set to ‘1’, In case, no carry is generated, it
will be ‘0’.
• Parity Flag (PF) - this flag is set to 1 when there is even number of one bits in
result, and to 0 when there is odd number of one bits.
• AC-Auxiliary Carry Flag This is set, if there is a carry from the lowest
nibble, i.e. bit three, during addition or borrow for the lowest nibble, i.e. bit
three, during subtraction.
Execution Unit – Flag Register
• Z Zero: Zero Flag (ZF) - set to 1 when result is zero. For non-zero result this
flag is set to 0.
• Sign Flag (SF) - set to 1 when result is negative. When result is positive
it is set to 0. (This flag takes the value of the most significant bit.)
• T Trap: If this flag is set, the processor enters the single step
execution mode. In other words, a trap interrupt is generated
after execution of each instruction. The processor executes the
current instruction and the control is transferred to the Trap
interrupt service routine.
• Interrupt enable Flag (IF) - when this flag is set to 1 CPU reacts to
interrupts from external devices.
•D-Direction Flag This is used by string manipulation instructions. If this
flag bit is ‘0’, the string is processed beginning from the lowest address to
the highest address, i.e. auto incrementing mode. Otherwise, the string is
processed from the highest address towards the lowest address, i.e. auto
decrementing mode.
O-Overflow Flag
This flag is set, if an overflow occurs, i.e. if the result of a signed operation is large
enough to be accommodated in a destination register. For example, in case of the
addition of two signed numbers, if the result overflows into the sign bit, i.e. the
result is of more than 7 -bits in size in case of 8-bit signed operations and more
than I5-bits in size in case of I6-bit signed operations, then the overflow flag will
be set.
BIS – Segment Registers
• CS Code Segment: Used to compute the starting address of the
section of memory holding code (restricted to 64K in REAL mode).
• DS Data Segment: Used to compute the starting address of the
section of memory holding data (restricted to 64K in REAL mode).
• SS Stack Segment: Used to compute the starting address of the
section of memory holding the stack (restricted to 64K in REAL
mode).
• ES Extra Segment: Additional data segment used by some string
instructions.
• FS&GS Additional segment registers in the 80386 (and up) for
program use.
Segmented Memory:-
Two types of memory organization are in popular use.
These are linear addressing & segmented addressing.
EA (Effective Address)
20-bit (5-byte) 64 KB +
Physical Segment
16-bit
Memory address
Appended byte 0H
Warning: A very common mistake people make when performing this computation is to
forget they are working in hexadecimal, not decimal. It is surprising to see how many
people add 9+1 and get 10h rather than the correct answer 0Ah.
8086 Generating Physical
Addresses
CS
Memory System ES
Address Lines
SS
DS
19 0
Physical Address Dedicated Segment Registers
ADD BP
15 0 15 0
DI
Index Reg. Segment Reg. 0000
SI
SP
IP
Portion of BIU Circuitry
Dedicated Index Registers
In the 8086 chip architecture, the addressable memory space is divided into segments,
each of which can contain up to 64K of memory. Segments can only start on a
paragraph address. A paragraph address is a byte location that is evenly divisible by
16 bytes. Every 16th byte in memory contains segment number n. To access specific
bytes or words in memory, you must use an offset relative to the beginning of a
specified segment.
Together, a segment and an offset provide a segmented address that can locate any
byte in the 1 megabyte of address space in the 8086 processor.
CS
ES
physical address memory
SS
00000h
DS
paragraph 1
00010h
paragraph 2
00020h
paragraph 3 BP
DI
SI
SP
IP
offset
072CH 18H AD5FCH
or • Segment Address = ACEDH
072BH A3H AD5FBH
logical • Logical Address = 0724H
072AH 7EH AD5FAH
address 0729H 69H AD5F9H • Physical Address
0728H AAH AD5F8H = ACED0H + 0724H
0727H 2EH AD5F7H = AD5F4H
0726H 00H AD5F6H • M[ACED:0724]
0725H 55H AD5F5H = M[AD5F4] (word read)
0724H 02H AD5F4H = 5502H
0723H 72H AD5F3H
increasing 0722H 11H AD5F2H
0724H 0725H
0H 2H 5H 5H hex
0000 0010 0101 0101 binary
Register Transfer Language
Byte Read:
offset al M[0724h]
072CH 18H AD5FCH
or after: al = 02h
072BH A3H AD5FBH
logical
072AH 7EH AD5FAH
address 0729H 69H AD5F9H Word Read:
0728H AAH AD5F8H ax M[0724h]
0727H 2EH AD5F7H
after: ax = 5502h
0726H 00H AD5F6H
before: after:
072CH 18H AD5FCH
072CH 18H AD5FCH
072BH A3H AD5FBH
072BH A3H AD5FBH
072AH 7EH AD5FAH
072AH 7EH AD5FAH
0729H 69H AD5F9H
0729H 69H AD5F9H
0728H AAH AD5F8H
0728H AAH AD5F8H
0727H 2EH AD5F7H
0727H 2EH AD5F7H
0726H 00H AD5F6H
0726H 00H AD5F6H
0725H 55H AD5F5H
0725H 55H AD5F5H
0724H 7BH AD5F4H
0724H 02H AD5F4H
0723H 72H AD5F3H
0723H 72H AD5F3H
0722H 11H AD5F2H
0722H 11H AD5F2H
Memory Write Operations
(cont.)
Assume EAX = FAC4237B h
Word Write: M[0724h] ax
before: after:
072CH 18H AD5FCH
072CH 18H AD5FCH
072BH A3H AD5FBH
072BH A3H AD5FBH
072AH 7EH AD5FAH
072AH 7EH AD5FAH
0729H 69H AD5F9H
0729H 69H AD5F9H
0728H AAH AD5F8H
0728H AAH AD5F8H
0727H 2EH AD5F7H
0727H 2EH AD5F7H
0726H 00H AD5F6H
0726H 00H AD5F6H
0725H 23H AD5F5H
0725H 55H AD5F5H
0724H 7BH AD5F4H
0724H 02H AD5F4H
0723H 72H AD5F3H
0723H 72H AD5F3H
0722H 11H AD5F2H
0722H 11H AD5F2H
Memory Write Operations
(cont.)
Assume EAX = FAC4237B h
DWord Write: M[0724h] eax
before: after:
072CH 18H AD5FCH
072CH 18H AD5FCH
072BH A3H AD5FBH
072BH A3H AD5FBH
072AH 7EH AD5FAH
072AH 7EH AD5FAH
0729H 69H AD5F9H
0729H 69H AD5F9H
0728H AAH AD5F8H
0728H AAH AD5F8H
0727H FAH AD5F7H
0727H 2EH AD5F7H
0726H C4H AD5F6H
0726H 00H AD5F6H
0725H 23H AD5F5H
0725H 55H AD5F5H
0724H 7BH AD5F4H
0724H 02H AD5F4H
0723H 72H AD5F3H
0723H 72H AD5F3H
0722H 11H AD5F2H
0722H 11H AD5F2H
Default Segment/Index Pairs
Type of Memory Reference Default Segment Base Alternate Segment Base Offset
1. A pulse one clock wide from another bus master requests the
bus access to 8086.
2. During T4 (current) or T 1 (next) clock cycle, a pulse one clock
wide from 8086 to the requesting master, indicates that the
8086 has allowed the local bus to float and that it will enter the
"hold acknowledge" state at next clock cycle. The CPU's bus
interface unit is likely to be disconnected from the local bus of
the system.
3. A one clock wide pulse from the another master indicates to
8086 that the 'hold' request is about to end and the 8086 may
regain control of the local bus at the next clock cycle.
Thus each master to master exchange of the local bus is a
sequence of 3 pulses. There must be at least one dead
clock cycle after each bus exchange. The request and grant
pulses are active low. For the bus requests those are
received while 8086 is performing memory or I/O cycle, the
granting of the bus is governed by the rules as discussed in
case of HOLD, and HLDA in minimum mode.
8086 Addressing Modes
• Microprocessor needs
memory address to
access data from the
memory.
• Assembly language
may use several
addressing modes to
accomplish this task.
8086 Register Addressing Modes
Most 8086 instructions can operate on the 8086's general
purpose register set. By specifying the name of the register as
an operand to the instruction, you may access the contents of
that register. Consider the 8086 mov (move) instruction:
mov destination, source
This instruction copies the data from the source operand to the
destination operand. The eight and 16 bit registers are
certainly valid operands for this instruction. The only restriction
is that both operands must be the same size. Now let's look at
some actual 8086 mov instructions:
mov ax, bx ;Copies the value from BX into AX
mov dl, al ;Copies the value from AL into DL
Remember, the registers are the best place to keep often used
variables.
Mov makes a copy of Source and stores this value into Dest.
This instruction does not affect the original contents of Source.
It overwrites the previous value in Dest.
• The mP has a set of rules that apply whenever memory is addressed,
which define the segment and offset register combination used by
certain addressing modes[By Default].
Addressing Modes
1 Direct (absolute) memory addressing
– Instruction specifies the address of the data
– The data address (in the instruction) can be the full
physical address on the memory architecture in use
Addressing Modes
2 Register addressing
– When operands are held in the registers, e.g. MOV A, B
– Register addressing instructions are the fastest and use
the fewest bits compared to others
– Some call it inherent addressing also
3 Immediate addressing
– Used for constant values know when the program is written
– Data (i.e. constant values) can immediately follow the instruction
4.The Register Indirect Addressing Modes
• Register indirect addressing– Also called pointer register addressing
– Instruction contains address of the register that contains the address of
the needed data
– A 2-level addressing mode
There are four forms of this addressing mode on the 8086, best demonstrated
by the following instructions:
mov al, [bx]
mov al, [bp]
mov al, [si]
mov al, [di]
You can use the segment override prefix symbols if you wish to access data in
different segments. The following instructions demonstrate the use of these
overrides:
mov al, cs:[bx]
mov al, ds:[bp]
mov al, ss:[si]
mov al, es:[di]
5 Indexed addressing
– Finds a memory location based on an index
– Instruction contains the starting address of the array,the
index register contains the offset to reach the data being
addressed
The indexed addressing modes use the following syntax:
mov al,disp[bx]
mov al,disp[bp]
mov al,disp[si]
mov al,disp[di]
The offsets generated by these addressing modes are the sum of the constant and the
specified register. The addressing modes involving bx, si, and di all use the data
segment, the disp[bp] addressing mode uses the stack segment by default. As with the
register indirect addressing modes, you can use the segment override prefixes to specify
a different segment
These addressing modes are a slight modification of the base/indexed addressing modes with the
addition of an eight bit or sixteen bit constant. The following are some examples of these
addressing modes:
10 • Stack addressing
– Saves the return address when the program calls a
subroutine
– After fetching the jump op code and subroutine address,
the PC is made to point to the next op code (the return
address)
– This return address is pushed onto the stack by the
program
– The “return” instruction at the end of the subroutine pops
80x86 instructions
80x86 instructions can be (roughly) divided into seven different classes:
1) Arithmetic instructions:
add, inc sub, dec, cmp, neg, mul, imul, div, idiv
2) Data movement instructions:
mov, lea, les , push, pop, pushf, popf
3) Logical, shift, rotate, and bit instructions:
and, or, xor, not, shl, shr, rcl, rcr
4) I/O instructions:
in, out
5) String instructions:
movs, stos, lods
6) Program flow control instructions:
jmp, call, ret, conditional jumps
7) Miscellaneous instructions:
clc, stc, cmc
Arithmetic Instructions
The 80x86 provides many arithmetic operations: addition, subtraction, negation, multiplication,
division/modulo (remainder), and comparing two values. The instructions that handle these
operations are add, adc, sub, sbb, mul, imul, div, idiv, cmp, neg, inc, dec, xadd, cmpxchg, and
some miscellaneous conversion instructions: aaa, aad, aam, aas, daa, and das.
If you want to add several values together, you can easily compute the sum in a
single register:
J := K + M + N + P
mov ax, K
add ax, M
add ax, N
add ax, P
mov J, ax
Of course, if you want to add a constant to a memory location, you only need a single
instruction. The 80x86 lets you directly add a constant to memory:
J := J + 2 add J, 2
The Subtraction Instructions: SUB, SBB, DEC
The sub (subtract), sbb (subtract with borrow), dec (decrement), aas (ASCII(American
Standard Code for Information Interchange) adjust for subtraction), and das (decimal
adjust for subtraction) instructions work as you expect. Their syntax is very similar to th
of the add instructions:
sub reg, reg
sub reg, mem
sub mem, reg
sub reg, immediate data
sub mem, immediate data
sub eax/ax/al, immediate data
sbb forms are identical to sub.
dec reg
dec mem
dec reg16
The sub instruction computes the value dest := dest - src.
The sbb instruction computes dest := dest - src - C.
Note that subtraction is not commutative. If you want to compute the result for
dest := src - dest you will need to use several instructions, assuming you need to
preserve the source operand.
Since subtraction is not commutative, you cannot use the sub instruction as freely as the
add instruction. The following examples demonstrate some of the problems you may
encounter.
; J := K – J
mov ax, K ;This is a nice try, but it computes
sub J, ax ;J := J - K, subtraction isn't commutative!
mul operand8
or
imul operand8
computes:
ax := al * operand8
"*" represents an unsigned multiplication for mul and a signed multiplication for imul.
The 80x86 divide instructions perform a 64/32 division (80386 and later only), a
32/16 division or a 16/8 division. These instructions take the form:
div reg For unsigned division
div mem
idiv reg For signed division
idiv mem
You cannot, on the 80x86, simply divide one eight bit value by another. If the
denominator is an eight bit value, the numerator must be a sixteen bit value. If
you need to divide one unsigned eight bit value by another, you must zero
extend the numerator to sixteen bits. You can accomplish this by loading the
numerator into the al register and then moving zero into the ah register. Then
you can divide ax by the denominator operand to produce the correct result.
Failing to zero extend al before executing div may cause the 80x86 to produce
incorrect results!
The following examples show how to divide one sixteen bit value by another.
; J := K / M (unsigned)
mov ax, K ;Get dividend
mov dx, 0 ;Zero extend unsigned value in AX to DX.
< In practice, we should verify that M does not contain zero here >
div M
mov J, ax
;J := (K*M)/P(Signed)
The 80x86 supports three different shift instructions (shl and sal are the same instruction):
shl (shift left), sal (shift arithmetic left), shr (shift right), and sar (shift arithmetic right). The
80386 and later processors provide two additional shifts: shld and shrd.
The shift instructions move bits around in a register or memory location. The general format
for a shift instruction is
Dest is the value to shift and count specifies the number of bit positions to shift. For
example, the shl instruction shifts the bits in the destination operand to the left the number
of bit positions specified by the count operand.
SHL/SAL
The shl and sal mnemonics are synonyms. They represent the same instruction and use
identical binary encodings. These instructions move each bit in the destination operand one
bit position to the left the number of times specified by the count operand. Zeros fill vacated
positions at the L.O. bit; the H.O. bit shifts into the carry flag:
The sar instruction's main purpose is to perform a signed division by some power of two.
Each shift to the right divides the value by two. Multiple right shifts divide the previous
shifted result by two, so multiple shifts produce the following results:
sar ax, 1 ;Signed division by 2
sar ax, 2 ;Signed division by 4
sar ax, 3 ;Signed division by 8
sar ax, 4 ;Signed division by 16
sar ax, 5 ;Signed division by 32
sar ax, 6 ;Signed division by 64
sar ax, 7 ;Signed division by 128
sar ax, 8 ;Signed division by 256
SHR
The shr instruction shifts all the bits in the destination operand to the right one bit shifting
a zero into the H.O. bit:
Since shifting an unsigned integer value to the right one position is equivalent to dividing
that value by two, you can also use the shift right instruction for division by powers of
two:
shr ax, 1 ;Equivalent to AX/2
shr ax, 2 ;Equivalent to AX/4
shr ax, 3 ;Equivalent to AX/8
shr ax, 4 ;Equivalent to AX/16
shr ax, 5 ;Equivlaent to AX/32
shr ax, 6 ;Equivalent to AX/64
Remember that division by two using shr only works for unsigned operands
The Rotate Instructions: RCL, RCR, ROL, and ROR
The rotate instructions shift the bits around, just like the shift instructions, except the bits
shifted out of the operand by the rotate instructions recirculate through the operand.
They include rcl (rotate through carry left), rcr (rotate through carry right), rol (rotate left),
and ror (rotate right). These instructions all take the forms:
rcl dest, count
rol dest, count
rcr dest, count
ror dest, count
The specific forms are
rcl reg, 1
rcl mem, 1
rcl reg, imm (2)
rcl mem, imm (2)
rcl reg, cl
rcl mem, cl
rol uses the same formats as rcl.
rcr uses the same formats as rcl.
ror uses the same formats as rcl.
2- This form is avialable on 80286 and later processors only.
RCL
The rcl (rotate through carry left), as its name implies, rotates bits to the left, through
the carry flag, and back into bit zero on the right:
Note that if you rotate through carry an object n+1 times, where n is the number of bits
in the object, you wind up with your original value. Keep in mind, however, that some
flags may contain different values after n+1 rcl operations.
RCR
The rcr (rotate through carry right) instruction is the complement to the rcl instruction. It
shifts its bits right through the carry flag and back into the H.O. bit:
ROL
The rol instruction is similar to the rcl instruction in that it rotates its operand to the left
the specified number of bits. The major difference is that rol shifts its operand's H.O.
bit, rather than the carry, into bit zero. Rol also copies the output of the H.O. bit into
the carry flag:
ROR
The ror instruction relates to the rcr instruction in much the same way that the rol
instruction relates to rcl. That is, it is almost the same operation other than the source of
the input bit to the operand. Rather than shifting the previous carry flag into the H.O. bit
of the destination operation, ror shifts bit zero into the H.O. bit:
Write a program that counts the number of 1’s in a byte and writes
it into BL
DATA1: DB 61h
SUB BL,BL ;clear BL to keep the number of 1s
MOV DL,8 ;rotate total of 8 times
MOV AL,DATA1
AGAIN: ROL AL,1 ;rotate it once
JNC NEXT ;check for 1(Jump if No Carry)
INC BL ;if CF=1 then add one to count
NEXT: DEC DL ;go through this 8 times
JNZ AGAIN ;if not finished go back(Jump if Not Zero)
NOP
Data Movement Instructions
The data movement instructions copy values from one location to another. These instructions
include mov, xchg, lds, lea, les, lfs, lgs, lss, push, pusha, pushad, pushf, pushfd, pop, popa, popad,
popf, popfd, lahf, and sahf
The MOV Instruction
The mov instruction takes several different forms:
mov reg, reg
mov mem, reg
mov reg, mem
mov mem, immediate data
mov reg, immediate data
mov ax/al, mem
mov mem, ax/al
mov segreg, mem16
mov segreg, reg16
mov mem16, segreg
mov reg16, segreg
There are two very important details to note about the mov instruction. First, there is no memory to
memory move operation. The mod-reg-r/m addressing mode byte allows two register operands or
a single register and a single memory operand. There is no form of the mov instruction that allows
you to encode two memory addresses into the same instruction. Second, you cannot move
immediate data into a segment register. The only instructions that move data into or out of a
segment register have mod-reg-r/m bytes associated with them; there is no format that moves an
immediate value into a segment register. Two common errors beginning programmers make are
attempting a memory to memory move and trying to load a segment register with a constant.
Immediate value moves
mov ax, 7 ; Immediate to
register
mov mem, 7 ; Immediate to
memory direct
mov mem[bx], 7 ; Immediate to
memory indirect
Register moves
mov mem, ax ; Register to
memory direct
mov mem[bx], ax ; Register to
memory indirect
mov ax, bx ; Register to
register
mov ds, ax ; General register
to segment register
OUT 37FH, AL ; Immediate port address must not be greater than FFH
OUT 32H, BL ; 8-bit output port must use AL
OUT 32, 48 ; Immediate output data is not allowed
lds reg16, mem32:
reg16 := [mem32]
ds := [mem32 + 2]
les reg16, mem32:
reg16 := [mem32]
es := [mem32 + 2]
15 8 7 0 7 0
BX YY XX XX 5000
YY 5001
mm
5002
nn mm
DS/ES
nn 5003
Consider the following lea instructions:
lea ax, [bx]
lea bx, 3[bx]
lea ax, 3[bx]
The lea ax, [bx] instruction copies the address of the expression [bx] into the ax
register.Since the effective address is the value in the bx register, this instruction copies
bx’s value into the ax register. Again, this instruction isn’t very interesting because
mov can do the same thing, even faster.
The lea bx,3[bx] instruction copies the effective address of 3[bx] into the bx
register.Since this effective address is equal to the current value of bx plus three, this
lea instruction effectively adds three to the bx register. There is an add instruction that
will let you add three to the bx register, so again, the lea instruction is superfluous for
this purpose.
The third lea instruction above shows where lea really begins to shine. lea ax, 3[bx]
copies the address of the memory location 3[bx] into the ax register; i.e., it adds three
with the value in the bx register and moves the sum into ax. This is an excellent
example of how you can use the lea instruction to do a mov operation and an addition
with a single instruction.
The PUSH and POP Instructions
The 80x86 push and pop instructions manipulate data on the 80x86's hardware stack. There are some
varieties of the push and pop instructions, they are
push reg16
pop reg16
push reg32 (3)
pop reg32 (3)
push segreg
pop segreg
push memory
pop memory
(3)- Available only on 80386 and later processors.
The first two instructions push and pop a 16 bit general purpose register. This is a compact (one
byte) version designed specifically for registers. Note that there is a second form that provides a
mod-reg-r/m byte that could push registers as well; most assemblers only use that form for pushing
the value of a memory location.
The second pair of instructions push or pop an 80386 32 bit general purpose register. This is really
nothing more than the push register instruction described in the previous paragraph with a size
prefix byte.
The third pair of push/pop instructions let you push or pop an 80x86 segment register.
"So what do these instructions do?" you're probably asking by now. The push instructions move
data onto the 80x86 hardware stack and the pop instructions move data from the stack to memory
or to a register. The following is an algorithmic description of each instruction:
Notice three things about the 80x86 hardware stack. First, it is always in the stack segment
(wherever ss points). Second, the stack grows down in memory. That is, as you push values onto
the stack the CPU stores them into successively lower memory locations. Finally, the 80x86
hardware stack pointer (ss:sp) always contains the address of the value on the top of the stack (the
last value pushed on the stack).
Computer Interrupt
Interrupt request: a signal that immediate attention is needed
Interrupt processing: what CPU does in response to request
Interrupt service: what is done in software as a result
• 2 General Types of Interrupts:
External - generated outside CPU by other hardware
Internal - generated within CPU as a result of instruction or
operation
- x86 internals: int, into, divide error, and single step
- “trap” generally means any processor generated
interrupt; in x86, usually means the single step interrupt
Software Interrupts
Type 0 -255 :
The 8086 INT instruction can be used to cause the 8086 to do one of the 256 possible interrupt
types. The interrupt type is specified by the number as a part of the instruction.
With the software interrupts you can call the desired routines from many different programs in
a system. e.g. BIOS in IBM PC. The IBM PC has in its ROM collection of routines, each
performing some specific function such as reading character from keyboard, writing character
to CRT. This collection of routines referred to as Basic Input Output System or BIOS.
The BIOS routines are called with INT instructions. We will summarize interrupt response and
how it is serviced by going through following steps.
1. 8086 pushes the flag register on the stack.
2. It disables the single step and the INTR input by clearing the trap flag and interrupt flag in
the flag register .
3. It saves the current CS and IP(IP contains the offset of the next instruction to be fetched from
the beginning of the code segment) register contents by pushing them on the stack.
4. It does an indirect far jump to the start of the routine by loading the new values of CS and IP
register .
5. Once these values are loaded in the CS and IP , 8086 will fetch the instruction from the new
address which is the starting address of interrupt service routine.
6. An IRET instruction at the end of the interrupt service routine gets the previous values of CS
and IP by popping the CS and IP from the stack.
7. At the end the flag register contents are copied back into flag register by popping the flag
register form stack.
8086 Interrupt Types
Divide by Zero Interrupt (Type 0)
When the quotient from either a DIV or IDIV instruction is too large to fit in the result register; 8086
will automatically execute type 0 interrupt