开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜