开发工具:
文件大小: 180kb
下载次数: 0
上传时间: 2019-10-12
详细说明:Microchip公司的快速平方根算法,适合对算法感兴趣的朋友sectlon⊥nf
Type Address Location size(Bytes
R VCR
orog
init
0x00002a
program
code
0x00002c
program 0x0000f4
SRoot
0x000120
y Usage
start
0X000000
284 out of 32786 program addresses used, program memory utilization is 0%
Title"Square Root Calling routine Demo
★六★大大大大青★古★六★大六大古古十★大六大大六古大★k大古大★
大★大六大古古大青大大★大大★★大大★大古★古大古大大
Author: Ross Fosler
Applications Engineer
★★★
Microchip Technology Inc
★大★
Program: main. asm
★★★
This routine calls the square root function
o土 ind the root ot t
大大
Last Rev: August 10, 2000
ve1.00
大★★★士计★★大★★大★★★★
k★★★★大★★大★★★士★★★★★★
1stp=18C252
#include p1bc252. Inc
EXTERN ARGA ARGA, ARGA2 ARGA3
EXTERN RESO, RESI
exTern sart
F
equ
equ
R Vctr
0x0000
Calling Routine
SRoot
CODE
Ma
moV⊥w
0xCF
mov Iw
movwf
ARGAo, a
call
sart
;sqrt:(0×CF48)
reso Should now contain 0xE6
movlw
UXEO
ArGa3, a
0X12
movwf
ARGA2,a
ARGAl, a
0x40
movwf
ARGAo a
call
i Sart(OxEO12A140)
REST: RFSo should now contain 0xFF8T
bra
Main
END
★★★★★★★★★★★★★★★★★★★*★★★★★★★★★★★★★★★★★★★★★★★★★*★★★★★★★★★★★★*大★★大大★
Title16/32 bit Integer square Root
;***★**为★*★为大★**大*★为★为★******★为*★为大为★*★★**决*为★*★为大为**为***★为为★
FoSler
大λ大
Applications Engineer
Microchip Technology Inc
★★★
Program: sgrt. asm
★★★
This module contains code to perform fast integer
为*
square root functions on either 16 or 32 bit
★★★
values
** Last Rev: August 10, 2000
★★★
Ver 1.00
;木木木木木青木木木木木木大大木木木木木木木木木大木木大大木木木木木青有木木木木木大青青大木
十★k★★★★★女★★★★头为出十★★★★
;***★★****★*★★***★★★***为**★*★**★★**★***
大★★★★害女★★★大★★
MSB
equ
7
general literal constants
LSB
e qu
W
eee
0010
equ
;*★*大********大**为大大***大大大*为**来为*大大***大*实大为**大为*x方*为*大*大
k大kkkk青k大k
UDATA ACS
ARGAO
e吕
111
i various argument registers
ARGAl
ARGA2
ARGA3
GLOBAL ARGAO, ARGAl, ARGA2, ARGA3
LH
ARG1
res
ARGIL
res
res
GLOBAL ARGIH, ARGIL, ARG2H, ARG2L
SARG
res
i signed arguments
res
GLOBAL SARG1 SARG2
RESI
resu⊥ t registers
RESO
GLOBAL RESC
ES1
SORESO
re s
SORESI
111
SORES 2
e吕
SoRES
res
LOBAl SqRESO, SQRESI, SQRES2, SQRES3
BITLOCO
e s
temporary registers
TlOC1
res
TEMP1
The function of this square root routine is to determine the root
to the nearest integer. At the same time the root is ound at the
best possible speed; therefore, the root is found a little differently
for the two basic sizes of numbers, 16-bit and 32-bit. The following
iates the two and jumps to the approp
Sart(ARGA3: ARGA2: ARGAl: ARGAO)=RESI: RESO
tsts
ARGA3 a
determine if the number is 16-bi-
1 the best functi
bra
sart32
CIrf
RESI, a
sarti
GLOBAL
★★★★★★★头★十★★★★★★★★★头k★*★★★女★★★★★出害★★★★+★★头头十*头★★★女★头★★*头
*Sq1 aare Rcot***★★*x★***★*★★*★★大*****★★*★**★★*
Sart16(ARGAl: ARGAO)- RESO
sarti
clre
TEMPo a
clear the temp solution
movlw
setup the first. bit.
BITLOCO
mowW土
rESo a
th
RESO
movE
PRODL, w,a
i ARGA- PRod test
bwwf
RAO
PRODH, w,a
subwnfb
ARGAl,W,a
btfsc
STATUS a
bra
NextBit
if positive then next bit
ii negative then rotate right
movEs
TEMPO, RESo move last gocd value back into RESO
at
BITLOCO, W
back into reso
i。rwE
RESO, F,a
btfsc
BITLOCO, 7,a
if last value was tested then get
bra
Squares
elso go back for another test
tEit
RESO, TEMPO
copy the last good approximation.
rnc土
B江Oc0,R,a
egist
move
B⊥ILoC0,W,a
i。rwf
RESO F a
bt土sc
BITLOC0, 7 a
i⊥ ast va⊥ ue was tested then ge
bra
Done
out
e 8
TEMPO, RESO
i put the final result in RESO
return
GLOBAL
Sar=16
;*为★★★**★共为★★★大*★*** Scare root**★★★为★*★★****★*★★*★★*★★****大为*为
Sart 32(ARGA3: ARGA2: ARGAl: ARGAO)= RESl: RESO
sart32
TEMPo, a
i clear the temp solution
TEMPI
B士roC0,a
i setup the first bit
cIrf
rEs, a
movwf
BITLOC-, a
BitLoc 0x8000
RES1, a
RES
0x8000
RESO, ARGIL
moff
REST ARGTH
Sal6
ARGA- PRod test
SORESI, w,a
subway
ARGAl W, a
web
SQRES3, W,a
subwtb
ARGA3 w,a
bra
NxtBt16
if positive then next bit
if negative the
tate right
0x00
TEMPO RESO
;Ⅲove1 ast gocd value back into R彐S0
moff
TEMPl, RES1
tote the bit and put it
BITLOCO F
move
B工TLoc-,,a
i back into RESl: RESO
⊥oYwf
RESl, F,a
bTTlOCO w. a
RESO
btfsc
STATUS C a
i if last value was tested then ge
bra
Done 3 2
;。ut
bra
Squarl6
i elso gc back for another lest
NxtBt16 addle
0xC0
c1 ear ca卫1
move
RES1 TEMP1
rcf
BITLCC1. F. a
i rotate the bi--ocation register
B工TLCC1,N,a
i and put back into RESl: RESO
wt
REST F a
most
B⊥LCC0,N,a
f
tisc
STATUS c a
if last value was tested then geL
bra
Done3 2
i out
16
Done32 ovff
TEMPO, RESO
i put the final result in RES1: RESO
movie
return
Sgr=32
*****★为大为***x**为★为★为大为*★**为*为为为★**★**x*为★为大★****★★*共***★*****k**
*********16x16 Unsigned square***x****★******************
SORES3: SQRESO ARGIH: ARGIL 2
Sg16
f
ARGIL, W
a
mulwf
ARGIL
ARGIL ARGZL-
moff
PRODH SQRESl
motif
PRODL SQRESO
mulan
ARGIH
ARG1H ARG2H->
PRODH: PRODI
motif
PRODH SQreS3
moff
PRODL SQRES2
ARGIL W,a
mulwf
ARGIH
ARGIL ARGZH
PRODH: PRODI
movi
sQR三S1,P
move
PROdH, W.a
i products
addwfc
sQR三s2,P,a
addwfc
ARGIH, W, a
mmulwf
ARGIL
i ARGIH ARG2L->
PRODH. PRO
PRODL W
addwf
SQRESl, F,a
i Add cross
cIrf
WREG, W
dwf
SQRES3, F,a
GLOBAL
Sal6
大★★★★★★★★★★★★★★★★★★★大★★★★大★★大★★★★★★★★★x★★★★★★★★★★★★*大★★★★★★★★★★★★大
MICROCHIP
DNV Certification, Inc.
DNV MSC
USA
The netherlands
Accredited by the RvA
ANSI*RAB
QMS
★
lso9001/QS-9000
REGISTERED FIRM
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.