Subject: RE: Subject: Re: div by 10 on Z80
dkelvey at hotmail.com
Thu Jan 24 00:01:57 CST 2008
> 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
>> ld a,#2
>> ld de,#-640d
>> add hl,de
>> jr c, div1
>> sbc hl,de
>> rl a
>> jr nc,divloop
>> add hl,hl
> 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.
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
I think there is still some interest in coding tricks. Even if they
are using DEC machines.
Shed those extra pounds with MSN and The Biggest Loser!
More information about the cctalk