#2734 - Saj - Tue Feb 11, 2003 5:46 pm
Hi, I'm studying C/C++ to become a programmer. I want to learn some assembly to stop myself from using classes that other people have written. (i.e. I want to personally speak to mr arm processor and tell him he better display my sprite!)
Anyways, My question is : Do I need to practice Hex to fully understand assembly?
I ask this because I read things like;
Quote: |
The map starts at x(hex adress) and is x(size in hex) bytes long. |
Question again : Do I need to fully understand hex(convert hex in my head) to fully understand assembly?
Thanks :)
#2737 - DekuTree64 - Tue Feb 11, 2003 6:30 pm
Well, you don't have to, but it's very handy. Like, the address of ROM data on GBA is 0x8000000, which is pretty easy to remember, but in decimal that's 134217728. And you can just use hex for things that are easier that way, and then decimal for the rest. I've done some assembly coding, and I can't convert hex in my head without some time (and a paper if it's a very big number). Unless of course if it's something simple like 0x100, which I instantly see as 256.
#2743 - tepples - Tue Feb 11, 2003 7:04 pm
To become familiar enough with hexadecimal numerals to understand memory maps, here's what you should concentrate on getting down pat:
1. Memorize powers of 2 up to 0x10000 (== 65536) in hex and decimal
2. Memorize three times powers of 2 up to 0xc000 (== 49152) in hex and decimal
3. Know how to convert numbers up to 0x60 (== 96) between hex and decimal
4. Know how to multiply and divide by 2 in hex
5. Know how to multiply and divide by 0x400 (== 1024) in hex to convert bytes to kilobytes
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#2744 - jeff - Tue Feb 11, 2003 8:09 pm
One reason that HEX is so useful, is because base 16 is a multiple of base 2.
In assembly (and C), you often want to do many things with bits, and this is where HEX can be more than helpful.
For example, let's say I have a 32-bit value, and only want the upper 16-bits:
x = x & 0xFFFF0000;
Since each hex digit is 4 bits, this was easy to figure out what value to use. Try that in decimal (4294901760).
Jeff
#2782 - Saj - Wed Feb 12, 2003 6:31 pm
WOW! All great answers!!
Thanks!!
I'll do a little practice every day till I get it.
plus- As I do more assembly tutorials & mini projects, I guess I'll become more familiar with hex values.
Thanks again for all your help. :)
#3284 - sketcher - Fri Feb 21, 2003 8:10 pm
It's also nice to think of it that every two digits in Hex makes up a byte in memory (given the standard 8 bit sized byte).
Hex is also great for compressing more data into a smaller space. If for example you wanted to create states for a character you could have 16 unique states per hex digit and do something like this 0x00FF00EA. Each place could hold different info while taking up a much smaller space than using a standard integer enumeration.
{top 2 digits represent character health
next 2 represent character class
next digit represents character team alliance
etc...}
You should realize this isn't just good for on the GBA either. GBA is just an obvious choice because it is such limited hardware. But data packing/compression is also important on high end hardware too. Think about networked games and the impact this can have on reducing your bandwidth over sending a bunch of integers!
_________________
"Oh yeah, so what kind of warrior are you? A code warrior? HAHAHA!"