From d50af2e474281a1e88d191f783c2792824698974 Mon Sep 17 00:00:00 2001 From: hachem Date: Thu, 10 Sep 2026 05:52:08 +0200 Subject: feat: conditional select --- docs/language.md | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'docs/language.md') diff --git a/docs/language.md b/docs/language.md index a4743b3..ecdbf19 100644 --- a/docs/language.md +++ b/docs/language.md @@ -171,6 +171,12 @@ while .countdown rcx > 0 // emits `.countdown:` … `jmp .countdown` … `.c rcx -= 1 ``` +A **conditional select** picks one of two register values without a branch: `dst = a if else b`. It lowers to `csel` on AArch64 (one instruction) and `cmov` on x86 (a default move plus a conditional move, arranged so `dst` may safely alias either source). Both sources must be registers. + +```hdass +r3 = r1 if r1 > r2 else r2 // r3 = max(r1, r2), branchless +``` + ## Dereference (`^`) `^reg` is the memory at the address in `reg` — NASM's `[reg]`. On the left of `=` it stores there. The store width comes from the value operand, so a sized sub-register picks the size: -- cgit v1.3