I've just completed the first draft of various routines that convert numeric values to strings (to be used in "The Art of ARM Assembly, Volume 2").
This library includes the following conversions:
1. Various forms of 32-bit integer to hexadecimal string output.
2. Signed and unsigned 32-bit and 64-bit integer to decimal string output.
3. 64-bit double-precision floating-point to string output.
I've still got to write some code for 32-bit floating-point output.
And I've still got to write the string to numeric functions.
But I thought I'd put this out there for those who are interested.
This code compiles and runs on a Raspberry Pi (I've run and tested it on a Pi 400, though it should work fine on a Pi 3 or 4).
The optimizations I've done were specific to the Pi 400 (Cortex A73). YMMV on other platforms (such as the Pi 3).
The functions themselves are all Thumb code (T32). It should be *fairly* trivial to convert this code to run on a Cortex-M7 (e.g., Teensy 4). However, the floating-point code uses hardware FP instructions (double-precision), so a bit of work is necessary to convert the code to run on lesser CPUs.
Ignoring the hardware FP instructions, most of the code should be easy enough to port to Cortex-M3 and later CPUs. It will take a *lot* of work to get this code running on a Cortex-M0+ (think Raspberry Pi Pico or Arduino Zero) device. That will come later.
This code has appropriate make files to build under PiOS. At some point or another I will put together an example that builds on a Teensy 4 using the Arduino IDE.
I do have a bunch of 64-bit ARM functions that do the equivalent of these functions. That library is part of "The Art of ARM Assembly, Volume 1" which will probably be out early next year. I'll post the code as soon as the technical review of the book is done.
Note: updated 2023/08/20 to include single-precision floating-point conversion functions.
Note: update 2023/08/22 to include string to numeric conversion functions (32-bit and 64-bit integers, 32- and 64-bit floats).
Cheers,
Randy Hyde
Arm numeric to string conversions (updated 8/22/2023)
Arm numeric to string conversions (updated 8/22/2023)
- Attachments
-
- ao32aalib.zip
- (115.91 KiB) Downloaded 537 times