Subject: Re: div by 10 on Z80 was RE: Reading Polymorphic

dwight elvey dkelvey at hotmail.com
Wed Jan 23 10:26:08 CST 2008





> From: dkelvey at hotmail.com
> To: cctalk at classiccmp.org
> Date: Wed, 23 Jan 2008 07:22:09 -0800
> Subject: RE: Subject: Re: div by 10 on Z80 was RE: Reading Polymorphic
>
>
>
>
>
>> From: dkelvey at hotmail.com
>>>
>>
>> Oops!! I blew it. I forgot an 'add hl,hl' !!!!!!$$$####
>>
>> Here is the change using the sign bit instead. Still saves time and cycles
>> by not needing the DJNZ. One less cycle per loop. The and at the end
>> balances the ld B#7 but the ld a, #1 is one more byte. Still the jp
>> is faster than the jr for the 7 loops. Still 19 bytes!
>>
>> div10:
>> ld a,#1
>> ld de,#-640d
>> divloop:
>> add hl,de
>> jr c,div1
>> sbc hl,de
>> div1:
>> rl a
>> add hl,hl
>> jp p,div1
Oops   Should be jp p,divloop   Dwight
>> add hl,hl
>> and #7F
>> ret
>>
>> Dwight
>>
>
> Hi
> It is getting bad, I'm dreaming solutions now.
> Here is one that uses the minimum bytes but is slightly
> slower because of the jr instead of the jp for the loop:
>
> div10:
> ld a,#2
> ld de,#-1280d
> divloop:
> add hl,hl
> add hl,de
> jr c,div1
> sbc hl,de
> div1:
> rl a
> jr c,div1
> add hl,hl
> ret
>
> This is 16 bytes. One could still reduce the loop clocks by
> 9 cycles at the cost of one more byte. This could be done
> by replacing the jr c,div1 with a jp c,div1. ;)
> Dwight
>
> _________________________________________________________________
> Connect and share in new ways with Windows Live.
> http://www.windowslive.com/share.html?ocid=TXT_TAGHM_Wave2_sharelife_012008

_________________________________________________________________
Shed those extra pounds with MSN and The Biggest Loser!
http://biggestloser.msn.com/



More information about the cctalk mailing list