code wiki / (root) / nx_emu_loongarch64_main.nx

nx_emu_loongarch64_main.nx source

↩ module page · 17 lines · 642 B

1// nx_emu_loongarch64_main.nx -- CLI for NX-EMU loongarch64: load + run a 2// static LA64 ELF. Usage: nx_emu_loongarch64 <prog.elf> (exit = guest exit). 3// Nishi CARRIES loongarch64 on its own interpreter -- NO qemu (qemu = bench). 4// license_tier: ORIGINAL 5 6import "nx_emu_loongarch64.nx" 7import "nx_syscalls_x86_64.nx" 8 9func main(argc: i64, argv: *i64) -> i64 { 10 if argc < 2 { return 200 } 11 let path: *u8 = argv[1] as *u8 12 let lenbox: *i64 = sys_mmap(16) as *i64 13 let buf: *u8 = sys_read_file_x86_64(path, lenbox) 14 if (buf as i64) == 0 { return 201 } 15 let r: i64 = emu_loongarch64_load_elf(buf, lenbox[0]) 16 return r 17}