code wiki / _hdl_build / nx_constidx_probe.nx
nx_constidx_probe.nx source
↩ module page · 28 lines · 816 B
1// nx_constidx_probe.nx -- MINIMAL REPRODUCER: index a const *u8 directly.
2// Paired with nx_constidx_ctrl.nx, which is byte-identical EXCEPT it copies the literal into a local `let`
3// first. If probe FAILS and ctrl BUILDS, the defect is isolated to CONST[i] with nothing else varying.
4// license_tier: ORIGINAL No hw writes (Rule 26).
5import "nx_syscalls.nx"
6
7const CP_S: *u8 = "abc" as *u8
8const CP_N: i64 = 3
9
10func cp_sum() -> i64 {
11 var t: i64 = 0
12 var i: i64 = 0
13 while i < CP_N {
14 t = t + (CP_S[i] as i64)
15 i = i + 1
16 }
17 return t
18}
19
20func main(argc: i64, argv: *i64) -> i64 {
21 let v: i64 = cp_sum()
22 if v == 294 {
23 sys_write(1, "CONSTIDX-PROBE ok sum=294\n" as *u8, 26)
24 return 0
25 }
26 sys_write(1, "CONSTIDX-PROBE WRONG-SUM\n" as *u8, 24)
27 return 1
28}