forth: SP@ / SP! (+4; Hayes 174/590)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled

This commit is contained in:
2026-04-24 21:07:10 +00:00
parent acf9c273a2
commit 387a6e7f5d
5 changed files with 42 additions and 3 deletions

View File

@@ -81,7 +81,7 @@ Representation:
- [x] `S"`, `C"`, `."`, `TYPE`, `COUNT`, `CMOVE`, `FILL`, `BLANK`
- [x] `CHAR`, `[CHAR]`, `KEY`, `ACCEPT`
- [x] `BASE` manipulation: `DECIMAL`, `HEX`
- [ ] `DEPTH`, `SP@`, `SP!`
- [x] `DEPTH`, `SP@`, `SP!`
- [ ] Drive Hayes Core pass-rate up
### Phase 5 — Core Extension + optional word sets
@@ -99,6 +99,13 @@ Representation:
_Newest first._
- **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
target depth and truncates the stack via `drop` on the dstack list.
This preserves the save/restore idiom `SP@ … SP!` even though the
returned "pointer" is really a count.
- **Phase 4 — `BASE`/`DECIMAL`/`HEX`/`BIN`/`OCTAL` (+9; Hayes unchanged).**
Moved `base` from its top-level state slot into `state.vars["base"]`
so the regular `@`/`!`/VARIABLE machinery works on it.