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