Changing Hex in memory to Decimal on screen
Posted: Sat Dec 26, 2020 7:55 pm
Hi folks. I'm looking at my ASM code again and have came up against my next great challenge. Showing numbers on the screen in decimal even though the numbers stored in memory are in hex.
So I'm making labels like so:
which are going to then be printed on screen in decimal.
These numbers are going to be used in calculations and will change as the user presses up and down arrows depending on wither they are at the day, month or year selection.
My question is, how do I change a hex number into something I can then print on screen?
I was going to make some sort of equation that would then break things down and allocate the relevant hex number for the print char to print. I.e. &0b == Decimal 11 which would be broken into 1 and 1. I'd change that to &31 and &31, printing both (with the print char routine) out to give me 11 on screen.
Is this the correct way to go? maybe break it down using binary then compares depending on each nibble of the byte.
It'll get even more confusing when I get to the years.
I feel like this isn't going to be very efficient though.
So I'm making labels like so:
Code: Select all
;days
dayDate: db &0b
monthDate: db &04
yearDate: dw &0c73
These numbers are going to be used in calculations and will change as the user presses up and down arrows depending on wither they are at the day, month or year selection.
My question is, how do I change a hex number into something I can then print on screen?
I was going to make some sort of equation that would then break things down and allocate the relevant hex number for the print char to print. I.e. &0b == Decimal 11 which would be broken into 1 and 1. I'd change that to &31 and &31, printing both (with the print char routine) out to give me 11 on screen.
Is this the correct way to go? maybe break it down using binary then compares depending on each nibble of the byte.
It'll get even more confusing when I get to the years.
I feel like this isn't going to be very efficient though.