| Thread Tools | Search this thread |
|---|
gangti
| July 1, 2009 9:18 PM PDT x64/ia64 Assemly Instructions in Code Porting | ||||
refer to: http://software.intel.com/en-us/articles/use-explicit-prototyping/#comment-26974 May someone give an answer??? Contents: file.c ================================================== #undef NULL #define NULL 0 void main() { func(NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL); } void func(char *arg1, char *arg2, char *arg3, char *arg4, char *arg5, char *arg6, char *arg7, char *arg8, char *arg9) { // } ================================================== When I port above code from x86 to x64/ia64, I found: A. In windows x64 platform, when compiled with cl (vs2005's x64 cross compiler)the first four param will be transferred to func with universal registers, using mov(same as movzx) assembly instructions, so the upper 32 bits will be zeroed. So in the above code, arg1~arg4 will be transferred correctly, although arg5~arg9 may have problem. But in linux x64 platform, when compiled with cc(gcc's component), I found the first sixth parm will be transferred with universal registers. So in the above code, arg1~arg6 will be transferred correctly, although arg7~arg9 may have problem. B. In windows ia64 platform, when compiled with cl (vs2005's ia64 cross compiler)the first eight param will be transferred to func with universal registers, using mov(upper bits will be signed extended)assembly instruction. In this case, that is 0 extended for the upper bits. The other params will be put in the stack memory, but they will be first put to registers, and then stack memory. So in the above code, all params will be transferred correctly. So the questions is, whether I am right or not? May I rely on the knowledge of intermediate assembly code, and just modify the code as follows for windows x64?????? ================================================== #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) { // } ================================================== Another questions is that, why linux x64 put the first six params to registers while windows x64 put the first four params to registers???? The hardware(cpu especially) is the same, so why shouldn't the calling conventions is the same???? --the end-- | |||||
|
|||||||||||||
|
|||||||||||||
|
|||||||||||||
| 8286 users have contributed to 31231 threads and 99107 posts to date. |
|---|
| In the past 24 hours, we have 7 new thread(s) 31 new posts(s), and 43 new user(s). In the past 3 days, the most popular thread for everyone has been comparison cilk++, openmp, pthreads first results The most posts were made to comparison cilk++, openmp, pthreads first results The post with the most views is Very amusing... Escalated as Please welcome our newest member titanius.anglesmith |