This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Arithmetic Calculate (64 bits)

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

Parents
  • 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.

Reply
  • 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.

Children