Immagino dipenda dall'architettura e dal compilatore, comunque ho fatto una veloce prova con GCC (MingW perchè sono su Windows) su x86_64 e l'assembly generato è identico, quindi penso si possa dedurre che non c'è alcuna differenza.
In altre parole ho fatto:
test.c
#include <stdio.h>
int main(){
for(;;){
printf("ciao\n");
}
return 0;
}
test1.c
#include <stdio.h>
int main(){
while(1){
printf("ciao\n");
}
return 0;
}
Eseguito i comandi
gcc -S test.c
gcc -S test1.c
E ottenuto i seguenti risultati:
test.s
.file "test.c"
.def __main; .scl 2; .type 32; .endef
.section .rdata,"dr"
.LC0:
.ascii "ciaoImmagino dipenda dall'architettura e dal compilatore, comunque ho fatto una veloce prova con GCC (MingW perchè sono su Windows) su x86_64 e l'assembly generato è identico, quindi penso si possa dedurre che non c'è alcuna differenza.
In altre parole ho fatto:
test.c
#include <stdio.h>
int main(){
for(;;){
printf("ciao\n");
}
return 0;
}
test1.c
#include <stdio.h>
int main(){
while(1){
printf("ciao\n");
}
return 0;
}
Eseguito i comandi
gcc -S test.c
gcc -S test1.c
E ottenuto i seguenti risultati:
test.s
.file "test.c"
.def __main; .scl 2; .type 32; .endef
.section .rdata,"dr"
.LC0:
.ascii "ciao{parsed_message}"
.text
.globl main
.def main; .scl 2; .type 32; .endef
.seh_proc main
main:
pushq %rbp
.seh_pushreg %rbp
movq %rsp, %rbp
.seh_setframe %rbp, 0
subq , %rsp
.seh_stackalloc 32
.seh_endprologue
call __main
.L2:
leaq .LC0(%rip), %rcx
call puts
jmp .L2
.seh_endproc
.ident "GCC: (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 5.1.0"
.def puts; .scl 2; .type 32; .endef
test1.s
.file "test1.c"
.def __main; .scl 2; .type 32; .endef
.section .rdata,"dr"
.LC0:
.ascii "ciao{parsed_message}"
.text
.globl main
.def main; .scl 2; .type 32; .endef
.seh_proc main
main:
pushq %rbp
.seh_pushreg %rbp
movq %rsp, %rbp
.seh_setframe %rbp, 0
subq , %rsp
.seh_stackalloc 32
.seh_endprologue
call __main
.L2:
leaq .LC0(%rip), %rcx
call puts
jmp .L2
.seh_endproc
.ident "GCC: (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 5.1.0"
.def puts; .scl 2; .type 32; .endef
Per trovare le differenze ho lanciato da shell MSYS:
diff test.s test1.s
E ho ottenuto come output:
1c1
< .file "test.c"
---
> .file "test1.c"
Ovvero l'unica differenza è (ovviamente) nel nome del file sorgente che viene lasciato nell'assembly (se non sbaglio) come informazione di debug."
.text
.globl main
.def main; .scl 2; .type 32; .endef
.seh_proc main
main:
pushq %rbp
.seh_pushreg %rbp
movq %rsp, %rbp
.seh_setframe %rbp, 0
subq , %rsp
.seh_stackalloc 32
.seh_endprologue
call __main
.L2:
leaq .LC0(%rip), %rcx
call puts
jmp .L2
.seh_endproc
.ident "GCC: (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 5.1.0"
.def puts; .scl 2; .type 32; .endef
test1.s
.file "test1.c"
.def __main; .scl 2; .type 32; .endef
.section .rdata,"dr"
.LC0:
.ascii "ciaoImmagino dipenda dall'architettura e dal compilatore, comunque ho fatto una veloce prova con GCC (MingW perchè sono su Windows) su x86_64 e l'assembly generato è identico, quindi penso si possa dedurre che non c'è alcuna differenza.
In altre parole ho fatto:
test.c
#include <stdio.h>
int main(){
for(;;){
printf("ciao\n");
}
return 0;
}
test1.c
#include <stdio.h>
int main(){
while(1){
printf("ciao\n");
}
return 0;
}
Eseguito i comandi
gcc -S test.c
gcc -S test1.c
E ottenuto i seguenti risultati:
test.s
.file "test.c"
.def __main; .scl 2; .type 32; .endef
.section .rdata,"dr"
.LC0:
.ascii "ciao{parsed_message}"
.text
.globl main
.def main; .scl 2; .type 32; .endef
.seh_proc main
main:
pushq %rbp
.seh_pushreg %rbp
movq %rsp, %rbp
.seh_setframe %rbp, 0
subq , %rsp
.seh_stackalloc 32
.seh_endprologue
call __main
.L2:
leaq .LC0(%rip), %rcx
call puts
jmp .L2
.seh_endproc
.ident "GCC: (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 5.1.0"
.def puts; .scl 2; .type 32; .endef
test1.s
.file "test1.c"
.def __main; .scl 2; .type 32; .endef
.section .rdata,"dr"
.LC0:
.ascii "ciao{parsed_message}"
.text
.globl main
.def main; .scl 2; .type 32; .endef
.seh_proc main
main:
pushq %rbp
.seh_pushreg %rbp
movq %rsp, %rbp
.seh_setframe %rbp, 0
subq , %rsp
.seh_stackalloc 32
.seh_endprologue
call __main
.L2:
leaq .LC0(%rip), %rcx
call puts
jmp .L2
.seh_endproc
.ident "GCC: (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 5.1.0"
.def puts; .scl 2; .type 32; .endef
Per trovare le differenze ho lanciato da shell MSYS:
diff test.s test1.s
E ho ottenuto come output:
1c1
< .file "test.c"
---
> .file "test1.c"
Ovvero l'unica differenza è (ovviamente) nel nome del file sorgente che viene lasciato nell'assembly (se non sbaglio) come informazione di debug."
.text
.globl main
.def main; .scl 2; .type 32; .endef
.seh_proc main
main:
pushq %rbp
.seh_pushreg %rbp
movq %rsp, %rbp
.seh_setframe %rbp, 0
subq , %rsp
.seh_stackalloc 32
.seh_endprologue
call __main
.L2:
leaq .LC0(%rip), %rcx
call puts
jmp .L2
.seh_endproc
.ident "GCC: (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 5.1.0"
.def puts; .scl 2; .type 32; .endef
Per trovare le differenze ho lanciato da shell MSYS:
diff test.s test1.s
E ho ottenuto come output:
1c1
< .file "test.c"
---
> .file "test1.c"
Ovvero l'unica differenza è (ovviamente) nel nome del file sorgente che viene lasciato nell'assembly (se non sbaglio) come informazione di debug.