ARM Overview: Difference between revisions

section about no ARM native integer division and examples of division implementation on GCC
[unchecked revision][unchecked revision]
(section about no ARM native integer division and examples of division implementation on GCC)
Line 231:
 
==Coding Gotchas==
===== ARM Has No Native Integer Division =====
Yep, there are no instructions to perform native integer division. When you want to do division when targeting an ARM core your compiler automatically tries to call the following procedures. Most people
try to avoid division if possible, but if you must:
<pre>
unsigned int __aeabi_uidiv(unsigned int num, unsigned int den)
{
unsigned int x;
for (x = den; x < num; x += den);
return x;
}
 
int __aeabi_idiv(int num, int den)
{
return __aeabi_uidiv(num, den);
}
</pre>
===== Unaligned Memory Access And Byte Order =====
{| border="1px"
294

edits