Hello assembly (x86 GAS)

.global _start
_start:

  movl    $len,%edx         # third argument: message length
  movl    $msg,%ecx         # second argument: pointer to message to write
  movl    $1,%ebx           # first argument: file handle (stdout)
  movl    $4,%eax           # system call number (sys_write)
  int     $0x80             # call kernel

                            # and exit

  movl    $0,%ebx           # first argument: exit code
  movl    $1,%eax           # system call number (sys_exit)
  int     $0x80             # call kernel

.data # section declaration

  msg:
  .ascii    "Hello, world!\n"   # our dear string
  len = . - msg                 # length of our dear string`
    原文作者:dreambei
    原文地址: https://segmentfault.com/a/1190000000601254
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞