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: 2024/11/22 04:55,
TOP NEW HELP FIND: 
3.128.31.76:LOG IN

 ©2024 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! / MAKE!

<A HREF="http://ecomorder.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 visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. 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: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to ecomorder.com!

 

Welcome to ecomorder.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .