Comment appeler "printf" directement sans inclure stdio.h?Un simple programme C sans #include <stdio.h>
J'ai trouvé un tutoriel intéressant ici:
http://www.halcode.com/archives/2008/05/11/hello-world-c-and-gnu-as/
Alors, voici ma tentative:
int main(){
char ss[] = "hello";
asm (
"pushl %ebp ;"
"movl %esp, %ebp ;"
"subl $4, %esp ;"
"movl $ss, (%esp) ;"
"call _printf ;"
"movl $0, %eax ;"
"leave ;"
"ret ;"
);
return 0;
}
J'utilise MinGW 4.4, et voici comment je le compiler:
gcc -c bonjour.c -o bonjour.o
ld bonjour.o -o hello.exe C:/mingw/lib/crt2. o C: /mingw/lib/gcc/mingw32/4.4.0/crtbegin.o C: /mingw/lib/gcc/mingw32/4.4.0/crtend.o -LC:/mingw/lib/gcc/mingw32 /4.4.0 -LC:/MinGW/lib -lmingw32 -lgcc -lmsvcrt -lkernel32
Malheureusement, il échoue:
hello.o. hello.c :(texte + 0x26) : référence non définie à `ss '
Comment résoudre ce problème?
pourquoi devriez-vous? –
@Ahmed - L'apprentissage est-il interdit? L'acquisition des connaissances est-elle désapprouvée? –
bien, juste de la pure curiosité Je sais pratiquement que ce n'est pas important – anta40