* Passing parameters to assembler functions in 'C' 64 style.
@ 2008-12-04 20:20 £ukasz
2008-12-04 20:54 ` Robert Plantz
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: £ukasz @ 2008-12-04 20:20 UTC (permalink / raw)
To: linux-assembly
Hi.
I started to write assembler functions for C on 64-bit arch. On 32-bit arch. every parameters ware put on stack, now is different, what can be easyly seen reading source program. For example if im passing one
(int *) parameter, adress (&int) is kept in %rdi register, and so one if u are passing more parameters. Ofcurse is not dificult to use it if u know but is there any key according to which parameters are stored?. I've made some "experiments" with different numbers and kind parameters, but the "key" must be described somewhere.
Luke
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Passing parameters to assembler functions in 'C' 64 style.
2008-12-04 20:20 Passing parameters to assembler functions in 'C' 64 style £ukasz
@ 2008-12-04 20:54 ` Robert Plantz
2008-12-04 20:55 ` Frederic Marmond
2008-12-04 21:22 ` £ukasz
2 siblings, 0 replies; 4+ messages in thread
From: Robert Plantz @ 2008-12-04 20:54 UTC (permalink / raw)
To: blurrpp; +Cc: linux-assembly
You need the AMD64 Application Binary Interface (v0.99) available at
http://www.x86-64.org/documentation.html
In particular, see Figure 3.4 on page 21.
Pay attention to the use of rax. The default for floating point in
x88-64 is the SSE unit. If a function will accept floating point
arguments (for example, printf) the number of floating point arguments
must be placed in eax. Write a C program that calls printf and use the
-S option to see the assembly language.
A good way to see what the compiler is doing to C code is to use the
following options:
$ gcc -O0 -g -Wa,-adhls -fno-asynchronous-unwind-tables \
> myProg.c > myProg.lst
(I added the "\" here to avoid confusing word wrapping.)
Bob
On Thu, 2008-12-04 at 12:20 -0800, £ukasz wrote:
> Hi.
> I started to write assembler functions for C on 64-bit arch. On 32-bit arch. every parameters ware put on stack, now is different, what can be easyly seen reading source program. For example if im passing one
> (int *) parameter, adress (&int) is kept in %rdi register, and so one if u are passing more parameters. Ofcurse is not dificult to use it if u know but is there any key according to which parameters are stored?. I've made some "experiments" with different numbers and kind parameters, but the "key" must be described somewhere.
>
> Luke
--
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Passing parameters to assembler functions in 'C' 64 style.
2008-12-04 20:20 Passing parameters to assembler functions in 'C' 64 style £ukasz
2008-12-04 20:54 ` Robert Plantz
@ 2008-12-04 20:55 ` Frederic Marmond
2008-12-04 21:22 ` £ukasz
2 siblings, 0 replies; 4+ messages in thread
From: Frederic Marmond @ 2008-12-04 20:55 UTC (permalink / raw)
To: blurrpp; +Cc: linux-assembly
Hi Luke,
maybe this document may answer your question:
http://www.x86-64.org/documentation/abi.pdf
Have a particular look to section 3.2
Fred
Le Thursday 04 December 2008 à 21:20, £ukasz a écrit :
> Hi.
> I started to write assembler functions for C on 64-bit arch. On 32-bit
> arch. every parameters ware put on stack, now is different, what can be
> easyly seen reading source program. For example if im passing one (int *)
> parameter, adress (&int) is kept in %rdi register, and so one if u are
> passing more parameters. Ofcurse is not dificult to use it if u know but is
> there any key according to which parameters are stored?. I've made some
> "experiments" with different numbers and kind parameters, but the "key"
> must be described somewhere.
>
> Luke
>
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-assembly"
> in the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
--
DeepSee project, few links:
web: http://www.sand-labs.org/deepsee
blog: http://fmarmond.blogspot.com/search/label/DeepSee
twitt: http://twitter.com/fmarmond
IRC: #deepsee on freenode
--
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Passing parameters to assembler functions in 'C' 64 style.
2008-12-04 20:20 Passing parameters to assembler functions in 'C' 64 style £ukasz
2008-12-04 20:54 ` Robert Plantz
2008-12-04 20:55 ` Frederic Marmond
@ 2008-12-04 21:22 ` £ukasz
2 siblings, 0 replies; 4+ messages in thread
From: £ukasz @ 2008-12-04 21:22 UTC (permalink / raw)
To: linux-assembly
Thank You for answers. It helps a lot ( of course i chacked what gcc is doing with -S option, but i haven't enough time to chack what compiler would do witch ex. 1000 parameters of different kinds( if there exist some body who would wants to create such function, without using for ex. struc ;)), so i guess that there must be a 'key'). Any way thanks to U i have some clue.
Luke
--- On Thu, 12/4/08, £ukasz <blurrpp@yahoo.com> wrote:
> From: £ukasz <blurrpp@yahoo.com>
> Subject: Passing parameters to assembler functions in 'C' 64 style.
> To: linux-assembly@vger.kernel.org
> Date: Thursday, December 4, 2008, 9:20 PM
> Hi.
> I started to write assembler functions for C on 64-bit
> arch. On 32-bit arch. every parameters ware put on stack,
> now is different, what can be easyly seen reading source
> program. For example if im passing one
> (int *) parameter, adress (&int) is kept in %rdi
> register, and so one if u are passing more parameters.
> Ofcurse is not dificult to use it if u know but is there any
> key according to which parameters are stored?. I've made
> some "experiments" with different numbers and kind
> parameters, but the "key" must be described
> somewhere.
>
> Luke
>
>
>
> --
> To unsubscribe from this list: send the line
> "unsubscribe linux-assembly" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at
> http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-12-04 21:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-04 20:20 Passing parameters to assembler functions in 'C' 64 style £ukasz
2008-12-04 20:54 ` Robert Plantz
2008-12-04 20:55 ` Frederic Marmond
2008-12-04 21:22 ` £ukasz
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.