Quote:
|
Il file. asm è uguale al .s?
|
Cosa intendi per "uguale"?
Ogni compilatore genera un codice binario diverso, quindi i file .asm/.s in generale non sono uguali se creati da compilatori differenti.
Per esempio
GNU GCC tira fuori (partendo dall'Hello World) il seguente file prova.s:
Codice:
.file "test.c"
.def ___main; .scl 2; .type 32; .endef
.section .rdata,"dr"
LC0:
.ascii "CIAO MONDO!\0"
.text
.p2align 4,,15
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
leal 4(%esp), %ecx
andl $-16, %esp
pushl -4(%ecx)
pushl %ebp
movl %esp, %ebp
pushl %ecx
subl $4, %esp
call ___main
movl $LC0, (%esp)
call _puts
addl $4, %esp
xorl %eax, %eax
popl %ecx
popl %ebp
leal -4(%ecx), %esp
ret
.def _puts; .scl 2; .type 32; .endef
Se preferisci la sintassi Intel:
Codice:
.file "test.c"
.intel_syntax
.def ___main; .scl 2; .type 32; .endef
.section .rdata,"dr"
LC0:
.ascii "CIAO MONDO!\0"
.text
.p2align 4,,15
.globl _main
.def _main; .scl 2; .type 32; .endef
_main:
lea ecx, [esp+4]
and esp, -16
push DWORD PTR [ecx-4]
push ebp
mov ebp, esp
push ecx
sub esp, 4
call ___main
mov DWORD PTR [esp], OFFSET FLAT:LC0
call _puts
add esp, 4
xor eax, eax
pop ecx
pop ebp
lea esp, [ecx-4]
ret
.def _puts; .scl 2; .type 32; .endef
Se invece usi il compilatore
Borland:
Codice:
.386p
ifdef ??version
if ??version GT 500H
.mmx
endif
endif
model flat
ifndef ??version
?debug macro
endm
endif
?debug S "test.c"
?debug T "test.c"
_TEXT segment dword public use32 'CODE'
_TEXT ends
_DATA segment dword public use32 'DATA'
_DATA ends
_BSS segment dword public use32 'BSS'
_BSS ends
DGROUP group _BSS,_DATA
_TEXT segment dword public use32 'CODE'
_main proc near
?live1@0:
;
; int main(void){
;
push ebp
mov ebp,esp
;
; puts("CIAO MONDO!");
;
@1:
push offset s@
call _puts
pop ecx
;
; return 0;
;
xor eax,eax
;
; }
;
@3:
@2:
pop ebp
ret
_main endp
_TEXT ends
_DATA segment dword public use32 'DATA'
s@ label byte
; s@+0:
db "CIAO MONDO!",0
align 4
_DATA ends
_TEXT segment dword public use32 'CODE'
_TEXT ends
public _main
extrn _puts:near
?debug D "test.c" 14468 26281
end