Question

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;
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top