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
标签:mov,helloworld,start,x8,20230813,64,arm64,linux From: https://www.cnblogs.com/yangdinshan/p/17629170.html