Integer division with Cortex-M0 under RVDS

穿精又带淫゛_ 提交于 2019-12-12 00:29:33

问题


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:


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.



来源:https://stackoverflow.com/questions/11297965/integer-division-with-cortex-m0-under-rvds

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!