Created
June 22, 2015 15:24
-
-
Save asterite/abc2712891977f0fd84e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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