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

📄 test.s.bak

📁 关于DVD的MPEG2用的DSP代码,在DSP的实现MPEG的压缩,解压算法.
💻 BAK
📖 第 1 页 / 共 5 页
字号:
		movh	r1,%keyshift_com; read the new command
;		movi	StartAddrHigh, 0x40		; read from ROM
		movi	StartAddrHigh, DataSeg		; read from DRAM 10-13-98
		movh	%Nkey_value, r1	; key2=0
		multi	r1, 8			; computing the offset in the table

#ifdef	EFFECT
		movi	DMASize, 1		;  2 words to load
		movi	LocalAddr, NDec>>2	; set the location in local memory
		addi	r1, table
		shr	r1, 2
		dmarr	r1
		WaitDma	
#else	//EFFECT
		movi	ByteSize, 6		; (4-1)*2, 4 data to load
		movi	ByteLocal, NDec	; set the location in local memory
		addi	r1, table
		dmabrr	r1	
#endif	//EFFECT	

		movh	r1, %NLength
		tstsi	r1, 256*2
		blt		Npos1_N			; if length >=N, pos1=N
		movi	r0,256*2 
		movh	%Npos1,r0		; Npos1=N
		j		Npos1_3N
Npos1_N:
		movi	r0,384*2
		movh	%Npos1, r0		; Npos1=3*N/2
Npos1_3N:


; modifies the current local search buffer, and load in DRAM the new sequence 
; r3 is needed by the subroutine
		movh	r3, %Csearch_ptr

		jsr	r11, SUB_search_update

; do the second part of the windowing
		movi	r6, 0x7fff
		movh	r5, %temp
#ifdef	EFFECT
		mov	AGRAdr5, r5		; a3 = pos1+length+deltac+0x1000
		movi	AGRInc5, 1*2	; increment of one sample
		movi	AGRSiz5, 0xffff	; linear buffer
#else	//EFFECT
		mov	AGRAdr3, r5		; a3 = pos1+length+deltac+0x1000
		movi	AGRInc3, 1*2	; increment of one sample
		movi	AGRSiz3, 0xffff	; linear buffer
#endif	//EFFECT
		mov	AGRAdr1, r7
		movi	AGRInc1, 2*2	; increment: skip on channel on two	
		movi	AGRSiz1, 0xffff	; linear buffer
		movi	AGRAdr0, window1; ptr on window, increment
		movi	AGRInc0, 0x2	; increment by one
		movi	AGRSiz0, 0xffff	; linear buffer
	
;**************************************
;***** desable interrupt mask **********
		movi	TrapReg, 0x0
		nop
		nop
;**************************************
;**************************************


		loop	128, end_of_second_window
#ifdef	EFFECT
		mulhf	r0, i0,i5
		maddhf	r0, r6, a1(0)
		nop
#else	//EFFECT
		mulhf	r0, i0,i3
		maddhf	r0, r6, a1(0)
#endif	//EFFECT
		rndhf	i1, r0
#ifdef	EFFECT
		mulhf	r0, i0,i5
		maddhf	r0, r6, a1(0)
		nop
#else	//EFFECT
		mulhf	r0, i0,i3
		maddhf	r0, r6, a1(0)
#endif	//EFFECT
		rndhf	i1, r0
end_of_second_window:

;**************************************
;***** enable interrupt mask ********
		movi	TrapReg, 0x24
;**************************************
;**************************************
		
; update the current end of search buffer in DRAM, and the search_ptr
		movh	r1,%CSBUF_START	; r1 = start @ of current search buffer
		addh	r0, r1,%NNb_1	; r0 = end @ of current search buffer
		movh	r2, %pos1		
		addh	r2, %Cdeltap	
		addi	r2, 0x1200		; r2 =Cgoal_start=pos1+Cdeltap+N+0x1000

; tests which channel is being processed
		tsti	r12, 0x1
		bne		right11
		movh	%LSEARCH_END, r0; update the left end of search in DRAM
		movh	%Lsearch_ptr, r1; update the Lsearch_ptr
		movh	%Lgoal_start, r2; update the start @ of goal in left search

		j		end_of_key_change
right11:
		movh	%RSEARCH_END, r0; update the right end of search in DRAM
		movh	%Rsearch_ptr, r1; update the Rsearch_ptr
		movh	%Rgoal_start, r2; update the start @ of goal in right search
;;;; update Length, Nb, pos1,Nb_1 since both channels have been processed

		movh	r0, %Nkey_value
		movh	%key_value, r0
		movh	r0, %NDec
		movh	%Dec, r0		; update Dec for the filtering
		movh	r0, %NNb
		movh	%Nb,r0			; update Nb 
		movh	r0, %NLength
		movh	%Length, r0		; update Length
		movh	r0, %Npos1
		movh	%pos1, r0		; update pos1
		movh	r0, %NNb_1
		movh	%Nb_1, r0		; update Nb_1
;;; update sizes of search buffer in local memory
		addi	r1, r0, 0x1000
		movh	%localsearch_ptr, r1

;;; update the value of the key
		movi	r0, 0x0
		movh	%key_change, r0	; reset the key_change to zero
;;; update the value of registers r8, r9, r10
		movh	r10, %Nb		; r10=Nb
		movh	r9, %Dec		; r9 = Dec
		movh	r8, %Length		; r8 = Length
;;; update the value of count, not to go through search init again !!!!
		movh	%count, r10

;;;;;; end of the key-change ;;;;;;;;
;;;;;; debug ;;;;;;;
		mov		r0, TrapReg
		movi	r1, 0xc260
;		dshr	r0, r1


		j		end_of_key_change


normal:

	
;*********************************************************************
;******* PERFORM WINDOWING ONLY IF KEYSHIFT IS REQUIRED **************
;********************************************************************* 
		movi	r1,Key_default	; no keyshift required
#ifdef	EFFECT
		movh	r19,%key_value
		tst	r1,r19
#else	//EFFECT
		tsth	r1, %key_value
#endif	//EFFECT
		beq	done_window
//debug
//		j	done_window
	
;******* jump to subroutine window ***********************************
;******* interrupt mask is desabbled within the subroutine ***********

		jsr	r11, SUB_ster_windowing
done_window:	

		
;****** wrap search pointer if necessary *****************************
		movh	r3, %Csearch_ptr
#ifdef	EFFECT
		movh	r19,%CSEARCH_END
		tst	r3,r19
#else	//EFFECT
		tstsh	r3, %CSEARCH_END
#endif	//EFFECT
		blt		not_wrapped3
		movh	r3, %CSBUF_START 
not_wrapped3:		
		
;****** save current sequence (length) in search buff in DRAM ********
;		movi	StartAddrHigh, 0x7
		movi	StartAddrHigh, DataSeg	// 10-13-9

#ifdef	EFFECT
	
		movh	r4, %localsearch_ptr	; r13 modif
		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
		shr	r3, 2

		loop	r1, transfer_buf3
		mov	LocalAddr, r4	
		dmawr	r3
		WaitDma

		addi	r4, 32
		addi	r3, 32
transfer_buf3:

		tsti	r0,0
		beq	Lno_extra_1
		subi	r19,r0,1	//-1 for dma
		mov	DMASize, r19	//remainder
		mov	LocalAddr, r4	; @ in local mem of decimated seq
		dmawr	r3
		WaitDma
Lno_extra_1:	

		add	r4, r0
		add	r3, r0		//inc ptrs
		shl	r4, 2		//restore for later use
		shl	r3, 2 

	
#else	//EFFECT
		mov		r1, r8
		subi	r1, 2			; r1=length-2= size of the transfert
		mov		ByteSize,r1		; size of transfert =length samples
		movh	r4, %localsearch_ptr	; r13 modif
		mov		ByteLocal,r4	; sets the location in local memory
		dmabwr	r3				; initiate the DMA transfert.
#endif	//EFFECT

;******* increments the pointer on DRAM search buffer ****************
ptr_increment3:
#ifndef	EFFECT	//already done above
		add		r3, r3, r8	; search_ptr=search_ptr +length
#endif	//EFFECT
		movh	%Csearch_ptr, r3
;******* update the start @ of the goal in the current search buffer**
		movh	r2, %pos1		
		addh	r2, %Cdeltap	
		addi	r2, 0x1200		; r2 =Cgoal_start=pos1+Cdeltap+N+0x1000

		tsti	r12, 0x1
		bne		right12
		movh	%Lgoal_start,r2	; update the @ of goal in left search buffer
#ifdef	EFFECT
		tsti	r3,LSBUF_END
		blt	Left_ok3
		subi	r3,0x1000	//wraping
Left_ok3:
#endif	//EFFECT
		movh	%Lsearch_ptr,r3	; update the pointer in left search buffer
		j		end_of_key_change
right12:		
		movh	%Rgoal_start,r2	; update the @ of goal in right search buffer
#ifdef	EFFECT
		tsti	r3,RSBUF_END
		blt	Right_ok3
		subi	r3,0x1000	//wraping
Right_ok3:
#endif	//EFFECT
		movh	%Rsearch_ptr,r3	; update the pointer in right search buffer



end_of_key_change:
;;;;;;; debug ;;;;;;
		mov		r0, TrapReg
		movi	r1, 0xc2d0
;		dshr	r0, r1

;******* common part even if key has just been changed ***************
;******* test which channel is being processed ***********************
		tsti	r12, 0x1
		bne		right10

;******* save the current registers in left channel ******************
		movh	r3, %Cdeltap
		movh	%Ldeltap, r3
;******* update left_right *******************************************
		movi	r12, 0x0
		movh	%left_right, r12
;******* update registers to process right channel *******************
		movi	r0, Rhistory	; right channel
		movi	r1, Rhist_point
		movi	r2,localA_data+2; right channel start at localA_data
//		movi	r2,0x1300+2
		movh	%Cinput_adr, r2
		movh	r3, %Rgoal_start
		movh	%Cgoal_start, r3; load @ of goal in right search buffer
		movh	r3, %Rsearch_ptr
		movh	%Csearch_ptr, r3; load right search ptr
		movh	r3, %RSEARCH_END
		movh	%CSEARCH_END, r3; load end of right search buffer 
		movi	r3, RSBUF_START_low
		movh	%CSBUF_START,r3
		movh	r3, %Rdeltap	; load value of right previous delta	
		movh	%Cdeltap, r3

;******* jump back to process right channel **************************
		j		right_filtering


right10:
;******* save the current registers in right channel ******************
		movh	r3, %Cdeltap
		movh	%Rdeltap, r3


run_through:


//		j	r27	//debug--------------------

	
#if 0
;;;;;; debug;;;;;
		mov		r0, TrapReg
		movi	r1, 0xc280
;		dshr	r0, r1


;******* perform the bass filtering ************************************
		movh	r2, %bass_com		; read the bass command
		tstsi	r2, 0x7				; test if bass is required 
		beq		bass_done		

		jsr	r11, SUB_bass
bass_done:

;;;;;; debug;;;;;
		mov		r0, TrapReg
		movi	r1, 0xc290
;		dshr	r0, r1

;******* perform the trebble filtering *********************************
		movh	r2, %trebble_com	; read the trebble command
		tstsi	r2, 0x7				; test if trebble is required
		beq		trebble_done
		tstsi	r2, 0x7
		bgt		do_trebble2
		jsr	r11,SUB_trebble1
		j	trebble_done
do_trebble2:
		jsr	r11,SUB_trebble2
trebble_done:

#else
;******* perform the bass filtering ************************************
		movh	r4, %bass_com		; read the bass command
		tstsi	r4, 0x7				; test if bass is required 
		beq		bass_done
	
		movi	r5, bass_coeff		; set up routine registers: r4,r5,r14,r15
		movi	r14, Lu0u1			; adress of Left bass history
		movi	r15, Ru0u1			; adress of Right bass history
		movi	r9, 0x0
		jsr	r11, SUB_trebble_bass
bass_done:

;******* perform the trebble filtering *********************************
		movh	r4, %trebble_com	; read the trebble command
		tstsi	r4, 0x7				; test if trebble is required
		beq	trebble_done
		movi	r5, trebble_coeff
		movi	r14, TLu0u1
		movi	r15, TRu0u1
		tstsi	r4, 0x7
		bgt	do_trebble2
		movi	r9, 0x0
		jsr	r11, SUB_trebble_bass
		j	trebble_done
do_trebble2:
		movi	r9, 0x1
		jsr	r11, SUB_trebble_bass
trebble_done:

#endif	//?

#if		(MICRO == 0)

		j	r27	//debug--tchou------------------

#endif
	
;**********************************************************************
;**********************************************************************
;******* if microphone is required, get a new sequence from micro *****
;******* get a new sequence from the microphone input *****************
#if		MICRO

Microphone_in:

#ifdef	EFFECT
		rlwi	r1,PCM_In_Current_Addr
		andi	r1,0xffff
		movi	r0,MIC_BUF_START_B		; range check in case nonexistence of hw
		tst	r1,r0
		blt	echo_mixing_done

		movi	r0,MIC_BUF_END_B
		tst	r1,r0
		bgt	echo_mixing_done

		movi	DcacheBase, MEM_SEG

		dlh	r0, mic_data_ptr		; read the current address of pointer
		nop

		tst	r1,r0
		bgte	got_256_samples
		addi	r1,MIC_BUF_SIZE_B

		movi	DcacheBase, DataSeg		

got_256_samples:
		sub	r1,r0
		tsti	r1,0x400
		blt	echo_mixing_done		;wait_till_next		; avoid dram bandwidth consume ;
		shr	r0, 2
		movi	DMASize, 31			; get 512 data (L/R)
		movi	StartAddrHigh, DataSeg		; read from the micro Fifo
		movi	r9, local_micro_44>>2

		loop	8, read_micro_fifo
		mov	LocalAddr,r9
		dmarr	r0				; read the micro block.
		WaitDma
		addi	r0,32
		addi	r9,32
read_micro_fifo:
		shl	r0, 2

#endif	//EFFECT

;******* update the microphone read pointer ***************************
//		addi	r0, 0x400
		tsti	r0, MIC_BUF_END_B
		blt	no_micro_read_wrap
		subi	r0, MIC_BUF_SIZE_B
no_micro_read_wrap:
		movi	DcacheBase, MEM_SEG
		nop
		dsh	r0,mic_data_ptr
#endif	//MICRO
;;;;;; debug;;;;;
//		mov	r0, TrapReg
//		movi	r1, 0xc2a0
;		dshr	r0, r1

//------------- Mic_automute and volume control ----------------------
		movi	DcacheBase,MEM_SEG
		nop
		nop
		dlw	r0,USER_ICFG
		nop
		andi	r0,ICFG_LS128_MASK
		tsti	r0,ICFG_LS128_MASK
		bne	need_not_automute_mic

		jsr	r11,SUB_automute_mic
		nop
		li	r5,0
		movi	r15,FLAG_LS128				//r15 as a flag of ls128
		j	one_micro_vol
need_not_automute_mic:
		movi	r15,0
		dlw		r5,mic1_vol			;mic1 (R) volume
one_micro_vol:
		dlw		r4,mic2_vol			;mic2 (L) volume
//-------------------------------------------------------------------		
		
#if		1				// For microphone volume control

		movi	AGRAdr0, local_micro_44
		movi	AGRInc0, 0x2
		movi	AGRSiz0, 0xffff

		movi	AGRAdr1, local_micro_44
		movi	AGRInc1, 0x2
		movi	AGRSiz1, 0xffff
		
		nop		
		loop	256,spkfon_vol_adj
		mulhf	r0, r4, i0			;mic2
		mulhf	r2, r5, i0			;mic1
		rndhf	i1,r0

⌨️ 快捷键说明

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