home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / DSPCG1.ZIP / FILTER.SRC < prev    next >
Encoding:
Text File  |  1989-02-10  |  83.2 KB  |  2,626 lines

  1. ;**************************** FIR_A.ASM **************************** 
  2. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3. ;                                                           ;
  4. ;               TMS320C30 FIR filter realization            ;
  5. ;                                                           ;
  6. ;     (c) Copyright 1989, Atlanta Signal Processors, Inc.   ;
  7. ;                    All Rights Reserved                    ;
  8. ;                                                           ;
  9. ;                       Time Optimized                      ;
  10. ;                                                           ;
  11. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  12.  
  13. ;Assemble code callable FIR filter subroutines
  14.  
  15. ;The following structure defines the data structure that the Init routine
  16. ;initializes.  This structure is passed, along with x(n) to the filter
  17. ;routines.
  18.  
  19. ;struct FIR {
  20. ;    float    (*filter)();    /* pointer to sample by sample filter routine */
  21. ;    void    (*filtera)();    /* pointer to array filter routine */
  22. ;    float    *coef_mem;    /* pointer to coef. memory */
  23. ;    float    *delay_mem;    /* pointer to delay memory */
  24. ;    float    zero;        /* a floating point 0 */
  25. ;    int    BK_reg;        /* value to be placed in BK register */
  26. ;    int    frtaps;        /* number of taps for RPTS forward */
  27. ;    };
  28.  
  29. ;        PERFORM THE SAMPLE BY SAMPLE FILTERING
  30. ;Input:
  31. ;    R0    x(n)
  32. ;    AR7    pointer to FIR filter structure
  33. ;Ouput:
  34. ;    R0    y(n)
  35. ;    R2, AR0, AR1, BK, RC, RS, RE destroyed
  36.  
  37.     .globl    FIR_A
  38. FIR_A:    
  39.     LDI    *+AR7(2),AR1    ; AR1 = address of coefficients
  40.     LDI    *+AR7(3),AR0    ; AR0 = address of x(n) in circular
  41.                 ; delay memory
  42.     LDF    0.0,R2        ; initialize R2
  43.     LDI    *+AR7(5),BK    ; Set block size for circular buffer
  44.                 ; of x(n)
  45.     STF    R0,*AR0        ; put x(n) in delay memory
  46.     MPYF    *AR1++,*AR0++%,R0 ; h(0)*x(n) -> R0
  47.     RPTS    *+AR7(6)
  48.     MPYF    *AR1++,*AR0++%,R0
  49. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2    
  50.     MPYF    *AR1++,*AR0++%,R0
  51. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2    
  52.     ADDF    R0,R2,R0    ; add last product
  53.     STI    AR0,*+AR7(3)    ; save updated circular buffer point
  54.                 ; for next sample
  55.     RETS            ; return y(n) in R0
  56.  
  57.  
  58. ;        PERFORM ARRAY FILTERING
  59. ;Input:
  60. ;    AR4    address of x(n) array
  61. ;    AR5    address of y(n) array
  62. ;    AR6    number of samples-1 in array
  63. ;    AR7    address of FIR filter structure
  64. ;Output:
  65. ;    AR(0-2), AR4, AR5, R(0-3), IR0, BK, RC, RS, RE, DP destroyed
  66.  
  67.  
  68. ; 'rblock' is set to one if the majority of the filter is to be executed
  69. ; in repeat block mode rather than repeat single mode.  The advantage
  70. ; of repeat block over single is that it saves 2 cycles per sample,
  71. ; although it adds at 10 cycles to the call.
  72. ; The advantage of repeat single is that it is it does not fetch
  73. ; the instruction every cycle.  If the instruction cache is on this
  74. ; becomes unimportant.
  75.  
  76. rblock    .set    1
  77.  
  78.     .globl    FIR_Aa
  79. FIR_Aa:    
  80.     LDI    *++AR7(2),AR1    ; AR1 = address of coefficients
  81.     LDI    *++AR7,AR0    ; AR0 = address of x(n) in circular
  82.                 ; delay memory
  83.                 ; NOTE: AR7 now points to delay address
  84.     LDF    *AR4++,R0    ; R0 = x(n) (first sample of array)
  85.     LDI    *+AR7(2),BK    ; Set block size for circular buffer
  86.                 ; of x(n)
  87.     LDI    *+AR7(4),IR0    ; IR0 = NUMBER of taps-1
  88.  
  89.     LDF    *+AR7,R2    ; initialize R2 to 0.0
  90. ||    STF    R0,*AR0        ; put x(n) in delay memory
  91.     MPYF    *AR1++,*AR0++%,R0 ; h(0)*x(n) -> R0
  92.     .if    rblock
  93.     RPTS    *+AR7(3)
  94.     .endif
  95. floop:
  96.     .if    rblock = 0
  97.     RPTS    *+AR7(3)
  98.     .endif
  99.     MPYF    *AR1++,*AR0++%,R0
  100. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2    
  101.     MPYF    *AR1--(IR0),*AR0++%,R0
  102. ||    ADDF    R0,R2,R3    ; h(l)*x(n-l) + R2 -> R2    
  103.  
  104.     .if    rblock
  105.     LDI    *+AR7(3),RC    ; Set the number of times to repeat
  106.     OR    100h,ST        ; Turn repeat on
  107.     .endif
  108.  
  109.     DBD    AR6,floop    ; do more samples?
  110.     LDF    *AR4,R1        ; get next sample
  111. ||    LDF    *+AR7,R2    ; initialize R2 to 0.0
  112.     MPYF3    *AR4++,*AR1++,R0; x(n+1) * h(0) -> R0
  113. ||    ADDF3    R0,R3,R3    ; final sum for y(n) -> R3
  114.     STF    R3,*AR5++    ; store y(n) into array
  115. ||    STF    R1,*AR0++%    ; store x(n+1) into delay memory
  116.  
  117.     .if    rblock
  118.     AND    0feffh,ST    ; turn off repeat
  119.     .endif
  120.     NOP    *AR0--%        ; back up delay pointer for next x(n)
  121.     STI    AR0,*AR7--(3)    ; save updated circular buffer point
  122.                 ; for next samples
  123.     RETS
  124.  
  125.     .end
  126. ;**************************** FIR_AASE.ASM **************************** 
  127. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  128. ;                                                           ;
  129. ;               TMS320C30 FIR filter realization            ;
  130. ;                                                           ;
  131. ;     (c) Copyright 1989, Atlanta Signal Processors, Inc.   ;
  132. ;                    All Rights Reserved                    ;
  133. ;                                                           ;
  134. ;                       Size Optimized                      ;
  135. ;                                                           ;
  136. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  137.  
  138. ;Assemble code callable FIR filter subroutines for
  139. ;  an even number of anti-symetric coefficients.
  140.  
  141. ;The following structure defines the data structure that the Inutine
  142. ;initializes.  This structure is passed, along with x(n) to the filter
  143. ;routines.
  144.  
  145. ;struct FIR {
  146. ;    float    (*filter)();    /* pointer to sample by sample filter routine */
  147. ;    void    (*filtera)();    /* pointer to array filter routine */
  148. ;    float    *coef_mem;    /* pointer to coef. memory */
  149. ;    float    *delay_mem;    /* pointer to delay memory */
  150. ;    float    zero;        /* a floating point 0 */
  151. ;    int    BK_reg;        /* value to be placed in BK register */
  152. ;    int    frtaps;        /* number of taps for RPTS forward */
  153. ;    int    rrtaps;        /* number of taps for RPTS reverse */
  154. ;    };
  155.  
  156. ;        PERFORM THE SAMPLE BY SAMPLE FILTERING
  157. ;Input:
  158. ;    R0    x(n)
  159. ;    AR7    pointer to FIR filter structure
  160. ;Ouput:
  161. ;    R0    y(n)
  162. ;    R2, AR0, AR1, BK, RC, RS, RE destroyed
  163.  
  164.     .globl    FIR_Aase
  165. FIR_Aase:    
  166.     LDI    *+AR7(2),AR1    ; AR1 = address of coefficients
  167.     LDI    *+AR7(3),AR0    ; AR0 = address of x(n) in circular
  168.                 ; delay memory
  169.     LDF    0.0,R2        ; initialize R2
  170.     LDI    *+AR7(5),BK    ; Set block size for circular buffer
  171.                 ; of x(n)
  172.     STF    R0,*AR0        ; put x(n) in delay memory
  173.     MPYF    *AR1++,*AR0++%,R0 ; h(0)*x(n) -> R0
  174.     RPTS    *+AR7(6)
  175.     MPYF    *AR1++,*AR0++%,R0
  176. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2    
  177.     MPYF    *--AR1,*AR0++%,R0
  178. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2
  179.     RPTS    *+AR7(7)
  180.     MPYF    *--AR1,*AR0++%,R0
  181. ||    SUBF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2
  182.     SUBF    R0,R2,R0    ; add last product
  183.     STI    AR0,*+AR7(3)    ; save updated circular buffer point
  184.                 ; for next sample
  185.     RETS            ; return y(n) in R0
  186.  
  187.  
  188. ;        PERFORM ARRAY FILTERING
  189. ;Input:
  190. ;    AR4    address of x(n) array
  191. ;    AR5    address of y(n) array
  192. ;    AR6    number of samples-1 in array
  193. ;    AR7    address of FIR filter structure
  194. ;Output:
  195. ;    AR(0-2), AR(4-6), R0, R2, BK, RC, RS, RE destroyed
  196. ;
  197.     .globl    FIR_Aasea
  198. FIR_Aasea:    
  199.     LDI    *++AR7(2),AR1    ; AR1 = address of coefficients
  200.     LDI    *++AR7,AR0    ; AR0 = address of x(n) in circular
  201.                 ; delay memory
  202.                 ; NOTE: AR7 now points to delay address
  203.     LDF    *AR4++,R0    ; R0 = x(n) (first sample of array)
  204.     LDI    *+AR7(2),BK    ; Set block size for circular buffer
  205.                 ; of x(n)
  206. floop:
  207.     LDF    *+AR7,R2    ; initialize R2 to 0.0
  208. ||    STF    R0,*AR0        ; put x(n) in delay memory
  209.     MPYF    *AR1++,*AR0++%,R0 ; h(0)*x(n) -> R0
  210.     RPTS    *+AR7(3)
  211.     MPYF    *AR1++,*AR0++%,R0
  212. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2    
  213.     MPYF    *--AR1,*AR0++%,R0
  214. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2
  215.     RPTS    *+AR7(4)
  216.     MPYF    *--AR1,*AR0++%,R0
  217. ||    SUBF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2
  218.     DBD    AR6,floop    ; do more samples?
  219.     LDI    *-AR7,AR1    ; AR1 = address of coefficients
  220.     SUBF    R0,R2,R0    ; add last product
  221.     LDF    *AR4++,R0    ; get next sample
  222. ||    STF    R0,*AR5++    ; output y(n) to array
  223.  
  224.     STI    AR0,*AR7--(3)    ; save updated circular buffer point
  225.                 ; for next samples
  226.     RETS
  227.  
  228.     .end
  229. ;**************************** FIR_AASO.ASM **************************** 
  230. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  231. ;                                                           ;
  232. ;               TMS320C30 FIR filter realization            ;
  233. ;                                                           ;
  234. ;     (c) Copyright 1989, Atlanta Signal Processors, Inc.   ;
  235. ;                    All Rights Reserved                    ;
  236. ;                                                           ;
  237. ;                       Size Optimized                      ;
  238. ;                                                           ;
  239. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  240.  
  241. ;Assemble code callable FIR filter subroutines for
  242. ;  an odd number of anti-symetric coefficients.
  243.  
  244. ;The following structure defines the data structure that the Init routine
  245. ;initializes.  This structure is passed, along with x(n) to the filter
  246. ;routines.
  247.  
  248. ;struct FIR {
  249. ;    float    (*filter)();    /* pointer to sample by sample filter routine */
  250. ;    void    (*filtera)();    /* pointer to array filter routine */
  251. ;    float    *coef_mem;    /* pointer to coef. memory */
  252. ;    float    *delay_mem;    /* pointer to delay memory */
  253. ;    float    zero;        /* a floating point 0 */
  254. ;    int    BK_reg;        /* value to be placed in BK register */
  255. ;    int    frtaps;        /* number of taps for RPTS forward */
  256. ;    int    rrtaps;        /* number of taps for RPTS reverse */
  257. ;    };
  258.  
  259. ;        PERFORM THE SAMPLE BY SAMPLE FILTERING
  260. ;Input:
  261. ;    R0    x(n)
  262. ;    AR7    pointer to FIR filter structure
  263. ;Ouput:
  264. ;    R0    y(n)
  265. ;    R2, AR0, AR1, BK, RC, RS, RE destroyed
  266.  
  267.     .globl    FIR_Aaso
  268. FIR_Aaso:    
  269.     LDI    *+AR7(2),AR1    ; AR1 = address of coefficients
  270.     LDI    *+AR7(3),AR0    ; AR0 = address of x(n) in circular
  271.                 ; delay memory
  272.     LDF    0.0,R2        ; initialize R2
  273.     LDI    *+AR7(5),BK    ; Set block size for circular buffer
  274.                 ; of x(n)
  275.     STF    R0,*AR0        ; put x(n) in delay memory
  276.     MPYF    *AR1++,*AR0++%,R0 ; h(0)*x(n) -> R0
  277.     RPTS    *+AR7(6)
  278.     MPYF    *AR1++,*AR0++%,R0
  279. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2    
  280.     MPYF    *AR1--,*AR0++%,R0
  281. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2
  282.     RPTS    *+AR7(7)
  283.     MPYF    *AR1--,*AR0++%,R0
  284. ||    SUBF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2
  285.     SUBF    R0,R2,R0    ; add last product
  286.     STI    AR0,*+AR7(3)    ; save updated circular buffer point
  287.                 ; for next sample
  288.     RETS            ; return y(n) in R0
  289.  
  290.  
  291. ;        PERFORM ARRAY FILTERING
  292. ;Input:
  293. ;    AR4    address of x(n) array
  294. ;    AR5    address of y(n) array
  295. ;    AR6    number of samples-1 in array
  296. ;    AR7    address of FIR filter structure
  297. ;Output:
  298. ;    AR(0-2), AR4, AR5, R0, R2, BK, RC, RS, RE destroyed
  299. ;
  300.     .globl    FIR_Aasoa
  301. FIR_Aasoa:    
  302.     LDI    *++AR7(2),AR1    ; AR1 = address of coefficients
  303.     LDI    *++AR7,AR0    ; AR0 = address of x(n) in circular
  304.                 ; delay memory
  305.                 ; NOTE: AR7 now points to delay address
  306.     LDF    *AR4++,R0    ; R0 = x(n) (first sample of array)
  307.     LDI    *+AR7(2),BK    ; Set block size for circular buffer
  308.                 ; of x(n)
  309. floop:
  310.     LDF    *+AR7,R2    ; initialize R2 to 0.0
  311. ||    STF    R0,*AR0        ; put x(n) in delay memory
  312.     MPYF    *AR1++,*AR0++%,R0 ; h(0)*x(n) -> R0
  313.     RPTS    *+AR7(3)
  314.     MPYF    *AR1++,*AR0++%,R0
  315. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2    
  316.     MPYF    *AR1--,*AR0++%,R0
  317. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2    
  318.     RPTS    *+AR7(4)
  319.     MPYF    *AR1--,*AR0++%,R0
  320. ||    SUBF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2    
  321.     DBD    AR6,floop    ; do more samples?
  322.     LDI    *-AR7,AR1    ; AR1 = address of coefficients
  323.     SUBF    R0,R2,R0    ; add last product
  324.     LDF    *AR4++,R0    ; get next sample
  325. ||    STF    R0,*AR5++    ; output y(n) to array
  326.  
  327.     STI    AR0,*AR7--(3)    ; save updated circular buffer point
  328.                 ; for next samples
  329.     RETS
  330.  
  331.     .end
  332. ;**************************** FIR_ASE.ASM **************************** 
  333. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  334. ;                                                           ;
  335. ;               TMS320C30 FIR filter realization            ;
  336. ;                                                           ;
  337. ;     (c) Copyright 1989, Atlanta Signal Processors, Inc.   ;
  338. ;                    All Rights Reserved                    ;
  339. ;                                                           ;
  340. ;                       Size Optimized                      ;
  341. ;                                                           ;
  342. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  343.  
  344. ;Assemble code callable FIR filter subroutines for
  345. ;  an even number of symetric coefficients.
  346.  
  347. ;The following structure defines the data structure that the Init routine
  348. ;initializes.  This structure is passed, along with x(n) to the filter
  349. ;routines.
  350.  
  351. ;struct FIR {
  352. ;    float    (*filter)();    /* pointer to sample by sample filter routine */
  353. ;    void    (*filtera)();    /* pointer to array filter routine */
  354. ;    float    *coef_mem;    /* pointer to coef. memory */
  355. ;    float    *delay_mem;    /* pointer to delay memory */
  356. ;    float    zero;        /* a floating point 0 */
  357. ;    int    BK_reg;        /* value to be placed in BK register */
  358. ;    int    frtaps;        /* number of taps for RPTS forward */
  359. ;    int    rrtaps;        /* number of taps for RPTS reverse */
  360. ;    };
  361.  
  362. ;        PERFORM THE SAMPLE BY SAMPLE FILTERING
  363. ;Input:
  364. ;    R0    x(n)
  365. ;    AR7    pointer to FIR filter structure
  366. ;Ouput:
  367. ;    R0    y(n)
  368. ;    R2, AR0, AR1, BK, RC, RS, RE destroyed
  369.  
  370.     .globl    FIR_Ase
  371. FIR_Ase:
  372.     LDI    *+AR7(2),AR1    ; AR1 = address of coefficients
  373.     LDI    *+AR7(3),AR0    ; AR0 = address of x(n) in circular
  374.                 ; delay memory
  375.     LDF    0.0,R2        ; initialize R2
  376.     LDI    *+AR7(5),BK    ; Set block size for circular buffer
  377.                 ; of x(n)
  378.     STF    R0,*AR0        ; put x(n) in delay memory
  379.     MPYF    *AR1++,*AR0++%,R0 ; h(0)*x(n) -> R0
  380.     RPTS    *+AR7(6)
  381.     MPYF    *AR1++,*AR0++%,R0
  382. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2    
  383.     RPTS    *+AR7(7)
  384.     MPYF    *--AR1,*AR0++%,R0
  385. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2
  386.     ADDF    R0,R2,R0    ; add last product
  387.     STI    AR0,*+AR7(3)    ; save updated circular buffer point
  388.                 ; for next sample
  389.     RETS            ; return y(n) in R0
  390.  
  391.  
  392. ;        PERFORM ARRAY FILTERING
  393. ;Input:
  394. ;    AR4    address of x(n) array
  395. ;    AR5    address of y(n) array
  396. ;    AR6    number of samples-1 in array
  397. ;    AR7    address of FIR filter structure
  398. ;Output:
  399. ;    AR(0-2), AR(4-6), R0, R2, BK, RC, RS, RE destroyed
  400. ;
  401.     .globl    FIR_Asea
  402. FIR_Asea:    
  403.     LDI    *++AR7(2),AR1    ; AR1 = address of coefficients
  404.     LDI    *++AR7,AR0    ; AR0 = address of x(n) in circular
  405.                 ; delay memory
  406.                 ; NOTE: AR7 now points to delay address
  407.     LDF    *AR4++,R0    ; R0 = x(n) (first sample of array)
  408.     LDI    *+AR7(2),BK    ; Set block size for circular buffer
  409.                 ; of x(n)
  410. floop:
  411.     LDF    *+AR7,R2    ; initialize R2 to 0.0
  412. ||    STF    R0,*AR0        ; put x(n) in delay memory
  413.     MPYF    *AR1++,*AR0++%,R0 ; h(0)*x(n) -> R0
  414.     RPTS    *+AR7(3)
  415.     MPYF    *AR1++,*AR0++%,R0
  416. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2    
  417.     RPTS    *+AR7(4)
  418.     MPYF    *--AR1,*AR0++%,R0
  419. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2
  420.     DBD    AR6,floop    ; do more samples?
  421.     LDI    *-AR7,AR1    ; AR1 = address of coefficients
  422.     ADDF    R0,R2,R0    ; add last product
  423.     LDF    *AR4++,R0    ; get next sample
  424. ||    STF    R0,*AR5++    ; output y(n) to array
  425.  
  426.     STI    AR0,*AR7--(3)    ; save updated circular buffer point
  427.                 ; for next samples
  428.     RETS
  429.  
  430.     .end
  431. ;**************************** FIR_ASO.ASM **************************** 
  432. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  433. ;                                                           ;
  434. ;               TMS320C30 FIR filter realization            ;
  435. ;                                                           ;
  436. ;     (c) Copyright 1989, Atlanta Signal Processors, Inc.   ;
  437. ;                    All Rights Reserved                    ;
  438. ;                                                           ;
  439. ;                       Size Optimized                      ;
  440. ;                                                           ;
  441. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  442.  
  443. ;Assemble code callable FIR filter subroutines for
  444. ;  an odd number of symetric coefficients.
  445.  
  446. ;The following structure defines the data structure that the Init routine
  447. ;initializes.  This structure is passed, along with x(n) to the filter
  448. ;routines.
  449.  
  450. ;struct FIR {
  451. ;    float    (*filter)();    /* pointer to sample by sample filter routine */
  452. ;    void    (*filtera)();    /* pointer to array filter routine */
  453. ;    float    *coef_mem;    /* pointer to coef. memory */
  454. ;    float    *delay_mem;    /* pointer to delay memory */
  455. ;    float    zero;        /* a floating point 0 */
  456. ;    int    BK_reg;        /* value to be placed in BK register */
  457. ;    int    frtaps;        /* number of taps for RPTS forward */
  458. ;    int    rrtaps;        /* number of taps for RPTS reverse */
  459. ;    };
  460.  
  461. ;        PERFORM THE SAMPLE BY SAMPLE FILTERING
  462. ;Input:
  463. ;    R0    x(n)
  464. ;    AR7    pointer to FIR filter structure
  465. ;Ouput:
  466. ;    R0    y(n)
  467. ;    R2, AR0, AR1, BK, RC, RS, RE destroyed
  468.  
  469.     .globl    FIR_Aso
  470. FIR_Aso:    
  471.     LDI    *+AR7(2),AR1    ; AR1 = address of coefficients
  472.     LDI    *+AR7(3),AR0    ; AR0 = address of x(n) in circular
  473.                 ; delay memory
  474.     LDF    0.0,R2        ; initialize R2
  475.     LDI    *+AR7(5),BK    ; Set block size for circular buffer
  476.                 ; of x(n)
  477.     STF    R0,*AR0        ; put x(n) in delay memory
  478.     MPYF    *AR1++,*AR0++%,R0 ; h(0)*x(n) -> R0
  479.     RPTS    *+AR7(6)
  480.     MPYF    *AR1++,*AR0++%,R0
  481. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2    
  482.     RPTS    *+AR7(7)
  483.     MPYF    *AR1--,*AR0++%,R0
  484. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2
  485.     ADDF    R0,R2,R0    ; add last product
  486.     STI    AR0,*+AR7(3)    ; save updated circular buffer point
  487.                 ; for next sample
  488.     RETS            ; return y(n) in R0
  489.  
  490.  
  491. ;        PERFORM ARRAY FILTERING
  492. ;Input:
  493. ;    AR4    address of x(n) array
  494. ;    AR5    address of y(n) array
  495. ;    AR6    number of samples-1 in array
  496. ;    AR7    address of FIR filter structure
  497. ;Output:
  498. ;    AR(0-2), AR4, AR5, R0, R2, BK, RC, RS, RE destroyed
  499. ;
  500.     .globl    FIR_Asoa
  501. FIR_Asoa:    
  502.     LDI    *++AR7(2),AR1    ; AR1 = address of coefficients
  503.     LDI    *++AR7,AR0    ; AR0 = address of x(n) in circular
  504.                 ; delay memory
  505.                 ; NOTE: AR7 now points to delay address
  506.     LDF    *AR4++,R0    ; R0 = x(n) (first sample of array)
  507.     LDI    *+AR7(2),BK    ; Set block size for circular buffer
  508.                 ; of x(n)
  509. floop:
  510.     LDF    *+AR7,R2    ; initialize R2 to 0.0
  511. ||    STF    R0,*AR0        ; put x(n) in delay memory
  512.     MPYF    *AR1++,*AR0++%,R0 ; h(0)*x(n) -> R0
  513.     RPTS    *+AR7(3)
  514.     MPYF    *AR1++,*AR0++%,R0
  515. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2    
  516.     RPTS    *+AR7(4)
  517.     MPYF    *AR1--,*AR0++%,R0
  518. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2    
  519.     DBD    AR6,floop    ; do more samples?
  520.     LDI    *-AR7,AR1    ; AR1 = address of coefficients
  521.     ADDF    R0,R2,R0    ; add last product
  522.     LDF    *AR4++,R0    ; get next sample
  523. ||    STF    R0,*AR5++    ; output y(n) to array
  524.  
  525.     STI    AR0,*AR7--(3)    ; save updated circular buffer point
  526.                 ; for next samples
  527.     RETS
  528.  
  529.     .end
  530. ;**************************** FIR_F.ASM **************************** 
  531. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  532. ;                                                           ;
  533. ;               TMS320C30 FIR filter realization            ;
  534. ;                                                           ;
  535. ;     (c) Copyright 1989, Atlanta Signal Processors, Inc.   ;
  536. ;                    All Rights Reserved                    ;
  537. ;                                                           ;
  538. ;                       Time Optimized                      ;
  539. ;                                                           ;
  540. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  541.  
  542. ;'C' code callable FIR filter subroutines
  543.  
  544. ;The following structure defines the 'C' structure that the Init routine
  545. ;initializes.  This structure is passed, along with x(n) to the filter
  546. ;routines.
  547.  
  548. ;struct FIR {
  549. ;    float    (*filter)();    /* pointer to sample by sample filter routine */
  550. ;    void    (*filtera)();    /* pointer to array filter routine */
  551. ;    float    *coef_mem;    /* pointer to coef. memory */
  552. ;    float    *delay_mem;    /* pointer to delay memory */
  553. ;    float    zero;        /* a floating point 0 */
  554. ;    int    BK_reg;        /* value to be placed in BK register */
  555. ;    int    frtaps;        /* number of taps for RPTS forward */
  556. ;    };
  557.  
  558.     .globl    _FIR_C
  559.     .globl    _FIR_Ca
  560.  
  561. FP    .set    AR3
  562.  
  563.  
  564. ;        PERFORM THE SAMPLE BY SAMPLE FILTERING
  565. ;float (*param->filter)(xn,param)
  566. ;float xn
  567. ;struct FIR *param;
  568. ;
  569. ; filter returns y(n) for input x(n)
  570. ;
  571. ; the filter routine must be called with x(0) first then x(1)
  572. ; and so on.
  573.  
  574. _FIR_C:    
  575.     PUSH    FP
  576.     LDI    SP,FP
  577.  
  578.     LDI    *-FP(3),AR2    ; AR2 = address of FIR filter structure
  579.     LDI    *+AR2(2),AR1    ; AR1 = address of coefficients
  580.     LDI    *+AR2(3),AR0    ; AR0 = address of x(n) in circular
  581.                 ; delay memory
  582.     LDF    0.0,R2        ; initialize R2
  583.     LDI    *+AR2(5),BK    ; Set block size for circular buffer
  584.                 ; of x(n)
  585.     LDF    *-FP(2),R0    ; R0 = x(n)
  586.     STF    R0,*AR0        ; put x(n) in delay memory
  587.     MPYF    *AR1++,*AR0++%,R0 ; h(0)*x(n) -> R0
  588.     RPTS    *+AR2(6)
  589.     MPYF    *AR1++,*AR0++%,R0
  590. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2
  591.     MPYF    *AR1++,*AR0++%,R0
  592. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2
  593.     ADDF    R0,R2,R0    ; add last product
  594.     
  595.     STI    AR0,*+AR2(3)    ; save updated circular buffer point
  596.                 ; for next sample
  597.     POP    FP
  598.     RETS            ; return y(n) in R0
  599.  
  600.  
  601. ;        PERFORM ARRAY FILTERING
  602. ;void (*param->filtera)(xy,xn,n,param)
  603. ;float *xn, *yn
  604. ;int n;
  605. ;struct FIR *param;
  606. ;
  607. ; filter returns y(n) for input x(n)
  608. ; xn and yn are pointers to arrays of size n+1 floats
  609. ;
  610. ; the filter routine must be called with x(0) thru x(n)
  611. ; first then x(n+1) thru x(....) and so on.
  612.  
  613. ; 'rblock' is set to one if the majority of the filter is to be executed
  614. ; in repeat block mode rather than repeat single mode.  The advantage
  615. ; of repeat block over single is that it saves 2 cycles per sample,
  616. ; although it adds at 10 cycles to the call.
  617. ; The advantage of repeat single is that it is it does not fetch
  618. ; the instruction every cycle.  If the instruction cache is on this
  619. ; becomes unimportant.
  620.  
  621. rblock    .set    1
  622.  
  623. _FIR_Ca:    
  624.     PUSH    FP
  625.     LDI    SP,FP
  626.     PUSH    AR4
  627.     PUSH    AR5
  628.     PUSH    AR7
  629.  
  630.     LDI    *-FP(2),AR4    ; AR4 = address of y(n)
  631.     LDI    *-FP(3),AR2    ; AR2 = address of x(n)
  632.     LDI    *-FP(4),AR5    ; AR5 = number of samples
  633.     LDI    *-FP(5),AR7    ; AR7 = address of FIR filter structure
  634.     LDI    *++AR7(2),AR1    ; AR1 = address of coefficients
  635.     LDI    *++AR7,AR0    ; AR0 = address of x(n) in circular
  636.                 ;  delay memory
  637.                 ;  NOTE: AR7 now points to delay address
  638.     LDF    *AR2++,R0    ; R0 = x(n) (first sample of array)
  639.     LDI    *+AR7(2),BK    ; Set block size for circular buffer
  640.                 ;  of x(n)
  641.     LDI    *+AR7(4),IR0    ; IR0 = NUMBER of taps-1
  642.  
  643.     LDF    *+AR7,R2    ; initialize R2 to 0.0
  644. ||    STF    R0,*AR0        ; put x(n) in delay memory
  645.     MPYF    *AR1++,*AR0++%,R0 ; h(0)*x(n) -> R0
  646.     .if    rblock
  647.     RPTS    *+AR7(3)
  648. floop:
  649.     .else
  650. floop:
  651.     RPTS    *+AR7(3)
  652.     .endif
  653.     MPYF    *AR1++,*AR0++%,R0
  654. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2
  655.     MPYF    *AR1--(IR0),*AR0++%,R0
  656. ||    ADDF    R0,R2,R3    ; h(l)*x(n-l) + R2 -> R3
  657.  
  658.     .if    rblock
  659.     LDI    *+AR7(3),RC    ; Set the number of times to repeat
  660.     OR    100h,ST        ; Turn repeat on
  661.     .endif
  662.  
  663.     DBD    AR5,floop    ; do more samples?
  664.     LDF    *AR2,R1        ; get next sample
  665. ||    LDF    *+AR7,R2    ; initialize R2 to 0.0
  666.     MPYF3    *AR2++,*AR1++,R0; x(n+1) * h(0) -> R0
  667. ||    ADDF3    R0,R3,R3    ; final sum for y(n) -> R3
  668.     STF    R3,*AR4++    ; store y(n) into array
  669. ||    STF    R1,*AR0++%    ; store x(n+1) into delay memory
  670.  
  671.     .if    rblock
  672.     AND    0feffh,ST    ; turn off repeat
  673.     .endif
  674.     NOP    *AR0--%        ; back up delay pointer for next x(n)
  675.     STI    AR0,*AR7    ; save updated circular buffer point
  676.                 ; for next samples
  677.  
  678.     POP    AR7
  679.     POP    AR5
  680.     POP    AR4
  681.     POP    FP
  682.     RETS
  683.  
  684.     .end
  685. ;**************************** FIR_FASE.ASM **************************** 
  686. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  687. ;                                                           ;
  688. ;               TMS320C30 FIR filter realization            ;
  689. ;                                                           ;
  690. ;     (c) Copyright 1989, Atlanta Signal Processors, Inc.   ;
  691. ;                    All Rights Reserved                    ;
  692. ;                                                           ;
  693. ;                       Size Optimized                      ;
  694. ;                                                           ;
  695. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  696.  
  697. ;'C' code callable FIR filter subroutines for
  698. ; an even number of anti-symetric coefficients
  699.  
  700. ;The following structure defines the 'C' structure that the Init routine
  701. ;initializes.  This structure is passed, along with x(n) to the filter
  702. ;routines.
  703.  
  704. ;struct FIR {
  705. ;    float    (*filter)();    /* pointer to sample by sample filter routine */
  706. ;    void    (*filtera)();    /* pointer to array filter routine */
  707. ;    float    *coef_mem;    /* pointer to coef. memory */
  708. ;    float    *delay_mem;    /* pointer to delay memory */
  709. ;    float    zero;        /* a floating point 0 */
  710. ;    int    BK_reg;        /* value to be placed in BK register */
  711. ;    int    frtaps;        /* number of taps for RPTS forward */
  712. ;    int    rrtaps;        /* number of taps for RPTS reverse */
  713. ;    };
  714.  
  715.     .globl    _FIR_Case
  716.     .globl    _FIR_Casea
  717.  
  718. FP    .set    AR3
  719.  
  720.  
  721. ;        PERFORM THE SAMPLE BY SAMPLE FILTERING
  722. ;        This routine requires that the coefs are assymetric
  723. ;        and there are an even number of them.
  724. ;
  725. ;float filter(xn,param)
  726. ;float xn
  727. ;struct FIR *param;
  728. ;
  729. ; filter returns y(n) for input x(n)
  730. ;
  731. ; the filter routine must be called with x(0) first then x(1)
  732. ; and so on.
  733.  
  734. _FIR_Case:
  735.     PUSH    FP
  736.     LDI    SP,FP
  737.  
  738.     LDI    *-FP(3),AR2    ; AR2 = address of FIR filter structure
  739.     LDI    *+AR2(2),AR1    ; AR1 = address of coefficients
  740.     LDI    *+AR2(3),AR0    ; AR0 = address of x(n) in circular
  741.                 ; delay memory
  742.     LDF    0.0,R2        ; initialize R2
  743.     LDI    *+AR2(5),BK    ; Set block size for circular buffer
  744.                 ; of x(n)
  745.     LDF    *-FP(2),R0    ; R0 = x(n)
  746.     STF    R0,*AR0        ; put x(n) in delay memory
  747.     MPYF    *AR1++,*AR0++%,R0 ; h(0)*x(n) -> R0
  748.     RPTS    *+AR2(6)
  749.     MPYF    *AR1++,*AR0++%,R0
  750. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2
  751.     MPYF    *--AR1,*AR0++%,R0
  752. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2
  753.     RPTS    *+AR2(7)
  754.     MPYF    *--AR1,*AR0++%,R0
  755. ||    SUBF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2
  756.     SUBF    R0,R2,R0    ; add last product
  757.     
  758.     STI    AR0,*+AR2(3)    ; save updated circular buffer point
  759.                 ; for next sample
  760.     POP    FP
  761.     RETS            ; return y(n) in R0
  762.  
  763.  
  764. ;        PERFORM ARRAY FILTERING
  765. ;void filtera(xy,xn,n,param)
  766. ;float *xn, *yn
  767. ;int n;
  768. ;struct FIR *param;
  769. ;
  770. ; filter returns y(n) for input x(n)
  771. ; xn and yn are pointers to arrays of size n+1 floats
  772. ;
  773. ; the filter routine must be called with x(0) thru x(n)
  774. ; first then x(n+1) thru x(....) and so on.
  775.  
  776. _FIR_Casea:    
  777.     PUSH    FP
  778.     LDI    SP,FP
  779.     PUSH    AR4
  780.     PUSH    AR5
  781.     PUSH    AR7
  782.  
  783.     LDI    *-FP(2),AR4    ; AR4 = address of y(n)
  784.     LDI    *-FP(3),AR2    ; AR2 = address of x(n)
  785.     LDI    *-FP(4),AR5    ; AR5 = number of samples
  786.     LDI    *-FP(5),AR7    ; AR7 = address of FIR filter structure
  787.     LDI    *++AR7(2),AR1    ; AR1 = address of coefficients
  788.     LDI    *++AR7,AR0    ; AR0 = address of x(n) in circular
  789.                 ; delay memory
  790.     LDF    *AR2++,R0    ; R0 = x(n) (first sample of array)
  791.     LDI    *+AR7(2),BK    ; Set block size for circular buffer
  792.                 ; of x(n)
  793.                 ; NOTE: AR7 now points to 0.0 in struct FIR
  794. floop:
  795.     LDF    *+AR7,R2    ; initialize R2 to 0.0
  796. ||    STF    R0,*AR0        ; put x(n) in delay memory
  797.     MPYF    *AR1++,*AR0++%,R0 ; h(0)*x(n) -> R0
  798.     RPTS    *+AR7(3)
  799.     MPYF    *AR1++,*AR0++%,R0
  800. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2
  801.     MPYF    *--AR1,*AR0++%,R0
  802. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2
  803.     RPTS    *+AR7(4)
  804.     MPYF    *--AR1,*AR0++%,R0
  805. ||    SUBF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2
  806.     DBD    AR5,floop    ; do more samples?
  807.     LDI    *-AR7,AR1    ; AR1 = address of coefficients
  808.     SUBF    R0,R2,R0    ; add last product
  809.     LDF    *AR2++,R0    ; get next sample
  810. ||    STF    R0,*AR4++    ; output y(n) to array
  811.  
  812.     STI    AR0,*AR7    ; save updated circular buffer point
  813.                 ; for next samples
  814.  
  815.     POP    AR7
  816.     POP    AR5
  817.     POP    AR4
  818.     POP    FP
  819.     RETS
  820.  
  821.     .end
  822. ;**************************** FIR_FASO.ASM **************************** 
  823. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  824. ;                                                           ;
  825. ;               TMS320C30 FIR filter realization            ;
  826. ;                                                           ;
  827. ;     (c) Copyright 1989, Atlanta Signal Processors, Inc.   ;
  828. ;                    All Rights Reserved                    ;
  829. ;                                                           ;
  830. ;                       Size Optimized                      ;
  831. ;                                                           ;
  832. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  833.  
  834. ;'C' code callable FIR filter subroutines for
  835. ; an odd number of anti-symetric coefficients
  836.  
  837. ;The following structure defines the 'C' structure that the Init routine
  838. ;initializes.  This structure is passed, along with x(n) to the filter
  839. ;routines.
  840.  
  841. ;struct FIR {
  842. ;    float    (*filter)();    /* pointer to sample by sample filter routine */
  843. ;    void    (*filtera)();    /* pointer to array filter routine */
  844. ;    float    *coef_mem;    /* pointer to coef. memory */
  845. ;    float    *delay_mem;    /* pointer to delay memory */
  846. ;    float    zero;        /* a floating point 0 */
  847. ;    int    BK_reg;        /* value to be placed in BK register */
  848. ;    int    frtaps;        /* number of taps for RPTS forward */
  849. ;    int    rrtaps;        /* number of taps for RPTS reverse */
  850. ;    };
  851.  
  852.     .globl    _FIR_Caso
  853.     .globl    _FIR_Casoa
  854.  
  855. FP    .set    AR3
  856.  
  857.  
  858. ;        PERFORM THE SAMPLE BY SAMPLE FILTERING
  859. ;        This routine requires that the coefs are assymetric
  860. ;        and there are an odd number of them.
  861. ;
  862. ;float filter(xn,param)
  863. ;float xn
  864. ;struct FIR *param;
  865. ;
  866. ; filter returns y(n) for input x(n)
  867. ;
  868. ; the filter routine must be called with x(0) first then x(1)
  869. ; and so on.
  870.  
  871. _FIR_Caso:
  872.     PUSH    FP
  873.     LDI    SP,FP
  874.  
  875.     LDI    *-FP(3),AR2    ; AR2 = address of FIR filter structure
  876.     LDI    *+AR2(2),AR1    ; AR1 = address of coefficients
  877.     LDI    *+AR2(3),AR0    ; AR0 = address of x(n) in circular
  878.                 ; delay memory
  879.     LDF    0.0,R2        ; initialize R2
  880.     LDI    *+AR2(5),BK    ; Set block size for circular buffer
  881.                 ; of x(n)
  882.     LDF    *-FP(2),R0    ; R0 = x(n)
  883.     STF    R0,*AR0        ; put x(n) in delay memory
  884.     MPYF    *AR1++,*AR0++%,R0 ; h(0)*x(n) -> R0
  885.     RPTS    *+AR2(6)
  886.     MPYF    *AR1++,*AR0++%,R0
  887. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2
  888.     MPYF    *AR1--,*AR0++%,R0
  889. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2
  890.     RPTS    *+AR2(7)
  891.     MPYF    *AR1--,*AR0++%,R0
  892. ||    SUBF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2
  893.     SUBF    R0,R2,R0    ; add last product
  894.     
  895.     STI    AR0,*+AR2(3)    ; save updated circular buffer point
  896.                 ; for next sample
  897.     POP    FP
  898.     RETS            ; return y(n) in R0
  899.  
  900.  
  901. ;        PERFORM ARRAY FILTERING
  902. ;void filtera(xy,xn,n,param)
  903. ;float *xn, *yn
  904. ;int n;
  905. ;struct FIR *param;
  906. ;
  907. ; filter returns y(n) for input x(n)
  908. ; xn and yn are pointers to arrays of size n+1 floats
  909. ;
  910. ; the filter routine must be called with x(0) thru x(n)
  911. ; first then x(n+1) thru x(....) and so on.
  912.  
  913. _FIR_Casoa:    
  914.     PUSH    FP
  915.     LDI    SP,FP
  916.     PUSH    AR4
  917.     PUSH    AR5
  918.     PUSH    AR7
  919.  
  920.     LDI    *-FP(2),AR4    ; AR4 = address of y(n)
  921.     LDI    *-FP(3),AR2    ; AR2 = address of x(n)
  922.     LDI    *-FP(4),AR5    ; AR5 = number of samples
  923.     LDI    *-FP(5),AR7    ; AR7 = address of FIR filter structure
  924.     LDI    *++AR7(2),AR1    ; AR1 = address of coefficients
  925.     LDI    *++AR7,AR0    ; AR0 = address of x(n) in circular
  926.                 ; delay memory
  927.     LDF    *AR2++,R0    ; R0 = x(n) (first sample of array)
  928.     LDI    *+AR7(2),BK    ; Set block size for circular buffer
  929.                 ; of x(n)
  930.                 ; NOTE: AR7 now points to 0.0 in struct FIR
  931. floop:
  932.     LDF    *+AR7,R2    ; initialize R2 to 0.0
  933. ||    STF    R0,*AR0        ; put x(n) in delay memory
  934.     MPYF    *AR1++,*AR0++%,R0 ; h(0)*x(n) -> R0
  935.     RPTS    *+AR7(3)
  936.     MPYF    *AR1++,*AR0++%,R0
  937. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2
  938.     MPYF    *AR1--,*AR0++%,R0
  939. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2
  940.     RPTS    *+AR7(4)
  941.     MPYF    *AR1--,*AR0++%,R0
  942. ||    SUBF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2
  943.     DBD    AR5,floop    ; do more samples?
  944.     LDI    *-AR7,AR1    ; AR1 = address of coefficients
  945.     SUBF    R0,R2,R0    ; add last product
  946.     LDF    *AR2++,R0    ; get next sample
  947. ||    STF    R0,*AR4++    ; output y(n) to array
  948.  
  949.     STI    AR0,*AR7    ; save updated circular buffer point
  950.                 ; for next samples
  951.  
  952.     POP    AR7
  953.     POP    AR5
  954.     POP    AR4
  955.     POP    FP
  956.     RETS
  957.  
  958.     .end
  959. ;**************************** FIR_FSE.ASM **************************** 
  960. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  961. ;                                                           ;
  962. ;               TMS320C30 FIR filter realization            ;
  963. ;                                                           ;
  964. ;     (c) Copyright 1989, Atlanta Signal Processors, Inc.   ;
  965. ;                    All Rights Reserved                    ;
  966. ;                                                           ;
  967. ;                       Size Optimized                      ;
  968. ;                                                           ;
  969. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  970.  
  971. ;'C' code callable FIR filter subroutines for
  972. ; an even number of symetric coefficients
  973.  
  974. ;The following structure defines the 'C' structure that the Init routine
  975. ;initializes.  This structure is passed, along with x(n) to the filter
  976. ;routines.
  977.  
  978. ;struct FIR {
  979. ;    float    (*filter)();    /* pointer to sample by sample filter routine */
  980. ;    void    (*filtera)();    /* pointer to array filter routine */
  981. ;    float    *coef_mem;    /* pointer to coef. memory */
  982. ;    float    *delay_mem;    /* pointer to delay memory */
  983. ;    float    zero;        /* a floating point 0 */
  984. ;    int    BK_reg;        /* value to be placed in BK register */
  985. ;    int    frtaps;        /* number of taps for RPTS forward */
  986. ;    int    rrtaps;        /* number of taps for RPTS reverse */
  987. ;    };
  988.  
  989.     .globl    _FIR_Cse
  990.     .globl    _FIR_Csea
  991.  
  992. FP    .set    AR3
  993.  
  994.  
  995. ;        PERFORM THE SAMPLE BY SAMPLE FILTERING
  996. ;        This routine requires that the coefs are symetric
  997. ;        and that there are an even number of them.
  998. ;
  999. ;float filter(xn,param)
  1000. ;float xn
  1001. ;struct FIR *param;
  1002. ;
  1003. ; filter returns y(n) for input x(n)
  1004. ;
  1005. ; the filter routine must be called with x(0) first then x(1)
  1006. ; and so on.
  1007.  
  1008. _FIR_Cse:
  1009.     PUSH    FP
  1010.     LDI    SP,FP
  1011.  
  1012.     LDI    *-FP(3),AR2    ; AR2 = address of FIR filter structure
  1013.     LDI    *+AR2(2),AR1    ; AR1 = address of coefficients
  1014.     LDI    *+AR2(3),AR0    ; AR0 = address of x(n) in circular
  1015.                 ; delay memory
  1016.     LDF    0.0,R2        ; initialize R2
  1017.     LDI    *+AR2(5),BK    ; Set block size for circular buffer
  1018.                 ; of x(n)
  1019.     LDF    *-FP(2),R0    ; R0 = x(n)
  1020.     STF    R0,*AR0        ; put x(n) in delay memory
  1021.     MPYF    *AR1++,*AR0++%,R0 ; h(0)*x(n) -> R0
  1022.     RPTS    *+AR2(6)
  1023.     MPYF    *AR1++,*AR0++%,R0
  1024. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2
  1025.     RPTS    *+AR2(7)
  1026.     MPYF    *--AR1,*AR0++%,R0
  1027. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2
  1028.     ADDF    R0,R2,R0    ; add last product
  1029.     
  1030.     STI    AR0,*+AR2(3)    ; save updated circular buffer point
  1031.                 ; for next sample
  1032.     POP    FP
  1033.     RETS            ; return y(n) in R0
  1034.  
  1035.  
  1036. ;        PERFORM ARRAY FILTERING
  1037. ;void filtera(xy,xn,n,param)
  1038. ;float *xn, *yn
  1039. ;int n;
  1040. ;struct FIR *param;
  1041. ;
  1042. ; filter returns y(n) for input x(n)
  1043. ; xn and yn are pointers to arrays of size n+1 floats
  1044. ;
  1045. ; the filter routine must be called with x(0) thru x(n)
  1046. ; first then x(n+1) thru x(....) and so on.
  1047.  
  1048. _FIR_Csea:    
  1049.     PUSH    FP
  1050.     LDI    SP,FP
  1051.     PUSH    AR4
  1052.     PUSH    AR5
  1053.     PUSH    AR7
  1054.  
  1055.     LDI    *-FP(2),AR4    ; AR4 = address of y(n)
  1056.     LDI    *-FP(3),AR2    ; AR2 = address of x(n)
  1057.     LDI    *-FP(4),AR5    ; AR5 = number of samples
  1058.     LDI    *-FP(5),AR7    ; AR7 = address of FIR filter structure
  1059.     LDI    *++AR7(2),AR1    ; AR1 = address of coefficients
  1060.     LDI    *++AR7,AR0    ; AR0 = address of x(n) in circular
  1061.                 ; delay memory
  1062.     LDF    *AR2++,R0    ; R0 = x(n) (first sample of array)
  1063.     LDI    *+AR7(2),BK    ; Set block size for circular buffer
  1064.                 ; of x(n)
  1065.                 ; NOTE: AR7 now points to 0.0 in struct FIR
  1066. floop:
  1067.     LDF    *+AR7,R2    ; initialize R2 to 0.0
  1068. ||    STF    R0,*AR0        ; put x(n) in delay memory
  1069.     MPYF    *AR1++,*AR0++%,R0 ; h(0)*x(n) -> R0
  1070.     RPTS    *+AR7(3)
  1071.     MPYF    *AR1++,*AR0++%,R0
  1072. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2
  1073.     RPTS    *+AR7(4)
  1074.     MPYF    *--AR1,*AR0++%,R0
  1075. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2
  1076.     DBD    AR5,floop    ; do more samples?
  1077.     LDI    *-AR7,AR1    ; AR1 = address of coefficients
  1078.     ADDF    R0,R2,R0    ; add last product
  1079.     LDF    *AR2++,R0    ; get next sample
  1080. ||    STF    R0,*AR4++    ; output y(n) to array
  1081.  
  1082.     STI    AR0,*AR7    ; save updated circular buffer point
  1083.                 ; for next samples
  1084.  
  1085.     POP    AR7
  1086.     POP    AR5
  1087.     POP    AR4
  1088.     POP    FP
  1089.     RETS
  1090.  
  1091.     .end
  1092. ;**************************** FIR_FSO.ASM **************************** 
  1093. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1094. ;                                                           ;
  1095. ;               TMS320C30 FIR filter realization            ;
  1096. ;                                                           ;
  1097. ;     (c) Copyright 1989, Atlanta Signal Processors, Inc.   ;
  1098. ;                    All Rights Reserved                    ;
  1099. ;                                                           ;
  1100. ;                       Size Optimized                      ;
  1101. ;                                                           ;
  1102. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1103.  
  1104. ;'C' code callable FIR filter subroutines for
  1105. ; an odd number of symetric coefficients
  1106.  
  1107. ;The following structure defines the 'C' structure that the Init routine
  1108. ;initializes.  This structure is passed, along with x(n) to the filter
  1109. ;routines.
  1110.  
  1111. ;struct FIR {
  1112. ;    float    (*filter)();    /* pointer to sample by sample filter routine */
  1113. ;    void    (*filtera)();    /* pointer to array filter routine */
  1114. ;    float    *coef_mem;    /* pointer to coef. memory */
  1115. ;    float    *delay_mem;    /* pointer to delay memory */
  1116. ;    float    zero;        /* a floating point 0 */
  1117. ;    int    BK_reg;        /* value to be placed in BK register */
  1118. ;    int    frtaps;        /* number of taps for RPTS forward */
  1119. ;    int    rrtaps;        /* number of taps for RPTS reverse */
  1120. ;    };
  1121.  
  1122.     .globl    _FIR_Cso
  1123.     .globl    _FIR_Csoa
  1124.  
  1125. FP    .set    AR3
  1126.  
  1127.  
  1128. ;        PERFORM THE SAMPLE BY SAMPLE FILTERING
  1129. ;        This routine requires that the coefs are symetric
  1130. ;        and that there are an odd number of them.
  1131. ;
  1132. ;float filter(xn,param)
  1133. ;float xn
  1134. ;struct FIR *param;
  1135. ;
  1136. ; filter returns y(n) for input x(n)
  1137. ;
  1138. ; the filter routine must be called with x(0) first then x(1)
  1139. ; and so on.
  1140.  
  1141. _FIR_Cso:
  1142.     PUSH    FP
  1143.     LDI    SP,FP
  1144.  
  1145.     LDI    *-FP(3),AR2    ; AR2 = address of FIR filter structure
  1146.     LDI    *+AR2(2),AR1    ; AR1 = address of coefficients
  1147.     LDI    *+AR2(3),AR0    ; AR0 = address of x(n) in circular
  1148.                 ; delay memory
  1149.     LDF    0.0,R2        ; initialize R2
  1150.     LDI    *+AR2(5),BK    ; Set block size for circular buffer
  1151.                 ; of x(n)
  1152.     LDF    *-FP(2),R0    ; R0 = x(n)
  1153.     STF    R0,*AR0        ; put x(n) in delay memory
  1154.     MPYF    *AR1++,*AR0++%,R0 ; h(0)*x(n) -> R0
  1155.     RPTS    *+AR2(6)
  1156.     MPYF    *AR1++,*AR0++%,R0
  1157. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2
  1158.     RPTS    *+AR2(7)
  1159.     MPYF    *AR1--,*AR0++%,R0
  1160. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2
  1161.     ADDF    R0,R2,R0    ; add last product
  1162.     
  1163.     STI    AR0,*+AR2(3)    ; save updated circular buffer point
  1164.                 ; for next sample
  1165.     POP    FP
  1166.     RETS            ; return y(n) in R0
  1167.  
  1168.  
  1169. ;        PERFORM ARRAY FILTERING
  1170. ;void filtera(xy,xn,n,param)
  1171. ;float *xn, *yn
  1172. ;int n;
  1173. ;struct FIR *param;
  1174. ;
  1175. ; filter returns y(n) for input x(n)
  1176. ; xn and yn are pointers to arrays of size n+1 floats
  1177. ;
  1178. ; the filter routine must be called with x(0) thru x(n)
  1179. ; first then x(n+1) thru x(....) and so on.
  1180.  
  1181. _FIR_Csoa:    
  1182.     PUSH    FP
  1183.     LDI    SP,FP
  1184.     PUSH    AR4
  1185.     PUSH    AR5
  1186.     PUSH    AR7
  1187.  
  1188.     LDI    *-FP(2),AR4    ; AR4 = address of y(n)
  1189.     LDI    *-FP(3),AR2    ; AR2 = address of x(n)
  1190.     LDI    *-FP(4),AR5    ; AR5 = number of samples
  1191.     LDI    *-FP(5),AR7    ; AR7 = address of FIR filter structure
  1192.     LDI    *++AR7(2),AR1    ; AR1 = address of coefficients
  1193.     LDI    *++AR7,AR0    ; AR0 = address of x(n) in circular
  1194.                 ; delay memory
  1195.     LDF    *AR2++,R0    ; R0 = x(n) (first sample of array)
  1196.     LDI    *+AR7(2),BK    ; Set block size for circular buffer
  1197.                 ; of x(n)
  1198.                 ; NOTE: AR7 now points to 0.0 in struct FIR
  1199. floop:
  1200.     LDF    *+AR7,R2    ; initialize R2 to 0.0
  1201. ||    STF    R0,*AR0        ; put x(n) in delay memory
  1202.     MPYF    *AR1++,*AR0++%,R0 ; h(0)*x(n) -> R0
  1203.     RPTS    *+AR7(3)
  1204.     MPYF    *AR1++,*AR0++%,R0
  1205. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2
  1206.     RPTS    *+AR7(4)
  1207.     MPYF    *AR1--,*AR0++%,R0
  1208. ||    ADDF    R0,R2,R2    ; h(l)*x(n-l) + R2 -> R2
  1209.     DBD    AR5,floop    ; do more samples?
  1210.     LDI    *-AR7,AR1    ; AR1 = address of coefficients
  1211.     ADDF    R0,R2,R0    ; add last product
  1212.     LDF    *AR2++,R0    ; get next sample
  1213. ||    STF    R0,*AR4++    ; output y(n) to array
  1214.  
  1215.     STI    AR0,*AR7    ; save updated circular buffer point
  1216.                 ; for next samples
  1217.  
  1218.     POP    AR7
  1219.     POP    AR5
  1220.     POP    AR4
  1221.     POP    FP
  1222.     RETS
  1223.  
  1224.     .end
  1225. ;**************************** IIR_A4.ASM **************************** 
  1226. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1227. ;                                                           ;
  1228. ;               TMS320C30 FIR filter realization            ;
  1229. ;                                                           ;
  1230. ;     (c) Copyright 1989, Atlanta Signal Processors, Inc.   ;
  1231. ;                    All Rights Reserved                    ;
  1232. ;                                                           ;
  1233. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1234.  
  1235. ;ASM30 IIR filter subroutines
  1236. ;4 cycles / sections; b0 = b2
  1237.  
  1238. ;The following structure defines the data structure that the Init routine
  1239. ;initializes.  This structure is passed, along with x(n) to the filter
  1240. ;routines.
  1241.  
  1242. ;struct IIR {
  1243. ;    float *filter;        ;address of sample by sample filter rout.
  1244. ;    float *filtera;        ;address of array filter routine
  1245. ;    float *coef;        ;address of coeficients
  1246. ;    float *delay;        ;address of Z-1 delays
  1247. ;    float BK2;        ;size of circular buffer/2
  1248. ;    int BK;            ;size of circular buffer
  1249. ;    int nRPTB;        ;number for RPTB instruction
  1250.  
  1251.  
  1252. ;Assemble code callable FIR filter subroutines
  1253.  
  1254. ;        PERFORM THE SAMPLE BY SAMPLE FILTERING
  1255. ;Input:
  1256. ;    R0    x(n)
  1257. ;    AR7    pointer to FIR filter structure
  1258. ;Ouput:
  1259. ;    R0    y(n)
  1260. ;    R2, AR0, AR1, AR2, BK, RC, RS, RE destroyed
  1261.  
  1262.     .global    IIR_A4
  1263. IIR_A4:
  1264.     LDI    *+AR7(3),AR1    ;Get address of Z-1's
  1265.     LDI    AR1,AR2        ;Copy into AR2
  1266.     LDF    0.0,R2        ;zero R2 for first time through loop
  1267.     LDI    *+AR7(4),IR0    ;Get 1/2 size of circular buffer
  1268.     LDI    *+AR7(5),BK    ;Get size of circular buffer
  1269.     LDI    *+AR7(6),RC    ;Get number of time to repeat section
  1270.     NOP    *AR2++(IR0)%    ;Make address of Z-2
  1271.     LDI    *+AR7(2),AR0    ;Get address of coefficients
  1272.  
  1273.     RPTB    loop        ;do sections
  1274.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0
  1275. ||    ADDF3    R0,R2,R2    ;Z + B1' * Z-1 + Z-2 -> R2
  1276.                 ;from last iteration
  1277.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  1278. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  1279.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  1280. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
  1281. loop:    ADDF3    *AR2,R2,R2    ;Z + Z-2 -> R2
  1282. ||    STF    R2,*AR2++%    ;Z = A1 * Z-1 + Yi(n) + A2 * Z-2 -> Z-2
  1283.  
  1284.     ADDF    R2,R0        ;Z + B1' * Z-1 + Z-2 -> R0
  1285.     MPYF3    *+AR0,R0,R0    ;Do final gain compensation
  1286.     STI    AR1,*+AR7(3)    ;Update Z-1 address
  1287.  
  1288.     RETS
  1289.  
  1290. ;        PERFORM ARRAY FILTERING
  1291. ;Input:
  1292. ;    AR4    address of x(n) array
  1293. ;    AR5    address of y(n) array
  1294. ;    AR6    number of samples-1 in array
  1295. ;    AR7    address of FIR filter structure
  1296. ;Output:
  1297. ;    AR(0-2), AR(4-6), R(0-3), IR0, BK, RC, RS, RE, DP destroyed
  1298.  
  1299.     .global    IIR_A4a
  1300. IIR_A4a:
  1301.     LDI    *+AR7(3),AR1    ;Get address of Z-1's
  1302.     LDI    AR1,AR2        ;Copy into AR2
  1303.     LDF    0.0,R2        ;zero R2 for first time through loop
  1304.     LDI    *+AR7(4),IR0    ;Get 1/2 size of circular buffer
  1305.     LDI    *+AR7(5),BK    ;Get size of circular buffer
  1306.     LDI    *+AR7(6),RC    ;Get number of time to repeat section
  1307.     NOP    *AR2++(IR0)%    ;Make address of Z-2
  1308.     LDF    *AR4++,R0    ;Get x(n)
  1309.     LDI    *+AR7(7),IR0    ;Get length of coef. buffer-2
  1310.     LDI    *+AR7(2),AR0    ;Get address of coefficients
  1311.  
  1312.     RPTB    loopa        ;do sections
  1313.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0
  1314. ||    ADDF3    R0,R2,R2    ;Z + B1' * Z-1 + Z-2 -> R2
  1315. aloop:                ;from last iteration
  1316.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  1317. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  1318.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  1319. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
  1320. loopa:    ADDF3    *AR2,R2,R2    ;Z + Z-2 -> R2
  1321. ||    STF    R2,*AR2++%    ;Z = A1 * Z-1 + Yi(n) + A2 * Z-2 -> Z-2
  1322.  
  1323.     LDI    *+AR7(6),RC    ;Load repeat count
  1324.     OR    100h,ST        ;Turn repeat on
  1325.  
  1326.     DBD    AR6,aloop    ;any more samples?
  1327.  
  1328.     MPYF3    *AR0++,*AR1,R0;A1 * Z-1 -> R0 (for next sample)
  1329. ||    ADDF3    R0,R2,R2    ;Z + B1' * Z-1 + Z-2 -> R2
  1330.     MPYF3    *AR0--(IR0),R2,R1;Do final gain compensation
  1331.     LDF    *AR4++,R2    ;Get y0(n+1) = x(n+1) -> R2
  1332. ||    STF    R1,*AR5++    ;Output filtered data to array
  1333.  
  1334.     STI    AR1,*+AR7(3)    ;Update Z-1 address
  1335.  
  1336.     AND    0feffh,ST    ;Turn repeat off
  1337.  
  1338.     RETS
  1339.  
  1340.     .end
  1341. ;**************************** IIR_A45.ASM **************************** 
  1342.  
  1343. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1344. ;                                                           ;
  1345. ;               TMS320C30 FIR filter realization            ;
  1346. ;                                                           ;
  1347. ;     (c) Copyright 1989, Atlanta Signal Processors, Inc.   ;
  1348. ;                    All Rights Reserved                    ;
  1349. ;                                                           ;
  1350. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1351.  
  1352. ;'C' code callable IIR filter subroutines
  1353. ;9 cycles / 2 sections; even number of sections
  1354.  
  1355. ;The following structure defines the 'C' structure that the Init routine
  1356. ;initializes.  This structure is passed, along with x(n) to the filter
  1357. ;routines.
  1358.  
  1359. ;struct IIR {
  1360. ;    float *filter;        ;address of sample by sample filter rout.
  1361. ;    float *filtera;        ;address of array filter routine
  1362. ;    float *coef;        ;address of coeficients
  1363. ;    float *delay;        ;address of Z-1 delays
  1364. ;    float BK2;        ;size of circular buffer/2
  1365. ;    int BK;            ;size of circular buffer
  1366. ;    int nRPTB;        ;number for RPTB instruction
  1367.  
  1368. ;Assemble code callable FIR filter subroutines
  1369.  
  1370. ;        PERFORM THE SAMPLE BY SAMPLE FILTERING
  1371. ;Input:
  1372. ;    R0    x(n)
  1373. ;    AR7    pointer to FIR filter structure
  1374. ;Ouput:
  1375. ;    R0    y(n)
  1376. ;    R2, AR0, AR1, AR2, BK, RC, RS, RE destroyed
  1377.  
  1378.     .global    IIR_A45
  1379. IIR_A45:
  1380.     LDI    *+AR7(3),AR1    ;Get address of Z-1's
  1381.     LDI    AR1,AR2        ;Copy into AR2
  1382.     LDF    0.0,R2        ;zero R2 for first time through loop
  1383.     LDI    *+AR7(4),IR0    ;Get 1/2 size of circular buffer
  1384.     LDI    *+AR7(5),BK    ;Get size of circular buffer
  1385.     LDI    *+AR7(6),RC    ;Get number of time to repeat section
  1386.     NOP    *AR2++(IR0)%    ;Make address of Z-2
  1387.     LDI    *+AR7(2),AR0    ;Get address of coefficients
  1388.  
  1389.     RPTB    loop        ;do 2 sections at a time sections
  1390. ;section a
  1391.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0
  1392. ||    ADDF3    R0,R2,R2    ;Z + B1' * Z-1 + B2' * Z-2 -> R2
  1393.                 ;from last iteration
  1394.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  1395. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  1396.     MPYF3    *AR0++,*AR2++%,R0;B2' * Z-2 -> R0
  1397. ||    ADDF3    R0,R2,R3    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R3
  1398.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  1399. ||    ADDF3    R0,R3,R2    ;Z + B2' * Z-2 -> R2
  1400. ;section b
  1401.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0
  1402. ||    ADDF3    R0,R2,R2    ;Z + B1' * Z-1 + B2' * Z-2 -> R2
  1403.                 ;from last iteration
  1404.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  1405. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  1406.     MPYF3    *AR0++,*AR2,R0    ;B2' * Z-2 -> R0
  1407. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
  1408.     STF    R3,*-AR2(1)    ;save Z(last section) for next sample
  1409. ||    STF    R2,*AR2++%    ;save Z = A1 * Z-1 + Yi(n) + A2 * Z-2
  1410. loop:    MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  1411. ||    ADDF3    R0,R2,R2    ;Z + B2' * Z-2 -> R2
  1412.  
  1413.     ADDF    R2,R0        ;Z + B1' * Z-1 + B2' * Z-2 -> R0
  1414.     MPYF    *+AR0,R0    ;Do final gain compensation
  1415.     STI    AR1,*+AR7(3)    ;Update Z-1 address
  1416.  
  1417.     RETS
  1418.  
  1419. ;        PERFORM ARRAY FILTERING
  1420. ;Input:
  1421. ;    AR4    address of x(n) array
  1422. ;    AR5    address of y(n) array
  1423. ;    AR6    number of samples-1 in array
  1424. ;    AR7    address of FIR filter structure
  1425. ;Output:
  1426. ;    AR(0-2), AR(4-6), R(0-3), IR0, BK, RC, RS, RE, DP destroyed
  1427.  
  1428.     .global    IIR_A45a
  1429. IIR_A45a:
  1430.     LDI    *+AR7(3),AR1    ;Get address of Z-1's
  1431.     LDI    AR1,AR2        ;Copy into AR2
  1432.     LDF    0.0,R2        ;zero R2 for first time through loop
  1433.     LDI    *+AR7(4),IR0    ;Get 1/2 size of circular buffer
  1434.     LDI    *+AR7(5),BK    ;Get size of circular buffer
  1435.     LDI    *+AR7(6),RC    ;Get number of time to repeat section
  1436.     NOP    *AR2++(IR0)%    ;Make address of Z-2
  1437.     LDF    *AR4++,R0    ;Get x(n)
  1438.     LDI    *+AR7(7),IR0    ;Get length of coef. buffer-2
  1439.     LDI    *+AR7(2),AR0    ;Get address of coefficients
  1440.     
  1441.     RPTB    loopa        ;do sections
  1442. ;section a
  1443.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0
  1444. ||    ADDF3    R0,R2,R2    ;Z + B1' * Z-1 + B2' * Z-2 -> R2
  1445. aloop:                ;from last iteration
  1446.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  1447. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  1448.     MPYF3    *AR0++,*AR2++%,R0;B2' * Z-2 -> R0
  1449. ||    ADDF3    R0,R2,R3    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R3
  1450.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  1451. ||    ADDF3    R0,R3,R2    ;Z + B2' * Z-2 -> R2
  1452. ;section b
  1453.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0
  1454. ||    ADDF3    R0,R2,R2    ;Z + B1' * Z-1 + B2' * Z-2 -> R2
  1455.                 ;from last iteration
  1456.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  1457. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  1458.     MPYF3    *AR0++,*AR2,R0    ;B2' * Z-2 -> R0
  1459. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
  1460.     STF    R3,*-AR2(1)    ;save Z(last section) for next sample
  1461. ||    STF    R2,*AR2++%    ;save Z = A1 * Z-1 + Yi(n) + A2 * Z-2
  1462. loopa:    MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  1463. ||    ADDF3    R0,R2,R2    ;Z + B2' * Z-2 -> R2
  1464.  
  1465.     LDI    *+AR7(6),RC    ;Load repeat count
  1466.     OR    100h,ST        ;Turn repeat on
  1467.  
  1468.     DBD    AR6,aloop    ;any more samples?
  1469.  
  1470.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0 (for next sample)
  1471. ||    ADDF3    R0,R2,R2    ;Z + B1' * Z-1 + Z-2 -> R2
  1472.     MPYF3    *AR0--(IR0),R2,R1;Do final gain compensation
  1473.     LDF    *AR4++,R2    ;Get y0(n+1) = x(n+1) -> R2
  1474. ||    STF    R1,*AR5++    ;Output filtered data to array
  1475.  
  1476.     STI    AR1,*+AR7(3)    ;Update Z-1 address
  1477.  
  1478.     AND    0feffh,ST    ;Turn repeat off
  1479.  
  1480.     RETS
  1481.  
  1482.     .end
  1483. ;**************************** IIR_A45O.ASM **************************** 
  1484. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1485. ;                                                           ;
  1486. ;               TMS320C30 FIR filter realization            ;
  1487. ;                                                           ;
  1488. ;     (c) Copyright 1989, Atlanta Signal Processors, Inc.   ;
  1489. ;                    All Rights Reserved                    ;
  1490. ;                                                           ;
  1491. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1492.  
  1493. ;'C' code callable IIR filter subroutines
  1494. ;9 cycles / 2 sections; odd number of sections
  1495.  
  1496. ;The following structure defines the 'C' structure that the Init routine
  1497. ;initializes.  This structure is passed, along with x(n) to the filter
  1498. ;routines.
  1499.  
  1500. ;struct IIR {
  1501. ;    float *filter;        ;address of sample by sample filter rout.
  1502. ;    float *filtera;        ;address of array filter routine
  1503. ;    float *coef;        ;address of coeficients
  1504. ;    float *delay;        ;address of Z-1 delays
  1505. ;    float BK2;        ;size of circular buffer/2
  1506. ;    int BK;            ;size of circular buffer
  1507. ;    int nRPTB;        ;number for RPTB instruction
  1508.  
  1509. ;Assemble code callable FIR filter subroutines
  1510.  
  1511. ;        PERFORM THE SAMPLE BY SAMPLE FILTERING
  1512. ;Input:
  1513. ;    R0    x(n)
  1514. ;    AR7    pointer to FIR filter structure
  1515. ;Ouput:
  1516. ;    R0    y(n)
  1517. ;    R2, AR0, AR1, AR2, BK, RC, RS, RE destroyed
  1518.  
  1519.     .global    IIR_A45o
  1520. IIR_A45o:
  1521.     LDI    *+AR7(3),AR1    ;Get address of Z-1's
  1522.     LDI    AR1,AR2        ;Copy into AR2
  1523.     LDF    0.0,R2        ;zero R2 for first time through loop
  1524.     LDI    *+AR7(4),IR0    ;Get 1/2 size of circular buffer
  1525.     LDI    *+AR7(5),BK    ;Get size of circular buffer
  1526.     LDI    *+AR7(6),RC    ;Get number of time to repeat section
  1527.     NOP    *AR2++(IR0)%    ;Make address of Z-2
  1528.     LDI    *+AR7(2),AR0    ;Get address of coefficients
  1529.  
  1530.     RPTB    loop        ;do 2 sections at a time sections
  1531. ;section a
  1532.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0
  1533. ||    ADDF3    R0,R2,R2    ;Z + B1' * Z-1 + B2' * Z-2 -> R2
  1534.                 ;from last iteration
  1535.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  1536. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  1537.     MPYF3    *AR0++,*AR2++%,R0;B2' * Z-2 -> R0
  1538. ||    ADDF3    R0,R2,R3    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R3
  1539.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  1540. ||    ADDF3    R0,R3,R2    ;Z + B2' * Z-2 -> R2
  1541. ;section b
  1542.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0
  1543. ||    ADDF3    R0,R2,R2    ;Z + B1' * Z-1 + B2' * Z-2 -> R2
  1544.                 ;from last iteration
  1545.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  1546. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  1547.     MPYF3    *AR0++,*AR2,R0    ;B2' * Z-2 -> R0
  1548. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
  1549.     STF    R3,*-AR2(1)    ;save Z(last section) for next sample
  1550. ||    STF    R2,*AR2++%    ;save Z = A1 * Z-1 + Yi(n) + A2 * Z-2
  1551. loop:    MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  1552. ||    ADDF3    R0,R2,R2    ;Z + B2' * Z-2 -> R2
  1553. ;last section
  1554.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0
  1555. ||    ADDF3    R0,R2,R2    ;Z + B1' * Z-1 + B2' * Z-2 -> R2
  1556.                 ;from last iteration
  1557.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  1558. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  1559.     MPYF3    *AR0++,*AR2,R0;B2' * Z-2 -> R0
  1560. ||    ADDF3    R0,R2,R3    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R3
  1561.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  1562. ||    ADDF3    R0,R3,R2    ;Z + B2' * Z-2 -> R2
  1563.  
  1564.     ADDF    R2,R0        ;Z + B1' * Z-1 + B2' * Z-2 -> R2
  1565.     MPYF3    *+AR0,R0,R0    ;Do final gain compensation
  1566. ||    STF    R3,*AR2++%    ;save Z = A1 * Z-1 + Yi(n) + A2 * Z-2
  1567.     STI    AR1,*+AR7(3)    ;Update Z-1 address
  1568.  
  1569.     RETS
  1570.  
  1571. ;        PERFORM ARRAY FILTERING
  1572. ;Input:
  1573. ;    AR4    address of x(n) array
  1574. ;    AR5    address of y(n) array
  1575. ;    AR6    number of samples-1 in array
  1576. ;    AR7    address of FIR filter structure
  1577. ;Output:
  1578. ;    AR(0-2), AR(4-6), R(0-3), IR0, BK, RC, RS, RE, DP destroyed
  1579.  
  1580.     .global    IIR_A45oa
  1581. IIR_A45oa:
  1582.     LDI    *+AR7(3),AR1    ;Get address of Z-1's
  1583.     LDI    AR1,AR2        ;Copy into AR2
  1584.     LDF    0.0,R2        ;zero R2 for first time through loop
  1585.     LDI    *+AR7(4),IR0    ;Get 1/2 size of circular buffer
  1586.     LDI    *+AR7(5),BK    ;Get size of circular buffer
  1587.     LDI    *+AR7(6),RC    ;Get number of time to repeat section
  1588.     NOP    *AR2++(IR0)%    ;Make address of Z-2
  1589.     LDF    *AR4++,R0    ;Get x(n)
  1590.     LDI    *+AR7(7),IR0    ;Get length of coef. buffer-1
  1591.     LDI    *+AR7(2),AR0    ;Get address of coefficients
  1592.     
  1593.     RPTB    loopa        ;do sections
  1594. ;section a
  1595.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0
  1596. ||    ADDF3    R0,R2,R2    ;Z + B1' * Z-1 + B2' * Z-2 -> R2
  1597. aloop:                ;from last iteration
  1598.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  1599. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  1600.     MPYF3    *AR0++,*AR2++%,R0;B2' * Z-2 -> R0
  1601. ||    ADDF3    R0,R2,R3    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R3
  1602.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  1603. ||    ADDF3    R0,R3,R2    ;Z + B2' * Z-2 -> R2
  1604. ;section b
  1605.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0
  1606. ||    ADDF3    R0,R2,R2    ;Z + B1' * Z-1 + B2' * Z-2 -> R2
  1607.                 ;from last iteration
  1608.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  1609. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  1610.     MPYF3    *AR0++,*AR2,R0    ;B2' * Z-2 -> R0
  1611. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
  1612.     STF    R3,*-AR2(1)    ;save Z(last section) for next sample
  1613. ||    STF    R2,*AR2++%    ;save Z = A1 * Z-1 + Yi(n) + A2 * Z-2
  1614. loopa:    MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  1615. ||    ADDF3    R0,R2,R2    ;Z + B2' * Z-2 -> R2
  1616. ;last section
  1617.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0
  1618. ||    ADDF3    R0,R2,R2    ;Z + B1' * Z-1 + B2' * Z-2 -> R2
  1619.                 ;from last iteration
  1620.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  1621. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  1622.     MPYF3    *AR0++,*AR2,R0;B2' * Z-2 -> R0
  1623. ||    ADDF3    R0,R2,R3    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R3
  1624.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  1625. ||    ADDF3    R0,R3,R2    ;Z + B2' * Z-2 -> R2
  1626.  
  1627.     LDI    *+AR7(6),RC    ;Load repeat count
  1628.     OR    100h,ST        ;Turn repeat on
  1629.  
  1630.     DBD    AR6,aloop    ;any more samples?
  1631.  
  1632.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0 (for next sample)
  1633. ||    ADDF3    R0,R2,R2    ;Z + B1' * Z-1 + Z-2 -> R2
  1634.     MPYF3    *AR0--(IR0),R2,R1;Do final gain compensation
  1635. ||    STF    R3,*AR2++%    ;save Z = A1 * Z-1 + Yi(n) + A2 * Z-2
  1636.     LDF    *AR4++,R2    ;Get y0(n+1) = x(n+1) -> R2
  1637. ||    STF    R1,*AR5++    ;Output filtered data to array
  1638.  
  1639.     STI    AR1,*+AR7(3)    ;Update Z-1 address
  1640.  
  1641.     AND    0feffh,ST    ;Turn repeat off
  1642.  
  1643.     RETS
  1644.  
  1645.     .end
  1646. ;**************************** IIR_A4M.ASM **************************** 
  1647. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1648. ;                                                           ;
  1649. ;               TMS320C30 FIR filter realization            ;
  1650. ;                                                           ;
  1651. ;     (c) Copyright 1989, Atlanta Signal Processors, Inc.   ;
  1652. ;                    All Rights Reserved                    ;
  1653. ;                                                           ;
  1654. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1655.  
  1656. ;'C' code callable IIR filter subroutines
  1657. ;4 cycles / sections; b0 = -b2
  1658.  
  1659. ;The following structure defines the 'C' structure that the Init routine
  1660. ;initializes.  This structure is passed, along with x(n) to the filter
  1661. ;routines.
  1662.  
  1663. ;struct IIR {
  1664. ;    float *filter;        ;address of sample by sample filter rout.
  1665. ;    float *filtera;        ;address of array filter routine
  1666. ;    float *coef;        ;address of coeficients
  1667. ;    float *delay;        ;address of Z-1 delays
  1668. ;    float BK2;        ;size of circular buffer/2
  1669. ;    int BK;            ;size of circular buffer
  1670. ;    int nRPTB;        ;number for RPTB instruction
  1671.  
  1672. ;Assemble code callable FIR filter subroutines
  1673.  
  1674. ;        PERFORM THE SAMPLE BY SAMPLE FILTERING
  1675. ;Input:
  1676. ;    R0    x(n)
  1677. ;    AR7    pointer to FIR filter structure
  1678. ;Ouput:
  1679. ;    R0    y(n)
  1680. ;    R2, AR0, AR1, AR2, BK, RC, RS, RE destroyed
  1681.  
  1682.     .global    IIR_A4m
  1683. IIR_A4m:
  1684.     LDI    *+AR7(3),AR1    ;Get address of Z-1's
  1685.     LDI    AR1,AR2        ;Copy into AR2
  1686.     LDF    0.0,R2        ;zero R2 for first time through loop
  1687.     LDI    *+AR7(4),IR0    ;Get 1/2 size of circular buffer
  1688.     LDI    *+AR7(5),BK    ;Get size of circular buffer
  1689.     LDI    *+AR7(6),RC    ;Get number of time to repeat section
  1690.     NOP    *AR2++(IR0)%    ;Make address of Z-2
  1691.     LDI    *+AR7(2),AR0    ;Get address of coefficients
  1692.  
  1693.     RPTB    loop        ;do sections
  1694.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0
  1695. ||    SUBF3    R2,R0,R2    ;Z + B1' * Z-1 + Z-2 -> R2
  1696.                 ;from last iteration
  1697.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  1698. ||    ADDF3    R2,R0,R2    ;A1 * Z-1 + Yi(n) -> R2
  1699.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  1700. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
  1701. loop:    SUBF3    R2,*AR2,R2    ;-(Z - Z-2) -> R2
  1702. ||    STF    R2,*AR2++%    ;Z = A1 * Z-1 + Yi(n) + A2 * Z-2 -> Z-2
  1703.  
  1704.     SUBF    R2,R0        ;Z + B1' * Z-1 + Z-2 -> R0
  1705.     MPYF    *+AR0,R0    ;Do final gain compensation
  1706.     STI    AR1,*+AR7(3)    ;Update Z-1 address
  1707.  
  1708.     RETS
  1709.  
  1710. ;        PERFORM ARRAY FILTERING
  1711. ;Input:
  1712. ;    AR4    address of x(n) array
  1713. ;    AR5    address of y(n) array
  1714. ;    AR6    number of samples-1 in array
  1715. ;    AR7    address of FIR filter structure
  1716. ;Output:
  1717. ;    AR(0-2), AR(4-6), R(0-3), IR0, BK, RC, RS, RE, DP destroyed
  1718.  
  1719.     .global    IIR_A4ma
  1720. IIR_A4ma:
  1721.     LDI    *+AR7(3),AR1    ;Get address of Z-1's
  1722.     LDI    AR1,AR2        ;Copy into AR2
  1723.     LDF    0.0,R2        ;zero R2 for first time through loop
  1724.     LDI    *+AR7(4),IR0    ;Get 1/2 size of circular buffer
  1725.     LDI    *+AR7(5),BK    ;Get size of circular buffer
  1726.     LDI    *+AR7(6),RC    ;Get number of time to repeat section
  1727.     NOP    *AR2++(IR0)%    ;Make address of Z-2
  1728.     LDF    *AR4++,R0    ;Get x(n)
  1729.     LDI    *+AR7(7),IR0    ;Get length of coef. buffer-2
  1730.     LDI    *+AR7(2),AR0    ;Get address of coefficients
  1731.     
  1732.     RPTB    loopa        ;do sections
  1733.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0
  1734. ||    SUBF3    R2,R0,R2    ;Z + B1' * Z-1 + Z-2 -> R2
  1735. aloop:                ;from last iteration
  1736.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  1737. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  1738.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  1739. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
  1740. loopa:    SUBF3    R2,*AR2,R2    ;-(Z - Z-2) -> R2
  1741. ||    STF    R2,*AR2++%    ;Z = A1 * Z-1 + Yi(n) + A2 * Z-2 -> Z-2
  1742.  
  1743.     LDI    *+AR7(6),RC    ;Load repeat count
  1744.     OR    100h,ST        ;Turn repeat on
  1745.  
  1746.     DBD    AR6,aloop    ;any more samples?
  1747.  
  1748.     MPYF3    *AR0++,*AR1,R0;A1 * Z-1 -> R0 (for next sample)
  1749. ||    SUBF3    R2,R0,R2    ;Z + B1' * Z-1 - Z-2 -> R2
  1750.     MPYF3    *AR0--(IR0),R2,R1;Do final gain compensation
  1751.     LDF    *AR4++,R2    ;Get y0(n+1) = x(n+1) -> R2
  1752. ||    STF    R1,*AR5++    ;Output filtered data to array
  1753.  
  1754.     STI    AR1,*+AR7(3)    ;Update Z-1 address
  1755.  
  1756.     AND    0feffh,ST    ;Turn repeat off
  1757.  
  1758.     RETS
  1759.  
  1760.     .end
  1761. ;**************************** IIR_A5.ASM **************************** 
  1762. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1763. ;                                                           ;
  1764. ;               TMS320C30 FIR filter realization            ;
  1765. ;                                                           ;
  1766. ;     (c) Copyright 1989, Atlanta Signal Processors, Inc.   ;
  1767. ;                    All Rights Reserved                    ;
  1768. ;                                                           ;
  1769. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1770.  
  1771. ;'C' code callable IIR filter subroutines
  1772. ;5 cycles / sections; one section only!
  1773.  
  1774. ;The following structure defines the 'C' structure that the Init routine
  1775. ;initializes.  This structure is passed, along with x(n) to the filter
  1776. ;routines.
  1777.  
  1778. ;struct IIR {
  1779. ;    float *filter;        ;address of sample by sample filter rout.
  1780. ;    float *filtera;        ;address of array filter routine
  1781. ;    float *coef;        ;address of coeficients
  1782. ;    float *delay;        ;address of Z-1 delays
  1783. ;    float BK2;        ;size of circular buffer/2
  1784. ;    int BK;            ;size of circular buffer
  1785. ;    int nRPTB;        ;number for RPTB instruction
  1786.  
  1787. ;Assemble code callable FIR filter subroutines
  1788.  
  1789. ;        PERFORM THE SAMPLE BY SAMPLE FILTERING
  1790. ;Input:
  1791. ;    R0    x(n)
  1792. ;    AR7    pointer to FIR filter structure
  1793. ;Ouput:
  1794. ;    R0    y(n)
  1795. ;    R2, AR0, AR1, AR2, BK, RC, RS, RE destroyed
  1796.  
  1797.     .global    IIR_A5
  1798. IIR_A5:
  1799.     LDI    *+AR7(2),AR0    ;Get address of coefficients
  1800.     LDI    *+AR7(3),AR1    ;Get address of Z-1's
  1801.     LDI    2,BK        ;Get size of circular buffer
  1802.  
  1803.     MPYF3    *AR0++,*AR1++%,R2;A1 * Z-1 -> R2
  1804.     MPYF3    *AR0++,*AR1,R0    ;A2 * Z-2 -> R0
  1805. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + x(n) -> R2
  1806.     MPYF3    *AR0++,*AR1,R0    ;B2 * Z-2 -> R0
  1807. ||    ADDF3    R0,R2,R2    ;Z = A1 * Z-1 + x(n) + A2 * Z-2 -> R2
  1808.     MPYF3    *AR0++,R2,R1    ;B0 * Z -> R1
  1809. ||    STF    R2,*AR1++%    ;A1 * Z-1 + x(n) + A2 * Z-2 -> Z-2
  1810.     MPYF3    *AR0++,*AR1++%,R0;B1 * Z-1 -> R0
  1811. ||    ADDF3    R0,R1,R2    ;B0 * Z + B2 * Z-2 -> R2
  1812.  
  1813.     ADDF    R2,R0        ;B0 * Z + B1 * Z-1 + B2 * Z-2 -> R0
  1814.     STI    AR1,*+AR7(3)    ;Update Z-1 address
  1815.  
  1816.     RETS
  1817.  
  1818. ;        PERFORM ARRAY FILTERING
  1819. ;Input:
  1820. ;    AR4    address of x(n) array
  1821. ;    AR5    address of y(n) array
  1822. ;    AR6    number of samples-1 in array
  1823. ;    AR7    address of FIR filter structure
  1824. ;Output:
  1825. ;    AR(0-2), AR(4-5), R(0-3), IR0, BK, RC, RS, RE, DP destroyed
  1826.  
  1827.     .global    IIR_A5a
  1828. IIR_A5a:
  1829.     LDI    4,IR0
  1830.     LDI    *+AR7(3),AR1    ;Get address of Z-1's
  1831.     LDI    *+AR7(2),AR0    ;Get address of coefficients
  1832.     LDI    AR6,RC        ;Get number of samples-1 to filter
  1833.     LDI    *+AR7(5),BK    ;Get size of circular buffer
  1834.     LDF    *AR4++,R2    ;Get x(n)
  1835.  
  1836.     MPYF3    *AR0++,*AR1++%,R0;A1 * Z-1 -> R0
  1837.  
  1838.     RPTB    loopa        ;do sections
  1839.     MPYF3    *AR0++,*AR1,R0    ;A2 * Z-2 -> R0
  1840. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + x(n) -> R2
  1841.     MPYF3    *AR0++,*AR1,R0    ;B2 * Z-2 -> R0
  1842. ||    ADDF3    R0,R2,R2    ;Z = A1 * Z-1 + x(n) + A2 * Z-2 -> R2
  1843.     MPYF3    *AR0++,R2,R1    ;B0 * Z -> R1
  1844. ||    STF    R2,*AR1++%    ;A1 * Z-1 + x(n) + A2 * Z-2 -> Z-2
  1845.     MPYF3    *AR0--(IR0),*AR1++%,R0    ;B1 * Z-1 -> R0
  1846. ||    ADDF3    R0,R1,R2    ;B0 * Z + B2 * Z-2 -> R2
  1847.  
  1848.     MPYF3    *AR0++,*AR1++%,R0;A1 * Z-1 -> R0 (for next sample)
  1849. ||    ADDF3    R0,R2,R3    ;B0 * Z + B1 * Z-1 + B2 * Z-2 -> R1
  1850. loopa    LDF    *AR4++,R2    ;Get y0(n+1) = x(n+1) -> R2
  1851. ||    STF    R3,*AR5++    ;Output filtered data to array
  1852.  
  1853.     NOP    *AR1--%        ;Backup to next Z-1
  1854.     AND    0feffh,ST    ;Turn repeat off
  1855.     STI    AR1,*+AR7(3)    ;Update Z-1 address
  1856.  
  1857.     RETS
  1858.  
  1859.     .end
  1860. ;**************************** IIR_C4.ASM **************************** 
  1861. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1862. ;                                                           ;
  1863. ;               TMS320C30 FIR filter realization            ;
  1864. ;                                                           ;
  1865. ;     (c) Copyright 1989, Atlanta Signal Processors, Inc.   ;
  1866. ;                    All Rights Reserved                    ;
  1867. ;                                                           ;
  1868. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1869.  
  1870. ;'C' code callable IIR filter subroutines
  1871. ;4 cycles / sections; b0 = b2
  1872.  
  1873. ;The following structure defines the 'C' structure that the Init routine
  1874. ;initializes.  This structure is passed, along with x(n) to the filter
  1875. ;routines.
  1876.  
  1877. ;struct IIR {
  1878. ;    float *filter;        ;address of sample by sample filter rout.
  1879. ;    float *filtera;        ;address of array filter routine
  1880. ;    float *coef;        ;address of coeficients
  1881. ;    float *delay;        ;address of Z-1 delays
  1882. ;    float BK2;        ;size of circular buffer/2
  1883. ;    int BK;            ;size of circular buffer
  1884. ;    int nRPTB;        ;number for RPTB instruction
  1885.  
  1886. FP    .set    AR3
  1887.  
  1888.  
  1889. ;        PERFORM THE SAMPLE BY SAMPLE FILTERING
  1890. ;float (*param->filter)(xn,param)
  1891. ;float xn
  1892. ;struct IIR *param;
  1893. ;
  1894. ; filter returns y(n) for input x(n)
  1895.  
  1896.     .global    _IIR_C4
  1897. _IIR_C4:
  1898.     PUSH    FP
  1899.     LDI    SP,FP
  1900.     PUSH    AR7
  1901.  
  1902.     LDI    *-FP(3),AR7    ;address of param -> AR7
  1903.     LDF    *-FP(2),R0    ;Y0(n) = x(n) -> R0
  1904.     LDI    *+AR7(3),AR1    ;Get address of Z-1's
  1905.     LDI    AR1,AR2        ;Copy into AR2
  1906.     LDF    0.0,R2        ;zero R2 for first time through loop
  1907.     LDI    *+AR7(4),IR0    ;Get 1/2 size of circular buffer
  1908.     LDI    *+AR7(5),BK    ;Get size of circular buffer
  1909.     LDI    *+AR7(6),RC    ;Get number of time to repeat section
  1910.     NOP    *AR2++(IR0)%    ;Make address of Z-2
  1911.     LDI    *+AR7(2),AR0    ;Get address of coefficients
  1912.  
  1913.     RPTB    loop        ;do sections
  1914.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0
  1915. ||    ADDF3    R0,R2,R2    ;Z + B1' * Z-1 + Z-2 -> R2
  1916.                 ;from last iteration
  1917.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  1918. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  1919.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  1920. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
  1921. loop:    ADDF3    *AR2,R2,R2    ;Z + Z-2 -> R2
  1922. ||    STF    R2,*AR2++%    ;Z = A1 * Z-1 + Yi(n) + A2 * Z-2 -> Z-2
  1923.  
  1924.     ADDF    R2,R0        ;Z + B1' * Z-1 + Z-2 -> R0
  1925.     MPYF3    *+AR0,R0,R0    ;Do final gain compensation
  1926.     STI    AR1,*+AR7(3)    ;Update Z-1 address
  1927.  
  1928.     POP    AR7
  1929.     POP    FP
  1930.     RETS
  1931.  
  1932. ;        PERFORM ARRAY FILTERING
  1933. ;void (*param->filtera)(xy,xn,n,param)
  1934. ;float *xn, *yn
  1935. ;int n;
  1936. ;struct IIR *param;
  1937. ;
  1938. ; filter returns y(n) for input x(n)
  1939. ; xn and yn are pointers to arrays of size n+1 floats
  1940. ;
  1941. ; the filter routine must be called with x(0) thru x(n)
  1942. ; first then x(n+1) thru x(....) and so on.
  1943.  
  1944.     .global    _IIR_C4a
  1945. _IIR_C4a:
  1946.     PUSH    FP
  1947.     LDI    SP,FP
  1948.     PUSH    AR7
  1949.     PUSH    AR6
  1950.     PUSH    AR5
  1951.     PUSH    AR4
  1952.  
  1953.     LDI    *-FP(2),AR5    ;Get address of y(n)
  1954.     LDI    *-FP(3),AR4    ;Get address of x(n)
  1955.     LDI    *-FP(5),AR7    ;address of param -> AR7
  1956.     LDI    *+AR7(3),AR1    ;Get address of Z-1's
  1957.     LDI    AR1,AR2        ;Copy into AR2
  1958.     LDI    *-FP(4),AR6    ;Get number of samples-1 to filter
  1959.     LDF    0.0,R2        ;zero R2 for first time through loop
  1960.     LDI    *+AR7(4),IR0    ;Get 1/2 size of circular buffer
  1961.     LDI    *+AR7(5),BK    ;Get size of circular buffer
  1962.     LDI    *+AR7(6),RC    ;Get number of time to repeat section
  1963.     NOP    *AR2++(IR0)%    ;Make address of Z-2
  1964.     LDF    *AR4++,R0    ;Get x(n)
  1965.     LDI    *+AR7(7),IR0    ;Get length of coef. buffer-2
  1966.     LDI    *+AR7(2),AR0    ;Get address of coefficients
  1967.     
  1968.     RPTB    loopa        ;do sections
  1969.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0
  1970. ||    ADDF3    R0,R2,R2    ;Z + B1' * Z-1 + Z-2 -> R2
  1971. aloop:                ;from last iteration
  1972.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  1973. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  1974.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  1975. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
  1976. loopa:    ADDF3    *AR2,R2,R2    ;Z + Z-2 -> R2
  1977. ||    STF    R2,*AR2++%    ;Z = A1 * Z-1 + Yi(n) + A2 * Z-2 -> Z-2
  1978.  
  1979.     LDI    *+AR7(6),RC    ;Load repeat count
  1980.     OR    100h,ST        ;Turn repeat on
  1981.  
  1982.     DBD    AR6,aloop    ;any more samples?
  1983.  
  1984.     MPYF3    *AR0++,*AR1,R0;A1 * Z-1 -> R0 (for next sample)
  1985. ||    ADDF3    R0,R2,R2    ;Z + B1' * Z-1 + Z-2 -> R2
  1986.     MPYF3    *AR0--(IR0),R2,R1;Do final gain compensation
  1987.     LDF    *AR4++,R2    ;Get y0(n+1) = x(n+1) -> R2
  1988. ||    STF    R1,*AR5++    ;Output filtered data to array
  1989.  
  1990.     STI    AR1,*+AR7(3)    ;Update Z-1 address
  1991.  
  1992.     AND    0feffh,ST    ;Turn repeat off
  1993.  
  1994.     POP    AR4
  1995.     POP    AR5
  1996.     POP    AR6
  1997.     POP    AR7
  1998.     POP    FP
  1999.     RETS
  2000.  
  2001.     .end
  2002. ;**************************** IIR_C45.ASM **************************** 
  2003. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2004. ;                                                           ;
  2005. ;               TMS320C30 FIR filter realization            ;
  2006. ;                                                           ;
  2007. ;     (c) Copyright 1989, Atlanta Signal Processors, Inc.   ;
  2008. ;                    All Rights Reserved                    ;
  2009. ;                                                           ;
  2010. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2011.  
  2012. ;'C' code callable IIR filter subroutines
  2013. ;9 cycles / 2 sections; even number of sections
  2014.  
  2015. ;The following structure defines the 'C' structure that the Init routine
  2016. ;initializes.  This structure is passed, along with x(n) to the filter
  2017. ;routines.
  2018.  
  2019. ;struct IIR {
  2020. ;    float *filter;        ;address of sample by sample filter rout.
  2021. ;    float *filtera;        ;address of array filter routine
  2022. ;    float *coef;        ;address of coeficients
  2023. ;    float *delay;        ;address of Z-1 delays
  2024. ;    float BK2;        ;size of circular buffer/2
  2025. ;    int BK;            ;size of circular buffer
  2026. ;    int nRPTB;        ;number for RPTB instruction
  2027.  
  2028. FP    .set    AR3
  2029.  
  2030.  
  2031. ; y(n) = (*param->filter)(x(n),param)
  2032. ;
  2033. ; float filter(xn,param)
  2034. ; float xn;
  2035. ; struct IIR *param;
  2036. ;
  2037.  
  2038.     .global    _IIR_C45
  2039. _IIR_C45:
  2040.     PUSH    FP
  2041.     LDI    SP,FP
  2042.     PUSH    AR7
  2043.  
  2044.     LDI    *-FP(3),AR7    ;address of param -> AR7
  2045.     LDF    *-FP(2),R0    ;Y0(n) = x(n) -> R0
  2046.     LDI    *+AR7(3),AR1    ;Get address of Z-1's
  2047.     LDI    AR1,AR2        ;Copy into AR2
  2048.     LDF    0.0,R2        ;zero R2 for first time through loop
  2049.     LDI    *+AR7(4),IR0    ;Get 1/2 size of circular buffer
  2050.     LDI    *+AR7(5),BK    ;Get size of circular buffer
  2051.     LDI    *+AR7(6),RC    ;Get number of time to repeat section
  2052.     NOP    *AR2++(IR0)%    ;Make address of Z-2
  2053.     LDI    *+AR7(2),AR0    ;Get address of coefficients
  2054.  
  2055.     RPTB    loop        ;do 2 sections at a time sections
  2056. ;section a
  2057.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0
  2058. ||    ADDF3    R0,R2,R2    ;Z + B1' * Z-1 + B2' * Z-2 -> R2
  2059.                 ;from last iteration
  2060.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  2061. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  2062.     MPYF3    *AR0++,*AR2++%,R0;B2' * Z-2 -> R0
  2063. ||    ADDF3    R0,R2,R3    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R3
  2064.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  2065. ||    ADDF3    R0,R3,R2    ;Z + B2' * Z-2 -> R2
  2066. ;section b
  2067.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0
  2068. ||    ADDF3    R0,R2,R2    ;Z + B1' * Z-1 + B2' * Z-2 -> R2
  2069.                 ;from last iteration
  2070.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  2071. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  2072.     MPYF3    *AR0++,*AR2,R0    ;B2' * Z-2 -> R0
  2073. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
  2074.     STF    R3,*-AR2(1)    ;save Z(last section) for next sample
  2075. ||    STF    R2,*AR2++%    ;save Z = A1 * Z-1 + Yi(n) + A2 * Z-2
  2076. loop:    MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  2077. ||    ADDF3    R0,R2,R2    ;Z + B2' * Z-2 -> R2
  2078.  
  2079.     ADDF    R2,R0        ;Z + B1' * Z-1 + B2' * Z-2 -> R0
  2080.     MPYF    *+AR0,R0    ;Do final gain compensation
  2081.     STI    AR1,*+AR7(3)    ;Update Z-1 address
  2082.  
  2083.     POP    AR7
  2084.     POP    FP
  2085.     RETS
  2086.  
  2087. ;        PERFORM ARRAY FILTERING
  2088. ;void (*param->filtera)(xy,xn,n,param)
  2089. ;float *xn, *yn
  2090. ;int n;
  2091. ;struct IIR *param;
  2092. ;
  2093. ; filter returns y(n) for input x(n)
  2094. ; xn and yn are pointers to arrays of size n+1 floats
  2095. ;
  2096. ; the filter routine must be called with x(0) thru x(n)
  2097. ; first then x(n+1) thru x(....) and so on.
  2098.  
  2099.     .global    _IIR_C45a
  2100. _IIR_C45a:
  2101.     PUSH    FP
  2102.     LDI    SP,FP
  2103.     PUSH    AR7
  2104.     PUSH    AR6
  2105.     PUSH    AR5
  2106.     PUSH    AR4
  2107.  
  2108.     LDI    *-FP(2),AR5    ;Get address of y(n)
  2109.     LDI    *-FP(3),AR4    ;Get address of x(n)
  2110.     LDI    *-FP(5),AR7    ;address of param -> AR7
  2111.     LDI    *+AR7(3),AR1    ;Get address of Z-1's
  2112.     LDI    AR1,AR2        ;Copy into AR2
  2113.     LDI    *-FP(4),AR6    ;Get number of samples-1 to filter
  2114.     LDF    0.0,R2        ;zero R2 for first time through loop
  2115.     LDI    *+AR7(4),IR0    ;Get 1/2 size of circular buffer
  2116.     LDI    *+AR7(5),BK    ;Get size of circular buffer
  2117.     LDI    *+AR7(6),RC    ;Get number of time to repeat section
  2118.     NOP    *AR2++(IR0)%    ;Make address of Z-2
  2119.     LDF    *AR4++,R0    ;Get x(n)
  2120.     LDI    *+AR7(7),IR0    ;Get length of coef. buffer-2
  2121.     LDI    *+AR7(2),AR0    ;Get address of coefficients
  2122.     
  2123.     RPTB    loopa        ;do sections
  2124. ;section a
  2125.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0
  2126. ||    ADDF3    R0,R2,R2    ;Z + B1' * Z-1 + B2' * Z-2 -> R2
  2127. aloop:                ;from last iteration
  2128.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  2129. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  2130.     MPYF3    *AR0++,*AR2++%,R0;B2' * Z-2 -> R0
  2131. ||    ADDF3    R0,R2,R3    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R3
  2132.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  2133. ||    ADDF3    R0,R3,R2    ;Z + B2' * Z-2 -> R2
  2134. ;section b
  2135.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0
  2136. ||    ADDF3    R0,R2,R2    ;Z + B1' * Z-1 + B2' * Z-2 -> R2
  2137.                 ;from last iteration
  2138.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  2139. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  2140.     MPYF3    *AR0++,*AR2,R0    ;B2' * Z-2 -> R0
  2141. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
  2142.     STF    R3,*-AR2(1)    ;save Z(last section) for next sample
  2143. ||    STF    R2,*AR2++%    ;save Z = A1 * Z-1 + Yi(n) + A2 * Z-2
  2144. loopa:    MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  2145. ||    ADDF3    R0,R2,R2    ;Z + B2' * Z-2 -> R2
  2146.  
  2147.     LDI    *+AR7(6),RC    ;Load repeat count
  2148.     OR    100h,ST        ;Turn repeat on
  2149.  
  2150.     DBD    AR6,aloop    ;any more samples?
  2151.  
  2152.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0 (for next sample)
  2153. ||    ADDF3    R0,R2,R2    ;Z + B1' * Z-1 + Z-2 -> R2
  2154.     MPYF3    *AR0--(IR0),R2,R1;Do final gain compensation
  2155.     LDF    *AR4++,R2    ;Get y0(n+1) = x(n+1) -> R2
  2156. ||    STF    R1,*AR5++    ;Output filtered data to array
  2157.  
  2158.     STI    AR1,*+AR7(3)    ;Update Z-1 address
  2159.  
  2160.     AND    0feffh,ST    ;Turn repeat off
  2161.  
  2162.     POP    AR4
  2163.     POP    AR5
  2164.     POP    AR6
  2165.     POP    AR7
  2166.     POP    FP
  2167.     RETS
  2168.  
  2169.     .end
  2170. ;**************************** IIR_C45O.ASM **************************** 
  2171. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2172. ;                                                           ;
  2173. ;               TMS320C30 FIR filter realization            ;
  2174. ;                                                           ;
  2175. ;     (c) Copyright 1989, Atlanta Signal Processors, Inc.   ;
  2176. ;                    All Rights Reserved                    ;
  2177. ;                                                           ;
  2178. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2179.  
  2180. ;'C' code callable IIR filter subroutines
  2181. ;9 cycles / 2 sections; odd number of sections
  2182.  
  2183. ;The following structure defines the 'C' structure that the Init routine
  2184. ;initializes.  This structure is passed, along with x(n) to the filter
  2185. ;routines.
  2186.  
  2187. ;struct IIR {
  2188. ;    float *filter;        ;address of sample by sample filter rout.
  2189. ;    float *filtera;        ;address of array filter routine
  2190. ;    float *coef;        ;address of coeficients
  2191. ;    float *delay;        ;address of Z-1 delays
  2192. ;    float BK2;        ;size of circular buffer/2
  2193. ;    int BK;            ;size of circular buffer
  2194. ;    int nRPTB;        ;number for RPTB instruction
  2195.  
  2196. FP    .set    AR3
  2197.  
  2198.  
  2199. ; y(n) = (param->filter)(x(n),param)
  2200. ;
  2201. ; float filter(xn,param)
  2202. ; float xn;
  2203. ; struct IIR *param;
  2204. ;
  2205.  
  2206.     .global    _IIR_C45o
  2207. _IIR_C45o:
  2208.     PUSH    FP
  2209.     LDI    SP,FP
  2210.     PUSH    AR7
  2211.  
  2212.     LDI    *-FP(3),AR7    ;address of param -> AR7
  2213.     LDF    *-FP(2),R0    ;Y0(n) = x(n) -> R0
  2214.     LDI    *+AR7(3),AR1    ;Get address of Z-1's
  2215.     LDI    AR1,AR2        ;Copy into AR2
  2216.     LDF    0.0,R2        ;zero R2 for first time through loop
  2217.     LDI    *+AR7(4),IR0    ;Get 1/2 size of circular buffer
  2218.     LDI    *+AR7(5),BK    ;Get size of circular buffer
  2219.     LDI    *+AR7(6),RC    ;Get number of time to repeat section
  2220.     NOP    *AR2++(IR0)%    ;Make address of Z-2
  2221.     LDI    *+AR7(2),AR0    ;Get address of coefficients
  2222.  
  2223.     RPTB    loop        ;do 2 sections at a time sections
  2224. ;section a
  2225.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0
  2226. ||    ADDF3    R0,R2,R2    ;Z + B1' * Z-1 + B2' * Z-2 -> R2
  2227.                 ;from last iteration
  2228.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  2229. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  2230.     MPYF3    *AR0++,*AR2++%,R0;B2' * Z-2 -> R0
  2231. ||    ADDF3    R0,R2,R3    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R3
  2232.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  2233. ||    ADDF3    R0,R3,R2    ;Z + B2' * Z-2 -> R2
  2234. ;section b
  2235.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0
  2236. ||    ADDF3    R0,R2,R2    ;Z + B1' * Z-1 + B2' * Z-2 -> R2
  2237.                 ;from last iteration
  2238.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  2239. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  2240.     MPYF3    *AR0++,*AR2,R0    ;B2' * Z-2 -> R0
  2241. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
  2242.     STF    R3,*-AR2(1)    ;save Z(last section) for next sample
  2243. ||    STF    R2,*AR2++%    ;save Z = A1 * Z-1 + Yi(n) + A2 * Z-2
  2244. loop:    MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  2245. ||    ADDF3    R0,R2,R2    ;Z + B2' * Z-2 -> R2
  2246. ;last section
  2247.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0
  2248. ||    ADDF3    R0,R2,R2    ;Z + B1' * Z-1 + B2' * Z-2 -> R2
  2249.                 ;from last iteration
  2250.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  2251. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  2252.     MPYF3    *AR0++,*AR2,R0;B2' * Z-2 -> R0
  2253. ||    ADDF3    R0,R2,R3    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R3
  2254.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  2255. ||    ADDF3    R0,R3,R2    ;Z + B2' * Z-2 -> R2
  2256.  
  2257.     ADDF    R2,R0        ;Z + B1' * Z-1 + B2' * Z-2 -> R2
  2258.     MPYF3    *+AR0,R0,R0    ;Do final gain compensation
  2259. ||    STF    R3,*AR2++%    ;save Z = A1 * Z-1 + Yi(n) + A2 * Z-2
  2260.     STI    AR1,*+AR7(3)    ;Update Z-1 address
  2261.  
  2262.     POP    AR7
  2263.     POP    FP
  2264.     RETS
  2265.  
  2266. ;        PERFORM ARRAY FILTERING
  2267. ;void (*param->filtera)(xy,xn,n,param)
  2268. ;float *xn, *yn
  2269. ;int n;
  2270. ;struct IIR *param;
  2271. ;
  2272. ; filter returns y(n) for input x(n)
  2273. ; xn and yn are pointers to arrays of size n+1 floats
  2274. ;
  2275. ; the filter routine must be called with x(0) thru x(n)
  2276. ; first then x(n+1) thru x(....) and so on.
  2277.  
  2278.     .global    _IIR_C45oa
  2279. _IIR_C45oa:
  2280.     PUSH    FP
  2281.     LDI    SP,FP
  2282.     PUSH    AR7
  2283.     PUSH    AR6
  2284.     PUSH    AR5
  2285.     PUSH    AR4
  2286.  
  2287.     LDI    *-FP(2),AR5    ;Get address of y(n)
  2288.     LDI    *-FP(3),AR4    ;Get address of x(n)
  2289.     LDI    *-FP(5),AR7    ;address of param -> AR7
  2290.     LDI    *+AR7(3),AR1    ;Get address of Z-1's
  2291.     LDI    AR1,AR2        ;Copy into AR2
  2292.     LDI    *-FP(4),AR6    ;Get number of samples-1 to filter
  2293.     LDF    0.0,R2        ;zero R2 for first time through loop
  2294.     LDI    *+AR7(4),IR0    ;Get 1/2 size of circular buffer
  2295.     LDI    *+AR7(5),BK    ;Get size of circular buffer
  2296.     LDI    *+AR7(6),RC    ;Get number of time to repeat section
  2297.     NOP    *AR2++(IR0)%    ;Make address of Z-2
  2298.     LDF    *AR4++,R0    ;Get x(n)
  2299.     LDI    *+AR7(7),IR0    ;Get length of coef. buffer-1
  2300.     LDI    *+AR7(2),AR0    ;Get address of coefficients
  2301.     
  2302.     RPTB    loopa        ;do sections
  2303. ;section a
  2304.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0
  2305. ||    ADDF3    R0,R2,R2    ;Z + B1' * Z-1 + B2' * Z-2 -> R2
  2306. aloop:                ;from last iteration
  2307.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  2308. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  2309.     MPYF3    *AR0++,*AR2++%,R0;B2' * Z-2 -> R0
  2310. ||    ADDF3    R0,R2,R3    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R3
  2311.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  2312. ||    ADDF3    R0,R3,R2    ;Z + B2' * Z-2 -> R2
  2313. ;section b
  2314.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0
  2315. ||    ADDF3    R0,R2,R2    ;Z + B1' * Z-1 + B2' * Z-2 -> R2
  2316.                 ;from last iteration
  2317.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  2318. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  2319.     MPYF3    *AR0++,*AR2,R0    ;B2' * Z-2 -> R0
  2320. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
  2321.     STF    R3,*-AR2(1)    ;save Z(last section) for next sample
  2322. ||    STF    R2,*AR2++%    ;save Z = A1 * Z-1 + Yi(n) + A2 * Z-2
  2323. loopa:    MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  2324. ||    ADDF3    R0,R2,R2    ;Z + B2' * Z-2 -> R2
  2325. ;last section
  2326.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0
  2327. ||    ADDF3    R0,R2,R2    ;Z + B1' * Z-1 + B2' * Z-2 -> R2
  2328.                 ;from last iteration
  2329.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  2330. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  2331.     MPYF3    *AR0++,*AR2,R0;B2' * Z-2 -> R0
  2332. ||    ADDF3    R0,R2,R3    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R3
  2333.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  2334. ||    ADDF3    R0,R3,R2    ;Z + B2' * Z-2 -> R2
  2335.  
  2336.     LDI    *+AR7(6),RC    ;Load repeat count
  2337.     OR    100h,ST        ;Turn repeat on
  2338.  
  2339.     DBD    AR6,aloop    ;any more samples?
  2340.  
  2341.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0 (for next sample)
  2342. ||    ADDF3    R0,R2,R2    ;Z + B1' * Z-1 + Z-2 -> R2
  2343.     MPYF3    *AR0--(IR0),R2,R1;Do final gain compensation
  2344. ||    STF    R3,*AR2++%    ;save Z = A1 * Z-1 + Yi(n) + A2 * Z-2
  2345.     LDF    *AR4++,R2    ;Get y0(n+1) = x(n+1) -> R2
  2346. ||    STF    R1,*AR5++    ;Output filtered data to array
  2347.  
  2348.     STI    AR1,*+AR7(3)    ;Update Z-1 address
  2349.  
  2350.     AND    0feffh,ST    ;Turn repeat off
  2351.  
  2352.     POP    AR4
  2353.     POP    AR5
  2354.     POP    AR6
  2355.     POP    AR7
  2356.     POP    FP
  2357.     RETS
  2358.  
  2359.     .end
  2360. ;**************************** IIR_C4M.ASM **************************** 
  2361. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2362. ;                                                           ;
  2363. ;               TMS320C30 FIR filter realization            ;
  2364. ;                                                           ;
  2365. ;     (c) Copyright 1989, Atlanta Signal Processors, Inc.   ;
  2366. ;                    All Rights Reserved                    ;
  2367. ;                                                           ;
  2368. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2369.  
  2370. ;'C' code callable IIR filter subroutines
  2371. ;4 cycles / sections; b0 = -b2
  2372.  
  2373. ;The following structure defines the 'C' structure that the Init routine
  2374. ;initializes.  This structure is passed, along with x(n) to the filter
  2375. ;routines.
  2376.  
  2377. ;struct IIR {
  2378. ;    float *filter;        ;address of sample by sample filter rout.
  2379. ;    float *filtera;        ;address of array filter routine
  2380. ;    float *coef;        ;address of coeficients
  2381. ;    float *delay;        ;address of Z-1 delays
  2382. ;    float BK2;        ;size of circular buffer/2
  2383. ;    int BK;            ;size of circular buffer
  2384. ;    int nRPTB;        ;number for RPTB instruction
  2385.  
  2386. FP    .set    AR3
  2387.  
  2388.  
  2389. ;        PERFORM THE SAMPLE BY SAMPLE FILTERING
  2390. ;float (*param->filter)(xn,param)
  2391. ;float xn
  2392. ;struct IIR *param;
  2393. ;
  2394. ; filter returns y(n) for input x(n)
  2395.  
  2396.     .global    _IIR_C4m
  2397. _IIR_C4m:
  2398.     PUSH    FP
  2399.     LDI    SP,FP
  2400.     PUSH    AR7
  2401.  
  2402.     LDI    *-FP(3),AR7    ;address of param -> AR7
  2403.     LDF    *-FP(2),R0    ;Y0(n) = x(n) -> R0
  2404.     LDI    *+AR7(3),AR1    ;Get address of Z-1's
  2405.     LDI    AR1,AR2        ;Copy into AR2
  2406.     LDF    0.0,R2        ;zero R2 for first time through loop
  2407.     LDI    *+AR7(4),IR0    ;Get 1/2 size of circular buffer
  2408.     LDI    *+AR7(5),BK    ;Get size of circular buffer
  2409.     LDI    *+AR7(6),RC    ;Get number of time to repeat section
  2410.     NOP    *AR2++(IR0)%    ;Make address of Z-2
  2411.     LDI    *+AR7(2),AR0    ;Get address of coefficients
  2412.  
  2413.     RPTB    loop        ;do sections
  2414.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0
  2415. ||    SUBF3    R2,R0,R2    ;Z + B1' * Z-1 + Z-2 -> R2
  2416.                 ;from last iteration
  2417.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  2418. ||    ADDF3    R2,R0,R2    ;A1 * Z-1 + Yi(n) -> R2
  2419.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  2420. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
  2421. loop:    SUBF3    R2,*AR2,R2    ;-(Z - Z-2) -> R2
  2422. ||    STF    R2,*AR2++%    ;Z = A1 * Z-1 + Yi(n) + A2 * Z-2 -> Z-2
  2423.  
  2424.     SUBF    R2,R0        ;Z + B1' * Z-1 + Z-2 -> R0
  2425.     MPYF    *+AR0,R0    ;Do final gain compensation
  2426.     STI    AR1,*+AR7(3)    ;Update Z-1 address
  2427.  
  2428.     POP    AR7
  2429.     POP    FP
  2430.     RETS
  2431.  
  2432. ;        PERFORM ARRAY FILTERING
  2433. ;void (*param->filtera)(xy,xn,n,param)
  2434. ;float *xn, *yn
  2435. ;int n;
  2436. ;struct IIR *param;
  2437. ;
  2438. ; filter returns y(n) for input x(n)
  2439. ; xn and yn are pointers to arrays of size n+1 floats
  2440. ;
  2441. ; the filter routine must be called with x(0) thru x(n)
  2442. ; first then x(n+1) thru x(....) and so on.
  2443.  
  2444.     .global    _IIR_C4ma
  2445. _IIR_C4ma:
  2446.     PUSH    FP
  2447.     LDI    SP,FP
  2448.     PUSH    AR7
  2449.     PUSH    AR6
  2450.     PUSH    AR5
  2451.     PUSH    AR4
  2452.  
  2453.     LDI    *-FP(2),AR5    ;Get address of y(n)
  2454.     LDI    *-FP(3),AR4    ;Get address of x(n)
  2455.     LDI    *-FP(5),AR7    ;address of param -> AR7
  2456.     LDI    *+AR7(3),AR1    ;Get address of Z-1's
  2457.     LDI    AR1,AR2        ;Copy into AR2
  2458.     LDI    *-FP(4),AR6    ;Get number of samples-1 to filter
  2459.     LDF    0.0,R2        ;zero R2 for first time through loop
  2460.     LDI    *+AR7(4),IR0    ;Get 1/2 size of circular buffer
  2461.     LDI    *+AR7(5),BK    ;Get size of circular buffer
  2462.     LDI    *+AR7(6),RC    ;Get number of time to repeat section
  2463.     NOP    *AR2++(IR0)%    ;Make address of Z-2
  2464.     LDF    *AR4++,R0    ;Get x(n)
  2465.     LDI    *+AR7(7),IR0    ;Get length of coef. buffer-2
  2466.     LDI    *+AR7(2),AR0    ;Get address of coefficients
  2467.     
  2468.     RPTB    loopa        ;do sections
  2469.     MPYF3    *AR0++,*AR1,R0    ;A1 * Z-1 -> R0
  2470. ||    SUBF3    R2,R0,R2    ;Z + B1' * Z-1 + Z-2 -> R2
  2471. aloop:                ;from last iteration
  2472.     MPYF3    *AR0++,*AR2,R0    ;A2 * Z-2 -> R0
  2473. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) -> R2
  2474.     MPYF3    *AR0++,*AR1++%,R0;B1' * Z-1 -> R0
  2475. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + Yi(n) + A2 * Z-2 -> R2
  2476. loopa:    SUBF3    R2,*AR2,R2    ;-(Z - Z-2) -> R2
  2477. ||    STF    R2,*AR2++%    ;Z = A1 * Z-1 + Yi(n) + A2 * Z-2 -> Z-2
  2478.  
  2479.     LDI    *+AR7(6),RC    ;Load repeat count
  2480.     OR    100h,ST        ;Turn repeat on
  2481.  
  2482.     DBD    AR6,aloop    ;any more samples?
  2483.  
  2484.     MPYF3    *AR0++,*AR1,R0;A1 * Z-1 -> R0 (for next sample)
  2485. ||    SUBF3    R2,R0,R2    ;Z + B1' * Z-1 - Z-2 -> R2
  2486.     MPYF3    *AR0--(IR0),R2,R1;Do final gain compensation
  2487.     LDF    *AR4++,R2    ;Get y0(n+1) = x(n+1) -> R2
  2488. ||    STF    R1,*AR5++    ;Output filtered data to array
  2489.  
  2490.     STI    AR1,*+AR7(3)    ;Update Z-1 address
  2491.  
  2492.     AND    0feffh,ST    ;Turn repeat off
  2493.  
  2494.     POP    AR4
  2495.     POP    AR5
  2496.     POP    AR6
  2497.     POP    AR7
  2498.     POP    FP
  2499.     RETS
  2500.  
  2501.     .end
  2502. ;**************************** IIR_C5.ASM **************************** 
  2503. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2504. ;                                                           ;
  2505. ;               TMS320C30 FIR filter realization            ;
  2506. ;                                                           ;
  2507. ;     (c) Copyright 1989, Atlanta Signal Processors, Inc.   ;
  2508. ;                    All Rights Reserved                    ;
  2509. ;                                                           ;
  2510. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2511.  
  2512. ;'C' code callable IIR filter subroutines
  2513. ;5 cycles / sections; one section only!
  2514.  
  2515. ;The following structure defines the 'C' structure that the Init routine
  2516. ;initializes.  This structure is passed, along with x(n) to the filter
  2517. ;routines.
  2518.  
  2519. ;struct IIR {
  2520. ;    float *filter;        ;address of sample by sample filter rout.
  2521. ;    float *filtera;        ;address of array filter routine
  2522. ;    float *coef;        ;address of coeficients
  2523. ;    float *delay;        ;address of Z-1 delays
  2524. ;    float BK2;        ;size of circular buffer/2
  2525. ;    int BK;            ;size of circular buffer
  2526. ;    int nRPTB;        ;number for RPTB instruction
  2527.  
  2528. FP    .set    AR3
  2529.  
  2530.  
  2531. ;        PERFORM THE SAMPLE BY SAMPLE FILTERING
  2532. ; This is a one 2nd order section only filter
  2533. ;
  2534. ;y(n) = filter(x(n),param)
  2535. ;
  2536. ; float filter(xn,param)
  2537. ; float xn;
  2538. ; struct IIR *param;
  2539. ;
  2540.  
  2541.     .global    _IIR_C5
  2542. _IIR_C5:
  2543.     PUSH    FP
  2544.     LDI    SP,FP
  2545.  
  2546.     LDI    *-FP(3),AR2    ;address of param -> AR2
  2547.     LDI    *+AR2(2),AR0    ;Get address of coefficients
  2548.     LDI    *+AR2(3),AR1    ;Get address of Z-1's
  2549.     LDI    2,BK        ;Get size of circular buffer
  2550.     LDF    *-FP(2),R2    ;Y0(n) = x(n) -> R0
  2551.  
  2552.     MPYF3    *AR0++,*AR1++%,R0;A1 * Z-1 -> R0
  2553.     MPYF3    *AR0++,*AR1,R0    ;A2 * Z-2 -> R0
  2554. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + x(n) -> R2
  2555.     MPYF3    *AR0++,*AR1,R0    ;B2 * Z-2 -> R0
  2556. ||    ADDF3    R0,R2,R2    ;Z = A1 * Z-1 + x(n) + A2 * Z-2 -> R2
  2557.     MPYF3    *AR0++,R2,R1    ;B0 * Z -> R1
  2558. ||    STF    R2,*AR1++%    ;A1 * Z-1 + x(n) + A2 * Z-2 -> Z-2
  2559.     MPYF3    *AR0++,*AR1++%,R0;B1 * Z-1 -> R0
  2560. ||    ADDF3    R0,R1,R2    ;B0 * Z + B2 * Z-2 -> R2
  2561.  
  2562.     ADDF    R2,R0        ;B0 * Z + B1 * Z-1 + B2 * Z-2 -> R0
  2563.     STI    AR1,*+AR2(3)    ;Update Z-1 address
  2564.  
  2565.     POP    FP
  2566.     RETS
  2567.  
  2568. ;        PERFORM ARRAY FILTERING
  2569. ; This is a one 2nd order section only filter
  2570. ;
  2571. ;void (*param->filtera)(xy,xn,n,param)
  2572. ;float *xn, *yn
  2573. ;int n;
  2574. ;struct IIR *param;
  2575. ;
  2576. ; filter returns y(n) for input x(n)
  2577. ; xn and yn are pointers to arrays of size n+1 floats
  2578. ;
  2579. ; the filter routine must be called with x(0) thru x(n)
  2580. ; first then x(n+1) thru x(....) and so on.
  2581.  
  2582.     .global    _IIR_C5a
  2583. _IIR_C5a:
  2584.     PUSH    FP
  2585.     LDI    SP,FP
  2586.     PUSH    AR7
  2587.     PUSH    AR5
  2588.  
  2589.     LDI    *-FP(3),AR2    ;Get address of x(n)
  2590.     LDI    4,IR0
  2591.     LDI    *-FP(5),AR7    ;address of param -> AR7
  2592.     LDI    *+AR7(3),AR1    ;Get address of Z-1's
  2593.     LDI    *+AR7(2),AR0    ;Get address of coefficients
  2594.     LDI    *-FP(4),RC    ;Get number of samples-1 to filter
  2595.     LDI    *+AR7(5),BK    ;Get size of circular buffer
  2596.     LDF    *AR2++,R2    ;Get x(n)
  2597.  
  2598.     MPYF3    *AR0++,*AR1++%,R0;A1 * Z-1 -> R0
  2599.     LDI    *-FP(2),AR5    ;Get address of y(n)
  2600.  
  2601.     RPTB    loopa        ;do sections
  2602.     MPYF3    *AR0++,*AR1,R0    ;A2 * Z-2 -> R0
  2603. ||    ADDF3    R0,R2,R2    ;A1 * Z-1 + x(n) -> R2
  2604.     MPYF3    *AR0++,*AR1,R0    ;B2 * Z-2 -> R0
  2605. ||    ADDF3    R0,R2,R2    ;Z = A1 * Z-1 + x(n) + A2 * Z-2 -> R2
  2606.     MPYF3    *AR0++,R2,R1    ;B0 * Z -> R1
  2607. ||    STF    R2,*AR1++%    ;A1 * Z-1 + x(n) + A2 * Z-2 -> Z-2
  2608.     MPYF3    *AR0--(IR0),*AR1++%,R0    ;B1 * Z-1 -> R0
  2609. ||    ADDF3    R0,R1,R2    ;B0 * Z + B2 * Z-2 -> R2
  2610.  
  2611.     MPYF3    *AR0++,*AR1++%,R0;A1 * Z-1 -> R0 (for next sample)
  2612. ||    ADDF3    R0,R2,R3    ;B0 * Z + B1 * Z-1 + B2 * Z-2 -> R1
  2613. loopa    LDF    *AR2++,R2    ;Get y0(n+1) = x(n+1) -> R2
  2614. ||    STF    R3,*AR5++    ;Output filtered data to array
  2615.  
  2616.     NOP    *AR1--%        ;Backup to next Z-1
  2617.     AND    0feffh,ST    ;Turn repeat off
  2618.     STI    AR1,*+AR7(3)    ;Update Z-1 address
  2619.  
  2620.     POP    AR5
  2621.     POP    AR7
  2622.     POP    FP
  2623.     RETS
  2624.  
  2625.     .end
  2626.