code wiki / (root) / nx_emu_loongarch64.nx

nx_emu_loongarch64.nx

buildroot/runtime/nx_emu_loongarch64.nx

6779 B143 linesdepth 3pulls 3 transitivereach 1 importersview sourcekind librarytopic emu
docsdependenciesstructsconstsfunctions

about

nx_emu_loongarch64.nx -- sovereign LoongArch64 (LA64) interpreter (NX-EMU). Flat 32 GPRs (r0==zero), little-endian, NO register windows, NO delay slots. Decode/execute pure NishiLang per the LoongArch ISA -- NO qemu (qemu-loongarch64 = differential BENCHMARK that must agree). How Nishi CARRIES loongarch64 execution (operator: nishi carries; externals=bench). Encodings (verified via objdump of the nxc2 la64 backend output): 3R (w&0xFFFF8000): add.d 0x00108000 sub.d 0x00118000 mul.d 0x001d8000 and 0x00148000 or 0x00150000 xor 0x00158000 sll.d 0x00188000 srl.d 0x00190000 sra.d 0x00198000 div.d 0x00220000 mod.d 0x00228000 2RI12 (w&0xFFC00000): addi.d 0x02c00000 ld.d 0x28c00000 st.d 0x29c00000 jirl (w&0xFC000000)==0x4C000000 (ret = jirl $zero,$ra,0) bl (w&0xFC000000)==0x54000000 (split offs26) syscall (w&0xFFFF8000)==0x002B0000 (a7=num, a0..=args; exit=93) license_tier: ORIGINAL

dependencies 1 imports · 1 importers

nx_syscalls_x86_64.nx nx_emu_loongarch64.nx nx_emu_loongarch64_main.nx

imports: nx_syscalls_x86_64.nx

imported by: nx_emu_loongarch64_main.nx

structs

none

consts

20const LA_MAGIC_200000000: i64 = 200000000
22const LA_GUEST_SIZE: i64 = 16777216
23const LA_SYS_READ: i64 = 63
24const LA_SYS_WRITE: i64 = 64
25const LA_SYS_EXIT: i64 = 93
26const LA_SYS_EXITG: i64 = 94
27const LAE_UNSUPPORTED: i64 = -1
28const LAE_FAULT: i64 = -3

functions

30func la_g_ld(mem: *u8, va: i64, width: i64) -> i64 { // little-endian
36func la_g_st(mem: *u8, va: i64, width: i64, val: i64) -> i64
41func la_rd(r: *i64, n: i64) -> i64 { if n == 0 { return 0 } return r[n] }
42func la_wr(r: *i64, n: i64, v: i64) -> i64 { if n != 0 { r[n] = v } return 0 }
44func emu_loongarch64_run_mem(mem: *u8, mem_size: i64, entry: i64, sp0: i64) -> i64
123func emu_loongarch64_load_elf(buf: *u8, len: i64) -> i64
called by 1: main calls 2: la_g_ldemu_loongarch64_run_mem