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

📄 v2a.asm

📁 ECE345, Visual-to-Audio Electronic Travel Aid Code for TM320C54x (v2a.asm) download This project
💻 ASM
字号:
;==========================================================
; v2a.asm
;  written by Chunwei Jethro Lam, UIUC, jethrolam@gmail.com
;  last update: 5/2001
;  ASM code for TM320C54x DSP, perform FIR filtering where the filter 
;  weights corresponds to a 5x5 image, i.e., the filter weights are the
;  weighted sum of Head Related Transfer Functions (HRTF)
;  according to the pixel values in a 5x5 image, e.g., 
;       [0 0 0 0 0; 0 0 0 0 a; 0 0 0 0 0; b 0 0 0 0; 0 0 0 0 0]
;        becomes
;       h[n] = a * hrtf-90e20[n] + b * hrtf90e-20[n]
;  The 25 pixel values are received via the serial port.
;===========================================================

;============================================
; Incorporate core1.asm
;============================================
	.copy "v:\ece320\54x\dsplib\core1.asm"		

;============================================
; Initialize Constants
;============================================	
FIR_len		.set	64			; for 64-tap FIR.
MAP_len		.set	25			; for 5x5 map
REPEAT_len	.set	25*64-1

;============================================
; DATA Section
;============================================
		    .sect ".data"	
			.align	16
BRC_hold	.space 16
			.align	128	
lcoef		.copy "w:\ece320\v2a\hrtf\hrtfla-90e40.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfla-45e40.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfla0e40.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfla45e40.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfla90e40.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfla-90e20.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfla-45e20.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfla0e20.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfla45e20.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfla90e20.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfla-90e0.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfla-45e0.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfla0e0.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfla45e0.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfla90e0.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfla-90e-20.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfla-45e-20.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfla0e-20.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfla45e-20.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfla90e-20.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfla-90e-40.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfla-45e-40.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfla0e-40.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfla45e-40.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfla90e-40.asm"	
		
rcoef		.copy "w:\ece320\v2a\hrtf\hrtfra-90e40.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfra-45e40.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfra0e40.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfra45e40.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfra90e40.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfra-90e20.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfra-45e20.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfra0e20.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfra45e20.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfra90e20.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfra-90e0.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfra-45e0.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfra0e0.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfra45e0.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfra90e0.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfra-90e-20.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfra-45e-20.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfra0e-20.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfra45e-20.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfra90e-20.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfra-90e-40.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfra-45e-40.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfra0e-40.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfra45e-40.asm"	
			.copy "w:\ece320\v2a\hrtf\hrtfra90e-40.asm"	

			.align	128	
map			.copy "w:\ece320\v2a\hrtf\map.asm" 

			.align	128	
locoef		.copy "w:\ece320\v2a\hrtf\hrtfla0e0.asm"	
			.align	128	
rocoef		.copy "w:\ece320\v2a\hrtf\hrtfra0e0.asm"	

			.align	128	
lfirstate 
			.space 64*16		; Allocate 128 words of storage for filter state for left channel.
			.align	128	
rfirstate 
			.space 64*16		; Allocate 128 words of storage for filter state for right channel.
			
;============================================
; TEXT Section
;============================================
		.sect ".text"
main
	; Initialize address registers 
	stm		#FIR_len,	BK		; initialize circular buffer length
	stm		#lfirstate,	AR2		; initialize state pointer
	stm		#rfirstate,	AR3		; initialize state pointer
	stm		#locoef,	AR4		; initialize map pointer
	stm		#rocoef,	AR5		; initialize ocoef pointer
	stm 	#1,			AR0		; initialize AR0 for pointer increment
	
loop
	; Wait for a new block of 64 samples to come in
	WAITDATA
	
		; BlockLen = the number of samples that come from WAITDATA
		stm 	#BlockLen-1,BRC		; Save repeat count into block repeat counter
		rptb 	endblock-1			; Repeat between here and 'endblock' label
	
		ld      *AR6,	16,	A		; Receive ch1 into A accumulator
		mar 	*+AR6(2)            ; Rcv data is in every other channel
    	ld      *AR6,	16,	B		; Receive ch2 into B accumulator
    	mar 	*+AR6(2)            ; Rcv data is in every other channel
    	ld		A,	B				; Transfer A into B for safekeeping

		; Executes a single FIR filter for both channel.
    	sth   	A,*AR2+%		; store current input into state buffer
    	sth   	B,*AR3+%		; store current input into state buffer
    
    	rptz  	A,(FIR_len-1)		; clear A and repeat
    	mac   	*AR2+0%,*AR4+0%,A	; multiply ocoefficient by state & accumulate
    	rptz  	B,(FIR_len-1)		; clear B and repeat
    	mac   	*AR3+0%,*AR5+0%,B	; multiply ocoefficient by state & accumulate
    
    	rnd	A			; Round off value in A to 16 bits 
    	rnd	B			; Round off value in B to 16 bits                        

    	; end of FIR filter code. Output is in the high part of 'A.'
    	sth 	A, *AR7+	; ch1
    	sth 	A, *AR7+	; ch2
    	sth 	A, *AR7+	; ch3
    	sth 	B, *AR7+	; ch4
    	sth 	B, *AR7+	; ch5 
    	sth 	B, *AR7+	; ch6
   	
endblock

;===================================
; Read 5x5 map from serial port  
;===================================
	; Check if there is a request of write
	stm		#map,	AR3    
	READSER 1 
	cmpm	AR1,	#0 
	bc		main,	TC
	nop

	; Update Map
	stm		#0,		AR2
	
readser_loop
	READSER 1		; Read one byte from serial port
    mar		*AR2+;
	cmpm	AR3, #map+MAP_len  
	bc	readser_loop, NTC

	; Initialize address registers
	stm		FIR_len,	AR0
	stm 	#lcoef,		AR2      		
	stm 	#rcoef,		AR3      		
	stm 	#map,		AR4      		
	stm 	#locoef,	AR6
	stm 	#rocoef,	AR7

_serial_loop
	; Repeat for each overall coef
    stm 	#FIR_len-1, BRC		
    rptb 	ocoef_endloop-1		

	; Store starting position of AR2, AR3
	pshm	AR2
	pshm	AR3

	; push loop param
	pshm	BRC
	pshm	REA
	pshm	RSA

	; Repeat for each map pixel
	; Accumulate coef of each map pixel into A
	ld	#0, A
	ld	#0, B

	stm 	#MAP_len-1, BRC	
	rptb 	map_endloop-1		
	mac		*AR2,	*AR4,	A
	mac		*AR3,	*AR4+,	B
	mar 	*AR2+0
	mar 	*AR3+0
	nop
	nop
	nop
map_endloop
	; store resulting B into AR6+, AR7+ (left, right)
	sfta	A, -4	
	sfta	B, -4	
	stl	A, *AR6+	
	stl	B, *AR7+	
	
	; restore loop param 
	popm	RSA
	popm	REA
	popm	BRC
	ssbx	1, 15

	; Restore AR2, AR3, AR4 to the next coeff 
	popm	AR3
	popm	AR2
	stm 	#map,AR4      		
	mar 	*AR3+
	mar 	*AR2+
	nop
	nop
	nop
ocoef_endloop
	b 	main

⌨️ 快捷键说明

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