6-4 Intro To Interrupts: An Interrupt Is A Hardware-Generated CALL or A Software-Generated CALL
6-4 Intro To Interrupts: An Interrupt Is A Hardware-Generated CALL or A Software-Generated CALL
١
Interrupt Vectors
• A 4-byte number stored in the first 1024 bytes
of memory (00000H–003FFH) in real mode.
– in protected mode, the vector table is replaced by
an interrupt descriptor table that uses 8-byte
descriptors to describe each of the interrupts
• 256 different interrupt vectors.
– each vector contains the address of an interrupt
service procedure
٢
Interrupt Vectoring Process
Interrupt Handler
Calling program
Interrupt Instructions
• Three different interrupt instructions available:
– INT, INTO, and INT 3
• In real mode, each fetches a vector from the
vector table, and then calls the procedure
stored at the location addressed by the vector.
• In protected mode, each fetches an interrupt
descriptor from the interrupt descriptor table.
• Similar to a far CALL instruction because it
places the return address (IP/EIP and CS)
on the stack.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions Copyright ©2009 by Pearson Education, Inc.
Architecture, Programming, and Interfacing, Eighth Edition Upper Saddle River, New Jersey 07458 • All rights reserved.
Barry B. Brey
٣
INTs
٤
• When a software interrupt executes, it:
– pushes the flags onto the stack
– clears the T and I flag bits
– pushes CS onto the stack
– fetches the new value for CS from the
interrupt vector
– pushes IP/EIP onto the stack
– fetches the new value for IP/EIP from
the vector
– jumps to the new location addressed by
CS and IP/EIP
٥
Common Interrupts
Software interrupts will call interrupt service
routines (ISRs) either in BIOS or DOS
• INT 10h Video Services
• INT 16h Keyboard Services
• INT 17h Printer Services
• INT 1Ah Time of Day
• INT 1Ch User Timer Interrupt
• INT 21h MS-DOS Services
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions Copyright ©2009 by Pearson Education, Inc.
Architecture, Programming, and Interfacing, Eighth Edition Upper Saddle River, New Jersey 07458 • All rights reserved.
Barry B. Brey
٦
Function 09h of INT 21h
• INT 21h: invoke MS-DOS services
– Function code in AH, e.g. 09H = write string
– The string must be terminated by a '$' character.
– DS must point to the string's segment, and DX
must contain the string's offset.
mov ah,9
mov dx,OFFSET string
int 21h
string DB ‘Hello, World!$’
٧
IRET/IRETD
• Used only with software or hardware interrupt
service procedures.
• IRET is used in real mode and IRETD in the
protected mode.
• IRET instruction will
– pop stack data back into the IP
– pop stack data back into CS
– pop stack data back into the flag register
• Accomplishes the same tasks as the POPF
followed by a far RET instruction.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions Copyright ©2009 by Pearson Education, Inc.
Architecture, Programming, and Interfacing, Eighth Edition Upper Saddle River, New Jersey 07458 • All rights reserved.
Barry B. Brey
INT 3
• A special software interrupt designed to
function as a breakpoint.
– a 1-byte instruction, while others are 2-byte
• Common to insert an INT 3 in software to
interrupt or break the flow of the software.
– function is called a breakpoint
– breakpoints help to debug faulty software
• A breakpoint occurs for any software interrupt,
but because INT 3 is 1 byte long, it is easier to
use for this function.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions Copyright ©2009 by Pearson Education, Inc.
Architecture, Programming, and Interfacing, Eighth Edition Upper Saddle River, New Jersey 07458 • All rights reserved.
Barry B. Brey
٨
INTO
• Interrupt on overflow (INTO) is a conditional
software interrupt that tests overflow flag (O).
– If O = 0, INTO performs no operation
– if O = 1 and an INTO executes, an interrupt
occurs via vector type number 4
• The INTO instruction appears in software that
adds or subtracts signed binary numbers.
• JO or INTO instructions detect the overflow.
Interrupt Control
• Two instructions control the INTR pin.
• The set interrupt flag instruction (STI) places
1 in the I flag bit.
– which enables the INTR pin
• The clear interrupt flag instruction (CLI)
places a 0 into the I flag bit.
– which disables the INTR pin
• The STI instruction enables INTR and the CLI
instruction disables INTR.
The Intel Microprocessors: 8086/8088, 80186/80188, 80286, 80386, 80486 Pentium,
Pentium Pro Processor, Pentium II, Pentium, 4, and Core2 with 64-bit Extensions Copyright ©2009 by Pearson Education, Inc.
Architecture, Programming, and Interfacing, Eighth Edition Upper Saddle River, New Jersey 07458 • All rights reserved.
Barry B. Brey
٩
6–5 MACHINE CONTROL AND
MISCELLANEOUS INSTRUCTIONS
• These instructions provide control and perform
various other functions.
HLT
• Stops the execution of software.
• DOS and Windows both use interrupts
extensively.
– so HLT will not halt the computer when
operated under these operating systems
١٠
NOP
• In early years, before software development
tools were available, a NOP, which performs
absolutely no operation, was often used to pad
software with space for future machine
language instructions.
• When the microprocessor encounters a NOP,
it takes a short time to execute.
١١