Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Blink_LED.s Lab #1 sample program
- ; This program blink the LEDs on the DE0 board
- ; Stack related directives
- AREA STACK, NOINIT, READWRITE, ALIGN=4 ; Name this block of code as STACK, reside in the RAM area
- Stack_Size EQU 0x200 ; Stack Size = 0x200 bytes
- Stack_Mem SPACE Stack_Size ; Reserve the space in RAM
- TOP_STACK ; Set top of stack location
- ; Vector Table - link to Address 0 at Reset
- AREA RESET, DATA, READONLY ; Name this block of code as RESET, reside in the ROM area
- __Vectors DCD TOP_STACK ; Vector table start here, first enty is the 'Top of stack'
- DCD START ; second entry is the Reset vector address
- ; User Application
- AREA texts, CODE, READONLY ; Name this block of code as texts, reside in the ROM area
- ENTRY ; Mark first instruction to execute
- START PROC ; Declaration of subroutine/function
- MOVS R2,#0xA ; Store address 0xA0000000 in R2; start with 0xA
- LSLS R2,R2,#28 ; Logical left shift R2 to obtain the correct address-0xA0000000
- MOVS R1,#0xA ; Store address 0xA0001000 in R3; start with 0xA **
- LSLS R1,R1,#16 ; R3 = 0xA0000 **
- ADDS R1,#0x1 ; R3 = 0xA0001 **
- LSLS R1,R1,#12 ; R3 = 0xA0001000 [Address of switches in R3] **
- leds_odd MOVS R0,#0xAA ; R0 = 0000 1010 1010
- LSLS R0,R0,#2 ; R0 = 0010 1010 1000
- ADDS R0,#0x02 ; R0 = 0010 1010 1010
- LDR R5,[R1] ; R4 = Mem[R3] **
- ORRS R0,R0,R5 ; Set Bits indicated by sliding switches **
- STR R0,[R2,#0x00] ; Store the value to the DE0_LED address
- BL DELAY ; Call the DELAY function
- leds_even MOVS R0,#0x55 ; R0 = 0000 0101 0101
- LSLS R0,R0,#2 ; R0 = 0001 0101 0100
- ADDS R0,#0x01 ; R0 = 0001 0101 0101
- LDR R5,[R1] ; R4 = Mem[R3] **
- ORRS R0,R0,R5 ; Set Bits indicated by sliding switches **
- STR r0,[r2,#0x00] ; Store the value to the DE0_LED address
- BL DELAY ; Call the DELAY function
- B leds_odd ; Repeat
- ENDP ; END of this subroutine
- ;Delay subroutine
- COUNTER EQU 0xFFFFF ; Counter to be used for delay looping
- DELAY PROC ; Declaration of DELAY subroutine
- MOVS R4,#3
- delay0 ldr R3,=COUNTER ; Initialize R3 with delay COUNTER
- delay1 SUBS R3,#1
- BNE delay1
- SUBS R4,#1
- BNE delay0
- BX LR ;Return to the calling function
- ENDP
- ; The following codes are not used in this application, but their symbols are required for error-free linking by default linker setup
- EXPORT __Vectors ; default symbol required by the linker, not used in this program
- EXPORT Reset_Handler ; default symbol required by linker, not needed in this program
- AREA texts, CODE, READONLY, ALIGN=4
- Reset_Handler PROC ; Typical code for Reset_vector handler
- LDR R0, =START ; User Application called by Label
- BX R0
- ENDP
- END ; End of code. Assembler ignore code beyind this point
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement