diff options
| author | hachem <im@hachem.wtf> | 2026-09-10 04:42:33 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2026-09-10 04:42:33 +0200 |
| commit | bf157cf09b8b0888c54a165b887309a4e801f608 (patch) | |
| tree | b72735972c2edb46c9324a74aeda9ff46c64682a /docs/language.md | |
| parent | bf3bd19f79936fa519a5285701763da58935592a (diff) | |
feat: add aarch64 as target
Diffstat (limited to 'docs/language.md')
| -rw-r--r-- | docs/language.md | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/docs/language.md b/docs/language.md index 79d7866..a4743b3 100644 --- a/docs/language.md +++ b/docs/language.md @@ -1,6 +1,16 @@ # hdass language reference -hdass emits NASM or FASM for x86-64 (`-t nasm` by default, `-t fasm`); masm is planned. The instruction bodies are the same Intel syntax for both — only the framing (headers, sections, constants, data) differs. The compiler output itself isn't tied to an OS, but the examples and toolchain here target Linux (Linux syscall numbers, ELF64, `ld`). Pipeline: `lex → parse → analyze → emit`. +hdass has two independent axes: the **architecture** (which instructions and registers) and the **assembler syntax** (how they are written). A target is a pairing: + +| `-t` | architecture | assembler | +| --- | --- | --- | +| `nasm` (default) | x86-64 | NASM | +| `fasm` | x86-64 | fasm | +| `arm64` | AArch64 | GNU as | + +For x86-64 the two syntaxes emit the same Intel instruction bodies and differ only in framing (headers, sections, constants, data). `arm64` is a separate instruction selector — different registers, three-operand arithmetic, `ldr`/`str`, `cmp`+`b.cond`, `svc #0` — and is early: assignments, arithmetic (`+ - * /`), control flow, calls, `syscall`, and the raw instruction statement work; floats, stack buffers, and division-remainder do not yet. masm is planned. Pipeline: `lex → parse → analyze → emit`. + +The portable way to write for more than one architecture is the [`logical_registers`](#extensions) extension: `r1..r14` are the general-purpose registers, mapped per target (x86-64 `r1 = rax`; AArch64 `r1 = x0`, i.e. `rN → x(N-1)`). Architecture-native register names (`rax`, `x0`) and the raw instruction statement are, by definition, locked to one architecture. Syscall ABIs also differ per architecture — Linux exit is `60` in `rax` on x86-64 but `93` in `x8` (logical `r9`) on AArch64 — so programs still carry arch-specific ABI constants even when the language is portable. The output isn't tied to an OS, but the examples and toolchain here target Linux (ELF, `ld` / `qemu-aarch64`). ## A first program |
