Subject: Re: div by 10 on Z80

Jim Battle frustum at pacbell.net
Thu Jan 24 22:42:34 CST 2008


Jim Battle wrote:
> dwight elvey wrote:
...
>> Based on an email I just had from the cpm news group, I thought
>> it might be fun to write some Z80 code to do the 0 to 799 as fast
>> as one could, with no size restriction. Just clocks count.
> 
> There is a trivial solution: a look up table.
> 
>     add hl,hl    ; double it
>     ld  de,table    ; base addr of table
>     add hl,de       ; index
>     ld  a,(hl)      ; pick up quotient
> ...
> table    db  0,0        ; 0: quotient, remainder
>     db  0,1        ; 1
>     db  0,2
>     db  0,3
> etc

oops, I accidentally deleted the tail end of my program during editing.  add

	inc hl
	ld  h,(hl)

after the last instruction above to fetch the remainder



More information about the cctech mailing list