code wiki / (root) / nxasm_x86.nx

nxasm_x86.nx

buildroot/runtime/nxasm_x86.nx

65145 B1096 linesdepth 1pulls 1 transitivereach 27 importersview sourcekind librarytopic nxasm
docsdependenciesstructsconstsfunctions

about

nxasm_x86.nx -- sovereign x86_64 assembler (AT&T .s text -> machine code) in NishiLang. The x86_64 sibling of nxasm_v2.nx (RV64). Drives nxasm_x86_enc.nx. Two-pass: pass 1 records label addresses, pass 2 emits bytes resolving call/jmp/jcc displacements. Parses the exact surface nxc2 --target x86_64 emits: directives (.att_syntax/ .text/.globl/.type/.size/.section -- all metadata, ignored), labels (`name:` incl. `.Lxxx:`), and AT&T operands (%reg / $imm / disp(%base) / symbol). Replaces GNU `as` on the output path; gas is kept only as a byte-exact oracle (Wheeler/benchmark). genealogy_id: intel_sdm_vol2 + att_syntax + nxasm_v2_two_pass_spine lineage_id: nishi_sovereign_x86_64_assembler_m3 license_tier: ORIGINAL

dependencies 1 imports · 26 importers

nxasm_x86_enc.nx nxasm_x86.nx nx_pe_compile_win.nx nx_pe_compile_win_call.nx nx_pe_compile_win_dll.nx nx_pe_compile_win_fread.nx nx_pe_compile_win_gui.nx nx_pe_compile_win_halloc.nx nx_pe_compile_win_httpd.nx nx_pe_compile_win_index.nx nx_pe_compile_win_io.nx nx_pe_compile_win_iotcli.nx

diagram shows first 10 each side; +0 more imports, +16 more importers in the complete lists below.

imports: nxasm_x86_enc.nx

imported by: nx_pe_compile_win.nxnx_pe_compile_win_call.nxnx_pe_compile_win_dll.nxnx_pe_compile_win_fread.nxnx_pe_compile_win_gui.nxnx_pe_compile_win_halloc.nxnx_pe_compile_win_httpd.nxnx_pe_compile_win_index.nxnx_pe_compile_win_io.nxnx_pe_compile_win_iotcli.nxnx_pe_compile_win_mmap.nxnx_pe_compile_win_nishi.nxnx_pe_compile_win_organ.nxnx_pe_compile_win_sw.nxnx_pe_compile_win_table.nxnx_pe_compile_win_uiserve.nxnx_pe_compile_win_write.nxnx_pe_compile_win_wsa.nxnx_pe_dll_com_device.nxnx_pe_dll_d3d11.nxnx_pe_dll_d3d11ctx.nxnx_pe_dll_d3d11draw.nxnx_pe_dll_d3d11shade.nxnx_pe_dll_d3d11tex.nxnx_pe_dll_id3d11.nxnx_pe_natbw.nx

structs

none

consts

19const OP_KIND: i64 = 0
20const OP_REG: i64 = 1
21const OP_IMM: i64 = 2
22const OP_BASE: i64 = 3
23const OP_DISP: i64 = 4
24const OP_SYMOFF: i64 = 5
25const OP_SYMLEN: i64 = 6
26const OP_INDEX: i64 = 7 // SIB index reg (-1 = none); op arrays are mmap(72)=9 slots
27const OP_SCALE: i64 = 8 // SIB scale value {1,2,4,8}
28const K_REG: i64 = 0
29const K_IMM: i64 = 1
30const K_MEM: i64 = 2
31const K_XMM: i64 = 3 // an xmm-named register operand (distinct from a GPR so movq can pick the GPR<->xmm SSE form)
32const K_SYM: i64 = 3
33const K_NONE: i64 = 4
34const K_IND: i64 = 5
35const K_RIP: i64 = 6
40const ASM_MAX_LABELS: i64 = 65536
321const ASM_LH_SIZE: i64 = 262144 // 2^18 = 4x ASM_MAX_LABELS load<=25%
322const ASM_LH_MASK: i64 = 262143

functions

43func axc_is_space(c: i64) -> i64
48func axc_is_digit(c: i64) -> i64
52func axc_is_ident(c: i64) -> i64
62func axc_cstr_len(s: *u8) -> i64
called by 1: axc_tok_is
69func axc_tok_is(src: *u8, off: i64, len: i64, lit: *u8) -> i64
81func axc_slice_eq(src: *u8, a: i64, alen: i64, b: i64, blen: i64) -> i64
92func axc_reg_num(src: *u8, off: i64, len: i64) -> i64
called by 1: axc_parse_operand calls 1: axc_tok_is
175func axc_parse_int(src: *u8, pos: *i64, le: i64) -> i64
197func axc_parse_operand(src: *u8, pos: *i64, le: i64, op: *i64) -> i64
300func axc_label_find(src: *u8, lab_off: *i64, lab_len: *i64, lab_addr: *i64,
calls 1: axc_slice_eq
324func axc_lh_hash(src: *u8, off: i64, len: i64) -> i64
336func axc_lh_build(src: *u8, lab_off: *i64, lab_len: *i64, n_lab: i64, lh: *i64) -> i64
357func axc_label_find_h(src: *u8, lab_off: *i64, lab_len: *i64, lab_addr: *i64,
378func axc_label_resolve(src: *u8, lab_off: *i64, lab_len: *i64, lab_addr: *i64,
called by 1: axc_emit calls 1: axc_label_find_h
391func axc_alu(out: *u8, op0: *i64, op1: *i64, rr_op: i64, imm_ext: i64) -> i64
called by 1: axc_emit calls 2: x86_alu_immx86_alu_rr
397func axc_jcc_cc(src: *u8, off: i64, len: i64) -> i64
called by 1: axc_emit calls 1: axc_tok_is
408func axc_setcc_cc(src: *u8, off: i64, len: i64) -> i64
called by 1: axc_emit calls 1: axc_tok_is
420func axc_cmovcc_cc(src: *u8, off: i64, len: i64) -> i64
called by 1: axc_emit calls 1: axc_tok_is
436func x86_atomic_rm(out: *u8, is0f: i64, opcode: i64, reg: i64, base: i64) -> i64
called by 1: axc_emit
448func x86_mfence_enc(out: *u8) -> i64 { out[0] = 0x0f as u8; out[1] = 0xae as u8; out[2] = 0xf0 as u8; return 3 }
called by 1: axc_emit
454func axc_emit(out: *u8, src: *u8, mn: i64, mnl: i64, op0: *i64, op1: *i64, op2: *i64,
844func axc_emit_bytes(src: *u8, start: i64, le: i64, dest: *u8, dest_off: i64, do_emit: i64) -> i64
called by 1: axc_pass calls 1: axc_is_digit
877func axc_apply_section(src: *u8, t0: i64, tlen: i64, j: i64, le: i64) -> i64
895func axc_pass(src: *u8, n: i64, out: *u8, text_size: i64, pass: i64,
1056func nxasm_x86_assemble(src: *u8, n: i64, out: *u8, out_cap: i64, p_entry: *i64) -> i64