code wiki / _hdl_build / nx_t_intprint.nx

nx_t_intprint.nx source

↩ module page · 22 lines · 950 B

1// nx_t_intprint.nx -- MINIMAL nxasm bisection probe (W-keystone diagnosis). 2// In ONE binary: a string write (control; proven to work via nxasm/_orch_probe) 3// + an integer print via modulo/divide (the suspect). If nxasm prints "str_ok" 4// but the integer is empty/garbage, the encoder defect is isolated to idiv/modulo. 5// license_tier: ORIGINAL 6import "nx_syscalls.nx" 7 8func pr_n(v: i64) -> i64 { 9 let b: *u8 = sys_mmap(28); var m: i64 = v; let t: *u8 = sys_mmap(28); var k: i64 = 0 10 if m == 0 { t[0] = 48 as u8; k = 1 } 11 while m > 0 { t[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } 12 var i: i64 = 0 13 while i < k { b[i] = t[k - 1 - i]; i = i + 1 } 14 sys_write(1, b, k); return 0 15} 16 17func main() -> i64 { 18 sys_write(1, "str_ok=" as *u8, 7) // CONTROL: string write (expect prints) 19 pr_n(42) // SUSPECT: idiv/modulo (expect "42") 20 sys_write(1, "\n" as *u8, 1) 21 sys_exit(0); return 0 22}