作业1
.text
.global _start
_start:
mov r0,#9
mov r1,#15
Loop:
cmp r0,r1
beq stop
subhi r0,r1
subcc r1,r0
b Loop
stop:
b stop
.end
作业2
用汇编for循环实现1~100之间的和
.text
.global _start
_start:
mov r0,#1 @int i=1
mov r1,#0 @int sum=0
bl sum
stop:
b stop
sum:
cmp r0,#100 @i<=100
add r1,r0 @sum+=i
add r0,#1 @i++
moveq pc,lr
b sum
.end
作业3
.text
.global _start
_start:
ldr r0,=0x40000800
ldr r1,=0x11111111
ldr r2,=0x22222222
ldr r3,=0x33333333
@ [0x40000804]=0x11111111 r0=0x40000800
str r1,[r0,#4]
@ [0x40000800]=0x22222222 r0=0x40000804
str r2,[r0],#4
@ [0x40000808]=0x33333333 r0=0x40000808
str r3,[r0,#4]!
.end