linux程序汇编,linux 64位汇编之hello world
64位linux下尝试用nasm写汇编程序,
系统调用的参数在man page的第二章
系统调用号可以在文件
/usr/include/x86_64-linux-gnu/asm/unistd_64.h
中查到
section .data
msg db "Hello,World!",10
len:equ $-msg
section .text
global _start
_start:
mov rax,1 ;系统调用号
mov rdi,1 ;参数1,stdout
mov rsi,msg ;参数2
mov rdx,len ;参数3
syscall ;系统调用
mov rax,60 ;exit调用号
mov rdi,0 ;exit状态,参数1
syscall ;系统调用
上面内容保存在文件hel.asm中
编译
nasm -g -f elf64 hel.asm
链接
ld -g -o hello hel.o
64位linux下尝试用nasm写汇编程序, 系统调用的参数在man page的第二章 系统调用号可以在文件 /usr/include/x86_64-linux-gnu/asm/unistd_64.h 中查到 section .data msg db "Hello,World!",10 len:equ $-msg section .text global _start _start: mov rax,1 ;系统调用号 mov rdi,1 ;参数1,stdout mov rsi,msg ;参数2 mov rdx,len ;参数3 syscall ;系统调用 mov rax,60 ;exit调用号 mov rdi,0 ;exit状态,参数1 syscall ;系统调用 上面内容保存在文件hel.asm中 编译 nasm -g -f elf64 hel.asm 链接 ld -g -o hello hel.o