Table of Contents

IronForgeCyber

Courses

Resources

Blog

Log In



IronForgeCyber

AboutPrivacyTerms

© 2026 IronForgeCyber. All rights reserved.

  1. courses
  2. asm-101
  3. binary
3 min read

Binary & Hex

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.

Number Bases

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:

DecimalBinaryHex
100000 10100x0a
160001 00000x10
420010 10100x2a
2551111 11110xff

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.

Bits, Bytes, and Words

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:

NameBitsBytesHex digits
byte812
word1624
dword3248
qword64816

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.

Signed Numbers

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:

BitsHexUnsignedSigned
0000 00010x0111
0111 11110x7f127127
1000 00000x80128−128
1111 11110xff255−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.

Reading Hex Dumps

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
$ 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.

Notice the bytes are laid out left to right in the order they sit in the file. When those bytes encode a multi-byte number, x86 stores them in reverse — least-significant byte first. That is endianness, and it gets the full worked treatment in Memory.