Date: Tue, 22 Jan 2008 19:33:15 -0800
From: dwight elvey <dkelvey at hotmail.com>
Here goes with using your idea to double use the a
register. Except
If I start it with 2, I can use the carry instead of the sign bit. What
fun!
Div10:
ld a,#2
ld de,#-640d
divloop:
add hl,de
jr c, div1
sbc hl,de
div1:
rl a
jr nc,divloop
add hl,hl
ret
Ah, but you forgot the add hl,hl to shift the dividend after each
iteration. Put it at the top of the loop so it doesn't interfere
with the operation of the "rl a/jr nc" pair and scale your divisor by
an additional power of 2 and you should have it.
By now, we've probably bored the hardware guys to tears and DEC
people are tearing out their hair, so we should probably drop the
subject.
My apologies, but I've always found bit-twiddling fun. It seems that
every platform has some peculiar characteristic that can be exploited
to good advantage.
Cheers,
Chuck