LED灯亮灭控制
cs
.text
.global _start
_start:
@1
ldr r0,=0x50000a28
ldr r1,[r0]
orr r1,r1,#(0x3<<4)
str r1,[r0]
@2
ldr r0,=0x50006000
ldr r1,[r0]
bic r1,r1,#(0x3<<20)
orr r1,r1,#(0x1<<20)
bic r1,r1,#(0x3<<16)
orr r1,r1,#(0x1<<16)
str r1,[r0]
ldr r0,=0x50007000
ldr r1,[r0]
bic r1,r1,#(0x3<<20)
orr r1,r1,#(0x1<<20)
str r1,[r0]
@3
ldr r0,=0x50006004
ldr r1,[r0]
bic r1,r1,#(0x1<<10)
bic r1,r1,#(0x1<<8)
str r1,[r0]
ldr r0,=0x50007004
ldr r1,[r0]
bic r1,r1,#(0x1<<10)
str r1,[r0]
@4
ldr r0,=0x50006008
ldr r1,[r0]
bic r1,r1,#(0x3<<20)
bic r1,r1,#(0x3<<16)
str r1,[r0]
ldr r0,=0x50007008
ldr r1,[r0]
bic r1,r1,#(0x3<<20)
str r1,[r0]
@5
ldr r0,=0x5000600c
ldr r1,[r0]
bic r1,r1,#(0x3<<20)
bic r1,r1,#(0x3<<16)
str r1,[r0]
ldr r0,=0x5000700c
ldr r1,[r0]
bic r1,r1,#(0x3<<20)
str r1,[r0]
loop:
bl led1_on
bl delay
bl led1_off
bl delay
bl led2_on
bl delay
bl led2_off
bl delay
bl led3_on
bl delay
bl led3_off
bl delay
b loop
led1_on:
ldr r0,=0x50006014
ldr r1,[r0]
bic r1,r1,#(0x1<<10)
str r1,[r0]
mov pc,lr
led1_off:
ldr r0,=0x50006014
ldr r1,[r0]
bic r1,r1,#(0x1<<10)
str r1,[r0]
led2_on:
ldr r0,=0x50007014
ldr r2,[r0]
bic r2,r2,#(0x1<<8)
str r2,[r0]
mov pc,lr
led2_off:
ldr r0,=0x50007014
ldr r2,[r0]
bic r2,r2,#(0x1<<8)
str r2,[r0]
led3_on:
ldr r0,=0x50006014
ldr r3,[r0]
bic r3,r3,#(0x1<<8)
str r3,[r0]
mov pc,lr
led3_off:
ldr r0,=0x50006014
ldr r3,[r0]
bic r3,r3,#(0x1<<8)
str r3,[r0]
delay:
ldr r4,=0x10000000
mm:
cmp r4,#0
subne r4,r4,#1
bne mm
mov pc,lr
.end