PIC Microcontoller Math Method

Fast 8 Bit Square Root

;**********************************************************************
;FAST 8 BIT SQUARE ROOT
;
;Author: Nikolai Golovchenko <golovchenko@mail.ru>
;Date: February 15, 2000
;
;Input and output in w
;ROM - 53
;RAM - 0
;Timing - 15..19 cycles including call and return
;**********************************************************************
Sqrt8f
;*** WARNING: ADDLW was expanded in three instructions! Check if previous instruction is a skip instruction. 
;        addlw -64       ;1
	mov	Hack, W
	mov	W, #-64	;1
	add	W, Hack
	snb	C
	jmp	sqrt8_15	;3
;*** WARNING: ADDLW was expanded in three instructions! Check if previous instruction is a skip instruction. 
;        addlw (64-16)
	mov	Hack, W
	mov	W, #(64-16)
	add	W, Hack
	snb	C
	jmp	sqrt4_7	;6
;*** WARNING: ADDLW was expanded in three instructions! Check if previous instruction is a skip instruction. 
;        addlw (16-4)
	mov	Hack, W
	mov	W, #(16-4)
	add	W, Hack
	snb	C
	jmp	sqrt2_3	;9
;*** WARNING: ADDLW was expanded in three instructions! Check if previous instruction is a skip instruction. 
;        addlw (4-1)
	mov	Hack, W
	mov	W, #(4-1)
	add	W, Hack
	snb	C
	retw	#1	;1 (15)
	retw	#0	;0 (16)
sqrt2_3
;*** WARNING: ADDLW was expanded in three instructions! Check if previous instruction is a skip instruction. 
;        addlw (4-9)
	mov	Hack, W
	mov	W, #(4-9)
	add	W, Hack
	snb	C
	retw	#3	;3 (16)
	retw	#2	;2 (17)
sqrt4_7
;*** WARNING: ADDLW was expanded in three instructions! Check if previous instruction is a skip instruction. 
;        addlw (16-36)
	mov	Hack, W
	mov	W, #(16-36)
	add	W, Hack
	snb	C
	jmp	sqrt6_7	;10
;*** WARNING: ADDLW was expanded in three instructions! Check if previous instruction is a skip instruction. 
;        addlw (36-25)
	mov	Hack, W
	mov	W, #(36-25)
	add	W, Hack
	snb	C
	retw	#5	;5 (16)
	retw	#4	;4 (17)
sqrt6_7
;*** WARNING: ADDLW was expanded in three instructions! Check if previous instruction is a skip instruction. 
;        addlw (36-49)
	mov	Hack, W
	mov	W, #(36-49)
	add	W, Hack
	snb	C
	retw	#7	;7 (17)
	retw	#6	;6 (18)
sqrt8_15
;*** WARNING: ADDLW was expanded in three instructions! Check if previous instruction is a skip instruction. 
;        addlw (64-144)
	mov	Hack, W
	mov	W, #(64-144)
	add	W, Hack
	snb	C
	jmp	sqrt12_15	;7
;*** WARNING: ADDLW was expanded in three instructions! Check if previous instruction is a skip instruction. 
;        addlw (144-100)
	mov	Hack, W
	mov	W, #(144-100)
	add	W, Hack
	snb	C
	jmp	sqrt10_11	;10
;*** WARNING: ADDLW was expanded in three instructions! Check if previous instruction is a skip instruction. 
;        addlw (100-81)
	mov	Hack, W
	mov	W, #(100-81)
	add	W, Hack
	snb	C
	retw	#9	;9 (16)
	retw	#8	;8 (17)
sqrt10_11
;*** WARNING: ADDLW was expanded in three instructions! Check if previous instruction is a skip instruction. 
;        addlw (100-121)
	mov	Hack, W
	mov	W, #(100-121)
	add	W, Hack
	snb	C
	retw	#11	;11 (17)
	retw	#10	;10 (18)
sqrt12_15
;*** WARNING: ADDLW was expanded in three instructions! Check if previous instruction is a skip instruction. 
;        addlw (144-196)
	mov	Hack, W
	mov	W, #(144-196)
	add	W, Hack
	snb	C
	jmp	sqrt14_15	;11
;*** WARNING: ADDLW was expanded in three instructions! Check if previous instruction is a skip instruction. 
;        addlw (196-169)
	mov	Hack, W
	mov	W, #(196-169)
	add	W, Hack
	snb	C
	retw	#13	;13 (17)
	retw	#12	;12 (18)
sqrt14_15
;*** WARNING: ADDLW was expanded in three instructions! Check if previous instruction is a skip instruction. 
;        addlw (196-225)
	mov	Hack, W
	mov	W, #(196-225)
	add	W, Hack
	snb	C
	retw	#15	;15 (18)
	retw	#14	;14 (19)
;**********************************************************************