forth: LSHIFT/RSHIFT + 32-bit arith truncation + early binding (Hayes 174→268)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled

This commit is contained in:
2026-04-24 22:26:58 +00:00
parent 387a6e7f5d
commit 8e1466032a
7 changed files with 143 additions and 45 deletions

View File

@@ -82,7 +82,7 @@ Representation:
- [x] `CHAR`, `[CHAR]`, `KEY`, `ACCEPT`
- [x] `BASE` manipulation: `DECIMAL`, `HEX`
- [x] `DEPTH`, `SP@`, `SP!`
- [ ] Drive Hayes Core pass-rate up
- [x] Drive Hayes Core pass-rate up
### Phase 5 — Core Extension + optional word sets
- [ ] Full Core + Core Extension
@@ -99,6 +99,23 @@ Representation:
_Newest first._
- **Phase 4 close — LSHIFT/RSHIFT, 32-bit arith truncation, early
binding; Hayes 174→268 (42%).** Added `LSHIFT` / `RSHIFT` as logical
shifts on 32-bit unsigned values, converted through
`forth-to-unsigned`/`forth-from-unsigned`. All arithmetic
primitives (`+` `-` `*` `/` `MOD` `NEGATE` `ABS` `1+` `1-` `2+`
`2-` `2*` `2/`) now clip results to 32-bit signed via a new
`forth-clip` helper, so loop idioms that rely on `2*` shifting the
MSB out (e.g. Hayes' `BITS` counter) actually terminate.
Changed colon-def call compilation from late-binding to early
binding: `forth-compile-call` now resolves the target word at
compile time, which makes `: GDX 123 ; : GDX GDX 234 ;` behave
per ANS (inner `GDX` → old def, not infinite recursion). `RECURSE`
keeps its late-binding thunk via the new `forth-compile-recurse`
helper. Raised `MAX_CHUNKS` default to 638 (full `core.fr`) now
that the BITS and COUNT-BITS loops terminate. Hayes: 268 pass /
368 error / 2 fail.
- **Phase 4 — `SP@`/`SP!` (+4; Hayes unchanged; `DEPTH` was already present).**
`SP@` pushes the current data-stack depth (our closest analogue to a
stack pointer — SX lists have no addressable backing). `SP!` pops a