15.3.1 void f(int32 p0, int16 p1, void *p2) caller: pushl ... # p2 pushw ... # p1 pushl ... # p0 call sub1 sub1: pushl %ebp movl %esp,%ebp nop =============================================== ????? <- ESP =============================================== pushl ... # p2 ????? <- ESP =============================================== pushw # p1 ????? <- ESP =============================================== pushl # p0 ????? <- ESP ============================================== call sub1 ????? <- ESP ============================================== pushl %ebp ????? <- ESP ============================================== movl %esp,%ebp ????? <- EBP+14 <- EBP+12 <- EBP+8 <- EBP+4 <- ESP <- EBP+0 the parameter p0 can be accessed as 8(%ebp) ============================================== void sub1(int32 *pI, int32 v) { *pI = v; } <- EBP+12 <- EBP+8 <- EBP+4 <- EBP in assembly: oldBp = 0 retAddr = oldBp + 4 pI = retAddr + 4 v = pI + 4 sub1: pushl %ebp movl %esp,%ebp movl v(%ebp),%eax movl pI(%ebp),%ebx movl %eax,(%ebx) movl %ebp,%esp popl %ebp ret static int i sub1(&i, 0xabcd) .data i: .long 0 .text pushl $0xabcd pushl $i call sub1 addl $8,%esp ========================================== 15.3.2 void sub1(void) { char cmpChar; char *strPtr; char strBuffer[32]; ... } <- EBP ... <- EBP-32 <- EBP-36 <- ESP <- EBP-38 oldBp = 0 retAddr = oldBp + 4 strBuffer = oldBp - 32 strPtr = strBuffer - 4 cmpChar = strPtr - 2 sub1: pushl %ebp movl %esp,%ebp addl $cmpChar,%esp movl %ebp,%esp popl %ebp ret ========================================== struct XYZ { int x; char buffer[128] float f; }; struct XYZ sub1(void) { struct XYZ localvar; ... return localvar; } caller: sub1: pushl %ebp movl %esp,%ebp addl $localvar,%esp movl %ebp,%esp popl %ebp ret ======================================== sub1("asdf",23,13); struct XYZ sub1(char *ptr,...) { int *nextParam; nextParam = (int*)(&ptr+1); *nextParam } printf("%f %u...",0.2,300);