0

I am trying to divide a 64 bits integral type to a 32 bits one, and I am using RVDS 4.1 as a tool-chain.

Cortex-M0 does not have hardware divisor, so can I do the operation below? If so How?

unsigned long int b = 2590202;
unsigned long long int a = 953502716552001ULL;
unsigned long long int result;
result = a/b;
artless noise
  • 21,212
  • 6
  • 68
  • 105
albin
  • 773
  • 1
  • 8
  • 27

1 Answers1

1

The compiler will compile the division operation as a call to a library subroutine that performs a software 64-bit division algorithm. You might have to also tell the compiler to link with the math library, I have no experience with RVDS specifically.

Why not try compiling the code yourself and see what happens? Try disassembling the resulting machine code to see how it works: it should be very educational.

Colin D Bennett
  • 11,294
  • 5
  • 49
  • 66
  • 1
    RVDS does this operation on Cortex-M0 by using intrinsic library functions e.g. "__aeabi_uldivmod." I dissembled then I saw a branch to this function to satisfy divide operator. – albin Dec 07 '12 at 22:12