code wiki / _hdl_build / nx_emu_x86_mode_test.nx

nx_emu_x86_mode_test.nx

buildroot/runtime/_hdl_build/nx_emu_x86_mode_test.nx

2723 B37 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind gate/prooftopic emu
docsdependenciesstructsconstsfunctions

about

nx_emu_x86_mode_test.nx -- x86 full-system ladder R5 rung-1: the MODE-TRANSITION RULE. x86 boots in 16-bit REAL mode; CR0.PE=1 -> 32-bit PROTECTED; CR0.PG=1 + EFER.LME=1 -> 64-bit LONG. This encodes + verifies that state rule (the heart of the boot mode sequence). HONEST SCOPE: this is the rule as a logic function; wiring it into the emu's control-register decode (0F 22 mov cr0, 0F 30 wrmsr) and emulating the 16/32-bit real-mode boot code that drives it = R5 rung-2+ (the substantial part). No hardware writes (Rule 26). expect_exit: 0 license_tier: ORIGINAL

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_emu_x86_mode_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 md_puts sys_write x86_mode md_putn sys_mmap sys_write ↻ sys_exit

structs

none

consts

9const X86_REAL: i64 = 0
10const X86_PROTECTED: i64 = 1
11const X86_LONG: i64 = 2

functions

13func 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 calls 1: sys_write
14func md_putn(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
17func x86_mode(pe: i64, pg: i64, lme: i64) -> i64
called by 1: main
23func main() -> i64