code wiki / (root) / nxasm_arm64_enc.nx

nxasm_arm64_enc.nx

buildroot/runtime/nxasm_arm64_enc.nx

11597 B224 linesdepth 0pulls 0 transitivereach 1 importersview sourcekind librarytopic nxasm
docsdependenciesstructsconstsfunctions

about

nxasm_arm64_enc.nx -- sovereign aarch64 (A64) instruction encoder + ELF writer, written in NishiLang. The aarch64 sibling of nxasm_x86_enc.nx (x86_64) and asm_enc.nx (RV64). All A64 instructions are fixed 32-bit, emitted little-endian. Pure bit-manipulation -- no syscalls in the encode functions (arch-neutral, KAT-able under any lane). Each encoder returns the 32-bit word; the ELF writer + a64_put_u32le handle emission. Validated byte-exact vs the ARM A64 ISA (Arm ARM DDI 0487) -- the spec is the oracle (per the externals-as-oracle cardinal); golden words are cross-checked against canonical forms (mov x0,x1=0xAA0103E0, mul x2,x0,x1=0x9B017C02, sdiv x0,x1,x2=0x9AC20C20, ldr x0,[x1,#8]=0xF9400420). genealogy_id: arm_a64_isa_ddi0487 + osdev_elf lineage_id: nishi_sovereign_aarch64_encoder_m6 license_tier: ORIGINAL

dependencies 0 imports · 1 importers

nxasm_arm64_enc.nx nx_arm64_e2e_test.nx

imports: none

imported by: nx_arm64_e2e_test.nx

structs

none

consts

19const A64_XZR: i64 = 31
20const EM_AARCH64: i64 = 183 // 0xB7
21const A64_BASE: i64 = 0x10000
22const A64_HDRLEN: i64 = 120 // 64 ehdr + 56 one phdr

functions

25func a64_put_u32le(out: *u8, o: i64, w: i64) -> i64
32func a64_put_u64le(out: *u8, o: i64, v: i64) -> i64
called by 1: a64_build_elf
39func a64_enc_movz(sf: i64, Rd: i64, imm16: i64, hw: i64) -> i64
called by 2: maina64_mov_imm64
42func a64_enc_movn(sf: i64, Rd: i64, imm16: i64, hw: i64) -> i64
45func a64_enc_movk(sf: i64, Rd: i64, imm16: i64, hw: i64) -> i64
called by 1: a64_mov_imm64
51func a64_mov_imm64(out: *u8, o: i64, Rd: i64, imm: i64) -> i64
63func a64_enc_add_imm(sf: i64, Rd: i64, Rn: i64, imm12: i64, sh: i64) -> i64
called by 2: maina64_enc_sub_imm
66func a64_enc_sub_imm(sf: i64, Rd: i64, Rn: i64, imm12: i64, sh: i64) -> i64
called by 1: a64_enc_subs_imm calls 1: a64_enc_add_imm
69func a64_enc_subs_imm(sf: i64, Rd: i64, Rn: i64, imm12: i64, sh: i64) -> i64
called by 1: a64_enc_cmp_imm calls 1: a64_enc_sub_imm
72func a64_enc_cmp_imm(sf: i64, Rn: i64, imm12: i64) -> i64
77func a64_enc_add_shifted(sf: i64, Rd: i64, Rn: i64, Rm: i64, shift: i64, imm6: i64) -> i64
80func a64_enc_sub_shifted(sf: i64, Rd: i64, Rn: i64, Rm: i64, shift: i64, imm6: i64) -> i64
83func a64_enc_subs_shifted(sf: i64, Rd: i64, Rn: i64, Rm: i64) -> i64
called by 1: a64_enc_cmp_reg calls 1: a64_enc_sub_shifted
86func a64_enc_cmp_reg(sf: i64, Rn: i64, Rm: i64) -> i64
called by 1: main calls 1: a64_enc_subs_shifted
91func a64_enc_orr_shifted(sf: i64, Rd: i64, Rn: i64, Rm: i64, shift: i64, imm6: i64) -> i64
called by 1: a64_enc_mov_reg
94func a64_enc_and_shifted(sf: i64, Rd: i64, Rn: i64, Rm: i64) -> i64
97func a64_enc_eor_shifted(sf: i64, Rd: i64, Rn: i64, Rm: i64) -> i64
100func a64_enc_mov_reg(sf: i64, Rd: i64, Rm: i64) -> i64
105func a64_enc_madd(sf: i64, Rd: i64, Rn: i64, Rm: i64, Ra: i64) -> i64
called by 1: a64_enc_mul
108func a64_enc_mul(sf: i64, Rd: i64, Rn: i64, Rm: i64) -> i64
calls 1: a64_enc_madd
112func a64_enc_div(sf: i64, Rd: i64, Rn: i64, Rm: i64, is_signed: i64) -> i64
119func a64_enc_csinc(sf: i64, Rd: i64, Rn: i64, Rm: i64, cond: i64) -> i64
called by 1: a64_enc_cset
122func a64_enc_cset(sf: i64, Rd: i64, cond: i64) -> i64
calls 1: a64_enc_csinc
129func a64_enc_shiftv(sf: i64, Rd: i64, Rn: i64, Rm: i64, op2: i64) -> i64
137func a64_enc_ldst_reg(size: i64, L: i64, Rt: i64, Rn: i64, Rm: i64) -> i64
142func a64_enc_ldr_uimm(size: i64, Rt: i64, Rn: i64, imm12: i64) -> i64
145func a64_enc_str_uimm(size: i64, Rt: i64, Rn: i64, imm12: i64) -> i64
153func a64_enc_sturldur(L: i64, Rt: i64, Rn: i64, imm: i64) -> i64
156func a64_enc_stur(Rt: i64, Rn: i64, imm: i64) -> i64 { return a64_enc_sturldur(0, Rt, Rn, imm) }
157func a64_enc_ldur(Rt: i64, Rn: i64, imm: i64) -> i64 { return a64_enc_sturldur(1, Rt, Rn, imm) }
163func a64_enc_ldstp(idx: i64, L: i64, Rt: i64, Rt2: i64, Rn: i64, imm: i64) -> i64
167func a64_enc_stp_pre(Rt: i64, Rt2: i64, Rn: i64, imm: i64) -> i64 { return a64_enc_ldstp(3, 0, Rt, Rt2, Rn, imm) }
calls 1: a64_enc_ldstp
168func a64_enc_ldp_post(Rt: i64, Rt2: i64, Rn: i64, imm: i64) -> i64 { return a64_enc_ldstp(1, 1, Rt, Rt2, Rn, imm) }
calls 1: a64_enc_ldstp
169func a64_enc_stp_off(Rt: i64, Rt2: i64, Rn: i64, imm: i64) -> i64 { return a64_enc_ldstp(2, 0, Rt, Rt2, Rn, imm) }
calls 1: a64_enc_ldstp
170func a64_enc_ldp_off(Rt: i64, Rt2: i64, Rn: i64, imm: i64) -> i64 { return a64_enc_ldstp(2, 1, Rt, Rt2, Rn, imm) }
calls 1: a64_enc_ldstp
173func a64_enc_b(off: i64) -> i64
176func a64_enc_bl(off: i64) -> i64
179func a64_enc_bcond(cond: i64, off: i64) -> i64
called by 1: main
182func a64_enc_cbz(sf: i64, Rt: i64, off: i64) -> i64
called by 1: a64_enc_cbnz
185func a64_enc_cbnz(sf: i64, Rt: i64, off: i64) -> i64
calls 1: a64_enc_cbz
188func a64_enc_ret() -> i64 { return 0xD65F03C0 }
189func a64_enc_br(Rn: i64) -> i64 { return 0xD61F0000 | ((Rn & 0x1F) << 5) }
190func a64_enc_blr(Rn: i64) -> i64 { return 0xD63F0000 | ((Rn & 0x1F) << 5) }
191func a64_enc_svc0() -> i64 { return 0xD4000001 }
called by 1: main
196func a64_build_elf(code: *u8, code_len: i64, out: *u8) -> i64