How can I multiply 2 data that result in a 64 bit value? For example: unsigned long a = 4000000000, c; unsigned int b = 60000; c = a * b; //this have a problem!!! Has any library that can I use? Thanks Leonardo
It was Graham :) Have you figured out what my company makes yet, given all the comments about 8051s embedded in Ethernet chips? We use ARMs as well, as it happens. I occasionally contemplate writing my few U64 arithmetic routines in assembler. And I'm always struck by the fact that the DPTR has an INC instruction, but no DEC. This would seem to make little-endian math more natural for the 8051, as you just rip through a couple of U64s with dual DPTRs and ADC. Moving backwards for the big endian format is harder, though. Keil libraries seem to load entire U32s into registers, do the math, and then write the result back out. But that strategy doesn't work so well with U64s.
"It was Graham :)" So it was - sorry, Erik!
"I'm always struck by the fact that the DPTR has an INC instruction, but no DEC." Aren't there a few derivatives that do add a decrement instruction? Anyhow, still doesn't help with the OP's multiplications...
I don't see how anybody could add an instruction to the 8051 machine language without requiring a whole new compiler (like the MX51 does). What some derivatives do add is a special bit in an SFR that changes the meaning of the normal 'inc dptr' instruction into 'dec dptr'.
"What some derivatives do add is a special bit in an SFR that changes the meaning of the normal 'inc dptr' instruction into 'dec dptr'." That's probably what I've seen referred to, then.
"That's probably what I've seen referred to, then" Or perhaps not: http://www.keil.com/forum/docs/thread908.asp