Re: -mregparm on gcc doesnt work correctly?



junkoi wrote:
Hi,

I have some expermentals with -mregparm option of gcc. I compile my
code (16bit, if that matters) like this

gcc -mregparm=2 ...

So I expect that the first 2 param of a function is transferred in EAX
and EDX, and from the 3rd params onward the params are put in stack.
So for example calling "function(x,y,z,v)" should put "z" and "v" in
stack.

But by disassembling my gcc-generated code, I surprised to see that it
uses ECX for the 3rd param, and only from 4th param it uses stack. So
in the above example, only "v" is in stack, but not "z" as expected (z
is in ECX!!). How is that possible??


Probably because anything but -mregparm=0 and -mregparm=3 gets virtually zero testing.

-hpa

.



Relevant Pages

  • -mregparm on gcc doesnt work correctly?
    ... I have some expermentals with -mregparm option of gcc. ... I compile my ... So I expect that the first 2 param of a function is transferred in EAX ... and from the 3rd params onward the params are put in stack. ...
    (comp.lang.asm.x86)
  • Re: how to make gcc know #inlcude ?
    ... Mopelee wrote: ... I have used param -I of GCC to tell the *.h file of framework at eg. ...
    (comp.lang.c)
  • Re: ref parameter
    ... I'm going to *guess* that the stack looked ... (because param is passed in by reference) ... The DLL then merrily writes over SerialNo *and then part of 'address ... Rather, in that context, "param" refers to the original parameter, which is passed as an address stored in a location that is referenced as an offset relative to the current stack frame. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: ref parameter
    ... I'm going to *guess* that the stack looked ... of param'*. ... of that is simply an offset relative to the current stack frame. ... But the address of the original parameter passed as "param" was stored in ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Finding the callstack programmatically
    ... try to compile it (with gcc -c) and link it with my program and if I call ... >> function call stack in the SIGSEGV handler? ...
    (comp.unix.programmer)