Re: How interrupts work (x86 vs. C64)




"João Jerónimo" <spamtrap@xxxxxxxxxx> wrote in message
news:453e3fca$0$49200$14726298@xxxxxxxxxxxxxxxxxx
Bjarni Juliusson wrote:
Some time ago I used interrupts at Commodore C-64. When I preset
address
of system interrupt (as I know there was only one interrupt available)
to my code (which ended with jump to original address of interrupt) the
result was, that my code was repeated continuously (~60 times pre
second, in other 'thread'). The interrupts at x86 seem to work
differently. How do they work, and how to 'emulate' behavior of
interrupt from C64 ?

There is a table in memory with pointers to a number of interrupt
routines to be called when the different interrupts occur. In real mode,
this table is at address 0, but in protected mode it can be located
anywhere and you set a register pointing to it.

I've read that (but not tried to) even in real mode you can have the IVT
anywhere in memory by setting its address using LIDT, just as in PMode...


Yes. You can relocate the RM IVT or the PM IDT by copying the table
elsewhere and using the LIDT instruction to set the new location.

For RM, DOS and DOS programs, (and perhaps BIOS) don't check to see if the
location of the IVT has been moved from 0. What this means is that you can
lock the IVT, preventing any further changes. The BIOS, DOS, and DOS
programs will modify the old IVT at 0, instead of the current one used by
the CPU. This technique was used by a virus many years ago, and may be used
by certain debuggers such as 386SWAT. Under MS-DOS v7.10 (Win98 SE),
locking the IVT in this manner is humorous at best. It appears that just
about every DOS internal command, or DOS program changes at least one
interrupt. About the only use for this technique that I've found, is to
save your original BIOS vectors to the memory around 640k or 512k, using a
small custom bootloader, which boots DOS afterward. You can then save them
from memory after DOS boots.

Perhaps, someone else (perhaps Mark Larson) could suggest some other use for
relocating the RM IVT.


Rod Pemberton

.



Relevant Pages

  • Re: Nobody should ever need to patch the kernel!!
    ... Even Dos was ... to call into it from interrupt time. ... without marking all of its memory ressources as 'free to be re-used'. ... do anything, due to not being active, cannot 'compromise' anyhting, ...
    (comp.os.linux.development.system)
  • Re: Using Visual Basic to Write System-Wide Hooks
    ... Keyboard handler jumped into my head because I had ... done it once with DOS, and some of the Interrupt vectoring started to ... albeit not a full memory recovery. ...
    (microsoft.public.vb.winapi)
  • Re: Using Visual Basic to Write System-Wide Hooks
    ... revector from the old Interrupt address to a new ... > was located in memory. ... This is a compact DOS program ... Complete assembler source code ...
    (microsoft.public.vb.winapi)
  • Re: Less keystrokes to exit from DOS
    ... you should do it via the DOS interrupts and not the IVT ... some other program can hook the DOS int to detect ... key configurations for the computer game that F12 is the "rockets" key ...
    (alt.lang.asm)
  • Re: HELP: C/C++ equivalent of dos,crt Pascal units
    ... I am trying to port an old Pascal DOS game to DOS C/C++. ... Assuming you want to do the same thing in Microsoft Visual ... outp(0x3c8, reg); ... procedure NewInt08; Interrupt; ...
    (microsoft.public.vc.language)