点亮三盏灯

.text 
.global _start
_start: 
@1.RCC时钟使能GPROE	RCC_MP_AHB4ENSERT[4]->1
LDR R0,=0X50000a28
LDR R1,[R0]
ORR R1,R1,#(0x1<<4)
ORR R1,R1,#(0x1<<5)
STR R1,[R0]
@2.设置PE10、PE8、PF10为输出模式 GPIOE_MODER[21:20]->01 [17:16]->01
@先清0
LDR R0,=0x50006000
LDR R2,=0x50007000
LDR R1,[R0]
LDR R3,[R2]
BIC R1,R1,#(0x3<<20)
BIC R1,R1,#(0x3<<16)
BIC R3,r3,#(0x3<<20)
@再置位
ORR R1,R1,#(0x1<<20)
ORR R1,R1,#(0x1<<16)
ORR R3,R3,#(0x1<<20)
STR R1,[R0]
STR R3,[R2]
@3.设置PE10、PE8、PF10为推挽输出 GPTOE_OTYPER[10]->0
LDR R0,=0X50006004
LDR R2,=0x50007004
LDR R1,[R0]
LDR R3,[R2]
BIC R1,R1,#(0x1<<10)
BIC R2,R2,#(0x1<<10)
STR R1,[R0]
STR R3,[R2]
@4.设置PE10、PE8、PF10为低速输出 GPROE_OSPEEDR[21:20]->00 [17:16]->01
LDR R0,=0x50006008
LDR R0,=0x50007008
LDR R1,[R0]
LDR R3,[R2]
BIC R1,R1,#(0X3<<20)
BIC R1,R1,#(0x3<<16)
BIC R3,R3,#(0x3<<20)
STR R1,[R0]
STR R3,[R2]
@5.设置PE10、PE8、PF10输出无上拉无下拉 GPIOE_PUPDR[21:20]->00
LDR R0,=0x5000600C
LDR R2,=0X5000700C
LDR R1,[R0]
LDR R3,[R2]
BIC R1,R1,#(0x3<<20)
BIC R1,R1,#(0x3<<16)
BIC R3,R3,#(0x3<<20)
STR R1,[R0]
STR R3,[R2]

@LED1、LED3闪烁
loop:
@LED1、LED3亮
BL led1_on
bl delay
@LED1、LED3灭
BL led1_off
bl delay
b loop


@LED1、LED3、LED2亮
led1_on:
 	LDR R0,=0x50006014
	LDR R1,[R0]
	ORR R1,R1,#(0x1<<10)
	ORR R1,R1,#(0x1<<8)
	STR R1,[R0]
	LDR R2,=0X50007014
	LDR R3,[R2]
	ORR R3,R3,#(0x1<<10)
	STR R3,[R2]
	mov pc,lr
@LED1、LED3、LED2灭
led1_off:
	LDR R0,=0x50006014
	LDR R1,[R0]
	BIC R1,R1,#(0x1<<10)
	BIC R1,R1,#(0x1<<8)
	STR R1,[R0]
	LDR R2,=0X50007014
	LDR R3,[R2]
	BIC R3,R3,#(0x1<<10)
	STR R3,[R2]
	mov pc,lr
@封装汇编的延时函数
delay:
	LDR R1,=0x10000000
mm:
	cmp R1,#0
	SUBNE R1,R1,#1
	BNE mm
	mov pc,lr



.end

你可能感兴趣的:(ARM,arm)