mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
examples: split asm.v to asm.amd64.v and asm.i386.v
This commit is contained in:
parent
2e6611372a
commit
74e73edac1
19
examples/asm.amd64.v
Normal file
19
examples/asm.amd64.v
Normal 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
|
||||
}
|
19
examples/asm.i386.v
Normal file
19
examples/asm.i386.v
Normal 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
|
||||
}
|
@ -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
|
||||
}
|
Loading…
Reference in New Issue
Block a user