x64/ia64 Assemly Instructions in Code Porting

gangti
Total Points:
35
Registered User
July 2, 2009 9:52 PM PDT
Rate
 
#2 Reply to #1
Quoting - srimks

Ans.[A]: The calling convention for 64-bit Windows is - the first parameter is transferred in RCX if it is an integer or in XMM0 if it is a float or double, second in RDX or XMM1, third in RB or XMM2 and fourth in R9 or in XMM9. No more than 4 parameters can be transferred in registers, ragardless of types. Any further parameters are transferred on the stack with the first parameter at the lowest address & aligned by 8.
                                                                       While in Linux, first six parameters are transferred in RDI, RSI, RDX, RCX, R8 & R9 resp.. The first 8 floating-point parameters are transferred in XMM0 - XMM7. All these registers can be used, so in maximum fourteen parameters can be transferred in registers. Any further parameters are transferred in stack with first parameter at the lowest address and aligned by 8.

Note that 64-bit Linux does not use the same registers for parameters transfer as done by 64-bit Windows. Also, for 64-bit, the calling save status registers for Windows(SI, RDI, XMM6 - XMM15) are different form Linux which means that calling conventions are different for Windows and Linux for 64-bit.

All compilers for 64-bit Windows use the COFF/PE32+ format, while compilers for Linux use ELF64 format.

HIH.

~BR
Mukkaysh Srivastav

I appreciate you answer of my question, and the whole knowledge of calling conventions.

My problem is that I just want to modify the arguments from 5 to 9 as following
code shows, for windows x64. Am I right or not?
I want to get an official answer from intel to persuade my boss. So I am looking
forward to you reply...
==================================================
#undef NULL
#define NULL 0
void main() {
func(NULL,NULL,NULL,NULL,(char*)NULL,
(char*)NULL,(char*)NULL,(char*)NULL,(char*)NULL);
}
void func(char *arg1, char *arg2, char *arg3,
char *arg4, char *arg5, char *arg6,
char *arg7, char *arg8, char *arg9)
{
//
}
==================================================

Though another way to approach this is to give an explictit prototype, I give the
above approach first. It's a pity that  I cannot change the approach now.

Intel Software Network Forums Statistics

8481 users have contributed to 31614 threads and 100679 posts to date.
In the past 24 hours, we have 31 new thread(s) 115 new posts(s), and 168 new user(s).

In the past 3 days, the most popular thread for everyone has been gemm(A,A,A) like possible? The most posts were made to gemm(A,A,A) like possible? The post with the most views is Dear Steve, excuse me for a d

Please welcome our newest member rohit5575