@.CharSet=CP1251
@GNU AS
@ +--------------------------------------------------------+
@ |       STM32F030 DEMO BOARD |
@ |             STM32F030F4P6               |
@ |            (  )                |
@ +--------------------------------------------------------+
@ |                                       |
@ |                                                        |
@ |  : GPIOA                               |
@ |  : 4 ( )              |
@ |                                                        |
@ +--------------------------------------------------------+
.syntax unified     @   
.thumb              @    Thumb
.cpu cortex-m0      @ 
.include "/src/inc/rcc.inc"
.include "/src/inc/gpio.inc"

.section .asmcode

@  
.GLOBAL   Start
Start:              @     
                    LDR        R0, = RCC + RCC_AHBENR    @    R0   RCC_AHBENR
                    LDR        R1, [ R0 ]                @    R1     ,    R0
                    LDR        R2, = RCC_AHBENR_IOPAEN   @    R2   IOPAENR  RCC_AHBENR
                    ORRS       R1, R1, R2                @   OR   R1  R2,    R2 (    IOPAEN)
                                                         @ ..   GPIOA
                    STR        R1, [ R0 ]                @   R1         R0 (    RCC_AHBENR)
                                                         @         RCC_AHBENR
                    LDR        R0, = GPIOA               @   R0   GPIOA
                    LDR        R1, [ R0, GPIO_MODER ]    @   R1  GPIOA   GPIO_MODER -     R1  GPIOA_MODER
                    LDR        R2, = GPIO_MODER_GENERAL_OUT << GPIO_MODER_4_N  @ PA4   
                    ORRS       R1, R1, R2                @ R1 OR R2 ->  OR  R1  R2 -   R1
                    STR        R1, [ R0, GPIO_MODER ]    @     

                    LDR        R2, =GPIO_BSRR_BS_4       @   R2     GPIOA4
                    LDR        R4, =GPIO_BSRR_BR_4       @   R4     GPIO4


loop:

                    STR        R2, [ R0, GPIO_BSRR ]     @    GPIO_BSRR     
                    BL         DELAY                     @  

                    STR        R4, [ R0, GPIO_BSRR ]     @    GPIO_BSRR     
                    BL         DELAY                     @  
                    B          loop                      @    loop ( )


@-------------------------------------------------------------------------
DELAY:              @   0,8 
                    LDR        R3, = 0x00100000    @   000100000   R3
delay_loop:
                    SUBS       R3, R3, #1    @   R3  ()    R3
                    BNE        delay_loop    @  :      Z=0    
                                             @     Z<>0     delay_loop
                    BX         LR            @ bezuslovnyi perehod na adres hranyashiisa v registre LR (registr schetchika poslednego perehoda)




