Skip to content

Instantly share code, notes, and snippets.

@thinkhy
Created February 10, 2011 12:50
Show Gist options
  • Save thinkhy/820457 to your computer and use it in GitHub Desktop.
Save thinkhy/820457 to your computer and use it in GitHub Desktop.
汇编代码由cl.exe /FAs输出
TITLE test.c
.386P
include listing.inc
if @Version gt 510
.model FLAT
else
_TEXT SEGMENT PARA USE32 PUBLIC 'CODE'
_TEXT ENDS
_DATA SEGMENT DWORD USE32 PUBLIC 'DATA'
_DATA ENDS
CONST SEGMENT DWORD USE32 PUBLIC 'CONST'
CONST ENDS
_BSS SEGMENT DWORD USE32 PUBLIC 'BSS'
_BSS ENDS
_TLS SEGMENT DWORD USE32 PUBLIC 'TLS'
_TLS ENDS
FLAT GROUP _DATA, CONST, _BSS
ASSUME CS: FLAT, DS: FLAT, SS: FLAT
endif
PUBLIC ___cdecl_func
_TEXT SEGMENT
_a$ = 8
_b$ = 12
_c$ = 16
_fmt$ = 20
_args$ = -4
___cdecl_func PROC NEAR
; 4 : void __cdecl __cdecl_func(int a,int b,int c,const char* fmt, ...) {
push ebp
mov ebp, esp
push ecx
; 5 : va_list args;
; 6 : va_start(args, fmt);
lea eax, DWORD PTR _fmt$[ebp+4]
mov DWORD PTR _args$[ebp], eax
; 7 : // result->size = vsprintf(result->buf, fmt, args);
; 8 : va_end(args);
mov DWORD PTR _args$[ebp], 0
; 9 :
; 10 : a = 0;
mov DWORD PTR _a$[ebp], 0
; 11 : b = 0;
mov DWORD PTR _b$[ebp], 0
; 12 : c = 0;
mov DWORD PTR _c$[ebp], 0
; 13 : }
mov esp, ebp
pop ebp
ret 0
___cdecl_func ENDP
_TEXT ENDS
PUBLIC ___stdcall_func@12 _TEXT SEGMENT
_a$ = 8
_b$ = 12
_c$ = 16
___stdcall_func@12 PROC NEAR
; 15 : void __stdcall __stdcall_func(int a,int b,int c) {
push ebp
mov ebp, esp
; 16 : a = 0;
mov DWORD PTR _a$[ebp], 0
; 17 : b = 0;
mov DWORD PTR _b$[ebp], 0
; 18 : c = 0;
mov DWORD PTR _c$[ebp], 0
; 19 : }
pop ebp
ret 12 ; 0000000cH
___stdcall_func@12 ENDP
_TEXT ENDS
PUBLIC _main
EXTRN _printf:NEAR
_DATA SEGMENT
$SG360 DB '%d', 00H
ORG $+1
$SG361 DB '%d %d', 00H
_DATA ENDS
_TEXT SEGMENT
_main PROC NEAR
; 22 : {
push ebp
mov ebp, esp
; 23 : __cdecl_func(1,2,3, "%d", 1);
push 1
push OFFSET FLAT:$SG360
push 3
push 2
push 1
call ___cdecl_func
add esp, 20 ; 00000014H
; 24 : __stdcall_func(1,2,3);
push 3
push 2
push 1
call ___stdcall_func@12
; 25 :
; 26 : printf("%d %d", 1, 2);
push 2
push 1
push OFFSET FLAT:$SG361
call _printf
add esp, 12 ; 0000000cH
; 27 : return 0;
xor eax, eax
; 28 : }
pop ebp
ret 0
_main ENDP
_TEXT ENDS
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment