feat(v4): HEAT-OP[0..31] and ANTICLOCK, read by HEAT-OP@ and ANTICLOCK@

#189 -- Captain Bob, 2026-11-12: "Add HEAT-OP. If it's a huge performance
hit, we'll revert it. If not ... it stands"; a full 33-cell array, as
DECOMPOSITION.md section 7 draws it; the Stadium feed is Phase 1's.

- node.h/node.c: v4_node_heat_regs_attach; a data fetch from base+k gives
  opcode k's count, base+32 the anti-clock (the low cell at 32 bits); a
  store changes nothing. Reset detaches them.
- host_map.h: HEAT_REG at word 13824, in what was free between the
  dictionary space and SEND_TEXT; the compile-time check covers it.
  Nothing moved. map-*.f18: HEAT-OP 13824, ANTICLOCK 13856.
- image.h/image.c/mkmap.c: the image carries the address; v4_image_born
  attaches the node's own counts.
- system.f18: HEAT-OP@ ( op -- n ), op mod 32; ANTICLOCK@ ( -- n ).
  word_count 318 -> 320 (hosted 317 -> 319): dict_hash changes.
- v4-dictionary.tsv: both words; DECOMPOSITION.md 7 records the build.

Also in this batch:
- Makefile: make init installs qemu-user -- hosted-check needs it
  (Captain Bob: "Add to make init now").
- .claude/memory/rules.md, rule 5: stop and ask when something comes up
  (Captain Bob: "you are supposed to stop and ask").

Tests first (logs/20261113-005047/heat-op): test_node did not compile;
test_host_quit 3 of 1337 failed. Suite: 199 programs, 7448554 checks, 0
failures; hosted-check, the three alike. Timing: no measurable cost.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
This commit is contained in:
Claude
2026-11-13 00:50:56 +00:00
parent 9710bd1779
commit dd6c393a89
21 changed files with 163 additions and 5 deletions
+1
View File
@@ -21,6 +21,7 @@ int v4_image_born(v4_node *n, v4_exec_state *es, v4_heat *h, const v4_image *im)
v4_node_console_input_attach(n, im->console_rx, im->console_status);
v4_node_stack_regs_attach(n, im->dstack_reg, im->rstack_reg);
v4_node_error_attach(n, im->node_error);
v4_node_heat_regs_attach(n, im->heat_reg, h->op, &es->anticlock);
v4_node_fault_attach(n, im->fault_table);
return 1;
}
+22
View File
@@ -21,10 +21,27 @@ void v4_node_reset(v4_node *n)
v4_node_console_input_attach(n, -1, -1);
v4_node_fault_attach(n, -1);
v4_node_stack_regs_attach(n, -1, -1);
v4_node_heat_regs_attach(n, -1, 0, 0);
v4_node_error_attach(n, -1);
v4_node_port_attach(n, -1);
}
void v4_node_heat_regs_attach(v4_node *n, v4_cell base, const v4_uheat_t *op, const v4_uheat_t *anticlock)
{
n->heat_reg = (op && anticlock) ? base : -1;
n->heat_op = op;
n->heat_anticlock = anticlock;
}
/* Which heat register addr is, 0 .. 32, or -1: none (detached, or another address). */
static int heat_reg_index(const v4_node *n, v4_cell addr)
{
v4_ucell k;
if (n->heat_reg < 0) return -1;
k = (v4_ucell)addr - (v4_ucell)n->heat_reg;
return k < (v4_ucell)V4_HEAT_REGS ? (int)k : -1;
}
void v4_node_error_attach(v4_node *n, v4_cell addr)
{
n->error_reg = addr;
@@ -121,6 +138,7 @@ void v4_node_store(v4_node *n, v4_cell addr, v4_cell value)
/* The stack registers: a store empties the stack. -1 when not attached. */
if (addr == n->dstack_reg) { v4_dstack_clear(&n->ds); return; }
if (addr == n->rstack_reg) { v4_rstack_clear(&n->rs); return; }
if (heat_reg_index(n, addr) >= 0) return; /* HEAT-OP and ANTICLOCK are read-only */
if (!v4_node_addr_ok(addr)) return;
n->mem[(unsigned)addr] = value;
/* NODE-ERROR: a non-zero code raises an error. -1 when not attached. */
@@ -161,6 +179,10 @@ v4_cell v4_node_fetch(v4_node *n, v4_cell addr)
}
if (addr == n->dstack_reg) return (v4_cell)n->ds.depth;
if (addr == n->rstack_reg) return (v4_cell)n->rs.depth;
{
int k = heat_reg_index(n, addr);
if (k >= 0) return (v4_cell)(v4_ucell)(k < 32 ? n->heat_op[k] : *n->heat_anticlock);
}
return v4_node_load(n, addr);
}