Mail Archives: djgpp/1999/10/05/05:21:42
On Mon, 4 Oct 1999, Alex Mendes da Costa wrote:
> I don't know if this is against the rules of the list
It isn't against the rules to ask questions relatred to DJGPP, and it
isn't against the rules to post sources.
> This code stuffs up my computer completely every time I try to run it,
> but it compiles alright.
Your interrupt handler is written in C. It doesn't matter that you
used inline assembly, the handler is still a C function. The FAQ
explains that for interrupt handlers written in C you need to use a
different procedure to install the handler. In particular, you need
to allocate a wrapper with a call to _go32_dpmi_allocate_iret_wrapper,
which will take care of all kinds of gory details that you neglected
to take care of and that are a must inside an interrupt handler.
So I suggest to use the procedure outlined in the FAQ (section 18.9)
for installing a hardware interrupt handlers written in C.
> void keyboard_handler()
> {
> asm("pushw %ax
> movb $0x20, %al
> outb %al, $0x20
> popw %ax
> sti
> iret");
> }
This is bad for another reason: the compiler can optimize all this asm
block out of existence, since you don't reference any variables. Use
"__asm__ __volatile__" instead of just "asm". The volatile qualifier
prevents the compiler from optimizing too aggressively.
- Raw text -