code wiki / _hdl_build / nx_emu_x86_k.nx
nx_emu_x86_k.nx
buildroot/runtime/_hdl_build/nx_emu_x86_k.nx
about
nx_emu_x86_k.nx -- x86 full-system ladder R4: the CONSOLIDATED kernel-subset x86-64 interpreter
(a reusable LIB; stops the per-rung duplication of R1-R3). Instruction set so far:
R1: mov imm/reg, shl, add, sub, syscall(write/exit)
R2: ZF/SF flags, cmp(48 39), jmp(EB), je(74), jne(75)
R3: 64-bit memory load/store via ModRM mod=00 base-indirect (48 89 store / 48 8B load)
R4: a STACK + push(50+r)/pop(58+r) + call(E8 rel32)/ret(C3) == real FUNCTION CALLS
Caller passes a `mem` region (RAM + stack live here; rsp = reg[4]). FLAT decode (nx_cc-friendly).
HONEST SCOPE: still flat 64-bit long-mode-ish execution; privilege modes (R5), IDT/paging (R6),
devices (R7), boot (R8+) are later rungs. No hardware writes (Rule 26). license_tier: ORIGINAL
dependencies 1 imports · 4 importers
imports: nx_syscalls_x86_64.nx
imported by: nx_emu_x86_boot_kernel_test.nxnx_emu_x86_k_test.nxnx_emu_x86_modes_test.nxnx_nishi_diskimg_test.nx
structs
| none |
consts
| none |
functions
| 12 | func k_i32(code: *u8, off: i64) -> i64 |
| 17 | func k_st64(mem: *u8, addr: i64, v: i64) -> i64 { var i: i64=0; while i<8 { mem[addr+i]=((v>>(i*8)) & 0xff) as u8; i=i+1 } return 0 } |
| 18 | func k_ld64(mem: *u8, addr: i64) -> i64 { var v: i64=0; var i: i64=0; while i<8 { v = v | ((mem[addr+i] as i64) << (i*8)); i=i+1 } return v } |
| 20 | func emu_x86_run_k(code: *u8, len: i64, mem: *u8) -> i64 |