Fast integer-to-string conversion (ARM32)
Posted: Wed Feb 28, 2024 9:50 pm
Attached are a couple of u32ToBuf/u32ToStr functions that convert a 32-bit unsigned value in R1 to a string of digits (stored at the location pointed at by R0).
One variant uses a "Radix-100" algorithm to process two output digits simultaneously. It includes a 200-byte lookup table to process pairs of characters for values in the range 0..99. The second version has a 40,000-byte lookup table and emits four characters simultaneously (0..9999). If you can live with the giant table, it's about 40% faster than the 2-character version.
One variant uses a "Radix-100" algorithm to process two output digits simultaneously. It includes a 200-byte lookup table to process pairs of characters for values in the range 0..99. The second version has a 40,000-byte lookup table and emits four characters simultaneously (0..9999). If you can live with the giant table, it's about 40% faster than the 2-character version.