void foo(SInt32 i, float f, double d, SInt16 s, UInt8 c);
Figure 2 Argument assignment with arguments of the fundamental data types
typedef struct {
|
float ary[8]; |
} big_struct; |
void callee(big_struct *p, int a, float b) |
{
|
big_struct callee_struct; |
... |
*p = callee_struct; |
return; |
} |
caller() {
|
big_struct caller_struct; |
callee(&caller_struct, 3, 42.0); |
} |
| Type | Name | Preserved | Notes |
|---|---|---|---|
| General-purpose register | EAX | No | Used to return integral and pointer values. The caller may also place the address to storage where the callee places its return value in this register. |
| EDX | No | Dividend register (divide operation). Available for general use for all other operations. | |
| ECX | No | Count register (shift and string operations). Available for general use for all other operations. | |
| EBX | Yes | Position-independent code base register. Available for general use in non–position-independent code. | |
| EBP | Yes | Stack frame pointer. Optionally holds the base address of the current stack frame. A routine’s parameters reside in the previous frame as positive offsets of this register’s value. Local variables reside at negative offsets. | |
| ESI | Yes | Available for general use. | |
| EDI | Yes | Available for general use. | |
| Stack-pointer register | ESP | Yes | Holds the address of the bottom of the stack. |
本文详细介绍了IA-32架构下的运行时环境,包括函数调用规范、参数传递、返回结果规则以及函数调用过程中的帧指针操作。在IA-32中,caller需将参数压栈并保存返回地址,callee则负责保存和恢复特定寄存器、分配局部变量空间。参数传递遵循从右到左的顺序,并进行对齐处理。返回值通常存储在EAX或STO寄存器中,结构体返回值可能涉及额外的指针参数。
2514

被折叠的 条评论
为什么被折叠?



