**EDITED TO ADD: for all those who are new like me, exploring this world, please see the forum thread where some of the more experienced coders here have pointed out some really useful Kernal routines which take the pain out of this!!
Hi all! As I journey towards 6502 mastery (LOL), this demo explores floating point numbers and how they are stored and managed in binary. It borrows heavily from others' code to achieve what I was struggling to do from first principles, and I am grateful to all the YouTubers, bloggers and hobbyists out there who have kindly shared their work in this area.
This particular routine takes a binary floating point number stored in memory and displays it on the screen in a human-readable decimal format. It also dumps some of the memory addresses involved so you can have a look under the hood.
Some functions include:
Displays the floating point number stored in MSB, NMSB, NLSB, LSB and BEXP as a decimal number on screen (PETSCII string)
Memory dump. Shows paired bytes at the address, looping for MemDumpLen addresses (default=8)
If you click try it now, you can poke around in memory to change the starting parameters of the programme. For example, to change the most significant byte of the mantissa, POKE $080E,XX and to change the binary exponent, POKE $081E,XX then type RUN again to see the results.
FLTTODEC was adapted by me for the specific hardware of the Commander X16 from Jeff Tranter's code, who in turn adapted it for CC65 from the original appearing in Compute! issues 9 and 11, 1981 by Marvin L. De Jong.
Jeff's Blog: https://jefftranter.blogspot.com/