delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/10/05/05:21:42

Date: Tue, 5 Oct 1999 09:48:58 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Alex Mendes da Costa <alexmdc AT virtualis DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: Problem with interrupts
In-Reply-To: <37F871DE.C5C687E5@virtualis.com>
Message-ID: <Pine.SUN.3.91.991005094839.2899E-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019