2019-11-16 22:58:09 +01:00
|
|
|
fn test_inline_asm() {
|
2019-11-16 23:07:21 +01:00
|
|
|
$if !windows {
|
|
|
|
$if !tinyc {
|
2019-11-16 22:58:09 +01:00
|
|
|
a := 10
|
|
|
|
b := 0
|
|
|
|
unsafe {
|
2019-11-16 23:07:21 +01:00
|
|
|
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
|
2019-11-16 23:07:21 +01:00
|
|
|
//
|
|
|
|
e := 0
|
|
|
|
unsafe {
|
|
|
|
asm(
|
|
|
|
"movl $5, %0"
|
|
|
|
:"=a"(e)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
assert e == 5
|
|
|
|
}
|
|
|
|
}
|
2019-11-16 22:58:09 +01:00
|
|
|
}
|