www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/10/19/06:06:35

Date: Mon, 19 Oct 1998 11:11:29 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Olivier Perron <perron AT art DOT alcatel DOT fr>
cc: djgpp AT delorie DOT com
Subject: Re: Questions about protected mode interrupt handler
In-Reply-To: <Pine.GSO.4.05.9810191002080.5562-100000@rtbsci146s>
Message-ID: <Pine.SUN.3.91.981019110341.7874W-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com

On Mon, 19 Oct 1998, Olivier Perron wrote:

> First: it seems I can't hook the serial port interrupt when I run under
> Windows95 (but it works well under plain DOS). Could someone explain me
> why ?

Probably because Windows doesn't like you? ;-)

But first, could you please explain ``I can't hook the serial port''?  
What exactly goes wrong?

> Second: rather than using _go32_dpmi_chain_protected_mode_interrupt_vector 
> or _go32_dpmi_allocate_iret_wrapper, can I compile my interrupt handler
> (wich is written in C) to an assembler file (with gcc -S) then edit the
> relevant .s file and replace the final `ret' with a `iret' and just
> register my interrupt handler with
> _go32_dpmi_set_protected_mode_interrupt_vector ?

Yes, you can--if you like to crash ;-).

Seriously, though: the wrappers do much more than just IRET.  Please take
a look at their sources inside djlsr201.zip (file src/libc/go32/gopint.c)
and you will see what I mean.  In particular, they allocate and lock a
stack for your handler, save and restore several registers, etc.  Without
this administrivia, code produced by GCC will instantly crash, because it
makes several assumptions like SS=DS=ES which aren't true inside an
interrupt handler, and because local variables are allocated on the stack
which you can't lock from C code. 

Discarding the wrappers is only possible if you write your handlers in 
assembly to begin with, and take care of all those gotchas by e.g. 
placing all the variables into the code segment, not using the stack, 
etc.

Moreover, I don't really understand why are you eager to toss the 
wrappers.  How can they hurt anything in your program?

- Raw text -


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