Re: A85: a div 6
[Prev][Next][Index][Thread]
Re: A85: a div 6
> can anyone give me some z80 asm for getting the integer division of
> a deivided by 6???
> quick, hackiest thing you can think of.
> im stumped. there should be a way to do this, but i cant find it.
> the only way i can think of would be to take a-6 and inc until a-6<0,
> then dont inc and you are done. this would suck bad, but i may have
> to use it.
There is a routine in the calculator's ROM which does integer division
rather quickly. I'm not sure if it's a good thing to use if you have
an 8-bit divisor, but in general it looks very efficient to me. To use
it, you call UNPACK_HL+2 with HL being the dividend and C holding the
divisor. It returns the quotient in HL and the remainder in A. It
works with any unsigned integers. To divide A by 6:
ld l,a
ld h,0
ld c,6
call UNPACK_HL+2
ld a,l ;If you really need result in A
References: