Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;******************** (C) COPYRIGHT HAW-Hamburg ********************************
- ;* File Name : main.s
- ;* Author : Alfred Lohmann
- ;* Author : Tobias Jaehnichen
- ;* Version : V2.0
- ;* Date : 23.04.2017
- ;* Description : This is a simple main.
- ; : The output is send to UART 1. Open Serial Window when
- ; : when debugging. Select UART #1 in Serial Window selection.
- ; :
- ; : Replace this main with yours.
- ;
- ;*******************************************************************************
- EXTERN Init_TI_Board ; Initialize the serial line
- EXTERN ADC3_CH7_DMA_Config ; Initialize the ADC
- ;EXTERN initHW ; Init Timer
- EXTERN puts ; C output function
- EXTERN TFT_puts ; TFT output function
- EXTERN TFT_cls ; TFT clear function
- EXTERN TFT_gotoxy ; TFT goto x y function
- EXTERN Delay ; Delay (ms) function
- EXTERN GPIO_G_SET ; Set output-LEDs
- EXTERN GPIO_G_CLR ; Clear output-LEDs
- EXTERN GPIO_G_PIN ; Output-LEDs status
- EXTERN GPIO_E_PIN ; Button status
- EXTERN ADC3_DR ; ADC Value (ADC3_CH7_DMA_Config has to be called before)
- ;********************************************
- ; Data section, aligned on 4-byte boundery
- ;********************************************
- AREA MyData, DATA, align = 4
- DataList DCD 35, -1, 13, -4096, 511, 101, -3, -5, 0, 65
- DataListEnd DCD 0
- GLOBAL DataList
- GLOBAL DataListEnd
- ;********************************************
- ; Code section, aligned on 8-byte boundery
- ;********************************************
- AREA |.text|, CODE, READONLY, ALIGN = 3
- ;--------------------------------------------
- ; main subroutine
- ;--------------------------------------------
- EXPORT main [CODE]
- main PROC
- push{r4,lr}
- mov r2, #1 ;Getauschtregister auf true
- ldr r4,=DataListEnd
- sub r4,#4 ;Einen Wert runter mit der Adresse, damit man letzte Adresse der Liste hat und es an der richtigen Stelle aufhört
- WHILE_01
- cmp r2, #0
- beq ENDWHILE_01
- DO_01
- mov r2, #0 ;Getauscht auf false
- ldr r3, =DataList ;r3 Zeiger für DataList
- WHILE_02
- cmp r3, r4 ;Prüfung ob Adresse Endadresse ist
- beq ENDWHILE_02
- DO_02
- ldr r0,[r3] ;Lädt den Wert an der aktuellen Stelle in r0
- ;add r3,#1 ;Setzt den Zeiger in der Liste eine Stelle weiter
- ldr r1,[r3,#4] ;Offset 4 für folgestelle der Liste/des Zeigers und lädt dann den folgewert in r1
- IF_03
- cmp r0, r1
- ble ENDIF_03 ;wenn r0(aktuell) <= r1(folge) ist beende die If-Bedingung
- THEN_03
- str r0, [r3,#4] ;Schiebt den aktuellwert an die Stelle des Folgewerts
- str r1, [r3] ;Schiebt den Folgewert an die Stelle des Aktuellerts => getauscht
- mov r2, #1 ;Getauscht auf true
- ENDIF_03
- add r3,#4 ;Zeiger um eine Stelle weiter setzen
- b WHILE_02
- ENDWHILE_02
- b WHILE_01
- ENDWHILE_01
- pop{r4,lr}
- bx lr
- forever b forever ; nowhere to retun if main ends
- ENDP
- ALIGN
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement