nx_x86.nx
buildroot/runtime/nx_x86.nx
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
imports: none
imported by: nx_x86_dos_gate.nxnx_x86_dosfs_gate.nxnx_x86_gate.nxnx_x86_modrm_gate.nx
structs
| none |
consts
| 2 | const O_MAGIC_65536: i64 = 65536 |
| 3 | const O_MAGIC_65535: i64 = 65535 |
| 14 | const O_MEM: i64 = 0 // 65536 guest bytes (one real-mode segment) |
| 15 | const O_REGS: i64 = 65536 // 8 GP regs (i64, hold 16-bit values) -> 65600 |
| 16 | const O_IP: i64 = 65600 |
| 17 | const O_ZF: i64 = 65608 |
| 18 | const O_CF: i64 = 65616 |
| 19 | const O_SF: i64 = 65624 |
| 20 | const O_MM: i64 = 65632 // 4-i64 ModR/M decode scratch (reg, is_reg, ea) -- avoids per-step alloc |
| 21 | const O_CON: i64 = 65664 // 4096-byte console output buffer (DOS INT 21h writes here) |
| 22 | const O_CON_LEN: i64 = 69760 // console length cursor |
| 23 | const O_EXIT: i64 = 69768 // set by INT 21h AH=4Ch (program terminate) |
| 24 | const O_FSNAME: i64 = 69776 // Nishi-DOS sovereign FS: one file's name (ASCIIZ) |
| 25 | const O_FSLEN: i64 = 69792 // its byte length |
| 26 | const O_FSDATA: i64 = 69800 // its bytes (up to 4096) |
| 27 | const O_HOPEN: i64 = 73896 // 8 file-handle open flags |
| 28 | const O_HPOS: i64 = 73960 // 8 file-handle byte positions |
functions
| 30 | func x86_reset(base: i64) -> i64 |
| 49 | func x86_load(base: i64, addr: i64, byte: i64) -> i64 |
| 56 | func x86_setzsf(base: i64, res: i64) -> i64 called by 1: x86_step |
| 65 | func x86_rd16(base: i64, ea: i64) -> i64 |
| 69 | func x86_wr16(base: i64, ea: i64, v: i64) -> i64 called by 1: x86_rm_set |
| 75 | func x86_peek16(base: i64, addr: i64) -> i64 { return x86_rd16(base, addr) } // gate/IO read |
| 79 | func x86_modrm(base: i64, ip: i64, mm: *i64) -> i64 called by 1: x86_step |
| 117 | func x86_rm_get(base: i64, mm: *i64) -> i64 |
| 121 | func x86_rm_set(base: i64, mm: *i64, v: i64) -> i64 |
| 128 | func x86_set_r8(base: i64, r: i64, v: i64) -> i64 called by 1: x86_step |
| 136 | func x86_fs_put(base: i64, name: *u8, data: *u8, len: i64) -> i64 called by 1: main |
| 149 | func x86_fs_nameeq(base: i64, off: i64) -> i64 called by 1: x86_dos_int21 |
| 164 | func x86_dos_int21(base: i64) -> i64 |
| 230 | func x86_con_len(base: i64) -> i64 { let c: *i64 = (base + O_CON_LEN) as *i64; return c[0] } |
| 231 | func x86_con_byte(base: i64, i: i64) -> i64 { let con: *u8 = (base + O_CON) as *u8; return con[i] as i64 } |
| 234 | func x86_step(base: i64) -> i64 |
| 392 | func x86_run(base: i64, cap: i64) -> i64 |
| 401 | func x86_reg(base: i64, r: i64) -> i64 { let regs: *i64 = (base + O_REGS) as *i64; return regs[r & 7] } |
| 402 | func x86_ip(base: i64) -> i64 { let ipp: *i64 = (base + O_IP) as *i64; return ipp[0] } |
| 403 | func x86_zf(base: i64) -> i64 { let z: *i64 = (base + O_ZF) as *i64; return z[0] } called by 1: main |
| 404 | func x86_cf(base: i64) -> i64 { let c: *i64 = (base + O_CF) as *i64; return c[0] } |
| 405 | func x86_sf(base: i64) -> i64 { let s: *i64 = (base + O_SF) as *i64; return s[0] } |