home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 6 / QRZ Ham Radio Callsign Database - Volume 6.iso / pc / files / dsp / 56100tar.z / 56100tar / 56100 / g722 / g722code / g722.asm < prev   
Encoding:
Assembly Source File  |  1992-04-15  |  51.1 KB  |  1,670 lines

  1.     opt mu,cc
  2.     page 60,60
  3.  
  4. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  5. ;;                                        ;
  6. ;;     File        : g722.asm                                 ;
  7. ;;                                        ;
  8. ;;    Date        : October 4th 1990, 14:26                ;
  9. ;;                                        ;
  10. ;;      Program for testing the encoder and decoder of G722. Including the QMF    ;
  11. ;;    transmit and receive filters, ADC (56ADC16 Sigma-delta) input and the    ;
  12. ;;    DAC (Burr-Brown PCM56) output.                        ;
  13. ;;                                        ;
  14. ;;    Author(s)    : Jean-Pierre Petit                    ;
  15. ;;              Speech Signal Processing Applications            ;
  16. ;;              Centre National d'Etudes des Telecommunications    ;
  17. ;;              LAA-TSS                        ;
  18. ;;              Route de Tregastel - BP40                ;
  19. ;;              Lannion                        ;
  20. ;;              France                        ;
  21. ;;                                        ;
  22. ;;    Tel.        : N/A                            ;
  23. ;;                                        ;
  24. ;;              Phil Atherton                        ;
  25. ;;              DSP Applications Group                ;
  26. ;;              Motorola Semiconductors Ltd                ;
  27. ;;              Colvilles Road                    ;
  28. ;;              Kelvin Industrial Estate                ;
  29. ;;              East Kilbride                        ;
  30. ;;              Scotland                        ;
  31. ;;                                        ;
  32. ;;    Tel.        : (+44/0) 3552 40377                    ;
  33. ;;                                        ;
  34. ;;    Target System    : DSP56116                        ;
  35. ;;              16 bit Signal Processor                ;
  36. ;;                                        ;
  37. ;;    Registers used    : all                            ;
  38. ;;                                        ;
  39. ;;    Inputs required    : Tx QMF & Encoder : Min. 14 bit 2's complement A/D    ;
  40. ;;                         data @ 16 kHz sampling frequency    ;
  41. ;;                                        ;
  42. ;;              Mode of G.722       : from external file MODCOD.TST    ;
  43. ;;              Decoder                        ;
  44. ;;                                        ;
  45. ;;    Outputs given    : Decoder & Rx QMF : 16 bit 2's complement D/A data    ;
  46. ;;                         @ 16 kHz                ;
  47. ;;                                        ;
  48. ;;    Revision    : 1.01                            ;
  49. ;;                                        ;                                        ;
  50. ;;    Last Revision    : 4 October 1990                    ;
  51. ;;    Date                                    ;
  52. ;;                                        ;
  53. ;;      Notes: This version inludes the initialization of the data Ram on a    ;
  54. ;;    hardware reset; this means that the program can be burned in a PROM.    ;
  55. ;;                                        ;
  56. ;;     The mode of decoder is read in from a file by the Application system    ;
  57. ;;    (file MODCOD.TST).                            ;
  58. ;;                                        ;
  59. ;;    The network is simulated by putting IS into IR in the program.        ;
  60. ;;                                        ;
  61. ;;    This version uses interrupts for the A/D and D/A connected to the ADS    ;
  62. ;;    board but does not cope with network interrupt.             ;
  63. ;;                                                                        ;
  64. ;;               Copyright MOTOROLA and CNET France Telecom                  ;
  65. ;;                                                                           ;
  66. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  67. ;;
  68. ;;      Interrupt equates
  69. ;;    =================
  70. ;;
  71. a_ipl        equ $ffdf            ; address of ipl reg
  72. set_ipl        equ $0C00            ; enable ssi0 interrupt
  73. set_mr        equ $fc                ; no masked interrupt
  74. ;;
  75. ;;    Port C equates
  76. ;;    ==============
  77. ;;
  78. a_pcc        equ $ffc1            ; port C control
  79. set_pcc        equ $02ff            ; set port C as SSI
  80. ;;
  81. ;;    SSI0 equates
  82. ;;    ============
  83. ;;
  84. a_txrx_0    equ $fff1            ; address tx and rx
  85. a_sr_0        equ $fff0            ; address status reg. ssi0
  86. a_crb_0        equ $ffd1            ; address ssi0 crb
  87. a_cra_0        equ $ffd0            ; address ssi0 cra
  88. ;;
  89. set_cra_0    equ $6000                       ; no prescaler
  90.                         ; 16 bits
  91.                         ; normal operation
  92. ;;
  93. set_crb_0a    equ $0500            ; no rx or tx enable yet
  94. set_crb_0    equ $b500                       ; rx interrupt enable
  95.                         ; normal mode
  96.                         ; synchronous mode
  97.                         ; active high frame sync.
  98.                         ; single bit frame sync.
  99.                         ; msb first
  100.                         ; data out rising clock edge
  101.                         ; data in falling clock edge
  102.                         ; external clock
  103.                         ; external frame sync.
  104.                         ; SC00 & SC10 frame sync i/o
  105.  
  106. ;;****************************************************************
  107. ;;
  108. ;;    Interrupt Service routines
  109. ;;    ==========================
  110. ;;
  111.     org    p:$0010
  112.     jsr roe_rx_0            ; receive rx_0 with execption
  113. ;;
  114.     org    p:$0012
  115.     jsr rok_rx_0            ; recieve rx_0 ok
  116. ;;
  117. ;;
  118. ;;****************************************************************
  119. ;;
  120. ;;    Simulation of hard reset
  121. ;;    ========================
  122. ;;
  123.     org    p:$00
  124.     jmp     prog
  125. ;;
  126. ;;    Area of X RAM
  127. ;;    =============
  128. ;;
  129.     org x:$00
  130. ;;
  131. ;;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  132. ;;
  133. ;;    data for test
  134. ;;    =============
  135. ;;
  136. mode        ds    1    ; mode of decoder from MODCOD.TST file
  137. x1_in        ds    1    ; input of qmf
  138. x0_in        ds    1    ; input of qmf
  139. xout1        ds    1    ; output of qmf
  140. xout2        ds    1    ; output of qmf
  141. adc_in_1    ds    1    ; input #1 for adc at 16 kHz
  142. adc_in_0    ds    1    ; input #0 for adc at 16 kHz
  143. dac_out_1    ds    1    ; output #1 for dac at 16 kHz
  144. dac_out_2    ds    1    ; output #2 for dac at 16 kHz
  145. flag_in        ds    1    ; flag to check 2nd input at 16 kHz
  146. sav_x0        ds    1    ; save for x0 in interrupt SSI
  147. ;;
  148. ;;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  149. ;;
  150. ;;    data for predictor in lower sub band coder
  151. ;;    ==========================================
  152. ;;
  153. dat_lsbcod     ds     23    ; data ram for the lower sub band predictor
  154. xl_cod         ds     1    ; input of lsbcod
  155. il_cod         ds     1    ; output of lsbcod
  156. ;;
  157. ;;
  158. ;;    data for predictor in higher sub band coder
  159. ;;    ===========================================
  160. ;;
  161. dat_hsbcod     ds     23    ; data ram for the higher sub band predictor
  162. xh_cod         ds     1    ; input of hsbcod
  163. ih_cod         ds     1    ; output of hsbcod
  164. ;;
  165. ;;    data for predictor in lower sub band decoder
  166. ;;    ============================================
  167. ;;
  168. dat_lsbdec     ds     23    ; data ram for the lower sub band predictor
  169. ilr_dec         ds     1    ; input of lsbdec
  170. yl_dec         ds     1    ; output of lsbdec
  171. ;;
  172. ;;;    data for predictor in higher sub band decoder
  173. ;;    =============================================
  174. ;;
  175. dat_hsbdec     ds     23    ; data ram for the higher sub band predictor
  176. ihr_dec         ds     1    ; input of hsbdec
  177. yh_dec         ds     1    ; output of hsbdec
  178. ;;
  179. ;;    output of encoder
  180. ;;    =================
  181. ;;
  182. is        ds     1    ; output code of encoder
  183. ;;
  184. ;;    input of decoder
  185. ;;    ================
  186. ;;
  187. ir        ds     1    ; receive code for input of decoder
  188. ;;
  189. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  190. ;;
  191. ;;    ============================================================
  192. ;;    This data ram area is initialized at reset by the init_const
  193. ;;    procedure
  194. ;;    ============================================================
  195. ;;
  196. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  197. ;;
  198. ;;    Table for selection of decoder (mode)
  199. ;;    =====================================
  200. ;;
  201. sel_mode    ds     1    ; for mode 1 = 64 kbit/s
  202.         ds     1    ; for mode 2 = 56 kbit/s
  203.         ds     1    ; for mode 3 = 48 kbit/s
  204. ;;
  205. ;;    constant area for lower sub band predictor
  206. ;;    ==========================================
  207. ;;
  208. const_pr_l     ds     1    ; inverse 4 bits quantizer
  209.         ds     1    ; log adaptation (4 bits)
  210.         ds     1    ; multiplicand factor
  211.         ds     1    ; upper limit of p_nbl (low sub band)
  212.         ds     1    ; to compute shift right
  213.         ds     1    ; table of 32 values
  214. ;;
  215. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  216. ;;
  217. ;;    constant area for higher sub band predictor
  218. ;;    ===========================================
  219. ;;
  220. const_pr_h     ds     1    ; inverse 2 bits quantizer
  221.         ds     1    ; log adaptation (2 bits)
  222.         ds     1    ; multiplicand factor
  223.         ds     1    ; upper limit of p_nbl (high sub band)
  224.         ds     1    ; to compute shift right
  225.         ds     1    ; table of 32 values
  226. ;;
  227. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  228. ;
  229. ;    quantizer thresholds (Q6) for lower sub_band encoder
  230. ;    ====================================================
  231. ;
  232. level__1    ds     1    ; Q6(-1)
  233. level_0        ds     1    ; Q6( 0)
  234. level_1        ds     1    ; Q6( 1)
  235. level_2        ds     1    ; Q6( 2)
  236. level_3        ds     1    ; Q6( 3)
  237. level_4        ds     1    ; Q6( 4)
  238. level_5        ds     1    ; Q6( 5)
  239. level_6        ds     1    ; Q6( 6)
  240. level_7        ds     1    ; Q6( 7)
  241. level_8        ds     1    ; Q6( 8)
  242. level_9        ds     1    ; Q6( 9)
  243. level_10    ds     1    ; Q6(10)
  244. level_11    ds     1    ; Q6(11)
  245. level_12    ds     1    ; Q6(19)
  246. level_13    ds     1    ; Q6(13)
  247. level_14    ds     1    ; Q6(14)
  248. level_15    ds     1    ; Q6(15)
  249. level_16    ds     1    ; Q6(16)
  250. level_17    ds     1    ; Q6(17)
  251. level_18    ds     1    ; Q6(18)
  252. level_19    ds     1    ; Q6(19)
  253. level_20    ds     1    ; Q6(20)
  254. level_21    ds     1    ; Q6(21)
  255. level_22    ds     1    ; Q6(22)
  256. level_23    ds     1    ; Q6(23)
  257. level_24    ds     1    ; Q6(24)
  258. level_25    ds     1    ; Q6(25)
  259. level_26    ds     1    ; Q6(26)
  260. level_27    ds     1    ; Q6(27)
  261. level_28    ds     1    ; Q6(28)
  262. level_29    ds     1    ; Q6(29)
  263. ;
  264. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  265. ;;
  266. ;;    Coefficients for QMF TX and RX filters
  267. ;;    ======================================
  268. ;;    Note: they must be seen as H[23],H[22] and so on
  269. ;;    ------------------------------------------------
  270. ;;
  271. q_coef        ds     24    ; for 24 coeffiecents
  272. ;;
  273. ;;=====================================================================
  274. ;;        QMF sections
  275. ;;        ============
  276. ;;=====================================================================
  277. ;;
  278. ;;    address for modulo arithmetic of delay TX line
  279. ;;    ==============================================
  280.     org    x:$100
  281. ;;
  282. dat_q_tx    ds    24    ; delay line for QMF tx filter
  283. ptr_q_tx    ds    1    ; modulo pointer to dat_q_tx
  284. ;;
  285. ;;
  286. ;;    address for modulo arithmetic of delay RX line
  287. ;;    ==============================================
  288.     org    x:$200
  289. ;;
  290. dat_q_rx    ds    24    ; delay line for QMF rx filter
  291. ptr_q_rx    ds    1    ; modulo pointer to dat_q_rx
  292. ;;
  293. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  294. ;;
  295. ;;    Beginning of test program
  296. ;;    ========================
  297. ;;
  298.         org     p:$40
  299. ;;
  300. prog        reset            ; reset on chip peripherals
  301.         nop            ; for the pipeline
  302.         nop
  303. ;;
  304.         ori     #$30,omr    ; saturation 32 bits,rounding 2s
  305.         nop            ; for the pipeline
  306.         nop
  307. ;;
  308. ;;    Reset section
  309. ;;    =============
  310. ;;
  311.         jsr init_const        ; init const in ram
  312.         jsr reset_cod        ; encoder reset
  313.         jsr reset_dec        ; decoder reset
  314.         jsr init_q_tx        ; reset qmf tx
  315.         jsr init_q_rx        ; reset qmf rx
  316. ;;
  317. ;;    ==============================================================
  318. ;;    read mode of decoder (not significant for encoder)
  319. ;;    mode 1, 2 or 3 is valid (64, 56 and 48 kbits/sec)
  320. ;;    ==============================================================
  321. ;;
  322. ;;    Apps input: select mode of decoder
  323. ;;    ==================================
  324. ;;
  325.         move    #$0101,x0    ; file #1 with 1 values input
  326.         move    #1,r1        ; data resides in x memory
  327.         move    #mode,r0     ; in variable x:mode
  328.  
  329.         org p:            ; for reference
  330. DEBI_CDMO    debug
  331.         nop            ; for the pipeline
  332.         nop
  333. ;;
  334. ;;    Initialise ssi0
  335. ;;    ===============
  336. ;;
  337.         move     #set_cra_0,b    ; set mode cra in x0
  338.         move     b1,x:a_cra_0    ; set mode in cra_0
  339.  
  340.         move     #set_crb_0a,b    ; set mode crb in x0
  341.         move     b1,x:a_crb_0    ; set mode in crb_0
  342.  
  343.         move     #set_pcc,b    ; for ssi in port c
  344.         move     b1,x:a_pcc    ; set port c ssi0/1
  345.  
  346.         move     b0,x:a_txrx_0    ; write 0 to ssi0 tx
  347.                     ; for init
  348.         move    #set_crb_0,b    ; enable tx & rx in ssi0
  349.         move    b1,x:a_crb_0
  350. ;;
  351. ;;    Set interrupt priority and mode register
  352. ;;    ========================================
  353. ;;
  354.         move     #set_ipl,x0    ; set x0 with ipl
  355.         move     x0,x:a_ipl    ; write ipl
  356.         andi     #set_mr,mr    ; unmask all interrupts
  357. ;;
  358. ;;
  359. ;;    Clear input_flag at 16 kHz
  360. ;;    ==========================
  361. ;;
  362.         clr     b
  363.         move     b,x:flag_in    ; set flag_in to 0
  364. ;;
  365. ;;||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
  366. ;;
  367. ;;    ==========
  368. ;;    Main loop
  369. ;;    ==========
  370.  
  371.         do     forever,sequence    ; forever i/o loop
  372. ;;
  373. ;;    Wait for two inputs at 16 kHz
  374. ;;    =============================
  375. ;;
  376. wait_2i        bftsth     #$0002,x:flag_in    ; test flag_in == 2
  377.         bcc     <wait_2i        ; wait for 2 inputs at 16 kHz
  378. ;;
  379. ;;    Ok for 2 inputs at 16 kHz
  380. ;;    =========================
  381. ;;
  382. ;;    Read adc values
  383. ;;    ===============
  384. ;;
  385.         move     x:adc_in_1,x0    ; read input#1 of adc
  386.         move     x0,x:x1_in    ; older sample
  387.         move     x:adc_in_0,x0    ; read input#0 of adc
  388.         move     x0,x:x0_in    ; newer sample
  389. ;;
  390. ;;
  391. ;;    Write dac values
  392. ;;    ================
  393. ;;
  394.         move     x:xout1,x0    ; read 1st output of qmfrx
  395.         move     x0,x:dac_out_1    ; output #1 for dac
  396.         move     x:xout2,x0    ; read 2nd output of qmfrx
  397.         move     x0,x:dac_out_2    ; output #2 for dac
  398. ;;
  399. ;;    Set flag_in to 0 for following interrupt
  400. ;;    ========================================
  401. ;;
  402.         clr     b        ; accb = 0
  403.         move    b,x:flag_in    ; set flag _in to 0
  404. ;;
  405. ;;*******************************************************************
  406. ;;
  407. ;;    Beginning of G722 encoder
  408. ;;    =========================
  409. ;;
  410. ;;    Call qmftx procedure
  411. ;;    ====================
  412. ;;
  413.         jsr qmf_tx        ; transmit qmf
  414. ;;
  415. ;;    Call encoder procedure
  416. ;;    ======================
  417. ;;
  418.         jsr encoder        ; call G722 encoder
  419. ;;
  420. ;;    Simulation of network transmission
  421. ;;    ==================================
  422. ;;
  423.         move x:is,a        ; load computed code
  424.         move a,x:ir        ; save new ouput code
  425. ;;
  426. ;;    Call encoder procedure
  427. ;;    ======================
  428. ;;
  429.         jsr decoder        ; call G722 encoder
  430. ;;
  431. ;;
  432. ;;    Call qmfrx procdeure
  433. ;;    ====================
  434. ;;
  435.         jsr qmf_rx        ; receive qmf
  436. ;;
  437. sequence
  438. ;;
  439. ;;***********************************************************************
  440. ;;*                                    *
  441. ;;*            End of Main program loop            *
  442. ;;*                                    *
  443. ;;***********************************************************************
  444. ;;
  445. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  446. ;;                                    ;;
  447. ;; structure of variables for predictor in lower sub band coder           ;;
  448. ;;                                      in higher sub band coder          ;;
  449. ;;                                      in lower sub band decoder         ;;
  450. ;;                                      in higher sub band decoder        ;;
  451. ;; the address of this structure is passed to the subroutine predictor    ;;
  452. ;; in the r2 address register                                             ;;
  453. ;; this structure need 23 words of ram that must be initialized for       ;;
  454. ;; correct oprationof the g722 algorithm (digital test sequence           ;;
  455. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  456. ;;
  457. delt         equ     0        ;
  458. sl            equ     1        ; signal predicted
  459. szl           equ     2        ; output of the zero predictor
  460. p_nbl         equ     3        ; nabla of the predictor
  461. al1           equ     4        ; first pole predictor coefficient
  462. al2           equ     5        ; first pole predictor coefficient
  463. bl1           equ     6        ; zero predictor coefficient
  464. bl2           equ     7        ; zero predictor coefficient
  465. bl3           equ     8        ; zero predictor coefficient
  466. bl4           equ     9        ; zero predictor coefficient
  467. bl5          equ     10        ; zero predictor coefficient
  468. bl6          equ     11        ; zero predictor coefficient
  469. rlt0         equ     12        ; pole signal predictor
  470. rlt1         equ     13        ; pole signal predictor
  471. dlt0         equ     14        ; zero signal predictor
  472. dlt1         equ     15        ; zero signal predictor
  473. dlt2         equ     16        ; zero signal predictor
  474. dlt3         equ     17        ; zero signal predictor
  475. dlt4         equ     18        ; zero signal predictor
  476. dlt5         equ     19        ; zero signal predictor
  477. dlt6         equ     20        ; zero signal predictor
  478. plt0         equ     21        ; pole partial signal predictor
  479. plt1         equ     22        ; pole partial signal predictor
  480. ;;
  481. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  482. ;                                                                   ;
  483. ;   Encoder: G722 encoder                                           ;
  484. ;            Compute the output, is, from inputs, xl_cod and xh_cod ;
  485. ;            First compute il_cod from xl_cod (lsbcod procedure)    ;
  486. ;            Then compute ih_cod from xh_cod (hsbcod procedure)     ;
  487. ;            Finally compute is from il_cod and ih_cod              ;
  488. ;                                                                   ;
  489. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  490. ;
  491. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  492. ;                                                                   ;
  493. ;   Lsbcod : lower sub band coder                                   ;
  494. ;            Compute the output code il_cod from input xl_cod       ;
  495. ;            First compute el then quantize on 6 bits               ;
  496. ;                                    ;
  497. ;   NOTE: entry point of encoder = lsbcod                           ;
  498. ;   =====================================                           ;
  499. ;                                     ;
  500. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  501. ;;
  502. encoder        move     x:xl_cod,a        ; read xl_cod in a
  503.         move     x:(dat_lsbcod+sl),b    ; read prediction
  504.         sub     b,a            ; compute el in a
  505. ;;
  506. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  507. ;                                                                   ;
  508. ;   Quantl : lower sub band 6 bits quantizer                        ;
  509. ;            el in a                                                ;
  510. ;            This procedure use a mixed tree and direct search      ;
  511. ;            to minimize speed and size of code                     ;
  512. ;            A full binary search procedure would save 20 cycles    ;
  513. ;            (10 instructions) but at the expense of 100 words      ;
  514. ;            of program.                                            ;
  515. ;                                                                   ;
  516. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  517. ;;
  518. quantl    move     #cod_6_mi,b        ; select table for el <0
  519.     move     #cod_6_pl,x0        ; select table for el >0
  520.     move     #level_0,r2        ; offset of table level in ram
  521.     tst     a            ; test if sign of el <0
  522.     tpl     x0,b            ; select table >0
  523.     move     b,r0            ; save table in r0
  524.     tfr     a,b     x:(r2+14),x0    ; level 14 in x0
  525.     move     x:dat_lsbcod,y0        ; y0 = detl
  526.     inc24     b            ; to compute |el| of G722
  527.     abs     b      x:(r2+6),x1    ; level 6 in x1
  528.     tst     a            ; test if a >=0
  529.     tmi     b,a            ; a = |el| = wd
  530. ;
  531. ;;    Beginning of the tree search
  532. ;;    ============================
  533. ;;
  534. test_14    mpy     y0,x0,b x:(r2+22),x0    ; level 22 in x0
  535.     move    b,b            ; set lsp of b to 0
  536.     cmp     b,a            ; test wd with level 14
  537.     bpl     <test_22        ; if >0 go test_22
  538. ;
  539. test_6    mpy     y0,x1,b            ; level 6 * detl
  540.     move     b,b            ; set lsp of b to 0
  541.     cmp     b,a            ; test wd with level 6
  542.     bpl     <init_7            ; if >0 go to init_7
  543. ;
  544. init__1    move     #-1,n0            ; set init of r0 index to -1
  545.     move     #level__1,r3        ; set r3 to level__1
  546.     move     x:(r0)+n0,b        ; dummy read to update r0 to r0-1
  547.     bra     <end_q6            ; direct branch to end of procedure
  548. ;
  549. init_7    move     #7,n0            ; set init of r0 index to 7
  550.     move     #level_7,r3        ; set r3 to level_7
  551.     move     x:(r0)+n0,b        ; dummy read to update r0 to r0+7
  552.     bra     <end_q6            ; direct branch to end of procedure
  553. ;;
  554. test_22    mpy     y0,x0,b            ; level 22 * detl
  555.     move     b,b            ; set lsp to b 0
  556.     cmp     b,a            ; test wd with level 22
  557.     bpl     <init_23        ; if >0 go ro init_23
  558. ;
  559. init_15    move     #15,n0            ; set init of r0 index to 15
  560.     move     #level_15,r3        ; set r3 to level_15
  561.     move     x:(r0)+n0,b        ; dummy read to update r0 to r0+15
  562.     bra     <end_q6            ; direct branch to end of procedure
  563. ;
  564. init_23    move     #23,n0            ; set init of r0 index to 23
  565.     move     #level_23,r3        ; set r3 to level_23
  566.     move     x:(r0)+n0,b        ; dummy read to update r0 to r0+23
  567.     bra     <end_q6            ; direct branch to end of procedure
  568. ;
  569. ;;
  570. ;;    Beginning of direct search for 7 values of index
  571. ;;    ================================================
  572. ;;
  573. end_q6    move     r0,r1            ; set r1 to init of r0
  574.     move     x:(r3)+,x0        ; read level -1,7,15,23
  575.     mpy     y0,x0,b  x:(r3)+,x0    ; read level  0,8,16,24
  576.     move     b,y1            ; set lsp of b to 0 (x1)
  577. ;
  578.     mpy     y0,x0,b x:(r0)+,x1 x:(r3)+,x0     ; r0++, read level 1,9,17,25
  579.     cmp     y1,a      b,y1            ; compare level -1,7,15,23
  580.     tpl     b,b      r0,r1            ; increment r1 if >0
  581. ;
  582.     mpy     y0,x0,b x:(r0)+,x1 x:(r3)+,x0     ; r0++, read level 2,10,18,26
  583.     cmp     y1,a      b,y1            ; compare level 0,8,16,24
  584.     tpl     b,b      r0,r1            ; increment r1 if >0
  585. ;
  586.     mpy     y0,x0,b x:(r0)+,x1 x:(r3)+,x0     ; r0++, read level 3,11,19,27
  587.     cmp     y1,a      b,y1            ; compare level 1,9,17,25
  588.     tpl     b,b      r0,r1            ; increment r1 if >0
  589. ;
  590.     mpy     y0,x0,b x:(r0)+,x1 x:(r3)+,x0     ; r0++, read level 4,12,20,28
  591.     cmp     y1,a      b,y1            ; compare level 2,10,18,26
  592.     tpl     b,b      r0,r1            ; increment r1 if >0
  593. ;
  594.     mpy     y0,x0,b x:(r0)+,x1 x:(r3)+,x0     ; r0++, read level 5,13,21,29
  595.     cmp     y1,a      b,y1            ; compare level 3,11,19,27
  596.     tpl     b,b      r0,r1            ; increment r1 if >0
  597. ;
  598.     mpy     y0,x0,b x:(r0)+,x1 x:(r3)+,x0     ; r0++, read level 6,14,22,30
  599.     cmp     y1,a      b,y1            ; compare level 4,12,20,28
  600.     tpl     b,b      r0,r1            ; increment r1 if >0
  601. ;
  602.     cmp     y1,a      x:(r0)+,x1        ; compare level 5,13,21,29
  603.     tpl     b,b      r0,r1            ; increment r1 if >0
  604. ;
  605.     move     #dat_lsbcod,r2        ; set offset for lsbcod
  606.     move     p:(r1),a        ; code il_cod in a
  607.     move     a,x:il_cod        ; save code for lower sub_band
  608. ;;
  609. ;;    We must call subroutine pred_l
  610. ;;    ==============================
  611. ;;
  612.     move     #const_pr_l,r3        ; set constant table for low band
  613.     jsr     pred_l            ; call subroutine pred_l
  614.                     ; with il_cod in a
  615.     move     a,x:(r2+sl)        ; save sl in lsbcod
  616. ;;
  617. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  618. ;                                                                   ;
  619. ;   Hsbcod : higher sub band coder                                  ;
  620. ;            Compute the output code ih_cod from input xh_cod       ;
  621. ;            First compute eh then quantize on 2 bits               ;
  622. ;                                                                   ;
  623. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  624. ;;
  625. hsbcod    move     #dat_hsbcod,r2        ; set offset of data hsbcod
  626.     move     x:xh_cod,b        ; read xh_cod in b
  627.     move     x:(r2+sl),a        ; read prediction
  628.     sub     a,b  x:(r2+delt),y0    ; compute eh in a
  629. ;                    ; read deth in y0
  630. ;;
  631. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  632. ;                                                                   ;
  633. ;   Quanth : higher sub band 2 bits quantizer                       ;
  634. ;            eh in a                                                ;
  635. ;                                                                   ;
  636. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  637. ;;
  638. quanth    move     #4512,x0        ; level of quantization
  639.     mpy     y0,x0,a            ; compute wd,save eh
  640.     tst     b  a,x1            ; test for sign of eh
  641.     bmi     <cod_hi_mi        ; if neg bra cod_hi_mi
  642.     move     #3,x0            ; lower limit
  643.     move     #2,y0            ; upper limit
  644.     cmp     x1,b  x0,a        ; set a with lower limit
  645.     tpl     y0,a            ; if plus =>upper limit
  646.     bra     <end_q2            ; end of quant_h
  647. ;                    ; with ih in a
  648. cod_hi_mi inc24 b
  649.     abs     b            ; compute |eh|
  650.     move     #1,x0            ; lower limit
  651.     move     #0,y0            ; upper limit
  652.     cmp     x1,b  x0,a        ; set a with lower limit
  653.     tpl     y0,a            ; ih in a
  654. ;
  655. end_q2    move a,x:ih_cod            ; save code for higher sub_band
  656. ;;
  657. ;;    We must call subroutine pred_h
  658. ;;    ==============================
  659. ;;
  660.     move     #const_pr_h,r3        ; constant table for high band
  661.     jsr     pred_h            ; call subrouinte pred_h
  662.                     ; with ih_cod in a
  663.     move     a,x:(r2+sl)        ; save sh in hsbcod
  664. ;;
  665. ;;    Computation of is code from il_cod and ih_cod
  666. ;;    =============================================
  667. ;;
  668.     move     x:il_cod,a        ; read il in RAM
  669.     move     x:ih_cod,x0        ; read ih in RAM
  670.     move     #64,y0            ; for << 6
  671.     imac     y0,x0,a            ; to compute cod
  672.     move     a,x:is            ; save is code in RAM
  673.     rts                ; return of encoder
  674. ;;
  675. ;;    End of encoder procedure
  676. ;;    ========================
  677. ;;
  678. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  679. ;;
  680. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  681. ;;                                    ;;
  682. ;;    Subroutine decoder : compute yl_dec and yh_dec from ir         ;;
  683. ;;                         First compute ilr_dec and ihr_dec         ;;
  684. ;;                         Then execute lsbdec and hsbdec            ;;
  685. ;;                                                                     ;;
  686. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  687. ;;
  688. decoder    move     x:ir,a            ; read receive code ir
  689.     move     #63,x0            ; set mask for ilr_dec
  690.     move     #3,y0            ; set mask for ihr_dec
  691.     asr     a     a,b        ; shift a save a in b
  692.     asr4     a            ; to compute ihr_dec
  693.     asr     a            ; final shift of 6 shifts
  694.     and     y0,a            ; mask ihr_dec
  695.     and     x0,b            ; mask for ilr_dec
  696.     move     b,x:ilr_dec        ; save ilr_dec
  697.     move     a,x:ihr_dec        ; save ihr_dec
  698. ;;
  699. ;;    lsbdec
  700. ;;    ======
  701. ;;
  702. ;;    Select mode of operation of lower sub band decoder
  703. ;;    ==================================================
  704. ;;
  705.     move     #dat_lsbdec,r2        ; set data ram
  706.     move     #sel_mode,r0        ; load table sel_mode in r0
  707.     move     x:mode,a        ; read mode of decoder
  708.     and     y0,a      a0,x0        ; mask mode bits, x0 == 0 (#3 still in y0)
  709.     dec24     a    b,y1        ; compute modified mode, ilr_dec in y1
  710.     tmi     x0,a            ; select default mode ==1
  711. ;;
  712. ;;    read table sel_mode
  713. ;;    ===================
  714. ;;
  715.     rep     a1            ; repeat 0 1 or 2 times
  716.     asr     b  x:(r0)+,x1        ; shift and dummy read
  717.     move     b,n1            ; offset for table QQ6,QQ5 or QQ4
  718.     move     x:(r0),r1        ; selected table in r1
  719.     move     x:(r2+sl),b        ; read prediction in b
  720.     move     x:(r1)+n1,x0        ; dummy read to compute r1+n1
  721.     move     x:(r2),y0        ; read detl in ram
  722.     move     p:(r1),x0        ; read table of inverse quantizer
  723.     mac     y0,x0,b  y1,a        ; compute yl, a = ilr_dec
  724.     asl     b            ; limit yl to 16384
  725.     asr     b            ; end of limiting
  726.     move     #const_pr_l,r3        ; for lower predictor
  727.     move     b,x:yl_dec        ; save reconstructed signal
  728. ;;
  729. ;;    call pred_l
  730. ;;    ===========
  731. ;;
  732.     jsr     pred_l            ; lower predictor
  733.     move     a,x:(r2+sl)        ; save next prediction
  734. ;;
  735. ;;    hsbdec
  736. ;;    ======
  737. ;;
  738.     move     #dat_hsbdec,r2        ; select ram
  739.     move     #const_pr_h,r3        ; select higher constant
  740.     move     x:ihr_dec,a        ; read ih in a
  741. ;;
  742. ;;    call pred_h
  743. ;;    ===========
  744. ;;
  745.     jsr     pred_h            ; higher predictor
  746.     move    x:(r2+dlt0),b        ; reconstructed signal
  747.     move     x:(r2+sl),y1        ; last prediction
  748.     add     y1,b  a,x:(r2+sl)    ; compute yh, save new sl
  749.     asl     b            ; limit yh
  750.     asr     b            ; end of limiting
  751.     move    b,x:yh_dec        ; save yh_dec
  752. ;;
  753. ;;    end of decoder
  754. ;;    ==============
  755. ;;
  756.     rts
  757. ;;
  758. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  759. ;;                                                                   ;;
  760. ;;    Subroutine pred_l: compute invqal, logscl, scalel              ;;
  761. ;;                       then compute the adaptive predictor         ;;
  762. ;;    Input : il in a (lower subband code)                           ;;
  763. ;;            r3 must point on const_pr_l (constant for lower band)  ;;
  764. ;;            r2 must point on data ram for lower band               ;;
  765. ;;                                                                   ;;
  766. ;;    Subroutine pred_h: compute invqah, logsch, scaleh              ;;
  767. ;;                                                                   ;;
  768. ;;    Input : ih in a (higher subband code)                          ;;
  769. ;;            r3 must point on const_pr_h (constant for higher band) ;;
  770. ;;            r2 must point on data ram for higher band              ;;
  771. ;;                                                                   ;;
  772. ;;    NOTE: pred_l and pred_h are the same but the entry point of    ;;
  773. ;;          pred_h skip the >> 2 of input code                       ;;
  774. ;;                                                                   ;;
  775. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  776. ;;
  777. ;;    Invaqal/h: inverse quantizer on 4/2 bits
  778. ;;    ========================================
  779. ;;
  780. ;;    assume a = il/ih (level of quantizer)
  781. ;;
  782. pred_l    lsr     a
  783.     lsr     a            ; to compute ilr = il >>2
  784. pred_h    move     a1,n0            ; offset for table QQ4/QQ2
  785.     move     x:(r3)+,r0        ; to address table QQ4/QQ2
  786.     move     n0,n1            ; for table W4/W2
  787.     move     x:(r3)+,r1        ; to address table W4/W2
  788.     move     x:(r0)+n0,x1        ; table QQ4/QQ2 (dummy read)
  789.     move     x:(r2),x0        ; detl =first data in structure
  790.     move     p:(r0),x1        ; read inverse quantizer output
  791.     mpy     x1,x0,b x:(r1)+n1,x0    ; b=detl*IQ4/IQ2, dummy read->r1+n1
  792.     clr     b   b,x:(r2+dlt0)    ; b=0, save new dlt0 in ram
  793. ;;
  794. ;;    Begin Logscl/h
  795. ;;    ==============
  796. ;;
  797.     move     x:(r3)+,x0        ; x0 =32512
  798.     move     x:(r2+p_nbl),y1        ; read old p_nbl
  799.     mpy     y1,x0,a  x:(r3)+,y0    ; a= p_nbl*32512; y0=18432/22528)
  800.     move     p:(r1),y1        ; read table W4/W2
  801.     add     y1,a            ; compute p_nbl*32512 + wl in a
  802.     tmi     b,a            ; limit to 0 if < 0
  803.     cmp     y0,a            ; test if > 18432/22528
  804.     tpl     y0,a            ; limit to 18432/22528
  805. ;;
  806. ;;    Begin Scalel/h
  807. ;;    ==============
  808. ;;
  809.     asr     a  a,x:(r2+p_nbl)    ; save new p_nbl
  810.     asr     a  x:(r3)+,x0        ; to compute 9/11-wd2 = 1 +(8/10-wd2)
  811.     asr4     a            ; a = p_nbl >> 6
  812.     move     x:(r3)+,r0        ; to address the ILB table
  813.     move     #31,y1            ; for mask
  814.     and     y1,a  a,b        ; b = p_nbl >> 6
  815.     move     a1,n0            ; offset of table ILB
  816.     asr4     b
  817.     asr     b   x:(r0)+n0,y1    ; b = p_nbl>>11, dummy read,r0->
  818.     tfr     x0,b  b,y1        ; b= 9/11, y1 = wd2 (lsp set to 0)
  819.     sub     y1,b            ; b1 = 9/11 - wd2 (always >=0)
  820.     move     p:(r0),a        ; read table ILB*2 (ie 9-wd2)
  821.     rep     b1            ; b1 must be >=0
  822.     asr     a            ; a = a >> (9/11-wd2)
  823.     move     a,a            ; set lsp of a  to 0
  824.     asl     a
  825.     asl     a            ; a = a << 2
  826.     move     a,x:(r2)        ; save new detl
  827. ;;
  828. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  829. ;;                                                                       ;;
  830. ;;            Predictor : compute the following equations of the         ;;
  831. ;;            ========= : G722 predictor (see detailed recommendation    ;;
  832. ;;                      : and 'C' program)                             ;;
  833. ;;                      :          upzero(dlt,bl);                       ;;
  834. ;;                      :          plt[0]=parrec(dlt[0],szl);            ;;
  835. ;;                      :          rlt[0]=recons(sl,dlt[0]);             ;;
  836. ;;                      :          uppol2(al,plt);                       ;;
  837. ;;                      :          uppol1(al,plt);                       ;;
  838. ;;                      :          szl=filtez(dlt,bl);                   ;;
  839. ;;                      :          spl=filtep(rlt,al);                   ;;
  840. ;;                      :          sl=predic(spl,szl);                   ;;
  841. ;;                                                                       ;;
  842. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  843. ;;
  844. predictor clr b  x:(r2+dlt0),a    ; a = dlt0, b=0
  845.     move     #64,x0        ; x0 = 128/2
  846.     move     #-64,y0        ; y0 = -128/2
  847.     tst     a        ; set flag
  848.     tgt     x0,b        ; if >0 b =64
  849.     tlt     y0,b        ; if < 0 b=-64 (else b=0)
  850.     asl     b  b0,y1    ; b=2*b; y1 = 0
  851.     move     b,y0        ; sign suppressed in y
  852. ;;
  853. ;;    address computation
  854. ;;    ===================
  855. ;;
  856.     move     #dlt6,n2    ; for address computation
  857.     move     #-2,n0        ; for updating the delay line
  858.     lea     (r2)+n2,r0    ; r0 = address of dlt6
  859.     move     #bl6,n2        ; for adress computation
  860.     move     n0,n3        ; idem
  861.     lea     (r2)+n2,r3    ; r3 = address of bl6
  862. ;;
  863. ;;    upzero
  864. ;;    ======
  865. ;;
  866.     move     #32640,x1        ; fixed coefficient for bli
  867.     move     x:(r0)+,a x:(r3)+,x0    ; a= dlt6, x0 = bl6
  868.     add     y,a    (r0)+n0        ; a= dlt6+wd1, r0 = &dlt5
  869.     abs     a    (r3)+n3        ; set sign of a0, r3 =&bl5
  870.     mpy     x1,x0,b    a0,x0        ; x0 = wd2, b= 32640*bl6
  871.     add     x0,b x:(r0)+,a x:(r3)+,x0 ; b = new bl6, a= dlt5,x0= bl5
  872. ;;
  873. ;;    loop for the following bli
  874. ;;    ==========================
  875. ;;
  876.     do     #5,end_upzero
  877.     add     y,a    a,x:(r0)+n0    ;save dlti in dlti-1,r0 =&dlti+1
  878.     abs     a    b,x:(r3)+n3    ; save bli
  879.     mpy     x1,x0,b    a0,x0        ; x0 = wd2, b= 32640*bli-1
  880.     add     x0,b    x:(r0)+,a x:(r3)+,x0    ;b =new bli-1
  881. end_upzero
  882. ;;
  883. ;;    We must compute the new plt0 and the rlt0 and save 2*dlt0 in dlt1
  884. ;;    for the filtez computation
  885. ;;    Also we must save the new bl1 coefficients in ram
  886. ;;    =================================================
  887. ;;
  888.     tfr     a,x0  b,x:(r3)+        ; x0=a=dlt0, save bl1 in ram
  889.     asl     a  x:(r2+szl),b        ; a=2*dlt0, b= szl
  890.     add     x0,b x:(r2+plt1),x1    ; b= plt0, x1=plt1 (ie plt2)
  891.     tfr     b,y1  a,x:(r0)+        ; save 2*dlt0 in dlt1
  892.     eor     x1,b  x:(r2+sl),a    ; sg0^sg2=b, a= sl
  893.     add     x0,a  x:(r2+plt0),x0    ; a= rlt0, x0 = plt0 (ie plt1)
  894.     asl     a     x0,x:(r2+plt1)    ; a=2*rlt0, save new plt1
  895.     tfr     y1,a  a,x:(r2+rlt0)    ; a= plt0, save 2*rlt0 in ram
  896.     eor     x0,a  y1,x:(r2+plt0)    ; sg0^sg1=a, save new plt0
  897.  
  898. ;;    uppol2 and uppol1
  899. ;;    =================
  900. ;;
  901. ;;    uppol2
  902. ;;    ======
  903. ;;
  904.     move     a1,x1            ; x1 = sg0 ^ sg1
  905.     move     b1,y1            ; y1 = sg0 ^ sg2
  906.     move     x:(r2+al1),a        ; a= al1
  907.     move     #-192,b            ; b=-192
  908.     neg     b    b,y0        ; b =192, y0 = -192
  909.     asl     a            ; to compute wd1
  910.     asl     a            ; for limiting and fixe a0 to 0
  911.     neg     a    a,x0        ; a= -wd1 , x0 = wd1 (4*al1)
  912.     tst     x1            ; test if sg0 ^ sg1 == 1 or 0
  913.     tlt     x0,a            ; if 1 a= wd1 ==>wd2
  914.     tlt     y0,b            ; if 1 b = -192 (wd1 of uppol1)
  915.     asr4     a            ; wd2 >>4
  916.     asr4     a            ; wd2 >>4
  917.     asl     a    b,y0        ; wd2 <<1
  918.                     ; y0 = wd1_uppol1
  919.     move     #128,b            ; for wd3
  920.     move     #-128,x0        ; for -wd3
  921.     tst     y1            ; test sg0 ^ sg2
  922.     tlt     x0,b            ; set b to wd3
  923.     add     a,b    x:(r2+al2),x0    ; b= wd4, read al2 in x0
  924.     move     #32512,y1        ; set 32512 in y1
  925.     move     b,b            ; limit wd4
  926.     mac     y1,x0,b            ; b= apl2
  927.     move     #-12288,a        ; set lower limit in a
  928.     move     b,b            ; limit apl2
  929.     neg     a    a,x0        ; a= 12288, x0=-12288
  930.     cmp     a,b            ; compare apl2 with +12288
  931.     tpl     a,b            ; set b to 12288 if gt
  932.     cmp     x0,b            ; compare apl2 with -12288
  933.     tmi     x0,b            ; set b to -12288 if lt
  934.     tfr     y0,a b,x:(r2+al2)    ; y0 = wd1, save new al2
  935. ;;
  936. ;;    uppol1
  937. ;;    ======
  938. ;;
  939.     move     #15360,x0        ; to compute wd3
  940.     sub     x0,b    x:(r2+al1),x0    ; b = -wd3, x0 = al1
  941.     neg     b    b,y0        ; b = wd3 , y0 = -wd3
  942.     move     #32640,x1        ; factor of al1
  943.     mac     x0,x1,a            ; a= apl1
  944.     move     a,a            ; limit apl1
  945.     cmp     b,a            ; test if a > wd3
  946.     tpl     b,a            ; set a to wd3 if gt
  947.     cmp     y0,a            ; test if a < wd3
  948.     tmi     y0,a            ; set to -wd3 if lt
  949. ;;
  950. ;;    filtez
  951. ;;    ======
  952. ;;
  953.     move     #dlt6,n2        ; for computation updating
  954.     move     #-1,n0            ; n0 = -1
  955.     lea     (r2)+n2,r0        ; r0 = address of dlt6
  956.     move     #bl6,n2            ;
  957.     move     n0,n3            ; n3 =-1
  958.     lea     (r2)+n2,r3        ; r3 = address of bl6
  959. ;;
  960.     move     a,x:(r2+al1)        ; save new al1
  961. ;;
  962.     move     x:(r0)+n0,y1 x:(r3)+n3,x1        ; y1 =dlt6, x1 = bl6
  963.     mpy     x1,y1,a x:(r0)+n0,y1 x:(r3)+n3,x1    ; y1 =dlt5, x1 = bl5
  964.     move     a,a                    ; limit partial product
  965.     mac     x1,y1,a x:(r0)+n0,y1 x:(r3)+n3,x1    ; y1 =dlt4, x1 = bl4
  966.     move     a,a                    ; limit partial product
  967.     mac     x1,y1,a x:(r0)+n0,y1 x:(r3)+n3,x1    ; y1 =dlt3, x1 = bl3
  968.     move     a,a                    ; limit partial product
  969.     mac     x1,y1,a x:(r0)+n0,y1 x:(r3)+n3,x1    ; y1 =dlt2, x1 = bl2
  970.     move     a,a                    ; limit partial product
  971.     mac     x1,y1,a x:(r0)+n0,y1 x:(r3)+n3,x1    ; y1 =dlt1, x1 = bl1
  972.     move     a,a                    ; limit partial product
  973.     mac     x1,y1,a x:(r0)+n0,y1 x:(r3)+n3,x1    ; y1 =dlt0, x1 = al2
  974. ;;                            ; a = szl then limit in x0
  975. ;;
  976. ;;    filtep
  977. ;;    ======
  978. ;;
  979.  
  980.     tfr     a,x0    x:(r0)+n0,y1            ; y1 =rlt1, x0 =szl
  981.     mpy     x1,y1,a x:(r0)+,y1 x:(r3)+n3,x1        ; y1 =rlt0, x1 = al1
  982.     move     a,a                    ; limit al2 * rlt2
  983.     mac     x1,y1,a x0,x:(r2+szl)            ; save szl
  984.     add     x0,a    y1,x:(r0)+            ; rlt0 in rlt1
  985.                                         ; prediction in accu a
  986. ;;
  987. ;;    return of subroutine pred_l or pred_h
  988. ;;
  989. ;;    ===============================================================
  990. ;;    WARNING: the prediction sl or sh is in accu A and must be saved
  991. ;;             in the calling procedure
  992. ;;    ===============================================================
  993. ;;
  994.     rts
  995. ;;
  996. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  997. ;                                    ;
  998. ;  reset_cod: subroutine to reset the encoder (lower and higher)    ;
  999. ;             state variables                                       ;
  1000. ;             We must call this subroutine in order to pass the     ;
  1001. ;             digital test sequences of the CCITT G722              ;
  1002. ;                                    ;
  1003. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1004. ;
  1005. reset_cod move     #dat_lsbcod,r0        ; pointer to data of l_coder
  1006.     move     #32,x0            ; set detl for reset
  1007.     move     x0,x:(r0)+        ; save in memory
  1008.     clr     a            ; set a to 0
  1009.     rep     #22            ; set 22 state variables to 0
  1010.     move     a,x:(r0)+        ; end for coder_low
  1011. ;
  1012.     move     #dat_hsbcod,r0        ; pointer to data of h_coder
  1013.     move     #8,x0            ; set deth for reset
  1014.     move     x0,x:(r0)+        ; save in memory
  1015.     rep     #22            ; set 22 state variables to 0
  1016.     move     a,x:(r0)+        ; end for coder_high
  1017. ;
  1018.     rts                ; return of subroutine
  1019. ;
  1020. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1021. ;                                    ;
  1022. ;  reset_dec: subroutine to reset the decoder (lower and higher)    ;
  1023. ;             states variables                                      ;
  1024. ;             We must call this subroutine in order to pass the     ;
  1025. ;             digital test sequences of CCITT G722                  ;
  1026. ;                                    ;
  1027. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1028. ;
  1029. reset_dec move     #dat_lsbdec,r0        ; pointer to data of l_decoder
  1030.     move     #32,x0            ; set detl for reset
  1031.     move     x0,x:(r0)+        ; save in memory
  1032.     clr     a            ; set a to 0
  1033.     rep     #22            ; set 22 state variables to 0
  1034.     move    a,x:(r0)+        ; end for decoder_low
  1035. ;
  1036.     move     #dat_hsbdec,r0        ; pointer to data of h_decoder
  1037.     move     #8,x0            ; set deth for reset
  1038.     move     x0,x:(r0)+        ; save in memory
  1039.     rep     #22            ; set 22 state variables to 0
  1040.     move     a,x:(r0)+        ; end for decoder_low
  1041. ;
  1042.     rts                ; return of subroutine
  1043. ;
  1044. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1045. ;;
  1046. ;;    Subroutine to initialise qmf TX filter
  1047. ;;    ======================================
  1048. ;;    Set to 0 all the delay line and initialize the pointer
  1049. ;;
  1050. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1051. ;;
  1052. init_q_tx move #dat_q_tx,r0        ; adress of delay line
  1053.     clr     a            ; a to 0
  1054.     move     r0,x:ptr_q_tx        ; save pointer value
  1055.     rep     #24            ; for 24 elements
  1056.     move     a,x:(r0)+        ; set all the line to 0
  1057.     rts                ; end of subprogram
  1058. ;;
  1059. ;;    end of init_q_tx
  1060. ;;    ================
  1061. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1062. ;;
  1063. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1064. ;;
  1065. ;;    Subroutine to initialise qmf RX filter
  1066. ;;    ======================================
  1067. ;;    Set to 0 all the delay line and initialize the pointer
  1068. ;;
  1069. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1070. ;;
  1071. init_q_rx move     #dat_q_rx,r0        ; adress of delay line
  1072.     clr     a            ; a to 0
  1073.     move     r0,x:ptr_q_rx        ; save pointer value
  1074.     rep     #24            ; for 24 elements
  1075.     move    a,x:(r0)+        ; set all the line to 0
  1076.     rts                ; end of subprogram
  1077. ;;
  1078. ;;    end of init_q_rx
  1079. ;;    ================
  1080. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1081. ;;
  1082. ;;    Subroutine to initialise constant in data ram
  1083. ;;    =============================================
  1084. ;;
  1085. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1086. ;;
  1087. init_const move #pr_sel_mode,r0        ; start of sel_mode
  1088.     move     #sel_mode,r3        ; in ram
  1089.     rep     #3            ; for 3 values
  1090.     move     p:(r0)+,x:(r3)+        ; prom_ram
  1091. ;;
  1092.     move     #pr_const_pr_l,r0    ; start of const_pr_l
  1093.     move     #const_pr_l,r3        ; in ram
  1094.     rep     #6            ; for 3 values
  1095.     move     p:(r0)+,x:(r3)+        ; prom_ram
  1096. ;;
  1097.     move     #pr_const_pr_h,r0    ; start of const_pr_h
  1098.     move     #const_pr_h,r3        ; in ram
  1099.     rep     #6            ; for 3 values
  1100.     move     p:(r0)+,x:(r3)+        ; prom_ram
  1101. ;;
  1102.     move     #pr_level__1,r0        ; start of level__1
  1103.     move     #level__1,r3        ; in ram
  1104.     rep     #31            ; for 3 values
  1105.     move     p:(r0)+,x:(r3)+        ; prom_ram
  1106. ;;
  1107.     move     #pr_q_coef,r0        ; start of q_ceof
  1108.     move     #q_coef,r3        ; in ram
  1109.     rep     #24            ; for 3 values
  1110.     move     p:(r0)+,x:(r3)+        ; prom_ram
  1111. ;;
  1112.  
  1113.     rts                ; end of subprogram
  1114. ;;
  1115. ;;    end of init_const
  1116. ;;    =================
  1117. ;;
  1118. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1119. ;;
  1120. ;;    Subroutine qmf_tx: transmit QMF filter operating at 8 kHz
  1121. ;;    input two samples at 16 kHz and output a low_band value and
  1122. ;;    a high_band value
  1123. ;;    The input values are x1_in and x0_in (the more recent is x0)
  1124. ;;    The ouput values are xl_cod and xh_cod
  1125. ;;
  1126. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1127. ;;
  1128. qmf_tx    move     x:ptr_q_tx,r0    ; recall pointer
  1129.     move     m0,x:ptr_q_tx    ; save m0 value
  1130.     move     #23,m0        ; modulo 24 for the delay line
  1131.     move     #q_coef,r3    ; for QMF TX and RX coefficients
  1132. ;;
  1133. ;;    Read the two values from ADC converter and scale them
  1134. ;;    ADC is supposed to be 16 bits (left justfified,14 bits precison)
  1135. ;;    ================================================================
  1136. ;;
  1137.     move     x:x1_in,b        ; recent the previous one
  1138.     move     x:x0_in,a        ; read the more recent
  1139.     move     b,x:(r0)+        ; save x1 in modulo delay line
  1140.     move     a,x:(r0)+        ; save x0 in modulo delay line
  1141.                     ; r0 points on H[23]
  1142. ;;
  1143. ;;    Begin mac operation: ACCUMA in a and ACCUMB in b
  1144. ;;    ================================================
  1145. ;;
  1146.     clr     a    x:(r0)+,y0    ; read xin[23]
  1147.     clr     b    x:(r3)+,x0    ; read h[23]
  1148.  
  1149.     do     #12,end_q_tx            ; for 12 values
  1150.     mac     x0,y0,b  x:(r0)+,y1  x:(r3)+,x1 ; mac and read next values
  1151.     mac     x1,y1,a  x:(r0)+,y0  x:(r3)+,x0 ; mac and read next values
  1152. end_q_tx                    ; end of do loop
  1153. ;;
  1154. ;;    Now save updated pointer and end the computation of xl_cod an xh
  1155. ;;    ===============================================================
  1156. ;;
  1157.     tfr     b,x            ; save 32 bit result in x
  1158.     add     a,b    (r0)-        ; compute xl_cod
  1159.     sub     x,a            ; compute xh_cod
  1160. ;;
  1161. ;;    Limiting the output values
  1162. ;;    ==========================
  1163. ;;
  1164.     asl     a            ; times 2
  1165.     asr     a            ; linited to -16384 and +16383
  1166.     asl     b            ; times 2
  1167.     asr     b            ; linited to -16384 and +16383
  1168.     move     b,x:xl_cod        ; for input of lsbcod
  1169.     move     a,x:xh_cod        ; for input of hsbdec
  1170.     move     x:ptr_q_tx,m0        ; recall m0 value
  1171.     move     r0,x:ptr_q_tx        ; save modulo pointer
  1172. ;;
  1173. ;;    end of qmf_tx subroutine
  1174. ;;    ========================
  1175. ;;
  1176.     rts
  1177.  
  1178. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1179. ;;
  1180. ;;    Subroutine for RX QMF filter
  1181. ;;    Compute two values from yl_dec and yh_dec (output of lsbdec and
  1182. ;;    hsbdec); the outputs are xout1 and xout2 (the more recent)
  1183. ;;
  1184. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1185. ;;
  1186. qmf_rx    move     x:ptr_q_rx,r0        ; recall saved pointer
  1187.     move     m0,x:ptr_q_rx        ; save old value of m0
  1188.     move     #23,m0            ; modulo 24 pointer
  1189.     move     #q_coef,r3        ; address of coefficients
  1190. ;;
  1191. ;;    Compute XS and XD (RECB and RECA) G722 procedure
  1192. ;;    ================================================
  1193. ;;
  1194.     move     x:yl_dec,a        ; recall yl = rl G722
  1195.     move     x:yh_dec,b        ; recall yh = rh G722
  1196.     add     a,b    b,y0        ; xs in b, x0 = rh
  1197.     sub     y0,a    b,x:(r0)+    ; xd in a, save xs
  1198.     move     a,x:(r0)+        ; save xd in delay line
  1199.                     ; now r0 points on xs11
  1200. ;;
  1201. ;;    Begin mac computation
  1202. ;;    =====================
  1203. ;;
  1204.     clr     a    x:(r0)+,y0    ; read xs11
  1205.     clr     b    x:(r3)+,x0    ; read H[23]
  1206. ;;
  1207.     do     #12,end_q_rx            ; for 12 values
  1208.     mac     x0,y0,b  x:(r0)+,y1  x:(r3)+,x1 ; mac and read next values
  1209.     mac     x1,y1,a  x:(r0)+,y0  x:(r3)+,x0 ; mac and read next values
  1210. end_q_rx                    ; end of do loop
  1211. ;;
  1212. ;;    Scaling for output
  1213. ;;    ==================
  1214. ;;
  1215.     asl     a    (r0)-        ; for times 2
  1216.     asl     b            ; for times 2
  1217.     asl     a            ; for coefficients scaling
  1218.     asl     a            ; 
  1219.     asl     b            ; for coefficients scaling
  1220.     asl     b            ; 
  1221.     move     b,x:xout2        ; the more recent
  1222.     move     a,x:xout1        ; the previous one
  1223.     move     x:ptr_q_rx,m0        ; recall m0 value
  1224.     move     r0,x:ptr_q_rx        ; save modulo pointer
  1225. ;;
  1226. ;;    End of subroutine qmf_rx
  1227. ;;    ========================
  1228. ;;
  1229.     rts
  1230. ;;
  1231. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1232. ;;
  1233. ;;    SSIO RX_0 interrupt recieve section
  1234. ;;    ===================================
  1235. ;;
  1236. roe_rx_0 nop                ; follows the noemal interrupt
  1237. rok_rx_0 move x0,x:sav_x0        ; save register x0
  1238.      move x:a_sr_0,x0        ; clear execption
  1239. ;;
  1240. ;;    =====================================================
  1241. ;;    If flag_in == 0, input adc_in_1 and output dac_out_1
  1242. ;;    then set flag_in to 1
  1243. ;;    =====================================================
  1244. ;;
  1245. ok_in_1    bfset     #$0001,x:flag_in      ; set flag_in to 0 if not set
  1246.     bcs     ok_in_2            ; was set to 1
  1247.     move     x:a_txrx_0,x0        ; read received word
  1248.     move     x0,x:adc_in_1        ; save 1st adc value
  1249.     move     x:dac_out_1,x0        ; read 1st dac value
  1250.     move     x0,x:a_txrx_0        ; save transmit word
  1251.     move     x:sav_x0,x0        ; restore x0
  1252.     rti
  1253. ;;
  1254. ok_in_2 bfchg     #$0003,x:flag_in      ; set flag_in to 2
  1255.     move     x:a_txrx_0,x0        ; read received word
  1256.     move     x0,x:adc_in_0        ; save 2nd adc value
  1257.     move     x:dac_out_2,x0        ; read 2nd dac value
  1258.     move     x0,x:a_txrx_0        ; save transmit word
  1259.     move     x:sav_x0,x0        ; restore x0
  1260.     rti
  1261. ;;
  1262. ;;
  1263. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1264. ;
  1265. ;    Table for coding il in lower sub band
  1266. ;    =====================================
  1267. ;
  1268. cod_6_mi    dc     %0000000000111111
  1269.         dc     %0000000000111111
  1270.         dc     %0000000000111110
  1271.         dc     %0000000000011111
  1272.         dc     %0000000000011110
  1273.         dc     %0000000000011101
  1274.         dc     %0000000000011100
  1275.         dc     %0000000000011011
  1276.         dc     %0000000000011010
  1277.         dc     %0000000000011001
  1278.         dc     %0000000000011000
  1279.         dc     %0000000000010111
  1280.         dc     %0000000000010110
  1281.         dc     %0000000000010101
  1282.         dc     %0000000000010100
  1283.         dc     %0000000000010011
  1284.         dc     %0000000000010010
  1285.         dc     %0000000000010001
  1286.         dc     %0000000000010000
  1287.         dc     %0000000000001111
  1288.         dc     %0000000000001110
  1289.         dc     %0000000000001101
  1290.         dc     %0000000000001100
  1291.         dc     %0000000000001011
  1292.         dc     %0000000000001010
  1293.         dc     %0000000000001001
  1294.         dc     %0000000000001000
  1295.         dc     %0000000000000111
  1296.         dc     %0000000000000110
  1297.         dc     %0000000000000101
  1298.         dc     %0000000000000100
  1299.         dc     %0000000000000100
  1300.         dc     %0000000000000100
  1301. ;    
  1302. ;
  1303. cod_6_pl    dc     %0000000000111101
  1304.         dc     %0000000000111101
  1305.         dc     %0000000000111100
  1306.         dc     %0000000000111011
  1307.         dc     %0000000000111010
  1308.         dc     %0000000000111001
  1309.         dc     %0000000000111000
  1310.         dc     %0000000000110111
  1311.         dc     %0000000000110110
  1312.         dc     %0000000000110101
  1313.         dc     %0000000000110100
  1314.         dc     %0000000000110011
  1315.         dc     %0000000000110010
  1316.         dc     %0000000000110001
  1317.         dc     %0000000000110000
  1318.         dc     %0000000000101111
  1319.         dc     %0000000000101110
  1320.         dc     %0000000000101101
  1321.         dc     %0000000000101100
  1322.         dc     %0000000000101011
  1323.         dc     %0000000000101010
  1324.         dc     %0000000000101001
  1325.         dc     %0000000000101000
  1326.         dc     %0000000000100111
  1327.         dc     %0000000000100110
  1328.         dc     %0000000000100101
  1329.         dc     %0000000000100100
  1330.         dc     %0000000000100011
  1331.         dc     %0000000000100010
  1332.         dc     %0000000000100001
  1333.         dc     %0000000000100000
  1334.         dc     %0000000000100000
  1335.         dc     %0000000000100000
  1336. ;    
  1337. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1338. ;;
  1339. ;;    Table ILB for scalel
  1340. ;;    ====================
  1341. ;;    Note: table ILB is scaled by 2 to avoid check of 8-wd2 <0
  1342. ;;    ====  in the shift operation
  1343. ;;
  1344. ;;
  1345. ILB        dc     2048*2
  1346.         dc     2093*2
  1347.         dc     2139*2
  1348.         dc     2186*2
  1349.         dc     2233*2
  1350.         dc     2282*2
  1351.         dc     2332*2
  1352.         dc     2383*2
  1353.         dc     2435*2
  1354.         dc     2489*2
  1355.         dc     2543*2
  1356.         dc     2599*2
  1357.         dc     2656*2
  1358.         dc     2714*2
  1359.         dc     2774*2
  1360.         dc     2834*2
  1361.         dc     2896*2
  1362.         dc     2960*2
  1363.         dc     3025*2
  1364.         dc     3091*2
  1365.         dc     3158*2
  1366.         dc     3228*2
  1367.         dc     3298*2
  1368.         dc     3371*2
  1369.         dc     3444*2
  1370.         dc     3520*2
  1371.         dc     3597*2
  1372.         dc     3676*2
  1373.         dc     3756*2
  1374.         dc     3838*2
  1375.         dc     3922*2
  1376.         dc     4008*2
  1377. ;;    
  1378. ;;    end of table ILB
  1379. ;;    ================
  1380. ;
  1381. ;    quantiser thresholds (Q6) for lower sub_band encoder
  1382. ;    ====================================================
  1383. ;
  1384. INICOD        dc       0*8        ; Q6( 0)
  1385.         dc      35*8        ; Q6( 1)
  1386.         dc      72*8        ; Q6( 2)
  1387.         dc     110*8        ; Q6( 3)
  1388.         dc     150*8        ; Q6( 4)
  1389.         dc     190*8        ; Q6( 5)
  1390.         dc     233*8        ; Q6( 6)
  1391.         dc     276*8        ; Q6( 7)
  1392.         dc     323*8        ; Q6( 8)
  1393.         dc     370*8        ; Q6( 9)
  1394.         dc     422*8        ; Q6(10)
  1395.         dc     473*8        ; Q6(11)
  1396.         dc     530*8        ; Q6(19)
  1397.         dc     587*8        ; Q6(13)
  1398.         dc     650*8        ; Q6(14)
  1399.         dc     714*8        ; Q6(15)
  1400.         dc     786*8        ; Q6(16)
  1401.         dc     858*8        ; Q6(17)
  1402.         dc     940*8        ; Q6(18)
  1403.         dc    1023*8        ; Q6(19)
  1404.         dc    1121*8        ; Q6(20)
  1405.         dc    1219*8        ; Q6(21)
  1406.         dc    1339*8        ; Q6(22)
  1407.         dc    1458*8        ; Q6(23)
  1408.         dc    1612*8        ; Q6(24)
  1409.         dc    1765*8        ; Q6(25)
  1410.         dc    1980*8        ; Q6(26)
  1411.         dc    2195*8        ; Q6(27)
  1412.         dc    2557*8        ; Q6(28)
  1413.         dc    2919*8        ; Q6(29)
  1414.         dc    2919*8        ; Q6(30)
  1415.         dc    2919*8        ; Q6(31)
  1416. ;
  1417. ;
  1418. ;    Inverse quantizer (Q6)
  1419. ;    ======================
  1420. ;
  1421. QQ6        dc      -17*8        ; code 000000
  1422.         dc      -17*8        ; code 000001
  1423.         dc      -17*8        ; code 000010
  1424.         dc      -17*8        ; code 000011
  1425.         dc     -3101*8        ; code 000100
  1426.         dc    -2738*8        ; code 000101
  1427.         dc    -2376*8        ; code 000110
  1428.         dc    -2088*8        ; code 000111
  1429.         dc    -1873*8        ; code 001000
  1430.         dc    -1689*8        ; code 001001
  1431.         dc    -1535*8        ; code 001010
  1432.         dc    -1399*8        ; code 001011
  1433.         dc    -1279*8        ; code 001100
  1434.         dc    -1170*8        ; code 001101
  1435.         dc    -1072*8        ; code 001110
  1436.         dc     -982*8        ; code 001111
  1437.         dc     -899*8        ; code 010000
  1438.         dc     -822*8        ; code 010001
  1439.         dc     -750*8        ; code 010010
  1440.         dc     -682*8        ; code 010011
  1441.         dc     -618*8        ; code 010100
  1442.         dc     -558*8        ; code 010101
  1443.         dc     -501*8        ; code 010110
  1444.         dc     -447*8        ; code 010111
  1445.         dc     -396*8        ; code 011000
  1446.         dc     -347*8        ; code 011001
  1447.         dc     -300*8        ; code 011010
  1448.         dc     -254*8        ; code 011011
  1449.         dc     -211*8        ; code 011100
  1450.         dc     -170*8        ; code 011101
  1451.         dc     -130*8        ; code 011110
  1452.         dc      -91*8        ; code 011111
  1453.         dc     3101*8        ; code 100000
  1454.         dc     2738*8        ; code 100001
  1455.         dc     2376*8        ; code 100010
  1456.         dc     2088*8        ; code 100011
  1457.         dc     1873*8        ; code 100100
  1458.         dc     1689*8        ; code 100101
  1459.         dc     1535*8        ; code 100110
  1460.         dc     1399*8        ; code 100111
  1461.         dc     1279*8        ; code 101000
  1462.         dc     1170*8        ; code 101001
  1463.         dc     1072*8        ; code 101010
  1464.         dc      982*8        ; code 101011
  1465.         dc      899*8        ; code 101100
  1466.         dc      822*8        ; code 101101
  1467.         dc      750*8        ; code 101110
  1468.         dc      682*8        ; code 101111
  1469.         dc      618*8        ; code 110000
  1470.         dc      558*8        ; code 110001
  1471.         dc      501*8        ; code 110010
  1472.         dc      447*8        ; code 110011
  1473.         dc      396*8        ; code 110100
  1474.         dc      347*8        ; code 110101
  1475.         dc      300*8        ; code 110110
  1476.         dc      254*8        ; code 110111
  1477.         dc      211*8        ; code 111000
  1478.         dc      170*8        ; code 111001
  1479.         dc      130*8        ; code 111010
  1480.         dc       91*8        ; code 111011
  1481.         dc       54*8        ; code 111100
  1482.         dc       17*8        ; code 111101
  1483.         dc      -54*8        ; code 111110
  1484.         dc      -17*8        ; code 111111
  1485. ;;    
  1486. ;
  1487. ;    Inverse quantizer (Q5)
  1488. ;    ======================
  1489. ;
  1490. QQ5        dc      -35*8        ; code 00000
  1491.         dc      -35*8        ; code 00001
  1492.         dc    -2919*8        ; code 00010
  1493.         dc    -2195*8        ; code 00011
  1494.         dc    -1765*8        ; code 00100
  1495.         dc    -1458*8        ; code 00101
  1496.         dc    -1219*8        ; code 00110
  1497.         dc    -1023*8        ; code 00111
  1498.         dc     -858*8        ; code 01000
  1499.         dc     -714*8        ; code 01001
  1500.         dc     -587*8        ; code 01010
  1501.         dc     -473*8        ; code 01011
  1502.         dc     -370*8        ; code 01100
  1503.         dc     -276*8        ; code 01101
  1504.         dc     -190*8        ; code 01110
  1505.         dc     -110*8        ; code 01111
  1506.         dc     2919*8        ; code 10000
  1507.         dc     2195*8        ; code 10001
  1508.         dc     1765*8        ; code 10010
  1509.         dc     1458*8        ; code 10011
  1510.         dc     1219*8        ; code 10100
  1511.         dc     1023*8        ; code 10101
  1512.         dc      858*8        ; code 10110
  1513.         dc      714*8        ; code 10111
  1514.         dc      587*8        ; code 11000
  1515.         dc      473*8        ; code 11001
  1516.         dc      370*8        ; code 11010
  1517.         dc      276*8        ; code 11011
  1518.         dc      190*8        ; code 11100
  1519.         dc      110*8        ; code 11101
  1520.         dc       35*8        ; code 11110
  1521.         dc      -35*8        ; code 11111
  1522. ;;    
  1523. ;    
  1524. ;    Inverse quantizer (Q4)
  1525. ;    ======================
  1526. ;
  1527. QQ4        dc        0*8        ; code 0000
  1528.         dc    -2557*8        ; code 0001
  1529.         dc    -1612*8        ; code 0010
  1530.         dc    -1121*8        ; code 0011
  1531.         dc     -786*8        ; code 0100
  1532.         dc     -530*8        ; code 0101
  1533.         dc     -323*8        ; code 0110
  1534.         dc     -150*8        ; code 0111
  1535.         dc     2557*8        ; code 1000
  1536.         dc     1612*8        ; code 1001
  1537.         dc     1121*8        ; code 1010
  1538.         dc      786*8        ; code 1011
  1539.         dc      530*8        ; code 1100
  1540.         dc      323*8        ; code 1101
  1541.         dc      150*8        ; code 1110
  1542.         dc        0*8        ; code 1111
  1543. ;;    
  1544. ;    Inverse quantizer (Q2)
  1545. ;    ======================
  1546. ;
  1547. QQ2        dc     -926*8        ; code   00
  1548.         dc     -202*8        ; code   01
  1549.         dc      926*8        ; code   10
  1550.         dc      202*8        ; code   11
  1551. ;    
  1552. ;    Multiplication factor
  1553. ;    =====================
  1554. ;
  1555. W4        dc      -60        ; code 0000
  1556.         dc     3042        ; code 0001
  1557.         dc     1198        ; code 0010
  1558.         dc      538        ; code 0011
  1559.         dc      334        ; code 0100
  1560.         dc      172        ; code 0101
  1561.         dc       58        ; code 0110
  1562.         dc      -30        ; code 0111
  1563.         dc     3042        ; code 1000
  1564.         dc     1198        ; code 1001
  1565.         dc      538        ; code 1010
  1566.         dc      334        ; code 1011
  1567.         dc      172        ; code 1100
  1568.         dc       58        ; code 1101
  1569.         dc      -30        ; code 1110
  1570.         dc      -60        ; code 1111
  1571. ;;    
  1572. ;;
  1573. W2         dc      798        ; code   00
  1574.             dc     -214        ; code   01
  1575.             dc      798        ; code   10
  1576.             dc     -214        ; code   11
  1577. ;;    
  1578. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1579. ;; 
  1580. ;;     Tables of constants that must be loaded in data RAM at reset
  1581. ;;    ============================================================
  1582. ;;
  1583. ;;    Note: they have the same name but with a pr_ prefix (prom)
  1584. ;;    ==========================================================
  1585. ;;
  1586. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1587. ;;
  1588. ;;    Table for selection of decoder (mode)
  1589. ;;    =====================================
  1590. ;;
  1591. pr_sel_mode    dc     QQ6        ; for mode 1 = 64 kbit/s
  1592.         dc     QQ5        ; for mode 2 = 56 kbit/s
  1593.         dc     QQ4        ; for mode 3 = 48 kbit/s
  1594. ;;
  1595. ;;    constant area for lower sub band predictor
  1596. ;;    ==========================================
  1597. ;;
  1598. pr_const_pr_l     dc     QQ4        ; inverse 4 bits quantizer
  1599.         dc     W4        ; log adaptation (4 bits)
  1600.         dc     32512        ; multiplicand factor
  1601.         dc     18432        ; upper limit of p_nbl (low sub band)
  1602.         dc     9        ; to compute shift right
  1603.         dc     ILB        ; table of 32 values
  1604. ;;
  1605. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1606. ;;
  1607. ;;    constant area for higher sub band predictor
  1608. ;;    ===========================================
  1609. ;;
  1610. pr_const_pr_h     dc     QQ2        ; inverse 2 bits quantizer
  1611.         dc     W2        ; log adaptation (2 bits)
  1612.         dc     32512        ; multiplicand factor
  1613.         dc     22528        ; upper limit of p_nbl (high sub band)
  1614.         dc     11        ; to compute shift right
  1615.         dc     ILB        ; table of 32 values
  1616. ;;
  1617. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1618. ;;
  1619. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1620. ;
  1621. ;    quantiser thresholds (Q6) for lower sub_band encoder
  1622. ;    ====================================================
  1623. ;
  1624. pr_level__1    dc      0*8        ; Q6(-1)
  1625. pr_level_0    dc      0*8        ; Q6( 0)
  1626. pr_level_1    dc      35*8        ; Q6( 1)
  1627. pr_level_2    dc      72*8        ; Q6( 2)
  1628. pr_level_3    dc     110*8        ; Q6( 3)
  1629. pr_level_4    dc     150*8        ; Q6( 4)
  1630. pr_level_5    dc     190*8        ; Q6( 5)
  1631. pr_level_6    dc     233*8        ; Q6( 6)
  1632. pr_level_7    dc     276*8        ; Q6( 7)
  1633. pr_level_8    dc     323*8        ; Q6( 8)
  1634. pr_level_9    dc     370*8        ; Q6( 9)
  1635. pr_level_10    dc     422*8        ; Q6(10)
  1636. pr_level_11    dc     473*8        ; Q6(11)
  1637. pr_level_12    dc     530*8        ; Q6(19)
  1638. pr_level_13    dc     587*8        ; Q6(13)
  1639. pr_level_14    dc     650*8        ; Q6(14)
  1640. pr_level_15    dc     714*8        ; Q6(15)
  1641. pr_level_16    dc     786*8        ; Q6(16)
  1642. pr_level_17    dc     858*8        ; Q6(17)
  1643. pr_level_18    dc     940*8        ; Q6(18)
  1644. pr_level_19    dc    1023*8        ; Q6(19)
  1645. pr_level_20    dc    1121*8        ; Q6(20)
  1646. pr_level_21    dc    1219*8        ; Q6(21)
  1647. pr_level_22    dc    1339*8        ; Q6(22)
  1648. pr_level_23    dc    1458*8        ; Q6(23)
  1649. pr_level_24    dc    1612*8        ; Q6(24)
  1650. pr_level_25    dc    1765*8        ; Q6(25)
  1651. pr_level_26    dc    1980*8        ; Q6(26)
  1652. pr_level_27    dc    2195*8        ; Q6(27)
  1653. pr_level_28    dc    2557*8        ; Q6(28)
  1654. pr_level_29    dc    2919*8        ; Q6(29)
  1655. ;;
  1656. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1657. ;;
  1658. ;;    Coefficients for QMF TX and RX filters
  1659. ;;    ======================================
  1660. ;;    Note: they must be seen as H[23],H[22] and so on
  1661. ;;    ------------------------------------------------
  1662. ;;
  1663. pr_q_coef    dc     3*2,-11*2,-11*2,53*2,12*2,-156*2
  1664.         dc     32*2,362*2,-210*2,-805*2,951*2,3876*2
  1665.         dc     3876*2,951*2,-805*2,-210*2,362*2,32*2
  1666.         dc     -156*2,12*2,53*2,-11*2,-11*2,3*2
  1667. ;;
  1668. ;;
  1669. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1670.     end