software projects by ryan davis

wilson

A pure ruby x86 assembler.

Wilson is a pure ruby x86 assembler. No, really. Worst Idea Evar.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class X
  defasm :superfast_meaning_of_life do
    eax.mov 42
    to_ruby eax # ruby fixnums = (n << 1) + 1
  end

  def inline_asm_example
    n = 1000

    asm :count_to_n do
      eax.xor eax
      count = self.label
      eax.inc
      eax.cmp n
      jne count

      to_ruby eax
    end
  end
end

p X.new.superfast_meaning_of_life # => 42
p X.new.inline_asm_example        # => 1000

Get The Code

If you just want to use wilson, you can install it via RubyGems:
gem install wilson
Fork me on GitHub If you want to hack on wilson, clone it from GitHub:
git clone git://github.com/seattlerb/wilson

Latest Activity