Menu
Coddy logo textTech

Why Hexadecimal?

Part of the Fundamentals section of Coddy's Assembly journey — lesson 10 of 45.

You now know that computers use binary. So why do assembly programmers rarely write binary directly?

The problem with binary:

Binary numbers are very long. Look at this example:

NumberBinary
25511111111
10001111101000
655351111111111111111

Writing long strings of 1s and 0s is slow, error-prone, and hard to read.

The solution: hexadecimal (base 16).

Hexadecimal (or "hex") uses 16 symbols:

DigitValue
0-90 to 9
A10
B11
C12
D13
E14
F15

Why hex is perfect for computers:

One hex digit represents exactly 4 bits (half a byte).

BitsHex digits needed
4 bits (nibble)1 hex digit
8 bits (1 byte)2 hex digits
16 bits (2 bytes)4 hex digits
32 bits (4 bytes)8 hex digits
64 bits (8 bytes)16 hex digits

Same number, three ways:

DecimalBinaryHexadecimal
25511111111FF
100011111010003E8
655351111111111111111FFFF

Notice how much shorter hex is than binary.

Where you will see hex in assembly:

  • Memory addresses (like 0x7FFF or 0x402000)
  • ASCII codes (like 0x41 for 'A', 0x0a for newline)
  • Register values in debuggers
  • Color values (like 0xFF0000 for red)

Hex is written with a prefix:

PrefixExampleMeaning
0x0xFFFF in hex (255 in decimal)
$$FFSame thing (used in some assemblers)
hFFhSame thing (older style)

In this course, we use 0x prefix: 0x0a, 0x41, 0xFF.

Try it yourself

This lesson doesn't include a code challenge.

quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals