code wiki / _hdl_build / nx_emu_x86_rm16_test.nx

nx_emu_x86_rm16_test.nx

buildroot/runtime/_hdl_build/nx_emu_x86_rm16_test.nx

3745 B60 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind gate/prooftopic emu
docsdependenciesstructsconstsfunctions

about

nx_emu_x86_rm16_test.nx -- x86 full-system ladder R5 rung-3: 16-bit REAL-MODE decode. The CPU boots in 16-bit real mode (operand size 16, NO REX prefix, different opcodes). This is a minimal real-mode interpreter for the boot-stub subset: B8+r iw mov r16, imm16 (B8=ax B9=cx BA=dx BB=bx ...) 89 /r mov r/m16, r16 (mod=11 reg-reg) 01 /r add r/m16, r16 (16-bit wrap) F4 hlt (stop) KAT: a real-mode stub computes ax = 40 + 2 = 42 then hlts. HONEST SCOPE: this minimal subset; the full real-mode ISA + segment:offset addressing + the far-jump that flushes into protected mode = further R5 work (then R6 paging, R7 devices, R8 kernel boot). No hardware writes (Rule 26). expect_exit: 0 license_tier: ORIGINAL

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_emu_x86_rm16_test.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main r16_puts sys_write sys_mmap r16_b r16_iw emu_x86_run_16 r16_num sys_mmap ↻ sys_write ↻ sys_exit

structs

none

consts

none

functions

14func r16_b(c: *u8, o: i64, b: i64) -> i64 { c[o]=(b & 0xff) as u8; return o+1 }
called by 1: main
15func r16_iw(c: *u8, o: i64, v: i64) -> i64 { c[o]=(v&0xff) as u8; c[o+1]=((v>>8)&0xff) as u8; return o+2 }
called by 1: main
16func r16_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 1: main calls 1: sys_write
17func r16_num(v: i64) -> i64 { let b: *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{b[i]=t[k-1-i];i=i+1} sys_write(1,b,k); return 0 }
called by 1: main calls 2: sys_mmapsys_write
20func emu_x86_run_16(code: *u8, len: i64, reg16: *i64) -> i64
called by 1: main
34func main() -> i64