首页 > 代码库 > Android ARM 汇编学习(一)
Android ARM 汇编学习(一)
给自己挖了个坑,一切都得从“Hello World”开始。
hello.S
.data msg: .ascii "Hello, World!\n" len = . - msg .text .globl _start _start: /* syscall write(int fd, const void *buf, size_t count) */ mov %r0, $1 /* fd -> stdout */ ldr %r1, =msg /* buf -> msg */ ldr %r2, =len /* count -> len(msg) */ mov %r7, $4 /* write is syscall #4 */ swi $0 /* invoke syscall */ /* syscall exit(int status) */ mov %r0, $0 /* status -> 0 */ mov %r7, $1 /* exit is syscall #1 */ swi $0 /* invoke syscall */
arm-linux-androideabi-as -o hello.o hello.S
arm-linux-androideabi-ld -s -o hello hello.o
adb push hello /data/local/tmp/hello
adb shell /data/local/tmp/hello
本文出自 “易寒” 博客,请务必保留此出处http://fjyihan.blog.51cto.com/2767207/1540181
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。