multidasm ~main
Runtime dynamic assembler for JIT compilation.
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
Multidasm
[!NOTE] Multidasm currently doesn't support runtime assembling. This is planned for the future.
Multidasm is a quick, dynamic comptime assembler for D. It targets CIL, x86, x86_64, and MIPS with minimal overhead and maximal throughput. Each backend uses a Block type, instruction methods, optional label(name), and finalize() to produce assembled bytes.
Modules
| Module | Target | Status |
|---|---|---|
multidasm.amd64 | x86 / x86_64 with MMX, SSE, AVX, AVX2 | 79% |
multidasm.mips | MIPS32 integer core, big-endian | 27% |
multidasm.cil | Common Intermediate Language (ECMA-335) | 100% |
Per-assembler documentation:
- AMD64 - Register and memory operands, REX/VEX prefixes, instruction encoding.
- MIPS - GPRs, I-type/J-type/R-type encoding, branch and jump label patching.
- CIL - Stack-based opcodes, branch labels, prefixes, metadata tokens.
Installation
dub add multidasm
For local development in this workspace:
{
"dependencies": {
"multidasm": {
"path": "../multidasm"
}
}
}
Usage
AMD64
Use Block!false for x86 and Block!true for x86_64. Registers are sized (Reg!8, Reg!16, Reg!32, Reg!64) and memory operands use Mem!(size).
import multidasm.amd64;
Block!true code;
with (code)
{
mov(rax, rdi);
add(rax, rsi);
ret();
}
ubyte[] assembled = code.finalize();
MIPS
MIPS uses Block with GPR registers and Mem operands. Output is big-endian. Labels are resolved automatically in finalize().
import multidasm.mips;
Block code;
with (code)
{
addiu(rv0, rzero, 10);
label("loop");
addiu(rv0, rv0, -1);
bne(rv0, rzero, "loop");
nop();
}
ubyte[] assembled = code.finalize();
CIL
CIL uses Block with stack-based opcodes. Branches and switches use string labels patched during finalize().
import multidasm.cil;
Block code;
with (code)
{
ldcI4_0();
stloc0();
label("loop");
ldloc0();
ldcI4(1);
add();
stloc0();
ldloc0();
ldcI4(10);
blt("loop");
ret();
}
ubyte[] assembled = code.finalize();
Roadmap
Oops, there's no formal roadmap!
- [x] x86
- [x] x86_64
- [ ] AVX-512
- [x] CIL
- [x] MIPS IV
- [ ] ARM
- [ ] z80
- [ ] IR
- [ ] Runtime assembling
License
Multidasm is licensed under AGPL-3.0.
- ~main released 6 days ago
- cetio/multidasm
- AGPL-3.0-only
- Copyright © 2024, cet
- Authors:
- Dependencies:
- tern
- Versions:
-
Show all 2 versions1.0.0 2026-Mar-04 ~main 2026-Jun-02 - Download Stats:
-
-
0 downloads today
-
2 downloads this week
-
2 downloads this month
-
2 downloads total
-
- Score:
- 0.7
- Short URL:
- multidasm.dub.pm