please dont rip this site

SX Microcontroller Math Method


Square 10 bits

;by John Payson

clrf DstH
	clr	DstM
	clr	DstL
	mov	W, SrcL
	and	W, #$0F
	sb	Src.4
	add	DstM, W
	rr	DstM
	rr	DstL
	sb	Src.5
	add	DstM, W
	rr	DstM
	rr	DstL
	sb	Src.6
	add	DstM, W
	rr	DstM
	rr	DstL
	sb	Src.7
	add	DstM, W
	call	Sqr4
	add	DstL, W
	swap	SrcL
	and	W, #$0F
	call	Sqr4
	add	DstM, W
; At this point, 16-bit result is in DstM:DstH
; 25 words of code prior to this point (plus a
; 17-word table-lookup). Total execution time:
; 35 cycles up to this point.
	sb	SrcH.0
	jmp	NoBit8
	mov	W, SrcL
	snb	C
	inc	DstH
	add	DstM, W
	snb	C
	inc	DstH
	inc	DstH
; Another 9 words for bit 8; 3 or 9 cycles to exec.
NoBit8:
	sb	SrcH.1
	jmp	NoBit9
	mov	W, #4
	sb	SrcH.0
	mov	W, #8
	add	DstH, W
	mov	W, <<SrcL
	snb	C
	inc	DstH
	snb	C
	inc	DstH
	add	DstM, W
	snb	C
	inc	DstH
	add	DstM, W
	snb	C
	inc	DstH
; Another 17 words for bit 9; 3 or 17 cycles to execute
; Total worst-case time: 35+26 = 61 cycles.
NoBit9:
	retw	#0	; All done!
Sqr4:
	add	PC, W
db 0,1,4,9,16,25,36,49,64,81,100,121,144,169,196,225

See also:


file: /techref/scenix/lib/math/sq/10b_sx.htm, 2KB, , updated: 2004/6/10 13:40, local time: 2008/11/21 02:03,
TOP NEW HELP FIND: 
38.103.63.58:LOG IN
©2008 PLEASE DON'T RIP! DO: LINK / DIGG! / MAKE!

 ©2008 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it!
<A HREF="http://www.piclist.com/techref/scenix/lib/math/sq/10b_sx.htm"> PIC Microcontroller Math Method Square 10 bits </A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be reviewed) Just type in the box and press the Post button. (HTML welcomed!): A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Did you find what you needed?

  PICList 2008 contributors:
o List host: MIT, Site host massmind.org, Top posters @20081121 Apptech, Jinx, Xiaofan Chen, olin piclist, Vitaliy, William \Chops\ Westfield, Tamas Rudnai, Alan B. Pearce, JonnyMac, Gerhard Fiedler,
* Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Shultz Electronics, Timothy Weber, on-going support is MOST appreciated!
* Contributors: Richard Seriani, Sr.
  'What can I do?' - SiCKO

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .