delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/05/30/22:32:43

Xref: news2.mv.net comp.os.msdos.djgpp:4399
From: malcolm AT manawatu DOT gen DOT nz (Malcolm Taylor)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: How are args passed in DJGPP?
Date: Thu, 30 May 1996 22:07:23 GMT
Organization: Grafik Software
Lines: 33
Message-ID: <4ol9vd$14b@news.manawatu.gen.nz>
References: <Pine DOT SGI DOT 3 DOT 91 DOT 960528205219 DOT 4525B-100000 AT sgi6 DOT york DOT ac DOT uk>
Reply-To: malcolm AT manawatu DOT gen DOT nz
NNTP-Posting-Host: malcolm.manawatu.gen.nz
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Shawn Hargreaves <slh100 AT york DOT ac DOT uk> wrote:

>On Mon, 27 May 1996, Richard Philp wrote:

>Arguments from C to the assembler function are passed on the stack, the 
>caller pushes them and then cleans up the stack after the asm function 
>returns. The return value is normally in %eax, at least for integers. I 
>would imagine pointers are the same, but floats and structures probably 
>different.

The passing of 32-bit and less arguments is normally by %eax if
optimizing. There are some compiler switches that select whether to
pass floating point in registers or on the stack. There are also
switches that will cause small structures to be passed in registers as
well, so I would not count on these unless I found the switches and
explicity turned them off for all the compilation. Just look in the
gcc docs under invoking...

>The easiest way to figure this out is to write a simple C function that 
>takes some parameters and returns something, and compile it with -S. Take 
>a look at the resulting .s file, and you can see exactly where gcc put 
>everything...

When compiling with optimisations it might come down to the whim of
the compiler what it chooses to do in some cases (esp with structures)
although I'm no expert here, so correct me if I'm wrong. Still
remember to compile the function with exactly the same switches as you
would the rest of your program, and with the same function prototype
as the assembly function you want to write. This way you can be most
sure that the assembler output will be consistent.

Malcolm

- Raw text -


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