v/vlib/compiler/tests/asm_test.v

27 lines
303 B
V
Raw Normal View History

2019-11-16 22:58:09 +01:00
fn test_inline_asm() {
a := 10
b := 0
unsafe {
asm (
"movl %1, %%eax;"
"movl %%eax, %0;"
:"=r"(b)
:"r"(a)
:"%eax"
)
2019-11-16 22:58:09 +01:00
}
assert a == 10
assert b == 10
//
e := 0
unsafe {
asm(
2019-11-17 00:22:43 +01:00
//".intel_syntax noprefix;"
//"mov %0, 5"
"movl $5, %0"
:"=a"(e)
)
}
assert e == 5
2019-11-16 22:58:09 +01:00
}