开发者

Minimal example to compile & run assembly with gcc?

开发者 https://www.devze.com 2023-03-16 20:00 出处:网络
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?
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

精彩评论

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