delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/21/17:22:45

From: Shawn Hargreaves <Shawn AT talula DOT demon DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Function Sizes (how to in asm?)
Date: Thu, 21 Aug 1997 18:55:37 +0100
Organization: None
Distribution: world
Message-ID: <UNUWnCAZEI$zEwON@talula.demon.co.uk>
References: <33FAE4E3 DOT 247F AT cornell DOT edu>
<Pine DOT SUN DOT 3 DOT 91 DOT 970821101322 DOT 26010I-100000 AT is>
NNTP-Posting-Host: talula.demon.co.uk
MIME-Version: 1.0
Lines: 31
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Eli Zaretskii writes:
>No, the problems with C functions are that (1) there's no way to
>compute their size (hence the trick with dummy functions around the
>handler); and (2) you don't have any control about what goes on on the
>stack in the code produced by the compiler, and so cannot easily lock
>the portion of stack that gets touched by the handler.

Can this really be true? I think I might finally have caught you out in
an error, Eli, for the first time ever! :-)

The functions in src/libc/go32/gopint.c 
(_go32_dpmi_allocate_iret_wrapper() and friends), allocate a custom
stack for the interrupt handler, which is locked. So it doesn't matter
however much data the compiler decides to put on the stack, as long as
it doesn't overflow the stack size (the default seems to be just under
32k, and I can't imagine an interrupt handler ever using more than
that!).

As far as I can see the only problems with C code are needing the dummy
marker functions (seems to work at present but could break with future
versions of the compiler), and the possibility that the generated code
might use external helper functions or global data (eg. floating point
constants, jump tables for a switch statement, or helper functions for
working with the "long long" data type). As long as you are careful in
how you lay things out, though, C interrupt handlers can be quite
reliable, and it's certainly a lot easier than doing everything in asm!


--
Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
Beauty is a French phonetic corruption of a short cloth neck ornament.

- Raw text -


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