asm-led.S
.text
.global _start
_start: /* 1. led灯的初始化 *//* 1.1 使能GPIOE、DPIOF外设控制器的时钟 */ldr r0, =0x50000A28ldr r1, [r0]orr r1, r1, #(0x3 << 4)str r1, [r0]/* 1.2 设置PE10、PE8、PF10引脚为输出模式 */ldr r0, =0x50006000ldr r1, [r0]bic r1, r1, #(0x3 << 16)orr r1, r1, #(0x1 << 16)bic r1, r1, #(0x3 << 20)orr r1, r1, #(0x1 << 20)str r1, [r0]ldr r0, =0x50007000ldr r1, [r0]bic r1, r1, #(0x3 << 20)orr r1, r1, #(0x1 << 20)str r1, [r0]/* 1.3 设置PE10、PE8、PF10引脚为推挽输出 */ldr r0, =0x50006004ldr r1, [r0]bic r1, r1, #(0x1 << 8)bic r1, r1, #(0x1 << 10)str r1, [r0]ldr r0, =0x50007004ldr r1, [r0]bic r1, r1, #(0x1 << 10)str r1, [r0]/* 1.4 设置PE10、PE8、PF10引脚为低速模式 */ldr r0, =0x50006008ldr r1, [r0]bic r1, r1, #(0x3 << 16)bic r1, r1, #(0x3 << 20)str r1, [r0]ldr r0, =0x50007008ldr r1, [r0]bic r1, r1, #(0x3 << 20)str r1, [r0]/* 1.5 设置PE10、PE8、PF10引脚禁止上拉和下拉电阻 */ldr r0, =0x5000600Cldr r1, [r0]bic r1, r1, #(0x3 << 16)bic r1, r1, #(0x3 << 20)str r1, [r0]ldr r0, =0x5000700Cldr r1, [r0]bic r1, r1, #(0x3 << 20)str r1, [r0]/* led1灯的初始化完成 */
loop:/* 设置PE10引脚输出高电平, 点亮LED1灯 */ldr r0, =0x50006014ldr r1, [r0]orr r1, r1, #(0x1 << 10)str r1, [r0]bl delay_1s/* 设置PE10引脚输出低电平, 熄灭LED1灯 */ldr r0, =0x50006014ldr r1, [r0]bic r1, r1, #(0x1 << 10)str r1, [r0]bl delay_1s/* 设置PF10引脚输出低电平, 点亮LED2灯 */ldr r0, =0x50007014ldr r1, [r0]orr r1, r1, #(0x1 << 10)str r1, [r0]bl delay_1s/* 设置PF10引脚输出低电平, 熄灭LED2灯 */ldr r0, =0x50007014ldr r1, [r0]bic r1, r1, #(0x1 << 10)str r1, [r0]bl delay_1s/* 设置PE8引脚输出高电平, 点亮LED3灯 */ldr r0, =0x50006014ldr r1, [r0]orr r1, r1, #(0x1 << 8)str r1, [r0]bl delay_1s/* 设置PE8引脚输出低电平, 熄灭LED3灯 */ldr r0, =0x50006014ldr r1, [r0]bic r1, r1, #(0x1 << 8)str r1, [r0]bl delay_1sb loop@ 大概1s的延时函数
delay_1s:mov r3, #0x10000000mm:cmp r3, #0subne r3, r3, #1bne mmmov pc, lr.end
效果图: