Hello,
This is my first post so please bear with me if I'm missing any information. I've just started learning the ARM language and am using Keil microVision5 currently. At the minute, I'm not too familiar with how to use ASCII codes. I know
LDR r1, = '1' will store the ASCII code for '1', which is 31, into register 1.
R1 0x00000031. But how I do re convert this back to it's numeric value, '1'?
To put it simply, let's say I have a number, 108, and I store each of these integers into three separate registers. I want to store this number, 108, into a single register, r0.
LDR r1, '1' or 0x00000031 LDR r2, '0' or 0x00000030 LDR r3, '8' or 0x00000038
So r0 should be 0x0000006C.
Thank you
If you look at an ASCII table (aka "ASCII chart"), eg
http://www.asciitable.com/
https://www.ascii-code.com/
You will notice that the code for digit 'n' is the value of n plus 0x30
So the conversion between ASCII code and numeric vale is simply a matter of adding or subtracting 0x30 - that is, the ASCII code for '0'.
To convert a multi-digit string to/from its numeric value, just apply the appropriate place value (power of ten) to each digit...
Oh I see. Sounds like I asked a stupid question haha. Thank you very much.
View all questions in Keil forum