45 lines
677 B
ArmAsm
45 lines
677 B
ArmAsm
|
.data
|
||
|
msg: .asciz "Hello World!\n"
|
||
|
|
||
|
.text
|
||
|
.global _start
|
||
|
_start:
|
||
|
ldr r0,=msg
|
||
|
bl print
|
||
|
mov r0,#0x0
|
||
|
bl exit
|
||
|
|
||
|
exit: @ NORETURN void exit(int code)
|
||
|
@ code already in r0
|
||
|
mov r7,#0x1
|
||
|
svc #0x0
|
||
|
|
||
|
print: @ void print(const char *str)
|
||
|
stmdb sp!,{r0,lr}
|
||
|
|
||
|
@ msg already in r0
|
||
|
bl strlen
|
||
|
|
||
|
mov r2,r0 @ len
|
||
|
ldr r1,[sp] @ msg
|
||
|
mov r7,#0x4 @ SYS_write
|
||
|
mov r0,#1 @ FD_stdout
|
||
|
svc #0x0
|
||
|
|
||
|
ldmia sp!,{r0,lr}
|
||
|
bx lr
|
||
|
|
||
|
strlen: @ u32 strlen(const char *str)
|
||
|
stmdb sp!,{r0,lr}
|
||
|
strlen_loop:
|
||
|
ldrb r1,[r0]
|
||
|
cmp r1,#0
|
||
|
beq strlen_end
|
||
|
|
||
|
add r0,r0,#1
|
||
|
b strlen_loop
|
||
|
strlen_end:
|
||
|
ldmia sp!,{r1,lr}
|
||
|
sub r0,r0,r1
|
||
|
bx lr
|