From: groepaz (groepaz_at_gmx.net)
Date: 2002-07-31 01:59:47
Hello Ullrich,
>> i have knocked up a testprog that shows the problem more exactly (and
>> another problem aswell).... attached at the bottom of this mail :)
UvB> Thanks a lot! I'm out of town until tomorrow evening, so don't expect any news
UvB> before thursday.
no problem :)
anyway.... found another thing :=P
that is, the runtime library appearently gets the result of the
modulo-operation wrong - the sign of the remainder to be exact. i have
checked with gcc (uhmz, to lazy to search for any proper definition, i
believe in gcc for that matter ;=P) and it shows that
sign(a % b) == sign (a)
the current implementation applies the same rules to the
modulo-operation as to the division/multiplication here, thus getting
the wrong result in 3 of 4 cases ;=P
however, i have looked at the runtime lib myself and noticed that not
only mod.s and lmod.s would need a patch, but it would probably make
sence to also modify the helper-routines and mul/div routines maybe
aswell to make the code more clean (patching mod.s is easy, but not
quite clean... and patching lmod.s is quite ugly without modified
helper routines).
a dirty hack for mod.s is below...
--
Best regards,
groepaz mailto:groepaz_at_gmx.net
--- mod.s
tosmoda0:
ldx #0
tosmodax:
jsr popsargs ; Get arguments from stack, adjust sign
jsr udiv16 ; Do the division
ldy ptr1 ; Result is in sreg, remainder in ptr1
ldx ptr1+1
lda tmp1 ; get back sign of divisor
eor tmp2
bpl L3 ; dont adjust
tya
jmp negax ; Adjust sign
L3:
tya
rts
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
This archive was generated by hypermail 2.1.3 : 2002-07-31 02:00:26 CEST