1. How do I convert ASCII input ( 1234567890abcdef) to Hex?
I mean, something like this : input - 64 (ascii) and convert to 064h ( hex) ?
Hi,
Well you will start by deciding how you input your
ASCII hexadecimal string. (One character at a time or
a complete string?) Then convert an ASCII character to
a binary value. For example you could use a lookup table.
; - - - ReadInput - - -
HEX2BIN DB 48 DUP (-1), 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 6 DUP (-1)
DB -1, 10, 11, 12, 13, 14, 15, 9 DUP(-1), 16 DUP(-1)
DB -1, 10, 11, 12, 13, 14, 15, 9 DUP(-1), 16 DUP(-1)
DB 128 DUP(-1)
Here valid hexadecimal ASCII codes are converted to
binary and invalid codes are minus one.
You can also convert codes with a compare and modify
algorithm if you prefer.
Then convert another digit to binary, multiply one value
by sixteen and add the two values to get a binary byte
value. More or less repeat, as needed, for word or double
word values.
Cheers,
Steve N.