please dont rip this site

SX Microcontroller Math Method


From: Tony Nixon

;       ------------------------------------------
; numerator:        nratorH  nratorM  nratorL
; denominator:      denomH   denomM   denomL
; result:           nratorH  nratorM  nratorL
; remainder:        remainH  remainM  remainL
; 54 instructions about 974 cycles
divizn	mov	W, #24
	mov	BCount, W
	mov	W, nratorH
	mov	shiftH, W
	mov	W, nratorM
	mov	shiftM, W
	mov	W, nratorL
	mov	shiftL, W
	clr	nratorH
	clr	nratorM
	clr	nratorL
	clr	remainH
	clr	remainM
	clr	remainL
dloop	clrb	C
	rl	shiftL
	rl	shiftM
	rl	shiftH
	rl	remainL
	rl	remainM
	rl	remainH
	mov	W, denomH
	mov	W, remainH-w
	sb	Z
	jmp	nochk
	mov	W, denomM
	mov	W, remainM-w
	sb	Z
	jmp	nochk
	mov	W, denomL
	mov	W, remainL-w
nochk	sb	C
	jmp	nogo
	mov	W, denomL
	sub	remainL, W
	sb	C
	dec	remainM
	mov	W, remainM
	xor	W, #$ff
	snb	Z
	dec	remainH
	mov	W, denomM
	sub	remainM, W
	sb	C
	dec	remainH
	mov	W, denomH
	sub	remainH, W
	setb	C
nogo	rl	nratorL
	rl	nratorM
	rl	nratorH
	decsz	BCount
	jmp	dloop

See also:

file: /Techref/scenix/lib/math/div/24by24tn_sx.htm, 1KB, , updated: 2004/6/10 14:40, local time: 2020/9/29 18:53,

 ©2020 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=""> SX Microcontroller Math Method - 24 BIT DIVISION</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 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!

Site supported by
sales, advertizing,
& kind contributors
just like you!

Please don't rip/copy
(here's why

Copies of the site on CD
are available at minimal cost.

Welcome to!