code wiki / _hdl_build / nx_emu_x86_modes_test.nx

nx_emu_x86_modes_test.nx

buildroot/runtime/_hdl_build/nx_emu_x86_modes_test.nx

7122 B98 linesdepth 4pulls 4 transitivereach 0 importersview sourcekind gate/prooftopic emu
docsdependenciesstructsconstsfunctions

about

nx_emu_x86_modes_test.nx -- x86 full-system ladder R5 rung-2: MODE MACHINERY IN EXECUTION. emu_x86_run_m = the R1-R4 decode + control registers CR0/CR3/EFER + the mode-transition instructions: 0F 22 (mov crX, r64) and 0F 30 (wrmsr -> EFER, simplified to EFER; full ecx-dispatch is a refinement). The emu tracks the LIVE cpu mode (real/protected/long) via the R5-1 rule and exposes the final CR/mode state. KAT: PE -> protected, then EFER.LME + CR0.PG -> LONG. HONEST SCOPE: still 64-bit-encoded driver code; emulating the actual 16/32-bit REAL-MODE boot entry that issues these = R5 rung-3. No hardware writes (Rule 26). expect_exit: 0 license_tier: ORIGINAL

dependencies 1 imports · 0 importers

nx_emu_x86_k.nx nx_emu_x86_modes_test.nx

imports: nx_emu_x86_k.nx

imported by: nobody (leaf or entry point)

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

main md_puts md_b md_i32 emu_x86_run_m md_mode k_i32 k_st64 k_ld64 md_num

structs

none

consts

none

functions

10func md_b(c: *u8, o: i64, b: i64) -> i64 { c[o]=(b & 0xff) as u8; return o+1 }
called by 1: main
11func md_i32(c: *u8, o: i64, v: i64) -> i64 { c[o]=(v&0xff) as u8; c[o+1]=((v>>8)&0xff) as u8; c[o+2]=((v>>16)&0xff) as u8; c[o+3]=((v>>24)&0xff) as u8; return o+4 }
called by 1: main
12func md_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
13func md_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
15func md_mode(pe: i64, pg: i64, lme: i64) -> i64 { if pe==0 { return 0 } if pg==1 { if lme==1 { return 2 } } return 1 }
called by 1: emu_x86_run_m
18func emu_x86_run_m(code: *u8, len: i64, mem: *u8, st: *i64) -> i64
called by 1: main calls 4: md_modek_i32k_st64k_ld64
62func main() -> i64