What's new

A little help with Converting Hex

Maxim Dude

Banned
Ok, well, I have converting Binary to Hex to Decimal and back again, but what I would like to know is converting Hex to Letters (A-Z), like in translating games, or something to that purpose. I'm not sure if all Hex can convert to is numbers or not, so this might be a worthless post, but I'm trying to learn ASM (Which is very complex, but very interesting for me), so I figure I should take it one step at a time.

Any help? Also, any resources you could point me to for ASM would be nicely appreciated, thanks :)
 

refraction

PCSX2 Coder
posting it once is enough, you dont need to post 3 times to get an answer, you just get a bollocking off the admin.

anyway use google to search for "HEX to ASCII" all your answers lie there.
 

bcrew1375

New member
If you are referring to games as in ROMs, they almost always do not use the ASCII standard. Sometimes the text is even compressed. If the text is uncompressed, you can decipher its table by using relative search. There are plenty of programs that will do this for you. For instance, if you search for the text "HELLO", the search relative would search the ROM for the hex numbers "08 05 0C 0C 0F" If it doesn't find that, it would search for "09 06 0D 0D 10", then "0A 07 0E 0E 11" and so on. Hex is already ASCII in a sense. It's just a matter of how you choose to display it. In C++ make two variables with the same hex value. Make one variable an int and make the other a char, and give them both a value of 0x41. Use cout to display them both. The int should should show the number 65(decimal) and the char should show a capital A.
 
Last edited:

BGNG

New member
Or, in Visual Basic, you can invoke a conversion from hexadecimal to decimal using the &H operator before the number, which is synonymous with 0x in C++. Using the Val function, which returns a number expressed by a String variable, you can convert a hex string to a decimal number by prefixing the string with "&H".

For example, let's say you have the hex number 3B stored in a String called W. By declaring a variable (let's say Integer named Q) and assigning it a value with the Val function, you can decode the hexadecimal in one step:

W = "3B"
Q = Val("&H" & W)


At the end, Q will be equal to 59.
__________

In addition, there is also the Hex function which returns a hexadecimal String for any numeric variable. So if you have Q equal to 59, you can convert it to hex as such:

Q = 59
W = Hex(Q)


Where W is a String variable. At the end, W will be equal to "3B"
 

Doomulation

?????????????????????????
Hehe, translating hex to decimal is pretty easy. You don't need it in Vb and it doesn't support shifting either, but in C...
It's very simple I discovered... just translate each letter in hex and shift it into position. Like this:

FF (15, 15) will be: (15 << 4) + 15 equals 255.
That's pretty neat... but still, you're banned, so can probably not read this.
 

BGNG

New member
Doomulation said:
You don't need it in Vb and it doesn't support shifting either[...]
And what if you're making an emulator, or calculator, or hex-dec-hex conversion utility? You're pretty good at making friends, aren't you?

And bit shifting is nothing more than multiplying or dividing by an exponent of 2. A mild speed hit, but not a big deal. (If speed REALLY matters in any given project, Visual Basic isn't the language of choice)... That is: 15 * 2 ^ 4 + 15 = 255
 

bcrew1375

New member
I don't think he wanted hex to decimal conversion. He wanted to know how to convert hex to letters. Like I said though, they are the same. It's just a matter of how you interpret it.
 

Doomulation

?????????????????????????
BGNG said:
And what if you're making an emulator, or calculator, or hex-dec-hex conversion utility? You're pretty good at making friends, aren't you?

And bit shifting is nothing more than multiplying or dividing by an exponent of 2. A mild speed hit, but not a big deal. (If speed REALLY matters in any given project, Visual Basic isn't the language of choice)... That is: 15 * 2 ^ 4 + 15 = 255
You misinterpret me. I mentioned you didn't need it in Vb because it has functions to convert hex to decimal already!
Yes I know shifting is possible through multiplication and division, but it's a little slower and a little more complicated and it isn't necessary on VB :)
 

Top