Hexadecimal

If you want to program in Assembly, you will need to know at least a little about the number base of hexadecimal (further written as "hex"). Hex consists of 16 digits, the numbers being 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f. The reason for this is that a byte is 8 bits long, so hex works very well for this purpose.

You ask: "How can I tell a hex number from any other number?"

The Answer: A hex number will either begin with a "$" or end with an "h". These are the universal symbols for hex.

In decimal, or base 10, you had a one's place, a ten's place, a hundred's place, and so on. Well, in hex, you have a one's place, a sixteen's place, a 256's place, and so on. An example of a binary number is such: $c3f8. This is the decimal equivalent of 50,168. To convert a hex number to decimal is not at all tricky, so I'll explain it to you.

In the number above ($c3f8) (and this works for all hex numbers) you count the number of places. The number above has 4. So that means that the far left number is equal to 4096 * whatever the number is, the next is equal to 256, and so on. To convert the hex number to decimal, just multiply the value of the place times the number there. So the conversion looks like:

4096 * c (12) + 256 * 3 + 16 * f (15) + 8 = 50,168

You ask: "How many different numbers can there be?"

The Answer: That number is the same as $ffff, or 4096 * 16, or 65,536.

In ASM you can also use the logical operators AND, OR, and XOR. These are nothing like the Boolean operators that come in the TI-86. These have a lot to do with ASM, and hex, but mainly binary so make sure that you know these, too.

Remember: If you get confused, read over the tutorial again, and if you get really confused, use your calculator, it can do these conversions for you!