Notation
Last updated:
A couple of conventions that show up everywhere in the rest of the book.
Hexadecimal
$10 and 0x10 is hexadecimal for the same number, 16 in decimal.
In this book I prefer $<number> since it's one character instead of two.
In most low-level programming, $10 is an address (decimal 16). Here it can
be an address or a value — it depends on context.
0x is the C-style prefix; both just mean "read what follows as hex". In a
language like C or Zig you'd write:
int value = 0x10; // C
const value = 0x10; // Zig
0-based vs 1-based
Mostly for beginners.
When we say "byte 0," we mean the first byte, and viceversa.
- Counting positions from 0 is 0-based;
- Counting from 1 is 1-based.
A common snag:
- There are 256 bytes between
$00and$ff. - But
$ffis 255 in decimal, not 256. - Decimal 256 is
0x100.
Assume first means byte $0 unless stated otherwise — though some things
really are 1-based. It's annoying at first, but you get used to it.