Assembly works on raw numbers, and those numbers show up in three bases: decimal (how we think), binary (how the hardware actually stores everything), and hexadecimal (how we read it without going cross-eyed). You will rarely write binary by hand, but you read hex constantly — every address, opcode, and memory dump is hex.
A base is just how many symbols you count with before carrying. Decimal uses ten (0–9), binary two (0–1), hex sixteen (0–9 then a–f). The same quantity, three ways:
| Decimal | Binary | Hex |
|---|---|---|
| 10 | 0000 1010 | 0x0a |
| 16 | 0001 0000 | 0x10 |
| 42 | 0010 1010 | 0x2a |
| 255 | 1111 1111 | 0xff |
Hex earns its place because of one tidy fact: one hex digit is exactly four bits (a nibble), so two hex digits are exactly one byte. Hex is nothing more than binary grouped into readable chunks — 0xff is 1111 1111 at a glance, where decimal 255 tells you nothing about the bits. That is why machine code is always shown in hex.
A bit is one binary digit; eight bits make a byte. x86 has its own names for larger groupings, and you will see them as operand-size keywords throughout the course:
| Name | Bits | Bytes | Hex digits |
|---|---|---|---|
| byte | 8 | 1 | 2 |
| word | 16 | 2 | 4 |
| dword | 32 | 4 | 8 |
| qword | 64 | 8 | 16 |
The oddity: on x86 a "word" is 16 bits, not the machine's natural 64. That is a historical leftover from the 16-bit 8086, and the names stuck — "dword" (double word) is 32, "qword" (quad word) is 64.
The CPU does not store a separate "is negative" flag on a value — the same bits are read as signed or unsigned depending on the instruction. The scheme for signed values is two's complement: the top bit is the sign, and to negate a number you invert every bit and add one.
For a single byte, that gives:
| Bits | Hex | Unsigned | Signed |
|---|---|---|---|
0000 0001 | 0x01 | 1 | 1 |
0111 1111 | 0x7f | 127 | 127 |
1000 0000 | 0x80 | 128 | −128 |
1111 1111 | 0xff | 255 | −1 |
So 0xff is both 255 and −1 — the bits are identical; only the interpretation differs. This is why a value "wrapping around" to a huge number and a value going slightly negative look the same in a register, and why picking the wrong signed/unsigned comparison is such a common bug.
A hex dump shows raw bytes as hex, usually with an ASCII column alongside. xxd is the standard tool. Every ELF binary — including the hello we built — begins with a four-byte magic number that identifies the format:
xxd -l 16 hello00000000: 7f45 4c46 0201 0100 0000 0000 0000 0000 .ELF............7f 45 4c 46 is that magic: 0x7f followed by the ASCII codes for E, L, F (shown in the right-hand column as .ELF). Being able to read a dump like this — hex on the left, meaning on the right — is a skill you will use in every reverse-engineering and exploitation task.