Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Austrian Coder

Conver e.g. 0x16004360 into something readable

This topic is 5202 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Not really. I need a Hex2Ascii konverter. I am working on a linux driver and i want know to readout all hardware registers. For instance, a return value of an register can be: 0x01d5

Now i want to check, if such a value contains an usefull info like an number or an letter.

PS: Found one: http://www.programmersheaven.com/zone3/cat415/30033.htm

Now the next problem: a hex counter. It is very hard for me to do such things, because i nerver worked if hex's.

[edited by - Austrian Coder on April 20, 2004 6:44:59 PM]

Share this post


Link to post
Share on other sites
char hexDigits[16] = {''0'', ''1'', ''2'', ''3'', ''4'', ''5'', ''6'', ''7'', ''8'', ''9'', ''A'', ''B'', ''C'', ''D'', ''E'', ''F''};

void HexToAscii(unsigned char c)
{
cout << "0x" << hexDigits[c >> 4]
<< hexDigits[c & 0x0F];
}

void HexToAscii(unsigned short s)
{
cout << "0x" << hexDigits[s >> 12]
<< hexDigits[(s >> 8) & 0x0F]
<< hexDigits[(s >> 4) & 0x0F]
<< hexDigits[s & 0x0F]
}

void HexToAscii(unsigned int i)
{
cout << "0x" << hexDigits[i >> 28]
<< hexDigits[(i >> 24) & 0x0F]
<< hexDigits[(i >> 20) & 0x0F]
<< hexDigits[(i >> 16) & 0x0F]
<< hexDigits[(i >> 12) & 0x0F]
<< hexDigits[(i >> 8) & 0x0F]
<< hexDigits[(i >> 4) & 0x0F]
<< hexDigits[i & 0x0F]
}

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!