public
Created

ASM fir filter with double data

  • Download Gist
fir_ddAsm
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
//extern void firAsm(chanend c, int H[],int X[], unsigned size);
 
#define NWORDS 7
// .cc_top biquadAsm, biquadAsm.func
.globl fir_ddAsm
.globl fir_ddAsm.nstackwords
.linkset fir_ddAsm.nstackwords,NWORDS
 
#define c r0
#define H r1
#define X r2
#define size r3
#define x r4
#define h r5
#define Xoff r6
#define i r7
#define state r8
#define Xm r9
#define ynl r10
#define ynh r11
 
firAsm:
entsp NWORDS
stw r4, sp[0]
stw r5, sp[1]
stw r6, sp[2]
stw r7, sp[3] // change to make sure that commit goes through to github
stw r8, sp[4]
ldc state,0
stw r9, sp[5]
ldaw Xm,X[size]
stw r10, sp[6]
 
.align 4
mainloop:
testct x,res[c]
bt x,allDone
in x,res[c] //read input to x
add i,size,0 //reset i to sizeof vector
stw x,X[state] // store word in X[state]
add r10,state,size
stw x,X[r10] // store word in X[state+size]
bf state,update //if state==0{state+=size}
updateR:
sub state,state,1
 
XoffupdateR:
ldc ynl,0 //reset MAC
ldc ynh,0 //reset MAC
bu entrypoint
 
update:
add state,state,size
ldaw Xoff,Xm[-1];
bu updateR
 
.align 4
subloop:
maccs ynh,ynl,h,x
entrypoint:
ldw x,Xoff[i] //Xoffset = X-1*int32
sub i,i,1
ldw h,H[i]
bt i,subloop
maccs ynh,ynl,h,x
shl ynh,ynh,1
ldc r4,31
shr ynl,ynl,r4
or r4,ynh,ynl
 
out res[c],r4
ldaw Xoff,Xoff[-1];
bu mainloop
allDone: // Now just restore all registers.
 
inct r3, res[c]
ldw r4, sp[0]
ldw r5, sp[1]
ldw r6, sp[2]
ldw r7, sp[3]
ldw r8, sp[4]
ldw r9, sp[5]
ldw r10, sp[6]
retsp NWORDS
 
// .cc_bottom biquadAsm.func

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.