`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).
20 lines
276 B
V
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
|
|
}
|