📄 sub_vector_max.s
字号:
;START_HEADER
;
; dsPIC30F6014 Demo Source File
; (c) Copyright 2005 Microchip Technology, All rights reserved
;
; --------------------------------------------------------------------------
; File Revision History:
; --------------------------------------------------------------------------
;
; $Log: sub_vector_max.s,v $
; Revision 1.2 2005/04/04 23:38:12 VasukiH
; Updated comments in header
;
; Revision 1.1.1.1 2003/08/23 00:38:33 VasukiH
; First import of demo source into CVS Repository
;
;
;
; --------------------------------------------------------------------------
;
; Software and Development Tools Info:
; --------------------------------------------------------------------------
; Tool Version
; --------------------------------------------------------------------------
; MPLAB IDE 7.0
; MPLAB C30 Toolsuite 1.30
; dsPICDEM(TM) Processor Board 1.10
; --------------------------------------------------------------------------
;
; File Notes:
;
;
; _sub_vector_max: Vector Maximum Value (and last index with maximum value).
;
; Operation:
; maxVal = max {srcV[n], n in {0, 1,...numElems-1} }
; residually,
; if srcV[i] = srcV[j] = maxVal, and i < j, then *(maxIndex) = j
;
; Input:
; w0 = number elements in vector(s) (numElems)
; w1 = ptr to source vector (srcV)
; w2 = ptr to index of maximum value (&maxIndex)
; Return:
; w0 = maximum value (maxVal)
;
; System resources usage:
; {w0..w2} used, not restored
; {w5..w7} used, not restored
;
; Cycles:
; 8 + 7*(numElems+1) (if srcV[n] <= srcV[n+1], 0 <= n < numElems-1)
; 8 + 7*numElem (if srcV[n] > srcV[n+1], 0 <= n < numElems-1)
;
;END_HEADER
.section .text
.global _sub_vector_max
_sub_vector_max:
push.d w4
push.d w6
mov [w1++],w7 ; w7 = srcV[0] (current maxVal)
clr [w2] ; *w2 = current max value index
dec w0,w6 ; w6 = numElems-1
bra le,_endMax ; no more elements...
_compare:
mov [w1++],w5 ; w5 = srcV[n+1]
cp w7,w5 ; srcV[n] < srcV[n+1] ?
bra gt,_noUpdate ; yes => no update
_doUpdate: ; no => do update
mov w5,w7 ; w7 = (current maxVal)
sub w0,w6,[w2] ; *w2 = current max value index
_noUpdate:
dec w6,w6 ; w6 = numElems-n
bra gt,_compare ; no more elements...
_endMax:
mov w7,w0 ; restore return value
pop.d w6
pop.d w4
return
.end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -