Guest User

Untitled

a guest
Apr 13th, 2017
156
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. filter_applications EQU (end_source-source)/4 - 5 ; find out how many times the filter needs to be applied
  2.  
  3. AREA Filter_Code, CODE, READONLY
  4. Reset_Handler
  5. ENTRY
  6. ; set up the filter parameters
  7. LDR r0,=source
  8. LDR r3,=dest
  9. MOVS r4,#filter_applications
  10. BMI exit
  11.  
  12.  
  13. filter_loop
  14. LDMIA r0,{r5-r9} ; get the next 5 data values to be filtered
  15. ADD r5,r5,r9 ; sum x[-2] with x[2]
  16. ADD r6,r6,r8 ; sum x[-1] with x[1]
  17. ADD r9,r5,r6 ; sum x[-2]+x[2] with x[-1]+x[1]
  18. ADD r7,r7,r9,LSR #1 ; sum x[0] with (x[-2]+x[2]+x[-1]+x[1])/2
  19. MOV r7,r7,LSR #2 ; form (x[0] + (x[-2]+x[-1]+x[1]+x[2])/2)/4
  20. STR r7,[r3],#4 ; save calculated filtered value, move to next output data item
  21. ADD r0,r0,#4 ; move on to next set of 5 inputs
  22. SUBS r4,r4,#1 ; move on to next set of 5 inputs
  23. BPL filter_loop ; continue until last set of 5 inputs reached
  24.  
  25.  
  26. exit
  27. B exit
  28.  
  29. ALIGN
  30. AREA Filter_ROData, DATA, READONLY
  31. source ; example saw tooth
  32. DCD 0,10,20,30,40,50,60,70,80,90,100,0,10,20,30,40,50,60,70,80,90,100
  33. DCD 0,10,20,30,40,50,60,70,80,90,100,0,10,20,30,40,50,60,70,80,90,100
  34. DCD 0,10,20,30,40,50,60,70,80,90,100,0,10,20,30,40,50,60,70,80,90,100
  35. DCD 0,10,20,30,40,50,60,70,80,90,100,0,10,20,30,40,50,60,70,80,90,100
  36.  
  37. AREA Filter_RWData, DATA, READWRITE
  38. dest
  39. SPACE end_source - source - 16
  40. end_dest
  41. END
RAW Paste Data