Re: A82: Dividing and remainders


[Prev][Next][Index][Thread]

Re: A82: Dividing and remainders



In a message dated 97-11-26 04:09:19 EST, you write:

> No, since it is located in the same place for all rom versions, you should
>  use call $A2. I have not looked at it for some time know, but i think it
>  is HL/A, Reminder in A and result in HL. 
>  
>  Dines

I believe that the address is actually $A3.  It is equivilant to UNPACK_HL+2
(UNPACK_HL divides hl by ten and stores the remainder in A and the result in
hl [used for displaying numbers]) so UNPACK_HL will skip the two byte
instruction 'ld a, $0A' (10d).  So load the divisor in a and the dividend in
hl and do 'call UNPACK_HL+2' (that will make the source easier to read)
Or else I suggest that you put DIVIDE_HL_A (or whatever) = UNPACK_HL+2.
I have not yet had to do division, so I'm lucky :-).

~Adamman

P.S. Andreas Ess has made some nice 16-bit mult and divide functions,
http://andi.ganymed.org