STM32用汇编点亮LED灯

gnu汇编编写

test.s

    .syntax unified
    .cpu cortex-m3
    .fpu softvfp 
    .thumb

.global _main
@.global isr_vector

    .section .text
    .type _main, %function
_main:
    /* 使能GPIOA的时钟 */
    ldr r0, =0x40021018
    ldr r1, =0x00000004
    str r1, [r0]

    /* 配置PA8位推挽输出模式 */
    ldr r0, =0x40010804
    ldr r1, [r0]
    bic r1, r1, #0x0000000f
    orr r1, r1, #0x00000001
    str r1, [r0]

    /* PA8置位 */
    ldr r0, =0x4001080c
    ldr r1, =0x00000100
    str r1, [r0]

    /*led闪烁 */
    ldr r0, =800000
    ldr r1, =0
blink:
    add r1, r1, #1
    cmp r1, r0
    blt blink
    ldr r1, =0x4001080c
    ldr r2, [r1]
    eor r2, r2, #0x00000100
    str r2, [r1]
    ldr r1, =0
    b blink


    .section .isr_vector, "ax", %progbits

_vector:
    .word 0x20000400 @栈初始地址
    .word _main     @程序起始地址




你可能感兴趣的:(笔记,stm32)