From: cclist at
sydex.com
To: cctalk at
classiccmp.org
Date: Wed, 23 Jan 2008 09:31:50 -0800
Subject: Subject: RE: Subject: Re: div by 10 on Z80
Date: Tue, 22 Jan 2008 19:33:15 -0800
From: dwight elvey
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.
Hi Chuck
See my other post. I realized the missing 'add hl,hl'. As you
can see, I moved this to the front of the loop and increased
the value of DE to -1280. This allowed the use of the bit
in the a register!!
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.
I think there is still some interest in coding tricks. Even if they
are using DEC machines.
Dwight
_________________________________________________________________
Shed those extra pounds with MSN and The Biggest Loser!
http://biggestloser.msn.com/