[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Exception Vectors and You...



Your code is still responsible for jumping through to the next vector.
You can find the old vector's address with Setexc(vector_number, -1L).
You then change the jmp instruction (like you did before), and install
the vector with Setexc(vector_number, entry_point_of_your_routine).

Setexc() just sets the vector address to point at your routine; thus
Setexc(0x100, foo) is basically equivalent to *((long *)0x400) = (long)foo.
The differences are that (1) Setexc deals with the vector number, which
is the address divided by 4; (2) Setexc always executes in supervisor
mode, so you don't have to worry about whether the vector is in protected
memory or not; and, most importantly, (3) Setexc lets the OS know that
you've changed the vector, and takes care of changing the memory protection
status of your application if you've forgotten to do this.

Source code for Setexc is in bios.c, if you want to see exactly what
it does in the current version of MiNT.