code wiki / _hdl_build / nx_emu_x86_segoff_test.nx
nx_emu_x86_segoff_test.nx
buildroot/runtime/_hdl_build/nx_emu_x86_segoff_test.nx
about
nx_emu_x86_segoff_test.nx -- x86 full-system ladder R5 rung-4: REAL-MODE SEGMENT:OFFSET ADDRESSING.
Real mode computes a physical address as phys = (segment << 4) + offset (segment*16 + offset).
This is how every boot-sector memory access works. KAT covers the canonical boot addresses
(0x07C0:0 = 0x7C00 boot load; 0xF000:0xFFF0 = 0xFFFF0 reset vector), a seg:off memory round-trip,
and the classic real-mode ALIASING (0000:0410 == 0040:0010 == phys 0x410).
HONEST SCOPE: the addressing model; the far-jump that flushes seg:off real mode into 32-bit
protected mode = R5 rung-5; full real-mode ISA = ongoing. No hardware writes (Rule 26).
expect_exit: 0 license_tier: ORIGINAL
dependencies 1 imports · 0 importers
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
structs
| none |
consts
| none |
functions
| 11 | func sg_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 12 | func sg_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 } |
| 15 | func x86_phys(seg: i64, off: i64) -> i64 { return (seg << 4) + off } called by 1: main |
| 17 | func sg_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 } called by 1: main |
| 18 | func sg_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 } called by 1: main |
| 20 | func main() -> i64 |