delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/31/02:32:43

From: tim <tim AT h2oent DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: _PASCAL in DJGPP
Date: 31 Aug 1997 02:07:26 GMT
Organization: H2O
Lines: 62
Message-ID: <5uajku$sbv@nr1.calgary.istar.net>
References: <01bcb3ed$03096660$4ac057c0 AT johan>
Reply-To: No AT delorie DOT com, More AT delorie DOT com, Spam AT delorie DOT com
NNTP-Posting-Host: pm306.spots.ab.ca
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

J. van der Laan wrote:
> 
> Does anyone know how to implement an _PASCAL calling convention in DJGPP? I
> have a lot of asm files that use that convention, and converting them all
> would be really a lot of work. In TURBOc you could just use "PASCAL" to
> make a function use that calling convention.
> Thanks in advance
> Jasper

DJGPP has a set of built in functions that might work.  I've never used
them.
I came accross them while scanning the info pages that came with DJGPP. 
I'm
going to copy the info page into this message.  This page came right out
of
the info for gcc.

Constructing Function Calls
===========================

   Using the built-in functions described below, you can record the
arguments a function received, and call another function with the same
arguments, without knowing the number or types of the arguments.

   You can also record the return value of that function call, and
later return that value, without knowing what data type the function
tried to return (as long as your caller expects that data type).

`__builtin_apply_args ()'
     This built-in function returns a pointer of type `void *' to data
     describing how to perform a call with the same arguments as were
     passed to the current function.

     The function saves the arg pointer register, structure value
     address, and all registers that might be used to pass arguments to
     a function into a block of memory allocated on the stack.  Then it
     returns the address of that block.

`__builtin_apply (FUNCTION, ARGUMENTS, SIZE)'
     This built-in function invokes FUNCTION (type `void (*)()') with a
     copy of the parameters described by ARGUMENTS (type `void *') and
     SIZE (type `int').

     The value of ARGUMENTS should be the value returned by
     `__builtin_apply_args'.  The argument SIZE specifies the size of
     the stack argument data, in bytes.

     This function returns a pointer of type `void *' to data describin
     how to return whatever value was returned by FUNCTION.  The data
     is saved in a block of memory allocated on the stack.

     It is not always simple to compute the proper value for SIZE.  The
     value is used by `__builtin_apply' to compute the amount of data
     that should be pushed on the stack and copied from the incoming
     argument area.

`__builtin_return (RESULT)'
     This built-in function returns the value described by RESULT from
     the containing function.  You should specify, for RESULT, a value
     returned by `__builtin_apply'.

I hope this helps.

- Raw text -


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