Android ARM 匯編學習(一)
hello.S
本文引用地址:http://butianyuan.cn/article/201611/317577.htm.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
評論