You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

181 lines
10 KiB

;* ======================================================================== *;
;* TEXAS INSTRUMENTS, INC. *;
;* *;
;* DSPLIB DSP Signal Processing Library *;
;* *;
;* Release: Revision 1.04b *;
;* CVS Revision: 1.7 Sun Sep 29 03:32:25 2002 (UTC) *;
;* Snapshot date: 23-Oct-2003 *;
;* *;
;* This library contains proprietary intellectual property of Texas *;
;* Instruments, Inc. The library and its source code are protected by *;
;* various copyrights, and portions may also be protected by patents or *;
;* other legal protections. *;
;* *;
;* This software is licensed for use with Texas Instruments TMS320 *;
;* family DSPs. This license was provided to you prior to installing *;
;* the software. You may review this license by consulting the file *;
;* TI_license.PDF which accompanies the files in this library. *;
;* ------------------------------------------------------------------------ *;
;* Copyright (C) 2003 Texas Instruments, Incorporated. *;
;* All Rights Reserved. *;
;* ======================================================================== *;
;* ======================================================================== *;
;* Assembler compatibility shim for assembling 4.30 and later code on *;
;* tools prior to 4.30. *;
;* ======================================================================== *;
.if $isdefed(".ASSEMBLER_VERSION")
.asg .ASSEMBLER_VERSION, $asmver
.else
.asg 0, $asmver
.endif
.if ($asmver < 430)
.asg B, CALL ; Function Call
.asg B, RET ; Return from a Function
.asg B, CALLRET ; Function call with Call / Ret chaining.
.if .TMS320C6400
.asg BNOP, CALLNOP ; C64x BNOP as a Fn. Call
.asg BNOP, RETNOP ; C64x BNOP as a Fn. Return
.asg BNOP, CRNOP ; C64x Fn call w/, Call/Ret chaining via BNOP.
.endif
.asg , .asmfunc ; .func equivalent for hand-assembly code
.asg , .endasmfunc ; .endfunc equivalent for hand-assembly code
.endif
;* ======================================================================== *;
;* End of assembler compatibility shim. *;
;* ======================================================================== *;
* ========================================================================= *
* *
* *
* TEXAS INSTRUMENTS, INC. *
* *
* NAME *
* DSP_minval *
* *
* REVISION DATE *
* 07-May-2001 *
* *
* USAGE *
* This routine is C-callable and can be called as: *
* *
* short DSP_minval(const short *x, int nx); *
* *
* x = address to array of values *
* nx = number of values in array *
* *
* *
* DESCRIPTION *
* This routine finds the minimum value of a vector and returns *
* the value. *
* *
* short DSP_minval(const short *x, int nx) *
* { *
* int i, min; *
* min = 32767; *
* for (i = 0; i < nx; i++) *
* if (x[i] < min) *
* min = x[i]; *
* return min; *
* } *
* *
* ASSUMPTIONS *
* Nx is a multiple of 4. *
* Nx is greater than or equal to 20. *
* *
* MEMORY NOTE *
* This code is ENDIAN NEUTRAL. *
* *
* NOTES *
* This code is interrupt tolerant but not interruptible. *
* *
* CODESIZE *
* 112 bytes *
* *
* CYCLES *
* nx / 4 + 10 *
* ------------------------------------------------------------------------- *
* Copyright (c) 2003 Texas Instruments, Incorporated. *
* All Rights Reserved. *
* ========================================================================= *
.sect ".text:_minval"
.global _DSP_minval
_DSP_minval:
* ===================== SYMBOLIC REGISTER ASSIGNMENTS ===================== *
.asg B4, B_nx
.asg A4, A_x
.asg A7, A_x_hi
.asg A6, A_x_lo
.asg A2, A_minA
.asg B5, B_minB
.asg B0, B_i
.asg B1, B_x
.asg B3, B_return
.asg A4, A_minAc
.asg A5, A_compareA
.asg B7, B_compareB
* =========================== PIPE LOOP PROLOG ============================ *
LDNDW .D1T1 *A_x++, A_x_hi:A_x_lo ;[ 1,1] Load 4 elem
|| B .S1 LOOP + 8 ;[ 2,2] Loop
|| SHR .S2 B_nx, 2, B_i ;[ 3,0] nx/4
LDNDW .D1T1 *A_x++, A_x_hi:A_x_lo ;[ 1,2] Load 4 elem
|| B .S2 LOOP ;[ 2,2] Loop
|| SUB .L2 B_i, 4, B_i ;[ 4,0] BDEC at 0
|| MVKL .S1 0x7FFF7FFF, A_minA
[ B_i]BDEC .S2 LOOP, B_i ;[ 2,2] Loop
|| LDNDW .D1T1 *A_x++, A_x_hi:A_x_lo ;[ 1,3] Load 4 elem
|| MVKH .S1 0x7FFF7FFF, A_minA
[ B_i]BDEC .S2 LOOP, B_i ;[ 2,3] Loop
|| LDNDW .D1T1 *A_x++, A_x_hi:A_x_lo ;[ 1,4] Load 4 elem
[ B_i]BDEC .S2 LOOP, B_i ;[ 2,4] Loop
|| LDNDW .D1T1 *A_x++, A_x_hi:A_x_lo ;[ 1,5] Load 4 elem
|| MV .L2X A_minA, B_minB ;[ 4,0] Part. copy
* =========================== PIPE LOOP KERNEL ============================ *
LOOP:
MIN2 .L1 A_x_hi, A_minA, A_minA ;[ 6,2] update min
|| MIN2 .L2X A_x_lo, B_minB, B_minB ;[ 6,2] update min
||[ B_i]BDEC .S2 LOOP, B_i ;[ 2,6] Loop
|| LDNDW .D1T1 *A_x++, A_x_hi:A_x_lo ;[ 1,7] Load 4 elem
* =========================== PIPE LOOP EPILOG ============================ *
MIN2 .L1 A_x_hi, A_minA, A_minA ;[ 6,6] update min
|| MIN2 .L2X A_x_lo, B_minB, B_minB ;[ 6,6] update min
|| RET .S2 B_return ;
SWAP2 .L2 B_minB, B_compareB ;[ 2,0]
|| SWAP2 .S1 A_minA, A_compareA ;[ 3,0]
MIN2 .L2 B_minB, B_compareB, B_minB ;[ 3,0] update min
MIN2 .L1 A_minA, A_compareA, A_minA ;[ 4,0] update min
MIN2 .L1X A_minA, B_minB, A_minA ;[ 5,0] final min
EXT .S1 A_minA, 16, 16, A_minAc ;[ 6,0]
;==== Branch occurs
* ========================================================================= *
* End of file: dsp_minval.asm *
* ------------------------------------------------------------------------- *
* Copyright (c) 2003 Texas Instruments, Incorporated. *
* All Rights Reserved. *
* ========================================================================= *