Date: Tue, 5 Oct 1999 09:48:58 +0200 (IST) From: Eli Zaretskii X-Sender: eliz AT is To: Alex Mendes da Costa cc: djgpp AT delorie DOT com Subject: Re: Problem with interrupts In-Reply-To: <37F871DE.C5C687E5@virtualis.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk 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.