Weisse Spuren
Surprisingly different, surprisingly effective ./design2013/header-t1-4_web.png

Hacker's Delight, by Henry S. Warren, Jr., describes a number of algorithms useful for resource-sensitive computing. Among them is a method for using a multiply instruction to implement division by a constant. There are a number of reasons why this can be useful in embedded devices, some of which do not have a divide instruction (e.g. Arm Cortex-M0). Even when a divide instruction is available, it might be undesirable, either because it is relatively slow or because the execution time is variable in a context where stable execution time is required. Even with high-performance non-embedded processors, the divide instruction might not be wanted, as explained by Matt Godbolt's lecture, "What has my compiler done for me lately? Unbolting the compiler's lid".

In fact, this algorithm is so effective that many compilers use it, silently transforming "x / 9u" into "( x * 0x38E38E39uLL ) >> 33", which can surprise the unsuspecting user while debugging. They see a division at the C source level but a multiplication in the disassembly view.

However, some of our favourite embedded compilers do not do this and so it can be useful to explicitly encode, at the C source level, the implementation using multiplication. This web page allows you to specify either signed or unsigned division by a given constant and applies the algorithm to derive the appropriate C code. The C code is intended for use with a multiply machine instruction that takes two 32-bit operands and provides convenient access to the upper 32 bits of the 64-bit result.

$$q = {n \over d}$$

$n$ type:    

$d =$

Newsbox Oben
GLIWA goes YouTube
Our brand new videos provide concrete and entertaining insights into the functions and advantages of the various components of the T1 Analysis Suite.

GLIWA providing fundamental
knowledge besides outstanding

The practice-oriented, book on methodology and analysis of embedded software timing. Numerous case studies help to avoid tricky problems, facilitate optimal use of processor resources and give many hints to secure correct runtime behavior.

Edited by Springer. Available as printed edition and eBook. Take a closer look here.
Now also available in Korea and China!
Peter Gliwa's coveted book was recently published in Korea and – in cooperation with the highly recognized Tsinghua University of Beijing – will also be available on the Chinese book market.

To find out more about T1 or to arrange a free presentation, just call:
+49 881 138522-70

T1 supports TC39x
Synchronized traces from 6 cores!
T1 makes it happen. Click here, to view a screenshot of T1 with 6 synchronized traces and some cross-core communications.


More details on the AURIX 2G can be found in Infineon's official press-release.
Newsbox Unten