Download WINDOWS ASSEMBLY LANGUAGE & SYSTEMS PROGRAMMING

Transcript
34 Windows Assembly Language & Systems Programming
3. The CPU then loads the FAR address into its CS:IP registers
and commences execution of the service routine.
4. Interrupt routines always terminate with an IRET instruction,
which has the effect of popping the three values saved on the
stack back off, into CS, IP, and FLAGS. Thus the CPU
carries on as before, as though nothing had happened.
IRET
instruction
Note that when a CALL instruction executes, it works in a similar
way, but a FAR CALL only saves CS and IP on the stack, not the
FLAGS. Also, if it is a NEAR CALL, only IP is saved on the
stack. In addition, the routine called must terminate with RET, not
IRET, as the latter pops three values off the stack (expecting
FLAGS to be on there as well).
CALL to an
ISR
Incidentally, a useful point arises from what I have written above.
You can use the CALL instruction to call the BIOS and DOS
services, despite the fact that they terminate with an RET:
PUSHF
CALL rou tinename
;push flags on stack.
That is, you push the FLAGS on beforehand, using a special
instruction, PUSHF (there is also a POPF). You do need to know
the address of the routine that you are calling, however, since it
doesn’t make use of the IVT, as INT does.
Protected Mode Interrupts
Just as segment registers no longer represent real addresses, so too
the interrupt mechanism no longer uses the Interrupt Vector Table
(IVT). Interestingly, when Windows is running, the IVT is still
there, but our applications don’t use it. It is still used by Windows,
but that’s another story.
Structure of
the /VT
So, just where is this IVT? Have a look back at page 11. The IVT
sits in RAM right down at OOOO:OOOO, occupying the first 1024
bytes. It is set up by the BIOS startup routine and filled in by DOS
also.
Interrupt
Descriptor
Table (ILIT)
The fundamental problem is that it contains real segment
addresses, which is a no-no in Protected mode (though is ok in
virtual-86 mode). Therefore a special table has to be created by
the Windows operating system, called the Interrupt Descriptor
Table (IDT), which contains the linear addresses of the services.
Linear addresses are real, but they are actual 24- or 32-bit
addresses, without the segment:offset structure.