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

📄 test.s

📁 关于DVD的MPEG2用的DSP代码,在DSP的实现MPEG的压缩,解压算法.
💻 S
📖 第 1 页 / 共 5 页
字号:
		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

#if	0
		movi	r0,0x2000
		dsw		r0,0x4000		; on level
		movi	r0,0x1000
		dsw		r0,0x4004		; off level

		movi	r0,0x00c8
		dsw		r0,0x4008		; on time
		movi	r0,0x05e6
		dsw		r0,0x400c		; off time
#endif
		
;****** 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
//----------------------------------------------------------------
#if	1
//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:
#endif
//----------------------------------------------------------------
;*****************************************************************
;********** 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
#if 1
//***************************************************
//	Add microphone only audio
//***************************************************
				
		mov	r0,r31
		andi	r0,0xffff
		la	r1,rtn_Microphone

		tst	r0,r1
		bne	Normal_audio
						
		jsr	r27, Microphone_in
		j	Reinit_audio_entry	
Normal_audio:

//---------------------------------------------------------
//***************************************************
//---------------------------------------------------------
                nop
                nop
                jsr      r11,sound_equalizer
                nop
                nop
		jsr	r27, SUB_PCM_OK
                nop
                nop
//---------------------------------------------------------
//***************************************************
//---------------------------------------------------------

Reinit_audio_entry:

// update entry
#endif

#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 *************


		
#if KEYSHIFT
main_pcm_out:
;******* test if search init is done yet or not **********************
#ifdef	EFFECT
		movh	r19,%count
		tst	r10,r19
#else	//EFFECT
		tstsh	r10, %count
#endif	//EFFECT
		blte	search_init_end	; if Nb<= count, init is done

;****** initialisation of both buffers search ************************
;************ load left_right flag = r12 ****************************
		movi	r12, 0x1		; first process left channel

		movi	r0, Lhistory	; left channel
		movi	r1, Lhist_point
		movi	r2, localA_data	; left channel start at localA_data
		movh	r3, %Lsearch_ptr
		movh	%Csearch_ptr, r3


	
;****** jump to filtering subroutine *********************************
channel2:

		jsr	r11, SUB_filtering	
		
	
;****** save decimated sequence in corresponding search buffer *******

#ifdef	EFFECT
		movh	r4, %localsearch_ptr
		shr	r4, 2	
		shr	r1, r8, 2	; size of the dma transfer in words
		andi	r0, r1, 0x1f	; remainder of 32-word block
		shr	r1, 5		// integer blocks of 32-word
		movi	DMASize, 31	; 32-word each block
		movh	r2, %Csearch_ptr
		shr	r2, 2

		loop	r1, transfer_dec
		mov	LocalAddr, r4	; @ in local mem of decimated seq
		dmawr	r2
		WaitDma

		addi	r4, 32
		addi	r2, 32
transfer_dec:

		tsti	r0,0
		beq	Lno_extra

⌨️ 快捷键说明

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