code wiki / (root) / nx_x86.nx

nx_x86.nx

buildroot/runtime/nx_x86.nx

15942 B405 linesdepth 0pulls 0 transitivereach 4 importersview sourcekind librarytopic x86
docsdependenciesstructsconstsfunctions

about

nx_x86.nx -- Implements a 16-bit real-mode x86 CPU skeleton for running COM-style programs and DOS interrupts.

dependencies 0 imports · 4 importers

nx_x86.nx nx_x86_dos_gate.nx nx_x86_dosfs_gate.nx nx_x86_gate.nx nx_x86_modrm_gate.nx

imports: none

imported by: nx_x86_dos_gate.nxnx_x86_dosfs_gate.nxnx_x86_gate.nxnx_x86_modrm_gate.nx

structs

none

consts

2const O_MAGIC_65536: i64 = 65536
3const O_MAGIC_65535: i64 = 65535
14const O_MEM: i64 = 0 // 65536 guest bytes (one real-mode segment)
15const O_REGS: i64 = 65536 // 8 GP regs (i64, hold 16-bit values) -> 65600
16const O_IP: i64 = 65600
17const O_ZF: i64 = 65608
18const O_CF: i64 = 65616
19const O_SF: i64 = 65624
20const O_MM: i64 = 65632 // 4-i64 ModR/M decode scratch (reg, is_reg, ea) -- avoids per-step alloc
21const O_CON: i64 = 65664 // 4096-byte console output buffer (DOS INT 21h writes here)
22const O_CON_LEN: i64 = 69760 // console length cursor
23const O_EXIT: i64 = 69768 // set by INT 21h AH=4Ch (program terminate)
24const O_FSNAME: i64 = 69776 // Nishi-DOS sovereign FS: one file's name (ASCIIZ)
25const O_FSLEN: i64 = 69792 // its byte length
26const O_FSDATA: i64 = 69800 // its bytes (up to 4096)
27const O_HOPEN: i64 = 73896 // 8 file-handle open flags
28const O_HPOS: i64 = 73960 // 8 file-handle byte positions

functions

30func x86_reset(base: i64) -> i64
called by 4: mainmainmainmain
49func x86_load(base: i64, addr: i64, byte: i64) -> i64
56func x86_setzsf(base: i64, res: i64) -> i64
called by 1: x86_step
65func x86_rd16(base: i64, ea: i64) -> i64
69func x86_wr16(base: i64, ea: i64, v: i64) -> i64
called by 1: x86_rm_set
75func x86_peek16(base: i64, addr: i64) -> i64 { return x86_rd16(base, addr) } // gate/IO read
called by 2: mainmain calls 1: x86_rd16
79func x86_modrm(base: i64, ip: i64, mm: *i64) -> i64
called by 1: x86_step
117func x86_rm_get(base: i64, mm: *i64) -> i64
called by 1: x86_step calls 1: x86_rd16
121func x86_rm_set(base: i64, mm: *i64, v: i64) -> i64
called by 1: x86_step calls 1: x86_wr16
128func x86_set_r8(base: i64, r: i64, v: i64) -> i64
called by 1: x86_step
136func x86_fs_put(base: i64, name: *u8, data: *u8, len: i64) -> i64
called by 1: main
149func x86_fs_nameeq(base: i64, off: i64) -> i64
called by 1: x86_dos_int21
164func x86_dos_int21(base: i64) -> i64
called by 1: x86_step calls 1: x86_fs_nameeq
230func x86_con_len(base: i64) -> i64 { let c: *i64 = (base + O_CON_LEN) as *i64; return c[0] }
called by 2: mainmain
231func x86_con_byte(base: i64, i: i64) -> i64 { let con: *u8 = (base + O_CON) as *u8; return con[i] as i64 }
called by 2: mainmain
234func x86_step(base: i64) -> i64
392func x86_run(base: i64, cap: i64) -> i64
called by 4: mainmainmainmain calls 1: x86_step
401func x86_reg(base: i64, r: i64) -> i64 { let regs: *i64 = (base + O_REGS) as *i64; return regs[r & 7] }
called by 3: mainmainmain
402func x86_ip(base: i64) -> i64 { let ipp: *i64 = (base + O_IP) as *i64; return ipp[0] }
403func x86_zf(base: i64) -> i64 { let z: *i64 = (base + O_ZF) as *i64; return z[0] }
called by 1: main
404func x86_cf(base: i64) -> i64 { let c: *i64 = (base + O_CF) as *i64; return c[0] }
405func x86_sf(base: i64) -> i64 { let s: *i64 = (base + O_SF) as *i64; return s[0] }