#14454 - animension - Tue Jan 06, 2004 11:49 pm
Quick question: how does the GBA handle long longs (64-bit integers)?
_________________
"Beer is proof that God loves us and wants us to be happy."
-- Benjamin Franklin
#14457 - DekuTree64 - Wed Jan 07, 2004 12:32 am
You have to sort of emulate a 64-bit processor for it. Basically you just use 2 regs to store each 64-bit number, and for addition, add the 2 bottom halves, and then adc (add with carry) the upper halves. Multiplication is trickier and takes a bunch of multiplyingand adding. It's the same theory behind how you do multiplication on paper. I think it would be destLo = lo1 * lo2, destHi = lo1 * hi1 + lo2 * hi1 + lo1 * hi2 + lo2 * hi2. hi1 * hi2 would naturally overflow 64 bits, so there's no point in doing it. Not sure how to do division, but GBA doesn't have a hardware divide anyway, so you could just write a 64-bit divider yourself.
To make life easy, let the compiler take care of all that dirty work for you.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku
#14459 - Miked0801 - Wed Jan 07, 2004 12:53 am
64-bit Multiplies are handled with mul/mla commands across 2 registers. I found DevKitAdv to have very limited 64-bit support and after having it yell at me a bit, have since stopped trying to use it.
Mike