code wiki / _hdl_build / nx_feat_gate.nx

nx_feat_gate.nx source

↩ module page · 45 lines · 2614 B

1// nx_feat_gate.nx -- LIVE feat-axis micro-gate organ (v2.1 "feature completeness co-equal with speed"). 2// v1 wires the cl-shift landmine row as an EXECUTABLE check: emit a tiny .s whose correct assembly 3// exits 42 (84 >> 1 via sarq %cl -- the exact historically-mis-encoded form), run it through OUR 4// assembler, run the ELF, exit==42 -> row PASS. Appends a dated FEAT line to /tmp/nishi_ladder.log so 5// the tick/page publish it. Pattern: one row per snippet; corpus grows by adding snippets (data). 6// license_tier: ORIGINAL 7import "nx_syscalls.nx" 8 9func fg_w(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 } 10 11func fg_run(path: *u8, a1: *u8, a2: *u8) -> i64 { 12 let envp: *i64 = sys_mmap(32) as *i64 13 envp[0] = "PATH=/usr/bin:/bin" as *u8 as i64; envp[1] = 0 14 let av: *i64 = sys_mmap(40) as *i64 15 av[0] = path as i64; av[1] = a1 as i64; av[2] = a2 as i64; av[3] = 0 16 let pid: i64 = sys_fork() 17 if pid == 0 { sys_execve(path, av, envp); sys_exit(127) } 18 let st: *i64 = sys_mmap(16) as *i64 19 sys_wait4(pid, st, 0) 20 let sig: i64 = st[0] & 0x7f 21 if sig != 0 { return 128 + sig } 22 return (st[0] >> 8) & 0xff 23} 24 25func main() -> i64 { 26 // the snippet: exit code = 84 >> 1 = 42, THROUGH sarq %cl (the landmine form) 27 // movq $1,%rcx (not movb $1,%cl): nxasm's movb has NO imm->reg form (2026-06-10 catch -- 28 // and it mis-assembled SILENTLY into a segfaulting ELF; both filed as feat rows). %cl IS 29 // rcx's low byte, so this still gates sarq %cl exactly, in the emitter-realistic form. 30 let s: *u8 = " .text\n .globl _start\n_start:\n movq $84, %rax\n movq $1, %rcx\n sarq %cl, %rax\n movq %rax, %rdi\n movq $60, %rax\n syscall\n" as *u8 31 let fd: i64 = sys_openat_wr("/tmp/feat_clshift.s" as *u8, 0x1a4) 32 fg_w(fd, s); sys_close(fd) 33 let rca: i64 = fg_run("_offc/nxasm_x86_main.elf" as *u8, "/tmp/feat_clshift.s" as *u8, "/tmp/feat_clshift.elf" as *u8) 34 var rc: i64 = 0 - 1 35 if rca == 0 { rc = fg_run("/tmp/feat_clshift.elf" as *u8, 0 as *u8, 0 as *u8) } 36 let lfd: i64 = sys_openat_append("/tmp/nishi_ladder.log" as *u8, 0x1a4) 37 if rc == 42 { 38 fg_w(lfd, "FEAT rung=R1 row=asm-cl-shifts status=PASS gate=exit42-sarq-cl date=2026-06-10\n" as *u8) 39 fg_w(1, "feat-gate asm-cl-shifts: PASS (exit 42)\n" as *u8) 40 sys_close(lfd); sys_exit(0); return 0 41 } 42 fg_w(lfd, "FEAT rung=R1 row=asm-cl-shifts status=FAIL gate=exit42-sarq-cl date=2026-06-10\n" as *u8) 43 fg_w(1, "feat-gate asm-cl-shifts: FAIL\n" as *u8) 44 sys_close(lfd); sys_exit(1); return 1 45}