📄 trebble_bass_new.s
字号:
;************************************************************************
; (c)1997 Copyright LuxSonor, Inc. All rights reserved
;
; Revision 1.0
;
;
; Module: AUDIO test code
;
; Initial version:Cecile Foret, mars 1997
; Jinshi Huang 12/1/98 for LS388/LS500
; Trebble/Bass filter test code
; Called by: test2.S
; r11=return adress
;
; bass filtering
; lattice 32 bits coefficients corresponding to each filter are stored at
; the end of the programm in the following order:
; k1,s1,k2,s2,c0,c1,c2 lower word first, upper word second
; input data are loacted from adress 0x0000 to 0x0400
; routine writes the filtered sequence at the same location in local mem.
;
;*************************************************************************
.nolist
#include "regdef2.h"
#include "stereo_user.h"
#include "memory2.h"
.list
.data
.global SUB_trebble_bass
;****** general command for the trebble bass filter **********************
; bass_com=0:6, bass -15 dB to -2.5 dB
; bass_com=7 bass 0 dB (default)
; bass_com=8:14,bass 2.5 to 15 dB
; idem for trebble command
#define SCALE_INPUT 0
SUB_trebble_bass:
;************* store the value of r8, and use r8 as a mask ***************
movh %r8_tmp, r8
#ifdef EFFECT
li r8,0x007fff00
#else //EFFECT
movi r8, 0x7fff ; mask needed for the saturation
#endif //EFFECT
#ifdef EFFECT
multi r4, 16 ; 7 coeff of 2 bytes for each filter
#endif //EFFECT
;************* deseable rounding bit in the StatusRegister ***************
mov r2, StatusReg
ori r2, 0x0100
mov StatusReg, r2
movi r0, 0x1
movh %one, r0
#if SCALE_INPUT
movi r0, 0x2aab ; 1/3
movh %scale, r0
movi r0, 0x7fff
movh %max, r0
#endif
;************ Choice of the latice coefficients **************************
#ifndef EFFECT
multi r4, 16 ; 7 coeff of 2 bytes for each filter
#endif //EFFECT
add r0, r4, r5 ; add trebble/bass base adress
; movi StartAddrHigh, 0x40 ; read coeff from the ROM
movi StartAddrHigh, DataSeg ; read coeff from the ROM 10-13-98
#ifdef EFFECT
shr r0, 2 ; to word addr
movi DMASize, 3 //4 words (8 shorts)
movi LocalAddr, (local_k2s2)>>2
dmarr r0
WaitDma
#else //EFFECT
movi ByteLocal,local_k2s2; where to put the coeff in local memory
movi ByteSize, 0xe
dmabrr r0
#endif //EFFECT
;************* main part of the routine **********************************
;************* set up the left channel first *****************************
movi r0, 0x1
movh %left_right, r0 ; left channel first
movh %Cu0u1, r14 ; current DRAM @ of history
movi r2, localA_data ; input data for the left channel
channel1_done:
;************ load the history of the lattice ****************************
; movi StartAddrHigh, 0x7
movi StartAddrHigh, DataSeg // 10-13-98
#ifdef EFFECT
shr r14, 2 ; to word addr
movi DMASize, 0 //1 words (2 shorts)
movi LocalAddr, (u1_1)>>2
dmarr r14
WaitDma
addi r14,1
movi DMASize, 0 //1 words (2 shorts)
movi LocalAddr, (u0_1)>>2
dmarr r14
WaitDma
#else //EFFECT
movi ByteLocal, u1_1
movi ByteSize, 0x2
dmabrr r14 ; load u1
addi r14, 0x4
movi ByteLocal, u0_1
movi ByteSize, 0x2
dmabrr r14 ; load u0
#endif //EFFECT
;************ copy k2, s2 to B part of memory ****************************
movh r0, %local_k2s2
movh %k2, r0
movh r0, %(local_k2s2+2)
movh %s2, r0
;************ set up the AGR *********************************************
#ifdef EFFECT
movi AGRAdr4, block2
movi AGRInc4, 0x2
movi AGRSiz4, 0x12
movi AGRSiz6, 0xffff
movi AGRSiz7, 0xffff
#else //EFFECT
movi AGRAdr2, block2
movi AGRInc2, 0x2
movi AGRSiz2, 0x12
#endif //EFFECT
movi AGRAdr0, local_k2s2
movi AGRInc0, 0x2
movi AGRSiz0, 0xc ; pointer on the lattice coeff
mov AGRAdr1, r2 ; either left or right....
movi AGRInc1, 0x4
movi AGRSiz1, 0xffff
;**************************************
;***** desable interrupt mask **********
movi TrapReg, 0x0
nop
nop
;**************************************
;**************************************
#ifdef EFFECT
movi AGRAdr5,one
#endif //EFFECT
loop 256, block_filter
#if SCALE_INPUT
movh r0, %scale
mulhf r4, r0, a1(0)
nop
rndhf a1(0), r4
#endif
;************ first block of the lattice filter s2,k2*********************
#ifdef EFFECT
debug1:
mulhf r4, i4, a0(0) ; u1[1][1]*k2= xtmp2
mulhf r6, i0, a4(-2) ; u1[1][0]*k2= xtmp1
mulhf r0, i4, a0(0) ; u1[1][1]*s2= utmp2
mulhf r2, i4, a0(2) ; u1[1][0]*s2= utmp1
maddhf r4, i4, a1(0) ; x2*s2+= xtmp2
msubhf r0, i4, a1(0) ; x2*k2-= utmp2
#else //EFFECT
mulhf r4, i2, a0(0) ; u1[1][1]*k2= xtmp2
mulhf r6, i0, a2(-2) ; u1[1][0]*k2= xtmp1
mulhf r0, i2, a0(0) ; u1[1][1]*s2= utmp2
mulhf r2, i2, a0(2) ; u1[1][0]*s2= utmp1
maddhf r4, i2, a1(0) ; x2*s2+= xtmp2
msubhf r0, i2, a1(0) ; x2*k2-= utmp2
#endif //EFFECT
;;; add both part of computation
rndhf r6, r6
#ifdef EFFECT
maddhf r4, r6, a5(0) ; x1
rndhf r2, r2
maddhf r0, r2, a5(0) ; u2
#else //EFFECT
maddhf r4, r6, %one ; x1
rndhf r2, r2
maddhf r0, r2, %one ; u2
#endif //EFFECT
;************ generate the new x1[0], x1[1], u1[0][1],u1[0][0] ************
#ifdef EFFECT
movi AGRAdr6,x1_1
movi AGRAdr7,x1_0
rndhf r2, r4 ; if saturation
movhf a6(0), r2
// andhf a7(0), r2, r8
and r3,r2,r8
movhf a7(0),r3
sub r3,r2,r4
bne x1_sat
//debug shrhf a7(0),r5,0x1
// movhf a7(0),r5
shl r4,16
shr r5,7
or r4,r5
movhf a7(0),r4
x1_sat:
movi AGRAdr6,u2_1
movi AGRAdr7,u2_0
rndhf r2, r0 ; if saturation
movhf a6(0), r2
// andhf a7(0), r2, r8 //0x0000 or 0x7fff if sat
and r3,r2,r8
movhf a7(0),r3
sub r2,r2,r0
bne u2_sat
//debug shrhf a7(0),r1,0x1
// movhf a7(0),r1
shl r0,16
shr r1,7
or r0,r1
movhf a7(0),r0
u2_sat:
#else //EFFECT
rndhf r2, r4 ; if saturation
movh %x1_1, r2
andhf %x1_0, r2, r8
sub r2,r2,r4
bnz x1_sat
shrhf %x1_0,r5,0x1
x1_sat:
rndhf r2, r0 ; if saturation
movh %u2_1, r2
andhf %u2_0, r2, r8
sub r2,r2,r0
bnz u2_sat
shrhf %u2_0,r1,0x1
u2_sat:
#endif //EFFECT
;************ second block of the lattice filter ***************************
#ifdef EFFECT
mulhf r4, i4, a0(0) ; u0[1][1]*k1= xtmp2
mulhf r6, i0, a4(-2) ; u0[1][0]*k1= xtmp1
mulhf r0, i4, a0(0) ; u0[1][1]*s1= utmp2
mulhf r2, i4, a0(-2) ; u0[1][0]*s1= utmp1
msubhf r0, i4, a0(0) ; x1[1]*k1-= utmp2
msubhf r2, i0, a4(-2) ; x1[0]*k1-= utmp1
maddhf r4, i4, a0(0) ; x1[1]*s1+= xtmp2
maddhf r6, i4, i0 ; x1[0]*s1+= xtmp1
#else //EFFECT
mulhf r4, i2, a0(0) ; u0[1][1]*k1= xtmp2
mulhf r6, i0, a2(-2) ; u0[1][0]*k1= xtmp1
mulhf r0, i2, a0(0) ; u0[1][1]*s1= utmp2
mulhf r2, i2, a0(-2) ; u0[1][0]*s1= utmp1
msubhf r0, i2, a0(0) ; x1[1]*k1-= utmp2
msubhf r2, i0, a2(-2) ; x1[0]*k1-= utmp1
maddhf r4, i2, a0(0) ; x1[1]*s1+= xtmp2
maddhf r6, i2, i0 ; x1[0]*s1+= xtmp1
#endif //EFFECT
;;; add both part of computation
rndhf r6, r6
#ifdef EFFECT
maddhf r4, r6, a5(0) ; u0
rndhf r2, r2
maddhf r0, r2, a5(0) ; u1
#else //EFFECT
maddhf r4, r6, %one ; u0
rndhf r2, r2
maddhf r0, r2, %one ; u1
#endif //EFFECT
;************ generate the new u0[0][0], u0[0][1] **************************
#ifdef EFFECT
movi AGRAdr6,u0_1
movi AGRAdr7,u0_0
rndhf r2, r4 ; if saturation
movhf a6(0), r2
// andhf a7(0), r2, r8
and r3,r2,r8
movhf a7(0),r3
sub r2,r2,r0
bne u0_sat
//debug shrhf a7(0),r5,0x1
// movhf a7(0),r5
shl r4,16
shr r5,7
or r4,r5
movhf a7(0),r4
u0_sat:
#else //EFFECT
rndhf r2, r4 ; if saturation
movh %u0_1, r2
andhf %u0_0, r2, r8
sub r2,r2,r4
bnz u0_sat
shrhf %u0_0,r5,0x1
u0_sat:
#endif //EFFECT
;************ generate the new u1[0][0], u1[0][1] *************************
#ifdef EFFECT
movi AGRAdr6,u1_1
movi AGRAdr7,u1_0
rndhf r2, r0 ; if saturation
movhf a6(0), r2
// andhf a7(0), r2, r8
and r3,r2,r8
movhf a7(0),r3
sub r2,r2,r0
bne u1_sat
//debug shrhf a7(0),r1,0x1
// movhf a7(0),r1
shl r0,16
shr r1,7
or r0,r1
movhf a7(0),r0
u1_sat:
#else //EFFECT
rndhf r2, r0 ; if saturation
movh %u1_1, r2
andhf %u1_0, r2, r8
sub r2,r2,r0
bnz u1_sat
shrhf %u1_0,r1,0x1
u1_sat:
#endif //EFFECT
;************ generate the output sample ***********************************
#ifdef EFFECT
mulhf r4, i4, a0(0) ; c2*u2[0][1]= ytmp2
mulhf r6, i4, i0 ; c2*u2[0][0]= ytmp1
maddhf r4, i4, a0(0) ; c1*u1[0][1]+=ytmp2
maddhf r6, i0, a4(6) ; c1*u1[0][0]+=ytmp1
maddhf r4, i4, a0(0) ; c0*u0[0][1]+=ytmp2
maddhf r6, i0, a4(10) ; c0*u0[0][0]+=ytmp1
#else //EFFECT
mulhf r4, i2, a0(0) ; c2*u2[0][1]= ytmp2
mulhf r6, i2, i0 ; c2*u2[0][0]= ytmp1
maddhf r4, i2, a0(0) ; c1*u1[0][1]+=ytmp2
maddhf r6, i0, a2(6) ; c1*u1[0][0]+=ytmp1
maddhf r4, i2, a0(0) ; c0*u0[0][1]+=ytmp2
maddhf r6, i0, a2(10) ; c0*u0[0][0]+=ytmp1
#endif //EFFECT
tsti r9, 0x0
beq do_round
#ifdef EFFECT
movi AGRAdr6,u1_1
movi AGRAdr7,u1_0
nop
maddhf r4, r8, a6(0)
maddhf r6, r8, a7(0)
movi AGRAdr6,u0_1
movi AGRAdr7,u0_0
nop
msubhf r4, r8, a6(0)
msubhf r6, r8, a7(0)
msubhf r4, r8, a6(0)
msubhf r6, r8, a7(0)
#else //EFFECT
maddhf r4, r8, %u1_1
maddhf r6, r8, %u1_0
msubhf r4, r8, %u0_1
msubhf r6, r8, %u0_0
msubhf r4, r8, %u0_1
msubhf r6, r8, %u0_0
#endif //EFFECT
do_round:
;;; add both part of computation
#ifdef EFFECT
nop
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -