Skip to content

Instantly share code, notes, and snippets.

@asterite
Created June 22, 2015 15:24
Show Gist options
  • Save asterite/abc2712891977f0fd84e to your computer and use it in GitHub Desktop.
Save asterite/abc2712891977f0fd84e to your computer and use it in GitHub Desktop.
require "../../spec_helper"
describe "Code gen: asm" do
it "codegens without inputs" do
run(%(
dst :: Int32
asm("mov $$1234, $0" : "=r"(dst))
dst
)).to_i.should eq(1234)
end
it "codegens with one input" do
run(%(
src = 1234
dst :: Int32
asm("mov $1, $0" : "=r"(dst) : "r"(src))
dst
)).to_i.should eq(1234)
end
it "codegens with two inputs" do
run(%(
c :: Int32
a = 20
b = 22
asm(
"add $2, $0"
: "=r"(c)
: "0"(a), "r"(b)
)
c
)).to_i.should eq(42)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment