69,369
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h >
#include "stdarg.h"
void (*error1)(const char *format, ...)
__attribute__((noreturn))
__attribute__((format(printf, 1, 2)));
void simple_va_fun(const char *format,...) ;
void caller1();
int main()
{
caller1();
}
void caller1()
{
error1 = &simple_va_fun;
error1("n=%d,%d,%d,%d,%d,\n", 4,5,4,7,3,8,2,9,100);
}
void simple_va_fun(const char *format,...)
{
va_list arg_ptr;
int nArgValue =3;
int nArgCout=0;
va_start(arg_ptr,format);
do
{
++nArgCout;
printf("the %d th arg: %d",nArgCout,nArgValue);
nArgValue = va_arg(arg_ptr,int);
}while(nArgValue != 100);
return;
}
00401050 <_caller1>:
401050: 55 push %ebp
401051: b8 64 00 00 00 mov $0x64,%eax
401056: 89 e5 mov %esp,%ebp
401058: 83 ec 28 sub $0x28,%esp
40105b: ba e0 10 40 00 mov $0x4010e0,%edx
401060: b9 04 00 00 00 mov $0x4,%ecx
401065: 89 44 24 24 mov %eax,0x24(%esp)
401069: b8 09 00 00 00 mov $0x9,%eax
40106e: 89 44 24 20 mov %eax,0x20(%esp)
401072: b8 02 00 00 00 mov $0x2,%eax
401077: 89 44 24 1c mov %eax,0x1c(%esp)
40107b: b8 08 00 00 00 mov $0x8,%eax
401080: 89 44 24 18 mov %eax,0x18(%esp)
401084: b8 03 00 00 00 mov $0x3,%eax
401089: 89 44 24 14 mov %eax,0x14(%esp)
40108d: b8 07 00 00 00 mov $0x7,%eax
401092: 89 15 20 30 40 00 mov %edx,0x403020
401098: ba 05 00 00 00 mov $0x5,%edx
40109d: 89 44 24 10 mov %eax,0x10(%esp)
4010a1: b8 04 00 00 00 mov $0x4,%eax
4010a6: 89 4c 24 0c mov %ecx,0xc(%esp)
4010aa: 89 54 24 08 mov %edx,0x8(%esp)
4010ae: 89 44 24 04 mov %eax,0x4(%esp)
4010b2: c7 04 24 00 20 40 00 movl $0x402000,(%esp)
4010b9: e8 22 00 00 00 call 4010e0 <_simple_va_fun>
4010be: 66 90 xchg %ax,%ax
004010c0 <_main>:
4010c0: 55 push %ebp
4010c1: b8 10 00 00 00 mov $0x10,%eax
4010c6: 89 e5 mov %esp,%ebp
4010c8: 83 ec 08 sub $0x8,%esp
4010cb: 83 e4 f0 and $0xfffffff0,%esp
4010ce: e8 5d 00 00 00 call 401130 <___chkstk>
4010d3: e8 e8 00 00 00 call 4011c0 <___main>
4010d8: e8 73 ff ff ff call 401050 <_caller1>
4010dd: c9 leave
4010de: c3 ret
4010df: 90 nop