From: Stuart M. <stu...@st...> - 2002-04-23 10:41:04
|
Adrian This is something I wrote a while ago when somebody asked the same question (I assume were talking gcc here). Simply: - r0-r7 are caller save (ie the called function can use them without having to save them first) - r8-r15 and pr are callee save (ie if the called function wants to update them then it must save them first) - First four integer parameters are passed in register r4-r7, remainder on the stack - r15 is the stack pointer, so will generally by saved/restored automatically, and r14 is the frame pointer, which you may or may not choose to use. - r0 is used for the return value, if it fits in a word, otherwise the function is called with r2 as a pointer to where the result should be stored. Floating point I'm not so sure about, and can be complex, but basically: - fr0-fr11 are caller save fr12-fr15 are callee save - Parameters are passed in dr4-dr10 (which corrisponds to fr4-fr11), but when a mix of floats and doubles are passed they are 'packed' into the lower registers, possibly 'rounding up' to get the next available double length register. The remainder are on the stack. In general the easiest way to do anything with this is experiment. Try writing a small C program which does what you want, and look at the generated assembler. So for your example: foobar(int32 x, void* y, int16 z) x, y and z will be in r4, r5 and r6 respectivly. Hope this is some help Stuart On Mon, 22 Apr 2002 22:42:38 +0100 ad...@mc... wrote: > if I have a function in C - say: > > foobar(int32 x, void* y, int16 z) > > When that turns up in SH4 assembler - how are the parameters passed? > > Adrian > > _______________________________________________ > Linuxdc-dev mailing list > Lin...@li... > https://lists.sourceforge.net/lists/listinfo/linuxdc-dev -- Stuart Menefy stu...@st... STMicroelectronics Ltd ST Intranet: mo.bri.st.com Bristol, UK Rest of the World: www.linuxsh.st.com |