Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- filter_applications EQU (end_source-source)/4 - 5 ; find out how many times the filter needs to be applied
- AREA Filter_Code, CODE, READONLY
- Reset_Handler
- ENTRY
- ; set up the filter parameters
- LDR r0,=source
- LDR r3,=dest
- MOVS r4,#filter_applications
- BMI exit
- filter_loop
- LDMIA r0,{r5-r9} ; get the next 5 data values to be filtered
- ADD r5,r5,r9 ; sum x[-2] with x[2]
- ADD r6,r6,r8 ; sum x[-1] with x[1]
- ADD r9,r5,r6 ; sum x[-2]+x[2] with x[-1]+x[1]
- ADD r7,r7,r9,LSR #1 ; sum x[0] with (x[-2]+x[2]+x[-1]+x[1])/2
- MOV r7,r7,LSR #2 ; form (x[0] + (x[-2]+x[-1]+x[1]+x[2])/2)/4
- STR r7,[r3],#4 ; save calculated filtered value, move to next output data item
- ADD r0,r0,#4 ; move on to next set of 5 inputs
- SUBS r4,r4,#1 ; move on to next set of 5 inputs
- BPL filter_loop ; continue until last set of 5 inputs reached
- exit
- B exit
- ALIGN
- AREA Filter_ROData, DATA, READONLY
- source ; example saw tooth
- DCD 0,10,20,30,40,50,60,70,80,90,100,0,10,20,30,40,50,60,70,80,90,100
- DCD 0,10,20,30,40,50,60,70,80,90,100,0,10,20,30,40,50,60,70,80,90,100
- DCD 0,10,20,30,40,50,60,70,80,90,100,0,10,20,30,40,50,60,70,80,90,100
- DCD 0,10,20,30,40,50,60,70,80,90,100,0,10,20,30,40,50,60,70,80,90,100
- AREA Filter_RWData, DATA, READWRITE
- dest
- SPACE end_source - source - 16
- end_dest
- END
RAW Paste Data