So I am taking an assembly language course and I am stuck on this problem from the book:
Using the windows 32 console (so I have an io.h
to use), I am supposed to t
If you need to convert a character (for simplicity, say, in upper case) representing a hex digit into the value of that digit you need to do this:
IF char >= 'A'
value = char - 'A' + 10
ELSE
value = char - '0'
ENDIF
If you need to do the reverse, you do the reverse:
IF value >= 10
char = value - 10 + 'A'
ELSE
char = value + '0'
ENDIF
Here you exploit the fact that the ASCII characters 0
through 9
have consecutive ASCII codes and so do the ASCII characters A
through F
.