Files
Alexander Medvednikov 49cb1fea28 examples, docs: use 64-bit registers in the amd64 inline assembly example
`int` is 64 bits wide on amd64, so the `r` constraints bind 64-bit
registers, and `mov eax, a` reached the assembler as `mov %rax, %eax`.
tcc accepted it, but gcc and clang reject the operand size mismatch
(`build_examples_clang` failed on examples/asm.v).
2026-09-28 08:00:30 +03:00

20 lines
276 B
V

// vtest build: !msvc
fn main() {
a := 100
b := 20
mut c := 0
$if amd64 {
asm amd64 {
mov rax, a
add rax, b
mov c, rax
; =r (c) // output
; r (a) // input
r (b)
}
}
println('a: ${a}') // 100
println('b: ${b}') // 20
println('c: ${c}') // 120
}