0

hi all ,...
iam making a simple disk editor , and i need a methode that
convert from ascii to Hex representation
thank u all

2
Contributors
2
Replies
4
Views
11 Years
Discussion Span
Last Post by abee
0

hi all ,...
iam making a simple disk editor , and i need a methode that
convert from ascii to Hex representation
thank u all

Easy enough. Just look at your ASCII chart...

You will need the characters '0' thru '9' they are ASCII values 48 ($30) thru 57 ($39).

If you want lower case, then 'a' thru 'f' are 97 ($61) thru 102 ($66).

If you want upper, then 'A' thru 'F' are 65 ($41) thru 70 ($46).

When you get a byte of data, just divide it down the middle -- this gives you two nibbles. Take a nibble, add the value 48 ($30) to it, then check to see if it is larger than 57 ($39) - if it isn't, then you've got your ASCII representation for that nibble; if it is, then you add (97 - 57) or (65 - 57) to it to get your ASCII representation for that nibble.

Hope this helps!

Nathan.

0

hi Nathan..
thank u for ur kind replay , and although i figured it out and completed my disk editor program , i want to thank u for ur interest.
and i hope we can meet agian in other arguments.
thank u
abee

Easy enough. Just look at your ASCII chart...

You will need the characters '0' thru '9' they are ASCII values 48 ($30) thru 57 ($39).

If you want lower case, then 'a' thru 'f' are 97 ($61) thru 102 ($66).

If you want upper, then 'A' thru 'F' are 65 ($41) thru 70 ($46).

When you get a byte of data, just divide it down the middle -- this gives you two nibbles. Take a nibble, add the value 48 ($30) to it, then check to see if it is larger than 57 ($39) - if it isn't, then you've got your ASCII representation for that nibble; if it is, then you add (97 - 57) or (65 - 57) to it to get your ASCII representation for that nibble.

Hope this helps!

Nathan.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.