汇编实现三个灯闪烁
汇编代码:
.text
.global _start
_start:
@设置GPIOE,GPIOF时钟使能LDR R0,=0X50000A28 LDR R1,[R0] ORR R1,R1,#(0x3<<4) STR R1,[R0] @设置PE10,PF10,PE8为输出
@LED1LDR R0,=0X50006000LDR R1,[R0]ORR R1,R1,#(0X1<<20)BIC R1,R1,#(0X1<<21)
@LED2LDR R2,=0X50007000LDR R3,[R2]ORR R3,R3,#(0X1<<20)BIC R3,R3,#(0X1<<21)STR R3,[R2]
@LED3ORR R1,R1,#(0X1<<16)BIC R1,R1,#(0X1<<17)STR R1,[R0]@设置PE10,PF10,PE8为推挽输出LDR R0,=0X50006004LDR R1,[R0]@LED1BIC R1,R1,#(0X1<<10)
@LED2LDR R2,=0X50007004LDR R3,[R2]BIC R3,R3,#(0X1<<10)STR R3,[R2]
@LED3BIC R1,R1,#(0X1<<8)STR R1,[R0]@设置PE10,PF10,PE8为低速输出LDR R0,=0X50006008LDR R1,[R0]@LED1BIC R1,R1,#(0X3<<20)@LED2LDR R2,=0X50006008LDR R3,[R2]BIC R3,R3,#(0X3<<20)STR R3,[R2]
@LED3BIC R1,R1,#(0X3<<16)STR R1,[R0]@设置PE10,PF10,PE8输出时无上拉下拉电阻
@LED1LDR R0,=0X5000600CLDR R1,[R0]BIC R1,R1,#(0X3<<20)
@LED2LDR R2,=0X5000600CLDR R3,[R2]BIC R3,R3,#(0X3<<20)STR R3,[R2]
@LED3BIC R1,R1,#(0X3<<16)STR R1,[R0]FLASH:BL LED1_ONBL LED2_OFFBL LED3_ONBL DELAYBL LED1_OFFBL LED2_ONBL LED3_OFFBL DELAYB FLASH@LED1亮
LED1_ON:
@设置PE10输出高电平LDR R0,=0X50006014LDR R1,[R0]ORR R1,R1,#(0X1<<10)STR R1,[R0]MOV PC,LR@LED1灭
LED1_OFF:
@设置PE10输出低电平LDR R0,=0X50006014LDR R1,[R0]BIC R1,R1,#(0X1<<10)STR R1,[R0]MOV PC,LR@LED2亮
LED2_ON:
@设置PE10输出高电平LDR R0,=0X50007014LDR R1,[R0]ORR R1,R1,#(0X1<<10)STR R1,[R0]MOV PC,LR@LED2灭
LED2_OFF:
@设置PE10输出低电平LDR R0,=0X50007014LDR R1,[R0]BIC R1,R1,#(0X1<<10)STR R1,[R0]MOV PC,LR@LED3亮
LED3_ON:
@设置PE8输出高电平LDR R0,=0X50006014LDR R1,[R0]ORR R1,R1,#(0X1<<8)STR R1,[R0]MOV PC,LR@LED3灭
LED3_OFF:
@设置PE8输出低电平LDR R0,=0X50006014LDR R1,[R0]BIC R1,R1,#(0X1<<8)STR R1,[R0]MOV PC,LR@延时
DELAY:LDR R3,=0x10000000
MM:CMP R3,#0SUBNE R3,R3,#1BNE MMMOV PC,LR.end
运行结果:
思维导图: