Generate ISA text
Build register names, labels, and repeated hot paths with Meta code, then pass generated lines back through the normal backend encoder.
isa(sym.join("vaddps ymm", to_string(i)))
Zig powered / Multi-ISA / Meta DSL
XIRASM keeps ISA text readable, then adds a compile-time Meta language for multi-ISA generation, layout, token parsing, checked binary structures, and PE/COFF/ELF recipes.
// natural ISA text stays natural
x86.use64();
origin(0x401000);
start:
xor eax, eax
// compile-time Meta generates source
for i in list.of(0, 1, 2, 3) {
isa(sym.join(
"vaddps ymm", to_string(i),
", ymm", to_string(i),
", ymm", to_string(i + 1)
));
}
packed struct Header {
magic: u16 = 0x5849,
size: u16,
}
emit.bytes(pack(Header { size: 4 }));
XIRASM gives binary authors structured tools without turning every instruction into a function call.
Build register names, labels, and repeated hot paths with Meta code, then pass generated lines back through the normal backend encoder.
isa(sym.join("vaddps ymm", to_string(i)))
Use token matching to write small DSLs, import tables, instruction descriptions, or source-like parsers inside assembly.
match.tokens("=mov dst:name =, src:tokens", line)
Define packed structs and unions, inspect size and offsets, then pack values directly into the output stream.
assert(sizeof(Header) == 4)
Finalizers run after layout is stable, so headers, sizes, checksums, and label-dependent fields can be backfilled deliberately.
store.u32(field, body_end - body_start)
PE, COFF, and ELF support lives in include-driven format libraries. The common path uses facade helpers; raw record builders remain available when you need expert control.
import("format/pe64.inc");
pe64_exe(1);
pe64_section(".text", 0);
start:
xor eax, eax
ret
text_end:
pe64_end_section(0);
pe64_finish_text(0, start, start, text_end, pe_rx);
import("format/elf64.inc");
elf64_exe(1);
elf64_segment(".text");
start:
mov eax, 60
xor edi, edi
syscall
text_end:
elf64_end_segment();
elf64_finish_load(0, start, start, elf_rx);
zig build
xirasm source.asm -o output.bin --target x86_64
xirasm init demo --target rv64
cd demo
xirasm build