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

📄 fir16_emac.s

📁 freescale MAC DSP的算法库(FFT
💻 S
📖 第 1 页 / 共 2 页
字号:
;--== Next input samples loading	==--
	move.w	(a0), d2				;iCurX0 = *pX;
	movea.l	a0, a4					;pCurX = pX;
	lea		2(a0), a0				;pX++;
	
;--== Next coefficients loading	==--
	move.l	a6, a3					;pCurCoef = pIirCoef;
	move.l	(a3), d4				;iCurA0 = *pCurCoef;
	lea		2(a3), a3				;pCurCoef++;
	
;--== Input samples and first coefficient multiplications ==--
	mac.w	d4.u, d2.l, <<, ACC0	;iOut0 = iCurA0 * iCurX0
	
;--== The count of inner loops calculation ==-- 
	move.l	d6, d5					;
	sub.l	d7, d5					;j = tmp - i;

	ble		.EndIn1TailH			;while(j > 0)
									;{
	btst.l	#0, d5
	beq		.ForIn1TailH
		
;--== This part is executed only if j is odd ==--	
;--== Next coefficients loading	==--
	move.w	(a3)+, d4				;iCurA0 = *pCurCoef++;
	
;--== Next input sample loading	==--
	move.w	-(a4), d2				;iCurX = *--pCurX;
	
;--== Input samples and first coefficient multiplications ==--
	mac.w	d4.l, d2.l, <<, ACC0	;iOut0 += iCurA0 * iCurX0
	
	subq.l	#1, d5
	beq		.EndIn1TailH

.ForIn1TailH:
	
;--== Next coefficients loading	==--
	move.l	(a3)+, d4				;iCurA0 = *pCurCoef++; iCurA1 = *pCurCoef++;
	
;--== Next input samples loading	==--
	move.l	-(a4), d2				;iCurX0 = *--pCurX;iCurX1 = *--pCurX;

;--== Two multiplications for each output sample ==--
	mac.w	d4.u, d2.l, <<, ACC0	;iOut0 += iCurA0 * iCurX0
	mac.w	d4.l, d2.u, <<, ACC0	;iOut0 += iCurA1 * iCurX1
	
	subq.l	#2, d5 					;j-= 2;
	bgt		.ForIn1TailH			;} // while(j > 0)
	
.EndIn1TailH:	
	
	move.l	12(a2), d5				;if(pIIR->iIirHistoryCount)
	beq		.EndInHTail				;{

;--== The count of inner loops calculation ==-- 
	move.l	d7, d5					;j = i

	ble		.EndInHTail				;if(j > 0)
									;{

;--== Current history buffer pointer initialization==--
	move.l  8(a2), a4				;pCurHustory = pIirHistory + tmp * 2
	adda.l	d6, a4					;
	adda.l	d6, a4					;while(j > 0)
									;{
	
	btst.l	#0, d5
	beq		.ForInHTail
;--== This part is executed only if j is odd ==--	
;--== Next coefficient loading	==--
	move.w	(a3)+, d4				;iCurA0 = *pCurCoef++;
	
;--== Next input sample loading	==--
	move.w	-(a4), d2				;iCurX = *--pCurX;
	
	mac.w	d4.l, d2.l, <<, ACC0	;iOut0 += iCurA0 * iCurX0
	
	subq.l	#1, d5
	beq		.EndInHTail
	
.ForInHTail:
	
;--== Next coefficients loading	==--
	move.l	(a3)+, d4				;iCurA0 = *pCurCoef++;iCurA1 = *pCurCoef++;
	
;--== Next input samples loading	==--
	move.l	-(a4), d2				;iCurX0 = *--pCurHistory;iCurX1 = *--pCurHistory;
	
--== Two multiplications for each output sample ==--
	mac.w	d4.u, d2.l, <<, ACC0	;iOut0 += iCurA0 * iCurX0
	mac.w	d4.l, d2.u, <<, ACC0	;iOut0 += iCurA1 * iCurX1
	
	subq.l	#2, d5					;j -= 2;
	bgt		.ForInHTail				;}//while (j > 0)
	
.EndInHTail:						;}//if(pIIR->iIirHistoryCount)

	
;--==Storing computed sample into the memory==--
	
	movclr.l	ACC0, d0			;*pY++ = iOut0;
;#ifndef __FRACT_M	
;	swap	d0						;
;#endif	
	move.w	d0, (a1)+				;
	
	subq.l	#1, d7					;i -= 1;
	bgt		.BegTailH				;}
	
.EndTailH:							;}//if(i)

;---====== Begin of cycle of getting Y[N+1]..Y[n] (N = (pIIR->iIirCoefCount - 1) / 2)======---
	move.l	4(a2), d6				;tmp = IIR->iIirCoefCount;
	
	move.l	76(a7), d7				;i = n;
	
	subq.l	#1, d6					;tmp--;
	sub.l	d6, d7					;i -= tmp;
	 		
	asr.l	#2, d7					;i /= 4;
	
	beq		.BegTail2				;while(i != 0)
									;{
;--==Y[N+1]..Y[k] computation, where k is (N + 1) + ((n - N - 1) % 4)
		
.BegD4E:								;Begin of inner loop 
	
;--== Next input samples loading ==--
	move.l	(a0), d2				;iCurX0 = pX[0]; iCurX1 = pX[1];
	move.l	4(a0), d3				;iCurX2 = pX[2]; iCurX3 = pX[3];
	movea.l	a0, a4					;pCurX = pX;
	lea		8(a0), a0				;pX += 4;
		
	move.l	a6, a3					;pCurCoef = pIirCoef;
;--== Next coefficient loading	==--
	move.w	(a3)+, d4				;iCurA0 = *pCurCoef;
	
;--== Input samples and first coefficient multiplications ==--
	mac.w	d4.l, d2.u, <<, ACC0	;iOut0 = iCurA0 * iCurX0
	mac.w	d4.l, d2.l, <<, ACC1	;iOut1 = iCurA0 * iCurX1
	mac.w	d4.l, d3.u, <<, ACC2	;iOut2 = iCurA0 * iCurX2
	mac.w	d4.l, d3.l, <<, ACC3	;iOut3 = iCurA0 * iCurX3
	
;--== The count of inner loops calculation ==-- 
	move.l	d6, d5					;j = tmp
	btst	#0, d5					;
	beq		.ForIn1EBeg				;if(j & 1)
									;{
	
;--== This multiplications executed only when j is odd ==--
;--== Next coefficient loading	==--
	move.w	(a3)+, d4				;iCurA0 = *pCurCoef++;
	
	move.w	d2, d3					;iCurX3 = iCurX2;
	move.w	-(a4), d2				;iCurX2 = iCurX1;
	swap	d2						;iCurX1 = iCurX0;
	swap	d3						;iCurX0 = *--pCurHistory;
	
	mac.w	d4.l, d2.u, <<, ACC0	;iOut0 += iCurA0 * iCurX0
	mac.w	d4.l, d2.l, <<, ACC1	;iOut1 += iCurA0 * iCurX1
	mac.w	d4.l, d3.u, <<, ACC2	;iOut2 += iCurA0 * iCurX2
	mac.w	d4.l, d3.l, <<, ACC3	;iOut3 += iCurA0 * iCurX3
		
	subq.l	#1, d5					;j -= 1;
	beq		.EndIn1E				;}

.ForIn1EBeg:

;--== Next coefficients loading	==--
	move.l	(a3)+, d4				;iCurA0 = *pCurCoef++; iCurA1 = *pCurCoef++;

.ForIn1E:
	subq.l	#2, d5					;for(;j >= 0; j -=2)
	blt		.EndIn1E				;{
	
;--== Three first input samples and coefficients multiplication ==--
	mac.w	d4.u, d2.u, <<, ACC1	;iOut1 += iCurA0 * iCurX0
	mac.w	d4.u, d2.l, <<, ACC2	;iOut2 += iCurA0 * iCurX1
	mac.w	d4.u, d3.u, <<, ACC3	;iOut3 += iCurA0 * iCurX2
	
;--== Loading two next input samples ==--	
	move.l	d2, d3					;iCurX3 = iCurX1; 	iCurX2 = iCurX0;
	move.l	-(a4), d2				;iCurX1 = *--pCurX; iCurX0 = *--pCurX;	
	
;--== Fourth input sample and coefficient multiplication ==--
	mac.w	d4.u, d2.l, <<, ACC0	;iOut0 += iCurA0 * iCurX1
	
;--== Next Four input sample and coefficients multiplication ==--
	mac.w	d4.l, d2.u, <<, ACC0	;iOut0 += iCurA1 * iCurX0
	mac.w	d4.l, d2.l, <<, ACC1	;iOut1 += iCurA1 * iCurX1
	mac.w	d4.l, d3.u, <<, ACC2	;iOut2 += iCurA1 * iCurX2
;--== Last mac instruction with next coefficients loading ==--
	mac.w	d4.l, d3.l, <<, (a3)+, d4, ACC3	;iOut3 += iCurA1 * iCurX3
											;iCurA0 = *pCurCoef++;iCurA1 = *pCurCoef++;
	
	bra		.ForIn1E				;}
	
.EndIn1E:	
	
;--==Storing computed samples into the memory==--
	
	movclr.l	ACC0, d0			;*pY++ = iOut0
;#ifndef __FRACT_M	
;	swap	d0						;
;#endif	
	move.w	d0, (a1)+				;
	
	movclr.l	ACC1, d0			;*pY++ = iOut1
;#ifndef __FRACT_M	
;	swap	d0						;
;#endif	
	move.w	d0, (a1)+				;
	
	movclr.l	ACC2, d2			;*pY++ = iOut2
;#ifndef __FRACT_M	
;	swap	d2						;
;#endif	
	move.w	d2, (a1)+				;

	movclr.l	ACC3, d0			;*pY++ = iOut3
;#ifndef __FRACT_M	
;	swap	d0						;
;#endif	
	move.w	d0, (a1)+				;

	subq.l	#1, d7					;i --;
	bne		.BegD4E					;}
	
.EndD4E:
;---=Computation of N % 4 last output samples==--
.BegTail2:

	move.l	4(a2), d6				;tmp = IIR->iIirCoefCount;
	move.l	76(a7), d7				;i = n;
	
	subq.l	#1, d6					;tmp--;
	sub.l	d6, d7					;i -= tmp;
	 		
	andi.l	#3, d7					;i &= 3;
	
	beq		.EndTail2				;while(i)
									;{
.BegOutTail2:
	
;--== Next input samples loading	==--
	move.w	(a0), d2				;iCurX0 = *pX;
	movea.l	a0, a4					;pCurX = pX;
	lea		2(a0), a0				;pX++;
	
	move.l	a6, a3					;pCurCoef = pIirCoef;
;--== Next coefficient loading	==--
	move.l	(a3), d4				;iCurA0 = *pCurCoef;
	lea		2(a3), a3				;pCurCoef++;
	
;--== Input samples and first coefficient multiplications ==--
	mac.w	d4.u, d2.l, <<, ACC0	;iOut0 += iCurA0 * iCurX0
	
;--== The count of inner loops calculation ==-- 
	move.l	d6, d5					;j = tmp;

	btst.l	#0, d5
	beq		.ForInTail2
		
;--== This part is executed only if j is odd ==--	
;--== Next coefficients loading	==--
	move.w	(a3)+, d4				;iCurA0 = *pCurCoef++; iCurA1 = *pCurCoef++;
	
;--== Next input samples loading	==--
	move.w	-(a4), d2				;iCurX = *--pCurX;
	
	mac.w	d4.l, d2.l, <<, ACC0	;iOut0 += iCurA0 * iCurX0
	subq.l	#1, d5
	beq		.EndInTail2
			
.ForInTail2:							;do{
	
;--== Next coefficients loading	==--
	move.l	(a3)+, d4				;iCurA0 = *pCurCoef++; iCurA1 = *pCurCoef++;
	
;--== Next input samples loading	==--
	move.l	-(a4), d2				;iCurX0 = *--pCurX;iCurX1 = *--pCurX;
	
;--== Two multiplications for each output sample ==--
	mac.w	d4.u, d2.l, <<, ACC0	;iOut0 += iCurA0 * iCurX0
	mac.w	d4.l, d2.u, <<, ACC0	;iOut0 += iCurA1 * iCurX1
	
	subq.l	#2, d5					;j--;
	bne		.ForInTail2				;}while(j);
	
.EndInTail2:	
	
;--==Storing computed sample into the memory==--
	movclr.l	ACC0, d0			;*pY++ = iOut0;
;#ifndef __FRACT_M	
;	swap	d0						;
;#endif	
	move.w	d0, (a1)+				;
	
	subq.l	#1, d7					;i--;
	bne		.BegOutTail2			;}//while(i)
	
.EndTail2:

;--==Filling history buffer==--

	move.l	8(a2), a3				;pCurHistory = IIR->pIirHistory;
	move.l	4(a2), d0				;i = IIR->iIirCoefCount;
	subq.l	#1, d0					;i--;
	move.l	d0, 12(a2)				;IIR->iIirHistoryCount = i;
	adda.l	d0, a3					;pCurHistory += i;
	adda.l	d0, a3					;
									;do{
.NextHist:
	move.w	-(a0), -(a3)			;*--pCurHistory = *--pX;
	
	subq.l	#1, d0					;i ++;
	bne		.NextHist				;}while(i);
	
;--==Restoring old MAC status register==--
	move.l	d1, MACSR
	
	movem.l	(a7), d0-d7/a0-a6 		
	lea		60(a7), a7				
	rts

⌨️ 快捷键说明

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