Quiz Entry - updated: 2026.07.14
How can you tell whether a value fits in a register of a given size?
Check whether the number lies within that width's representable range — and remember the signed and unsigned ranges differ.
Each width holds a fixed span of values; overflow is what happens when you exceed it.
| Size | Unsigned range | Signed range |
|---|---|---|
| 8-bit | 0 … 255 | −128 … 127 |
| 16-bit | 0 … 65,535 | −32,768 … 32,767 |
| 32-bit | 0 … ~4.29 billion | ±~2.15 billion |
| 64-bit | 0 … 2⁶⁴−1 | −2⁶³ … 2⁶³−1 |
The subtle trap in x86-64 is that immediate operands in instructions are 32-bit sign-extended, which interacts badly with large unsigned constants:
mov $0x7FFFFFFF, %eax # fine — fits in 32-bit signed
mov $0x80000000, %eax # OK into %eax, but as a 64-bit immediate it
# would sign-extend to 0xFFFFFFFF80000000!
movabs $0x80000000, %rax # use movabs for an exact 64-bit immediate
Tip: movl into a 32-bit register zero-extends the result, but an immediate encoded in an instruction is sign-extended — two different rules that are easy to confuse.
Go deeper:
Two's complement (Wikipedia) — the signed and unsigned representable ranges per bit-width.