20230813 arm64 汇编学习 helloworld.s
Programming with 64-Bit ARM Assembly Language Single Board Computer Development for Raspberry Pi and Mobile Devices —Stephen Smith
32 bits ARM64指令:
// //Assembly program to print "helloworld" to stdout // //x0-x2 parameters to linux function services //x8 linux function number .global _start // program starting address _start: mov x0,1 //1 is linux stdout ldr x1,=helloworld //string to print mov x2,13 //length to write to stdout mov x8,64 //64 is linux write system call svc 0 //call linux to output the string //setup the parameters to exit the program then call linux to do it mov x0,0 //return num mov x8,93 //service code 93 terminates svc 0 .data helloworld: .ascii "Hello World!\n------\n"
echo $? //获取上个程序的返回值或退出代码
_start 是程序的入口点,程序可以由很多文件链接,但是只能有一个 _start ;
svc 0 执行软中断0,linux内核中断处理程序寄存器器中的相应内容执行相应处理;
.data 表示后面的内容放在程序的数据段
标签 helloworld: 后面的 .ascii 是编码方式,后面的""内是具体内容;ldr 里面的 =helloworld 就是引用标签 获取内容;
#64 是linux的write 命令,系统调用num放在x8;
逆向, objdump -s -d helloworld.o
第一行表示 文件是arm64 小端 elf格式
.text里面是8行汇编代码转化成的8条指令;每个指令是32bit,4byte,一行4个指令,16byte
.data 保存的string
https://github.com/Apress/Programming-with-64-Bit-ARM-Assembly-Language 获取书中源码
git clone https://github.com/Apress/programming-with-64-bit-ARM-assembly-language.git
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列1:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
· 25岁的心里话