⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test.s

📁 关于DVD上的PCM的解码的代码,PCM的DSP压缩,解调的算法,用RISC32指令来写.
💻 S
📖 第 1 页 / 共 5 页
字号:
		addi	r9,32
decim_interp_coef:

#else

;******* load the 4 sets of filter coefficients ********************
;		movi	StartAddrHigh, 0x40	; read from ROM
		movi	StartAddrHigh, DataSeg	; read from DRAM 10-13-98
		movi	ByteSize,0xfe		; 128 coefficients in total 
		movi	ByteLocal, local_rate_filter
		dmabr	ratefilt			; adress in ROM of the rate filter
#endif	//EFFECT

#if		1
;*******************************************************************
;********** init of echo *******************************************
;********** init buffers in DRAM to zero ***************************
		movi	AGRAdr0, 0x1000
		movi	AGRInc0, 0x2
		movi	AGRSiz0, 0xffff
		movi	r0, 1403
		movi	r1, 0x0
			
buffer_init:
		movhf	i0, r1
		subi	r0, 0x1
#ifdef	EFFECT
		bne		buffer_init
#else	//EFFECT
		bnz		buffer_init
#endif	//EFFECT

#ifdef	EFFECT
		movi	DMASize, 31
		movi	r0, 0x1000>>2
		movi	r1, HBASE>>2
		
		loop	22, init_HBASE		//704 words
		mov	LocalAddr, r0
		dmawr	r1
		WaitDma

		addi	r0, 32
		addi	r1, 32
init_HBASE:
	
#else	//EFFECT
;		movi	StartAddrHigh, 0x7
		movi	StartAddrHigh, DataSeg	// 10-13-98
		movi	ByteSize, 0xaf4
		movi	ByteLocal, 0x1000
		dmabw	HBASE
#endif	//EFFECT
;********** init of gain coefficients ******************************
		movi	r0, 13107
		movh	%g1, r0			; NAP1
		movh	%g4, r0			; NAP3
		movi	r0, 19661
		movh	%g2, r0			; NAP2
		movi	r0, 9830
		movh	%g3, r0			; OAP1
		movi	r0, 3277
		movh	%g5, r0			; OAP2
		movi	r0, 1000		; default value of feedback gain 
		movh	%FBgain, r0

;********** init of the lowpass filter (feedback)*******************

#ifdef	EFFECT
		movi	LocalAddr, LPFB>>2
		movi	DMASize, 7	; 15 coefficients
		movi	r0, LPfilter
		shr	r0, 2
		dmarr	r0
		WaitDma
#else	//EFFECT
;		movi	StartAddrHigh, 0x40
		movi	StartAddrHigh, DataSeg	// 10-13-98
		movi	ByteLocal, 0x500
		movi	ByteSize, 0x1c	; 15 coefficients
		dmabr	LPfilter	
#endif	//EFFECT
	
;********** init pointers on DRAM histories ************************
		movi	r0, DL1_START	; init of pointer on DL1 (M0=256+64)	
		movh	%DL1_ptr, r0
		movi	r0, NAP1_START	; init of pointer on NAP1 
		movh	%NAP1_ptr, r0
		movi	r0, NAP2_START	; init of pointer on NAP2
		movh	%NAP2_ptr, r0
		movi	r0, NAP3_START	; init of pointer on NAP3
		movh	%NAP3_ptr, r0
		movi	r0, OAP2_START	; init of pointer on OAP2
		movh	%OAP2_ptr, r0
#endif		//1


;********************************************************************
;************** init of the keyshift algorithm **********************
		movi	BlockSkip, 0x0

#if ALG
;****** set up left_right flag **************************************
		movi	r0, 0x1
		movh	%left_right, r0	; left channel first

;****** set up the key_change flag and count2 ***********************
		movi	r0, 0x0
		movh	%key_change, r0
		movh	%count2, r0

;****** set up the echo delay dram storage pointer  ***********************
		movh	%ufon_on_counter, r0
		movh	%ufon_off_counter, r0
		movh	%energy_indicator, r0

		movi	r0,Decimated_echo_storge_start
		movh	%Echo_delay_ptr, r0

;****** load the value of key ***************************************

#ifdef	EFFECT
#else	//EFFECT
;		movi	StartAddrHigh, 0x40	; access to  ROM.
		movi	StartAddrHigh, DataSeg	; access to  DRAM. 10-13-98
		movi	r0, key_val		; adress in main memory in bytes
		movi	ByteSize, 0x0	; gets 1 coefficients
		movi	ByteLocal, key_value
					; @ in loc mem to put the coefficients
		dmabrr	r0		; start dma transfert
#endif	//EFFECT
	 
;****** load the filter coefficient in local memory ******************

#ifdef	EFFECT
		movi	r0, coeffA>>2
		movi	r1, FIR_coeff	; adress in main memory in bytes	
		shr	r1, 2			//to word addr
		movi	DMASize, 31		//32 words each	
	
		loop	15, init_coeff		//480 words		
		mov	LocalAddr, r0	
		dmarr	r1			;read data from DRAM
		WaitDma

		addi	r0, 32
		addi	r1, 32
init_coeff:
	
#else	//EFFECT
		movi	r0, FIR_coeff	; adress in main memory in bytes
		movi	ByteSize, 0x77e	; gets 960 coefficients
		movi	ByteLocal, localA_coeff 
					; @ in loc mem to put the coefficients
		dmabrr	r0		; start dma transfert 
#endif	//EFFECT
	
;******* compute & store coeff of triangular window ******************

#ifdef	EFFECT
		movi	r0, window1		//local addr
		shr	r0, 2
		movi	r1, window		; adress in main memory in bytes
		shr	r1, 2			//to word addr
		movi	DMASize, 31		//128 words	
	
		loop	4, init_window		//128 words		
		mov	LocalAddr, r0
		dmarr	r1			;read data from DRAM
		WaitDma

		addi	r0, 32
		addi	r1, 32
init_window:
	
#else	//EFFECT
		movi	r0, window
		movi	ByteSize, 0x1fe	; gets 256 samples (255*2=0x1fe)
		movi	ByteLocal, localA_window
					; @ in local memory for window coeff
		dmabrr	r0		; start dma transfert
#endif	//EFFECT
		
;******* initialisation of the pointer on search in DRAM *************
		movi	r1, LSBUF_START_low ;left channel
		movh	%Lsearch_ptr, r1
		movi	r1, RSBUF_START_low	; right channel
		movh	%Rsearch_ptr, r1		

;****** initialisation of the loop counter, count ********************
		movi	r1, 0x1		
		movh	%count, r1

;****** load the value of Dec, Length, Nb, (Nb-1)*Length *************
;****** depending on the value of key ********************************
;****** store result in r10,r8,r9 ************************************

		movi	r1, Key_default
		movh	%key_value, r1	;  key1=0

.if	0	
		movi	r0, 0x1		//debug
		movh	%key_change, r0	//debug	
		movi	r1, 8		//debug
		movh	%key_value, r1	//debug
.endif
		
#ifdef	EFFECT
		shl	r1, 3			//*8, 8 bytes per entry
		addi	r1, table		
		shr	r1, 2			//to word addr
		movi	DMASize, 1				
		movi	LocalAddr, Dec>>2
	
		dmarr	r1			;read data from DRAM
		WaitDma
#else	//EFFECT
		multi	r1, 8			; computing the offset in the table
		movi	ByteSize, 6		; (4-1)*2, 4 data to load
		movi	ByteLocal, Dec	; set the location in local memory
		addi	r1, table
		dmabrr	r1
#endif	//EFFECT
	
//debug
//debug1:		j	debug1
	
		movh	r10, %Nb		; r10=Nb
		movh	r9, %Dec		; r9 = Dec
		movh	r8, %Length		; r8 = Length

	
;****** load the value of NDec, NLength, NNb, (NNb-1)*NLength ********
;****** depending on the value of key ********************************

;******* initializes the value of pos1 and deltap *******************
		movi	r0, 0
		movh	%Ldeltap, r0	; Ldeltap = 0
		movh	%Rdeltap, r0	; Rdeltap = 0
		tstsi	r8, 256*2
		blt		pos1_N			; if length >=N, pos1=N
		movi	r0,256*2 
		movh	%pos1,r0		; pos1=N
		j		pos1_3N
pos1_N:
		movi	r0,384*2
		movh	%pos1, r0		; pos1=3*N/2
pos1_3N:


	
;******* initilializes the value of goal_pos_start *******************
		movh	r0, %pos1
		addi	r0, 0x1200		; r0=pos1+N+0x1000
		movh	%Cgoal_start, r0
		movh	%Lgoal_start, r0  
		movh	%Rgoal_start, r0

;******* Computes the effective length of search *********************
;******* Computes start position in this buffer **********************
;******* Computes end position of SBUF in DRAM (r12)******************
		subi	r4,r10,1		; r4=Nb-1   
		mult	r4,r4,r8		; r4 =(Nb-1)*length
		mult	r3,r10, r8		; r3=Nb*length
		movi	r1, LSBUF_START_low	;left channel
		addh	%LSEARCH_END,r1,r4	; END=SBUF_START+(Nb-1)*length
		movi	r1, RSBUF_START_low ;right channel
		addh	%RSEARCH_END,r1,r4	

		addi	r4, 0x1000		; part B of memory....
		movh	%localsearch_ptr,r4; localsearch_ptr=(Nb-1)*length
		subi	r3, 2	
#ifdef	EFFECT	
		mov	AGRAdr5, r4		; a3 points at (Nb-1)*length
		mov	AGRSiz5, r3		; size of search buffer=Nb*length-2
		movi	AGRInc5,2		; increment on search buffer 		
#else	//EFFECT
		mov	AGRAdr3, r4		; a3 points at (Nb-1)*length
		mov	AGRSiz3, r3		; size of search buffer=Nb*length-2
		movi	AGRInc3,2		; increment on search buffer 
#endif	//EFFECT

;******* initialisation of the history of filter, and its pointer ****
#ifdef	EFFECT
		movi	AGRAdr4, 0x1000
		movi	AGRInc4, 0x2
		movi	AGRSiz4, 0x2c
#else	//EFFECT
		movi	AGRAdr2, 0x1000
		movi	AGRInc2, 0x2
		movi	AGRSiz2, 0x2c
#endif	//EFFECT
		movi	r0, 0x0
;		movi	StartAddrHigh, 0x7
		movi	StartAddrHigh, DataSeg	// 10-13-98

#ifdef	EFFECT
		movi	r1, Lhistory	; DRAM address, ,left channel
		shr	r1, 2
		movi	LocalAddr, 0x1000>>2
		movi	DMASize, 11

		loop	23, hist_init
		movhf	i4, r0
hist_init:
		dmawr	r1				; left channel
		WaitDma
	
		movi	LocalAddr, 0x1000>>2
		movi	r1, Rhistory
		shr	r1, 2
		dmawr	r1				; right channel
		WaitDma
#else	//EFFECT
		movi	ByteLocal, 0x1000
		movi	ByteSize, 0x2c

		loop	23, hist_init
		movhf	i2, r0
hist_init:
		dmabwr	r1				; left channel

		movi	ByteLocal, 0x1000
		movi	ByteSize, 0x2c
		movi	r1, Rhistory
		dmabwr	r1				; right channel
#endif	//EFFECT
	
		movi	r0, 0x1000
;		movi	DirectBase, 0x7
//		movi	DirectBase, DataSeg		// 10-13-98
		movi	DcacheBase, DataSeg		//EFFECT
		dsh		r0, Lhist_point	; left channel	
		dsh		r0, Rhist_point	; right channel
		
;;		movh	%1000, r0
;;		movi	StartAddrHigh, 0x7
;;		movi	ByteLocal, 0x1000
;;		movi	ByteSize, 0x2
;;		dmabw	Lhist_point
		
;;		movi	ByteSize, 0x2
;;		dmabw	Rhist_point
#endif	//ALG


#ifndef	LS380
;************** put first 2 stereo block in PCMOUTBUF *************
		movi	AGRAdr0, 0x0
		movi	AGRSiz0, 0xffff
		movi	AGRInc0, 0x2
		movi	r1, 0x0

		loop	0, block1
		movhf	i0, r1
		movhf	i0, r1
block1:

;		movi	StartAddrHigh, 0x7
		movi	StartAddrHigh, DataSeg		// 10-13-98
		movi	BlockSkip, 0x0	; stereo

		movi	ByteSize, 0x3fe
		movi	ByteLocal, 0x0
		movi	r0, 0x9000		; OUTBUF start address in DRAM
		dmabwr	r0
		movi	ByteSize, 0x3fe
		movi	ByteLocal, 0x0
		movi	r0, 0x9400		; second block
		dmabwr	r0
#if 1	// 10-13-98 - audio will crash when reload disk, if this is enabled
		movi	ByteSize, 0x3fe
		movi	ByteLocal, 0x0
		movi	r0, 0x9800		; third block
		dmabwr	r0

		movi	ByteSize, 0x3fe
		movi	ByteLocal, 0x0
		movi	r0, 0x9c00		; fourth block
		dmabwr	r0
#endif	// 10-13-98
#endif	//LS380
//----------------------------------------------------------------
//ZhangWei:If HW_ECHO, GenIOMIS[0] = flag of microphone energy.
		movi	DcacheBase,MEM_SEG
		nop
		nop
		dlw	r0,USER_ICFG
		nop
		andi	r0,ICFG_HWECHO_MASK
		tsti	r0,ICFG_HWECHO_MASK
		bne	end_mm_flag
		nop
		rlwi	r0,GenIOMIS_Tri_State_Enable
		nop
		nop
		ori	r0,1
		rswi	r0,GenIOMIS_Tri_State_Enable
end_mm_flag:
//----------------------------------------------------------------
;*****************************************************************
;********** main loop ********************************************	
;*****************************************************************
main_audio_task:

	
		movi	DcacheBase, DataSeg		// 10-13-98
		mov		r0, TrapReg

// read data from DRAM to local buffer
// this part is not needed when karaoke function is cascaded
// with the MPEG audio decoder. But the memory map has to
// be changed

#ifndef	EFFECT
		jsr	r27, SUB_read_data
#else	//EFFECT
		movi	StartAddrHigh, DataSeg
		movi	DcacheBase, DataSeg	
#endif	//EFFECT		
				
; check value command vector 

		jsr	r11, SUB_command

// execute audio routines
	
//-----------------------------------------------------------------------------------------
//*******************************************************************************
//-----------------------------------------------------------------------------------------

                nop
                nop
                nop

                jsr      r11,sound_equalizer

                nop
                nop
                nop

		jsr	r27, SUB_PCM_OK

//-----------------------------------------------------------------------------------------
//*******************************************************************************
//-----------------------------------------------------------------------------------------

// update entry

#ifdef	EFFECT
		movi	DcacheBase, MEM_SEG
		la	r0, main_audio_task
		dsw	r0,Audio_Effect_Entry
#else	//EFFECT
		la	r0, main_audio_task
		movw	LWentry, r0	//change entry
#endif	//EFFECT
		j	r31		//return to calling routine
					//at top level
		
;********************************************************************
;********************************************************************



;;*******************************************************************
;;*********** process pcm out interrupt *****************************
;;*******************************************************************

SUB_PCM_OK: 

#ifdef	EFFECT
		movh	r10, %Nb		; r10=Nb
		movh	r9, %Dec		; r9 = Dec
		movh	r8, %Length		; r8 = Length
#endif	//EFFECT
		
;******* this part only has to be done for both channels *************


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -