code wiki / _hdl_build / lmprobe_lm004.nx

lmprobe_lm004.nx source

↩ module page · 22 lines · 1122 B

1// lmprobe_lm004.nx -- LANDMINE PROBE for LM-004 "negative literals as 0 - N (unary-minus literal landmine)". 2// CONTRACT: exit 0 => ROOT-FIXED (a unary-minus literal now parses and evaluates identically to the 3// 0 - N workaround); non-zero OR build-failure => STILL LIVE. If the landmine is intact this file is 4// expected to FAIL TO BUILD -- that is itself the STILL-LIVE verdict, not an inconclusive result. 5// license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0 6import "nx_syscalls.nx" 7import "nx_estr.nx" 8 9func main() -> i64 { 10 var bad: i64 = 0 11 let a: i64 = -5 12 if a != (0 - 5) { bad = 1 } 13 let b: i64 = -1 14 if b != (0 - 1) { bad = 1 } 15 // negative literal in expression position, and as a call argument 16 if (0 - 7) != -7 { bad = 1 } 17 if es_catn(sys_mmap(32), 0, -42) != 3 { bad = 1 } // "-42" is 3 bytes: sign handling downstream 18 if bad == 1 { es_puts("LM-004 STILL-LIVE (unary-minus literal wrong)\n" as *u8); sys_exit(1); return 1 } 19 es_puts("LM-004 ROOT-FIXED (unary-minus literal == 0 - N in decl, expr and arg position)\n" as *u8) 20 sys_exit(0) 21 return 0 22}