如果没有开发板,可以使用qemu来学习aarch64指令。
安装qemu和aarch64 toolchain
1 | $ sudo apt-get install qemu-user gcc-aarch64-linux-gnu |
test.c,打印hello world
1 2 3 4 5 6 7 8 | $ cat test.c #include <stdio.h> int main(int argc, char **argv) { printf("hello world\n"); return 0; } |
编译,执行
1 2 3 | $ aarch64-linux-gnu-gcc -static test.c $ qemu-aarch64 a.out hello world |
注意使用-static选项,因为一些库文件没有安装在host上,否则会提示:
1 2 | $ qemu-aarch64 a.out /lib/ld-linux-aarch64.so.1: No such file or directory |
参考
http://thinkingeek.com/2016/10/08/exploring-aarch64-assembler-chapter1/