i386 vs. AMD64 ABI Differences

眉间皱痕 提交于 2019-11-26 21:52:38

问题


Where can I find all the differences in data types between the i386 & AMD64 Application Binary Interface(ABI)s ?

I know that the long type is 32-bit in i386 ABI & 64-bit in AMD64. Is this correct?


回答1:


I suggest you download Dr Agner Fog's optimization manuals. He has a manual specifically about ABIs and their differences.

For differences in the instruction set between 32-bit mode and 64-bit mode, both Intel and AMD's instruction manuals should cover this in the introductory volume or the volumes after the instruction volumes(2a and 2b for Intel's instruction set reference, or 2 and 3 for AMD.)

See also other links in the x86 tag wiki.




回答2:


If you need all of the ABI details: subroutine calling conventions, which registers get what passed in them, which registers must be restored on return, exception handling -- which is completely different, there is a document you can download from Microsoft for the Windows ABI.

On the other hand, if you're just interested in data types, it only takes a couple of minutes to write a program that does:

fprintf (stdout, "size of int is %d\n", sizeof(int));
fprintf (stdout, "size of long int is %d\n", sizeof(long int));
// etc.

EDIT 4/7/11 to respond:

This link http://msdn.microsoft.com/en-us/library/7kcdt6fy.aspx works currently. No promises that MSFT won't move it tomorrow! Or Google "application binary interface site:microsoft.com"

All x86-64 OSes other than Windows use the x86-64 System V psABI. See Where is the X86-64 ABI documented?

The ABIs are defined by the operating systems and the compilers, not the hardware architects. For example, it's up to the compiler writers to decided whether a C/C++ int is 32 bits and a long int is 64 (x86-64 System V) -- or if both are 32-bit (x64 Windows), or even an int is 64 and a long int is 64, too (as some Fortran compilers do) -- or even int is 64 and long int is 128 or any other combination you can imagine. Intel and AMD can make recommendations, but the compiler writers and OS vendors are in control.



来源:https://stackoverflow.com/questions/5554856/i386-vs-amd64-abi-differences

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!