RSS Forums RSS
Please support our Assembly advertiser: Programming Forums
Views: 5747 | Replies: 2
Reply
Join Date: May 2006
Posts: 2
Reputation: abee is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
abee abee is offline Offline
Newbie Poster

Conversion from Ascii to Hex in ibm pc assembely

  #1  
May 1st, 2006
hi all ,...
iam making a simple disk editor , and i need a methode that
convert from ascii to Hex representation
thank u all
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Mar 2005
Posts: 99
Reputation: Evenbit is on a distinguished road 
Rep Power: 4
Solved Threads: 2
Evenbit's Avatar
Evenbit Evenbit is offline Offline
Junior Poster in Training

Re: Conversion from Ascii to Hex in ibm pc assembely

  #2  
May 4th, 2006
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}
Reply With Quote  
Join Date: May 2006
Posts: 2
Reputation: abee is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
abee abee is offline Offline
Newbie Poster

Re: Conversion from Ascii to Hex in ibm pc assembely

  #3  
May 4th, 2006
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

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.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 7:48 pm.
Newsletter Archive - Sitemap - Privacy Statement - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC