ARM > Efficient C for ARM > Division and Modulus
Previous topic:
Floating Point
Next topic:
Unaligned Data Access
ARM RISC OS PrivateEye PhotoFiler IntroductionToARM Geminus Toolbar Site Containers GitHub Hardware iOS Optimisation Project Aha Retro Links Dump Spectrum Risc PC The Great Escape LEGO Wedding Acorn Doodle Blender 3D Isometric 2D Article Sinclair Ocean TargetedOptimisation Disassembly Chase H.Q. Tip BasicOptimisation Slide Trace Hard Disc Vector Pixel Art Groening Simpsons Futurama Disenchantment BBC Micro Electron Archimedes MotionMasks Script Python Iyonix QuickFiler Game EfficientC
Like floating point, division is also emulated.
It’s implemented by two runtime library functions. In ARM’s tools they’re called:
__rt_sdiv
for signed values.__rt_udiv
for unsigned values.Slow:
It’s not always so bad for divisions by a constant:
Possible solutions:
Modulus is implemented by the same routine as division.