Download WINDOWS ASSEMBLY LANGUAGE & SYSTEMS PROGRAMMING

Transcript
CPU Architecture 33
Interrupts
Real mode
interrupts
INT n
Like everything else, Protected mode interrupts are a whole new
ball game. First, let’s review the mechanism in Real mode.
The standard method of doing I/O and file and memory
management, plus a heap of other operations, was by the BIOS
These are accessed from an
and DOS interrupt services.
application program by means of the INT instruction, with this
syntax:
:software interruDt
where “n” is an integer (whole number) from zero to FF (hex).
The usual procedure is that certain registers have to be loaded
prior to the INT, depending upon the particular service, and many
of the services have subfunctions, usually selected by a value in
the AH register.
MT-2 lb, fbe
main DOS
service
The most important of these is INT-2lh (h = hexadecimal), which
is the main DOS service, with dozens of subfunctions.
A comprehensive list is to be found in my previous book. In this
one you’ll find extra INT services especially relevant to Windows.
It is not that we do away with INT services entirely with
Windows, it’s just that many of the BIOS and DOS services are
designed for DOS and the Real mode and are no longer
appropriate.
Windows
functions
We access the Windows services by CALL instructions, not INTs,
and from the CPUs point of view there is a difference. Windows’
services, or functions, do all that many programmers would want,
though we dig a little deeper in this book and also show how
useful the INT services can be.
Real Mode Interrupts
Interrupts, whether from an external source (hardware) or
generated internally by the program (software), cause the same
reaction in the CPU:
1. The CPU pushes the current Instruction Pointer (IP), Code
Segment (CS), and FLAGS register onto the stack.
Interrupt
Vector
Table (/VT)
2. Then the CPU uses the value ‘9-i” as an index into the
Interrupt Vector Table (IVT), where it finds the FAR address
of the service routine.