ARM > Efficient C for ARM > Division and Modulus
Previous topic:
Floating Point
Next topic:
Unaligned Data Access
Blog RISC OS PrivateEye PhotoFiler IntroductionToARM Geminus Toolbar Site Containers GitHub Project Hardware iOS Optimisation Aha Retro Links Dump Spectrum Risc PC The Great Escape LEGO Wedding Acorn Doodle Blender 3D Isometric 2D Article ARM Sinclair Ocean Disassembly Chase H.Q. Tip TargetedOptimisation Trace Hard Disc Vector Archimedes Logo Recreation Pixel Art Groening Simpsons Futurama Disenchantment BBC Micro Electron BasicOptimisation Slide 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.