SX Microcontroller Math Method

8 Bit Square Root

by Nikolai Golovchenko

;**********************************************************************
;by Nikolai Golovchenko
;8 bit SQARE ROOT
;ACCB0 input/output
;TEMPB0, TEMPB1 used for temporary storage
;3+16*4-2+5=70 cycles execution time
;20 words of program memory
;3 bytes of RAM
;**********************************************************************
Sqrt8
	mov	W, #$40
	mov	TEMPB1, W
	clr	TEMPB0
sqrt8a
	mov	W, TEMPB1
	or	W, TEMPB0
	mov	W, ACCB0-w
	snb	C
	mov	ACCB0, W
	rr	TEMPB0
	mov	W, TEMPB1
	snb	TEMPB0.7
	or	TEMPB0, W
	clrb	TEMPB0.7
	rr	TEMPB1
	rr	TEMPB1
	sb	TEMPB1.7
	jmp	sqrt8a
	mov	W, TEMPB0
	mov	ACCB0, W
	ret
;**********************************************************************
;Last updated 15Nov99