First code for StarForth v4 (JUSTIFICATION.md section 10, step 1): one node of the 32-instruction core as a C99 model, with cell width as a build parameter. - Node: P, A, B, F18 circular stacks (10 and 9 deep, D-2), word-addressed memory (D-1), 5% guard bands on every bounded list. - Instruction word: six 5-bit slots in 32 bits at every cell width. - Executor: all 32 opcodes of DECOMPOSITION.md 1.3. Cell arithmetic wraps explicitly; no signed overflow or implementation-defined shift. - Heat: per-opcode and per-call-target counters and the anti-clock, driven by instruction retirement (1.4, D-6 interim). - Slot packer and runner for tests, and a reference unsigned multiply in plain C99 with no 128-bit type. Tests run at 32- and 64-bit cells, and under ASan and UBSan. They cover every opcode and execute the first section 4 definitions (NIP SWAP OR NEGATE ROT 0< 0= 2DUP - U<) against the C operation each stands for. UM* as written in section 4 is exact only while u1 <= 2^(n-2). Two known failing cases are pinned in test_foundation.c until it is rewritten. DECOMPOSITION.md: record D-9, the instruction word is 32 bits at every cell width (ruled 2026-10-02). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
20 lines
771 B
C
20 lines
771 B
C
/* testcode.h -- run a word on a node, for tests. */
|
|
#ifndef V4_TESTCODE_H
|
|
#define V4_TESTCODE_H
|
|
|
|
#include "v4/exec.h"
|
|
|
|
/* Where a word called by v4_test_call returns to. Nothing is executed there:
|
|
* arriving is the stop condition. */
|
|
#define V4_TEST_HALT ((v4_cell)(V4_NODE_WORDS - 1u))
|
|
|
|
/* Call the word at `entry` as a caller would: push a return address, set P,
|
|
* and step instruction words until the word returns. The stacks and A, B are
|
|
* left as the caller set them, so arguments go on the data stack first.
|
|
* Returns the number of instruction words stepped, or -1 if the word had not
|
|
* returned after `max_words`. */
|
|
long v4_test_call(v4_node *n, v4_exec_state *es, v4_heat *h,
|
|
v4_cell entry, long max_words);
|
|
|
|
#endif /* V4_TESTCODE_H */
|