Add a deterministic free-list heap for generated programs. heap_init accepts
an explicit page-aligned base and page count, so heap placement remains
independent of the still-open generated-program map. Blocks use a four-byte
header (total size with bit 15 allocated, and a next pointer that is a magic
value while allocated), two-byte payload alignment, first-fit allocation with
splitting, payload zeroing, address-ordered free insertion, and coalescing.
heap_free validates range, size, the used magic, and double-free; validation
is always on rather than a separately compiled debug build. A bounded x128
fixture exercises allocation, zeroing, splitting, coalescing, a multi-block
stress pass, double-free and corrupt-header detection, and exhaustion without
damaging live allocations. The fixture maps exhaustion to stable R005 through
flt_report; wiring new to the heap is E05-S03.
src/runtime/heap.s, src/common/heap.inc (new)tests/runtime/heap-test.s (new)scripts/build-heap-test.ps1, scripts/verify-heap-test.ps1 (new)docs/decisions.md, docs/architecture.md, docs/memory-map.mdplanning/claims/E05-S01.mdbuild/heap-test/$4000-$4FFF under CR $0E, not a
final generated-program map.HEAP_ERR_* on exhaustion; the test calls flt_report to demonstrate the
stable R005 path, while E05-S03 owns new integration.heap.s/heap.inc with an explicit page-granular region, first-fit
splitting, payload zeroing, sorted free insertion, coalescing, and always-on
validation.$4000-$4FFF; code ends at $28C4.JMP.heap_zero branched to its tail path
before loading A=0, so payload bytes were not zeroed. Fixed by loading A=0
at the tail entry, then reran successfully.scripts/build-heap-test.ps1 (link ends at $28C4)scripts/verify-heap-test.ps1 (x128 3.10)git diff --check$FA, code 5, address
$4000, and all eight phase flags 01; the screen shows
NOVA128 HEAP TEST, HEAP OK, RUNTIME FAULT R005. It verified allocation,
zeroing, first-fit splitting, sorted insertion, repeated coalescing, the
16-block stress/free cycle, double-free rejection, corrupt-magic rejection,
exhaustion without damaging live patterns, and return to 4096 free bytes.src/runtime/heap.s, src/common/heap.inc,
tests/runtime/heap-test.s, scripts/build-heap-test.ps1,
scripts/verify-heap-test.ps1, docs/decisions.md, docs/architecture.md,
docs/memory-map.md, this claim.HEAP_ERR_OOM
is returned to the caller, not automatically reported; E05-S03 owns the
new/R005 integration. Banked heaps remain deferred.Powered by TurnKey Linux.