Integer division with Cortex-M0 under RVDS

1.7k views Asked by At

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;
1

There are 1 answers

1
Colin D Bennett On BEST ANSWER

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.