1 Commits

Author SHA1 Message Date
carlos 54b64ca09f recomp_types: POP32 into esp leaves esp at the popped value
POP32 assigned dst before adding 4 to sp, so a lifted `pop esp` left esp
at the popped value + 4. The SDM has POP ESP load esp with the value read
from the old top of stack. Spartan: Total Warrior's round-to-int helper
(push esp; push eax; fld; frndint; fistp [esp]; pop eax; pop esp)
returned with esp off by 4, which put a garbage edi into a heap free.
POP32 now reads into a temporary, bumps sp, then writes dst; every other
destination behaves as before, and -O3 code is the same size.

Tests: the new ctest tests/stack_ops runs the lifter's emitted stack
statements (push/pop esp, the round-to-int idiom, an ordinary pop,
push/pop [esp+4], leave, pushad/popad) over a fake guest stack; the old
macro fails its three pop-esp checks. docs/pipeline/04-lifting.md and
docs/technical/register-model.md show the new macro.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 05:19:29 -07:00