Minimal example to compile & run assembly with gcc?
int main(int argc, char* argv[])
{
return 0;
}
what's the shortest assembly example to do the same that can be compiled into an executable by gcc?
I came across this ex开发者_Go百科ample but there're too many tags like hi_temp:,.data
etc,what's the minimal version?
.text
.align 4
.globl main
main:
pushl %ebp
movl %esp,%ebp
xorl %eax,%eax
leave
ret
To compile and run:
$ gcc -m32 asm.S
$ ./a.out
.text
.globl main
main:
xorl %eax,%eax ;return 0
ret
Here's an example of Hello World in assembly, along with an explanation:
http://asm.sourceforge.net/intro/hello.html
精彩评论