code wiki / _hdl_build / nx_sbroot_probe.nx
nx_sbroot_probe.nx source
↩ module page · 34 lines · 1384 B
1// nx_sbroot_probe.nx -- minimal repro for the portable-root reader. Diagnose, do not guess.
2// license_tier: ORIGINAL expect_exit: 0
3import "nx_suitebench_lib.nx"
4const K_MAGIC_65536: i64 = 65536
5
6func p_w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
7func p_n(v: i64) -> i64 {
8 let bb: *u8=sys_mmap(28); var m: i64=v
9 if m<0 { m=0-m; sys_write(1,"-" as *u8,1) }
10 let t: *u8=sys_mmap(28); var k: i64=0
11 if m==0 { t[0]=48 as u8; k=1 }
12 while m>0 { t[k]=(48+(m%10)) as u8; m=m/10; k=k+1 }
13 var i: i64=0
14 while i<k { bb[i]=t[k-1-i]; i=i+1 }
15 sys_write(1,bb,k); return 0
16}
17func main() -> i64 {
18 let scratch: *u8 = sys_mmap(512)
19 let buf: *u8 = sys_mmap(K_MAGIC_65536)
20 let path: *u8 = "knowledge/registry/suitebench.axes" as *u8
21
22 let bare: i64 = sb_read(path, buf, K_MAGIC_65536)
23 p_w("bare sb_read = " as *u8); p_n(bare); p_w("\n" as *u8)
24
25 let jl: i64 = sb_join(scratch, sb_root(0), path)
26 p_w("join(root0) len = " as *u8); p_n(jl); p_w(" -> [" as *u8); p_w(scratch); p_w("]\n" as *u8)
27 let viajoin: i64 = sb_read(scratch, buf, K_MAGIC_65536)
28 p_w("read(joined) = " as *u8); p_n(viajoin); p_w("\n" as *u8)
29
30 let rooted: i64 = sb_read_rooted(path, buf, K_MAGIC_65536, scratch)
31 p_w("sb_read_rooted = " as *u8); p_n(rooted); p_w("\n" as *u8)
32 sys_exit(0)
33 return 0
34}