tc2里面有一个tcc的命令行编译器,可以直接生成汇编源代码!!!
比如有个a.c的文件:
int max(int x,int y)
{
return x>y?x:y;
}
int main(void)
{
int a=2;
int b=3;
int d=4;
d = max(a,b);
return 0;
}
在命令行下面直接敲tcc显示帮助,,里面显示-S选项是输出汇编代码
tcc -S a.c
生成以下代码:
ifndef ??version
?debug macro
endm
endif
?debug S "a.c"
_TEXT segment byte public 'CODE'
DGROUP group _DATA,_BSS
assume cs:_TEXT,ds:DGROUP,ss:DGROUP
_TEXT ends
_DATA segment word public 'DATA'
d@ label byte
d@w label word
_DATA ends
_BSS segment word public 'BSS'
b@ label byte
b@w label word
?debug C E955ADE24603612E63
_BSS ends
_TEXT segment byte public 'CODE'
; ?debug L 1
_max proc near
push bp
mov bp,sp
; ?debug L 3
mov ax,word ptr [bp+4]
cmp ax,word ptr [bp+6]
jle @3
mov ax,word ptr [bp+4]
jmp short @2
@3:
mov ax,word ptr [bp+6]
@2:
jmp short @1
@1:
; ?debug L 4
pop bp
ret
_max endp
; ?debug L 6
_main proc near
push bp
mov bp,sp
sub sp,2
push si
push di
; ?debug L 8
mov si,2
; ?debug L 9
mov di,3
; ?debug L 10
mov word ptr [bp-2],4
; ?debug L 12
push di
push si
call near ptr _max
pop cx
pop cx
mov word ptr [bp-2],ax
; ?debug L 14
xor ax,ax
jmp short @4
@4:
; ?debug L 15
pop di
pop si
mov sp,bp
pop bp
ret
_main endp
_TEXT ends
?debug C E9
_DATA segment word public 'DATA'
s@ label byte
_DATA ends
_TEXT segment byte public 'CODE'
_TEXT ends
public _max
public _main
end
呵呵,直接看了,不用在debug里面看了,想研究,做研究更方便. |