From 74e73edac17cacc3ae91cfb11c3a7ae062f53fe1 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Mon, 7 Jun 2021 20:17:45 +0300 Subject: [PATCH] examples: split asm.v to asm.amd64.v and asm.i386.v --- examples/asm.amd64.v | 19 +++++++++++++++++++ examples/asm.i386.v | 19 +++++++++++++++++++ examples/asm.v | 18 ------------------ 3 files changed, 38 insertions(+), 18 deletions(-) create mode 100644 examples/asm.amd64.v create mode 100644 examples/asm.i386.v delete mode 100644 examples/asm.v diff --git a/examples/asm.amd64.v b/examples/asm.amd64.v new file mode 100644 index 0000000000..62c1cd3c5d --- /dev/null +++ b/examples/asm.amd64.v @@ -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 +} diff --git a/examples/asm.i386.v b/examples/asm.i386.v new file mode 100644 index 0000000000..990eb080ef --- /dev/null +++ b/examples/asm.i386.v @@ -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 +} diff --git a/examples/asm.v b/examples/asm.v deleted file mode 100644 index 88c75ec318..0000000000 --- a/examples/asm.v +++ /dev/null @@ -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 -}