Advertisement
Guest User

Untitled

a guest
Nov 20th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ARM 2.93 KB | None | 0 0
  1. ;******************** (C) COPYRIGHT HAW-Hamburg ********************************
  2. ;* File Name          : main.s
  3. ;* Author             : Alfred Lohmann
  4. ;* Author             : Tobias Jaehnichen  
  5. ;* Version            : V2.0
  6. ;* Date               : 23.04.2017
  7. ;* Description        : This is a simple main.
  8. ;                     : The output is send to UART 1. Open Serial Window when
  9. ;                     : when debugging. Select UART #1 in Serial Window selection.
  10. ;                     :
  11. ;                     : Replace this main with yours.
  12. ;
  13. ;*******************************************************************************
  14.  
  15.     EXTERN Init_TI_Board        ; Initialize the serial line
  16.     EXTERN ADC3_CH7_DMA_Config  ; Initialize the ADC
  17.     ;EXTERN initHW              ; Init Timer
  18.     EXTERN  puts                ; C output function
  19.     EXTERN  TFT_puts            ; TFT output function
  20.     EXTERN  TFT_cls             ; TFT clear function
  21.     EXTERN  TFT_gotoxy          ; TFT goto x y function  
  22.     EXTERN  Delay               ; Delay (ms) function
  23.     EXTERN GPIO_G_SET           ; Set output-LEDs
  24.     EXTERN GPIO_G_CLR           ; Clear output-LEDs
  25.     EXTERN GPIO_G_PIN           ; Output-LEDs status
  26.     EXTERN GPIO_E_PIN           ; Button status
  27.     EXTERN ADC3_DR              ; ADC Value (ADC3_CH7_DMA_Config has to be called before)
  28.  
  29. ;********************************************
  30. ; Data section, aligned on 4-byte boundery
  31. ;********************************************
  32.     AREA MyData, DATA, align = 4
  33.        
  34. DataList    DCD 35, -1, 13, -4096, 511, 101, -3, -5, 0, 65
  35. DataListEnd DCD 0
  36.    
  37.     GLOBAL DataList
  38.     GLOBAL DataListEnd
  39.  
  40. ;********************************************
  41. ; Code section, aligned on 8-byte boundery
  42. ;********************************************
  43.  
  44.     AREA |.text|, CODE, READONLY, ALIGN = 3
  45.  
  46. ;--------------------------------------------
  47. ; main subroutine
  48. ;--------------------------------------------
  49.     EXPORT main [CODE]
  50.    
  51. main    PROC
  52.     push{r4,lr}
  53.     mov r2, #1  ;Getauschtregister auf true
  54.     ldr r4,=DataListEnd
  55.     sub r4,#4   ;Einen Wert runter mit der Adresse, damit man letzte Adresse der Liste hat und es an der richtigen Stelle aufhört
  56.    
  57. WHILE_01
  58.     cmp r2, #0
  59.     beq ENDWHILE_01
  60.    
  61. DO_01
  62.     mov r2, #0      ;Getauscht auf false
  63.     ldr r3, =DataList   ;r3 Zeiger für DataList
  64.    
  65. WHILE_02
  66.     cmp r3, r4      ;Prüfung ob Adresse Endadresse ist
  67.     beq ENDWHILE_02
  68.  
  69. DO_02
  70.     ldr r0,[r3]     ;Lädt den Wert an der aktuellen Stelle in r0
  71.     ;add r3,#1      ;Setzt den Zeiger in der Liste eine Stelle weiter
  72.     ldr r1,[r3,#4]  ;Offset 4 für folgestelle der Liste/des Zeigers und lädt dann den folgewert in r1
  73.    
  74. IF_03
  75.     cmp r0, r1     
  76.     ble ENDIF_03    ;wenn r0(aktuell) <= r1(folge) ist beende die If-Bedingung
  77.    
  78. THEN_03
  79.     str r0, [r3,#4] ;Schiebt den aktuellwert an die Stelle des Folgewerts
  80.     str r1, [r3]    ;Schiebt den Folgewert an die Stelle des Aktuellerts => getauscht
  81.     mov r2, #1      ;Getauscht auf true
  82.    
  83. ENDIF_03
  84.     add r3,#4       ;Zeiger um eine Stelle weiter setzen
  85.     b WHILE_02
  86.    
  87. ENDWHILE_02
  88.     b WHILE_01
  89.    
  90. ENDWHILE_01
  91.  
  92.     pop{r4,lr}
  93.     bx lr
  94. forever b   forever     ; nowhere to retun if main ends    
  95.         ENDP
  96.    
  97.         ALIGN
  98.        
  99.         END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement