Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Near-misses

A function that compiles to almost the original's bytes is a near-miss. Of about 2,100 functions, 1,915 match exactly, 176 are near-misses (nearly always only register allocation), and 37 are written portably in place of the original's assembly.

uv run near-misses [files…] sorts them by comparing what the two versions compute: operations, branch conditions, calls and constants, counted and normalised so equivalent forms look alike, plus which stack slots have their addresses taken.

ClassMeaningAction
allocation onlythe same computations; different registers or frame slotsusually fine
frame layouta local whose address is taken sits elsewherecheck sizes: a too-small buffer would overrun
needs a lookthe tool lists what each version computes that the other doesn'treview by hand

Most "needs a look" entries are equivalent forms the tool doesn't recognise (16-bit arithmetic, lea for add, a view's body computed in place at +0x30, offsets from a cached base). The review pays off in real bugs: a decompiled function that sets midi->looping where the original sets audioObj::looping, a 1-byte local where the original's DOS IOCTL block was 2 bytes (which overwrote the saved frame pointer in the rebuilt game), and switch bodies swapped between cases all showed up as near-misses first. So review any near-miss with more than allocation differences before trusting it.

The reason for matching at all is the same: a function that matches byte for byte cannot hide a mistake.