[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [MiNT] C bit: modulo and divu.w
To clear things up a bit:
1) divu.w is an instruction that divides a LONG and NOT A WORD. This results
in a quotient and a restvalue, which must both be words.
2) divu.w can only correctly divide longs when quotient < 65536!!!!
It CAN for instance divide 100000 by 5 cos the quotient is < 65536
but our counter in this example is a longword...
anyway.. I would recode the original code:
/* snip */
uptime++;
uptimetick += 200;
if (uptime % 5) return;
/* snip */
to this:
/* snip */
uptimetick+=200;
if (uptimetick++ == 5)
{
uptimetick = 0;
return;
}
/* snip */
which ofcourse gets rid of the costly modulo operation alltoghether.
okay.. maybe I should stop writing now =)
Mail you later
Pieter van der Meer