ASCII to Hexadecimal - ASM

587 Views Asked by At

Checked around and didn't see any already answered questions that help. So I know to take the ASCII character of '9' you can subtract 30h to get the hexadecimal value of 9h.

Now to get the hexidecimal value of the ASCII character of 'A', would you have to subtract 32h and then add 1d? Am I at all on the right track?

1

There are 1 best solutions below

0
On

When getting a number from its ASCII value, you can subtract 0x30

sub al, 0x30

... or simply and by 0x0F, if you're sure it's a number

and al, 0x0F

When getting a character from its ASCII value, you must refer to the ASCII intervals.

sub al, 0x41 ; for upper-case characters (0x41 - 0x5A)
sub al, 0x61 ; for lower-case characters (0x61 - 0x7A)