[comp.lang.c] How to return from MS C function

todd@SEAS.UCLA.EDU (09/24/88)

How can I design an MS C function with extra function entry and exit
code so that the 8086/8088 registers are preserved unpon entry and
restored on exit?  Are there any other considerations?  In Turbo-C, I
just use the "interrupt" function modifier.  For example:

void interrupt myhandler()
{
	...
}

thx, --todd booth / ucla data communications
ArpaNet todd@seas.ucla.EDU / BitNet csdctgb@uclamvs.bitnet
UUCP    {ihnp4,ucbvax}!ucla-cs!todd / 213 825-1933

johnl@ima.ima.isc.com (John R. Levine) (09/25/88)

In article <16166@shemp.CS.UCLA.EDU> todd@SEAS.UCLA.EDU (Todd Booth) writes:
>
>How can I [in MS C get the equivalent of the Turbo C ]
>"interrupt" function modifier.  For example:
>
>void interrupt myhandler()

In MS C 5.0 and newer, you write

void interrupt myhandler()

Isn't competition great?  Sadly, in both Turbo and MS C the interrupt
function uses the stack that already exists at the time of the interrupt
rather than using a private stack.  This makes these things practically
worthless for any real code since you can't assume that a random DOS stack
has room for more than a few words of saved state, so you have to write
little assembler stubs to wrap your C code.  MS C also has yet to add the
segment relative pointers such as "char * _ss stack_relative_pointer;" that
Turbo inherited from its Wizard C predecessor.  That makes it considerably
more difficult to write code that runs with SS != DS, even when you know it's
safe to do so.  Yeah, I know all Windows applications run that way and
they're all written in MS C, but they are certainly a pain to write and debug.
-- 
John R. Levine, IECC, PO Box 349, Cambridge MA 02238-0349, +1 617 492 3869
{ bbn | think | decvax | harvard | yale }!ima!johnl, Levine@YALE.something
Rome fell, Babylon fell, Scarsdale will have its turn.  -G. B. Shaw

cramer@optilink.UUCP (Clayton Cramer) (09/28/88)

In article <16166@shemp.CS.UCLA.EDU>, todd@SEAS.UCLA.EDU writes:
> 
> How can I design an MS C function with extra function entry and exit
> code so that the 8086/8088 registers are preserved unpon entry and
> restored on exit?  Are there any other considerations?  In Turbo-C, I
> just use the "interrupt" function modifier.  For example:
> 
> thx, --todd booth / ucla data communications

MSC 5.x has the "interrupt" keyword -- I've written ISRs that use it,
in C, so I know it works.


-- 
Clayton E. Cramer
..!ames!pyramid!kontron!optilin!cramer