Last active
December 25, 2016 06:51
-
-
Save idt12312/e84a90912f56dc98ae876620fffac113 to your computer and use it in GitHub Desktop.
アセンブリでLチカをする : Nucleo STM32F103
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.text | |
.global _start | |
.code 16 | |
.syntax unified | |
.equ STACK_TOP, 0x20005000 | |
.equ RCC_APB2ENR, 0x40021018 | |
.equ GPIOA_CRL, 0x40010800 | |
.equ GPIOA_ODR, 0x4001080C | |
_start: | |
.org 0x00000000 | |
.word STACK_TOP | |
.word init | |
.type init, function | |
init: | |
// GPIOAのクロックを有効にする | |
LDR r0, =RCC_APB2ENR | |
movw r1, #0x0004 | |
str r1, [r0] | |
// PA5を出力に設定 | |
LDR r0, =(GPIOA_CRL+2) | |
movw r1, #0x0020 | |
str r1, [r0] | |
toggle_led: | |
// GPIOAの出力状態を読み出し、 | |
// PA5に当たるビットをXORで反転する | |
LDR r0, =GPIOA_ODR | |
ldr r1, [r0] | |
eor r1, #0x0020 | |
str r1, [r0] | |
LDR r0, =2000000 | |
wait_loop: | |
subs r0, #1 | |
bne wait_loop | |
b toggle_led | |
.end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment