code wiki / _hdl_build / nx_sitegate_emit_lib.nx

nx_sitegate_emit_lib.nx source

↩ module page · 10 lines · 933 B

1// nx_sitegate_emit_lib.nx -- shared emit helpers (gw / gn / t_row) for the site & sweep gate organs, 2// extracted from the ~24 byte-identical copies funcmine surfaced (rule 15). Verbatim bodies -> behaviour- 3// preserving by construction (compile-clean = identical machine code). license_tier: ORIGINAL No hw writes. 4import "nx_syscalls.nx" 5func gw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 6func gn(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)} let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1} sys_write(1,bb,k); return 0 } 7func t_row(name: *u8, ok: i64, tot: *i64) -> i64 { 8 if ok == 1 { gw(" PASS " as *u8); tot[0]=tot[0]+1 } else { gw(" FAIL " as *u8); tot[1]=tot[1]+1 } 9 gw(name); gw("\n" as *u8); return 0 10}