Hi!
If I have these bytes: $32 $36 $30 $31 which represent the value 2601.
How can I convert it to the corresponding hex value: $0A29
Convert number in ascii to hex value
- ahenry3068
- Posts: 1194
- Joined: Tue Apr 04, 2023 9:57 pm
Re: Convert number in ascii to hex value
What language are you using ?
Re: Convert number in ascii to hex value
Assembly ca65
- ahenry3068
- Posts: 1194
- Joined: Tue Apr 04, 2023 9:57 pm
Re: Convert number in ascii to hex value
In BASIC You use VAL(String$)
So A= VAL("2601")
Then in Numeric format 2601 and your Hex value are the same.
To represent it as HEX again you would use HEX$(A)
So A= VAL("2601")
Then in Numeric format 2601 and your Hex value are the same.
To represent it as HEX again you would use HEX$(A)
- ahenry3068
- Posts: 1194
- Joined: Tue Apr 04, 2023 9:57 pm
- ahenry3068
- Posts: 1194
- Joined: Tue Apr 04, 2023 9:57 pm
Re: Convert number in ascii to hex value
I couldn't find one .. I think you need to get on Discord and ask this question in ASM-DEV. I really don't know enough about assembly yet to help. I know how its done in High level language. I was hoping I could find a ROM call for you.
Re: Convert number in ascii to hex value
An example based on the above article:
https://github.com/stefan-b-jakobsson/x ... r/util.inc
The function util_str_to_bcd converts a NULL terminated ASCII/PETSCII string to Binary Coded Decimal format.
And the function util_bcd_to_bin converts a BCD value to a binary number that the 65c02 can use
https://github.com/stefan-b-jakobsson/x ... r/util.inc
The function util_str_to_bcd converts a NULL terminated ASCII/PETSCII string to Binary Coded Decimal format.
And the function util_bcd_to_bin converts a BCD value to a binary number that the 65c02 can use