please dont rip this site

microchip math sq new201003

 

ON 20100327@10:41:23 AM at page:
On a web page you were interested in at:
http://www.piclist.com/techref/microchip/math/sq/index.htm#40264.4454050926
Martin  Sturm[MDS-gmail-IE8] Code:

<PRE>; UNTESTED;
; Square 10bit unsigned
;  by Martin Sturm  2010
;
;   a*a --&gt; r
;   a = aH:aL		(10bit, right justified) (not modified)
;	r = rH:rM:rL	(20bit result)
;
; algorithm
;  r = 2^16*(aH*aH) + 2^8*(2*aH*aL) + aH*aL
;             2x2            2x8       8x8
;  r =        rH      :      rM     :  rL
;
; The 2x2 and 2x8 mult done inline, 8x8 mult algo is your choice
; if using a standard inline 8x8 multiplication (36 instr, 36 cycles)
;   65 instructions, 51-65 cycles, 58 avg
;
; incorrect result if A has non-zero bits above the 10th
;  use optional ANDLW 0x03 to correct for this if necessary
;
SQR_10x10 MACRO aH,aL, rH,rM,rL
 LOCAL g1, g2

	MULT_8x8 aL, aL, rM,rL		; rM:rL &lt;-- aL*aL
		; 36 instr, 36 cycles

	; rH = aH*aH   [2b x 2b square] (8 instr, 8 cyc)
	CLRF	rH
	MOVFW	aH	; multiplicand in W
;	ANDLW	0x03	; prevent errors if aH non-zero above 10th bit
	CLRC
	BTFSC	aH,1
	ADDWF	rH,F	; never sets carry
	RLF	rH,F
	BTFSC	aH,0
	ADDWF	rH,F	; never sets carry

	; rH:rM += 2*aH*aL  [2b x 8b mult] (21 instr, 7-21 cyc, avg. 14)
	MOVFW	aL		; multiplicand in W
	BTFSS	aH,0
	GOTO	g1
	ADDWF   rM,F	; add bH
	SKPNC
	INCF	rH,F
	ADDWF   rM,F	; add bH
	SKPNC
	INCF	rH,F	; rH small so this always clear carry
g1
	BTFSS	aH,1
	GOTO	g2
	RLF     aL,W	; carry guaranteed clear before here
			;  W now holds (2*aL &amp; 0xFF)
	ADDWF   rM,F	; add W to rM
	SKPNC
	INCF	rH,F
	ADDWF   rM,F	; add W to rM
	SKPNC
	INCF	rH,F
	MOVLW	0x02
	BTFSC	aL,7	;
	ADDWF	rH,F	; add twice the upper bit of 2*aL
g2
	ENDM</PRE>



ON 20100330@3:37:46 PM at page:
On a web page you were interested in at:
http://www.piclist.com/techref/microchip/math/sq/10b-ms.htm#
Martin  Sturm[MDS-gmail-IE8] edited the page. Difference:
http://www.piclist.com/techref/diff.asp?url=H:\techref\microchip\math\sq\10b-ms.htm&version=0



ON 20100330@5:06:28 PM at page:
On a web page you were interested in at:
http://www.piclist.com/techref/microchip/math/sq/10b-ms.htm#
Martin  Sturm[MDS-gmail-IE8] edited the page. Difference:
http://www.piclist.com/techref/diff.asp?url=H:\techref\microchip\math\sq\10b-ms.htm&version=1



ON 20100330@5:10:46 PM at page:
On a web page you were interested in at:
http://www.piclist.com/techref/microchip/math/sq/10b-ms.htm#
Martin  Sturm[MDS-gmail-IE8] edited the page. Difference:
http://www.piclist.com/techref/diff.asp?url=H:\techref\microchip\math\sq\10b-ms.htm&version=2



file: /Techref/microchip/math/sq/new201003.txt, 2KB, , updated: 2010/3/30 16:10, local time: 2012/2/10 12:48,
TOP NEW HELP FIND: 
38.107.179.233:LOG IN

 ©2012 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://www.piclist.com/techref/microchip/math/sq/new201003.txt"> microchip math sq new201003</A>

Did you find what you needed?

 
 
Feel the NEED for SPEED?
Ubicom SX18 thru SX52, PIC 16c5X compatibile, 50 to
75 MIPS microcontrollers!
Now US customers can buy the Excellent SXDev from SXList.com
for $150 + $15 import fee + s&h (~ $180 total+tax in CA)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .