Please support our Assembly advertiser: Programming Forums
Views: 5747 | Replies: 2
![]() |
•
•
•
•
Originally Posted by abee
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.
while (CPU is present) {some assembly required}
•
•
Join Date: May 2006
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 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
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
•
•
•
•
Originally Posted by Evenbit
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.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)





Linear Mode