why the "format" is in a .text field?
.text in assembly means "code section"
gcc -nostdlib file.s -o program Why do I get an error? /universe/earth/asm/file.s:14: undefined reference to `_printf' collect2: ld returned 1 exit status
you are not linking the standard libraries, where printf is located (-nostdlib option): the linker cannot find it
how to fix this error?
Either link the standard library (stdlib) explicitly, or link another library that provides a printf implementation, or remove the -nostdlib switch
Why the function print: isn't called in main field?
"print" is just a label: you can call it, jmp to it, or just let the control flow of the program go into it, as in this case. (I can tell that print is not a "function" because it lacks a proper prologue).
May I suggest you some assembly introductions?
- http://asm.sourceforge.net/intro.html
- http://en.wikibooks.org/wiki/X86_Assembly/Introduction
- http://www.tldp.org/HOWTO/html_single/Assembly-HOWTO/
Or many others you can find on the internet