examples: split asm.v to asm.amd64.v and asm.i386.v

pull/10394/head
Delyan Angelov 2021-06-07 20:17:45 +03:00
parent 2e6611372a
commit 74e73edac1
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
3 changed files with 38 additions and 18 deletions

View File

@ -0,0 +1,19 @@
fn main() {
a := 100
b := 20
mut c := 0
asm amd64 {
mov rax, a
add rax, b
mov c, rax
; =r (c)
; r (a)
r (b)
}
assert a == 100
assert b == 20
assert c == 120
println('a: $a') // 100
println('b: $b') // 20
println('c: $c') // 120
}

View File

@ -0,0 +1,19 @@
fn main() {
a := 100
b := 20
mut c := 0
asm i386 {
mov eax, a
add eax, b
mov c, eax
; =r (c)
; r (a)
r (b)
}
assert a == 100
assert b == 20
assert c == 120
println('a: $a') // 100
println('b: $b') // 20
println('c: $c') // 120
}

View File

@ -1,18 +0,0 @@
fn main() {
a := 100
b := 20
mut c := 0
$if amd64 {
asm amd64 {
mov eax, a
add eax, b
mov c, eax
; =r (c) // output
; r (a) // input
r (b)
}
}
println('a: $a') // 100
println('b: $b') // 20
println('c: $c') // 120
}