ARM_LED实现

.text 
.global _start
_start: 
@1.RCC时钟使能GPIOE   RCC_MP_AHB4ENSETR[4]->1

LDR R0,=0x50000a28
LDR R1,[R0]
ORR R1,R1,#(0x1<<4)
STR R1,[R0]

@2.设置PE10为输出模式  GPIOE_MODER[21:20]->01
    
LDR R0,=0x50006000
LDR R1,[R0]
BIC R1,R1,#(0x3<<20)
ORR R1,R1,#(0x1<<20)
STR R1,[R0]

@3.设置PE10为推挽输出  GPIOE_OTYPER[10]->0

LDR R0,=0x50006004
LDR R1,[R0]
BIC R1,R1,#(0x1<<10)
STR R1,[R0]

@4.设置PE10为低速输出  GPIOE_OSPEEDR[21:20]->00

LDR R0,=0x50006008
LDR R1,[R0]
BIC R1,R1,#(0x3<<20)
STR R1,[R0]

@5.设置PE10输出无上拉下拉 GPIOE_PUPDR[21:20]->00

LDR R0,=0x5000600C
LDR R1,[R0]
BIC R1,R1,#(0x3<<20)
STR R1,[R0]

@led2
ldr r2,=0x50000a28
ldr r3,[r2]
orr r3,r3,#(0x1<<5)
str r3,[r2]

ldr r2,=0x50007000
ldr r3,[r2]
bic r3,r3,#(0x3<<20)
orr r3,r3,#(0x1<<20)
str r3,[r2]

ldr r2,=0x50007004
ldr r3,[r2]
bic r3,r3,#(0x1<<10)
str r3,[r2]

ldr r2,=0x50007008
ldr r3,[r0]
bic r3,r3,#(0x3<<20)
str r3,[r0]

ldr r2,=0x5000700C
ldr r3,[r0]
bic r3,r3,#(0x3<<20)
str r3,[r0]

@led3
ldr r4,=0x50000a28
ldr r5,[r4]
orr r5,r5,#(0x1<<4)
str r5,[r4]

ldr r4,=0x50006000
ldr r5,[r4]
bic r5,r5,#(0x3<<16)
orr r5,r5,#(0x1<<16)
str r5,[r4]

ldr r4,=0x50006004
ldr r5,[r4]
bic r5,r5,#(0x1<<8)
str r5,[r4]

ldr r4,=0x50006008
ldr r5,[r4]
bic r5,r5,#(0x3<<16)
str r5,[r4]

ldr r4,=0x5000600C
ldr r5,[r4]
bic r5,r5,#(0x3<<16)
str r5,[r4]

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]
ORR 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] 
mov pc,lr

led2_on:
ldr r2,=0x50007014
ldr r3,[r2]
orr r3,r3,#(0x1<<10)
str r3,[r2]
mov pc,lr

led2_off:
ldr r2,=0x50007014
ldr r3,[r2]
bic r3,r3,#(0x1<<10)
str r3,[r2]
mov pc,lr

led3_on:
ldr r4,=0x50006014
ldr r5,[r4]
orr  r5,r5,#(0x1<<8)
str r5,[r4]
mov pc,lr

led3_off:
ldr r4,=0x50006014
ldr r5,[r4]
bic r5,r5,#(0x1<<8)
str r5,[r4]
mov pc,lr

@封装汇编的延时函数
delay:
    LDR R1,=0X10000000
mm:
    cmp R1,#0
    SUBNE R1,R1,#1
    BNE mm
    mov pc,lr	

.end

你可能感兴趣的:(arm开发)