Really Controlling the Flow: From Assembly to Ruby
I’ve recently been converting a bunch of Assembly code into Ruby. ZOMG Why, Why, Why? You may well ask. Well the Assembly code is Intel x86 flavoured, it’s never been run on Linux & we want to run on Linux. I could have converted to C, but everyone in my current team writes Ruby, and most importantly Ruby allows me (and you) to control the machine, rather than the other way around. We are the masters. They are the slaves!
My main issue with the conversion was figuring out what the JMP type conditional commands equivalent was in Ruby. From my 2 minutes of google searching I found there doesn’t seem to be a resource on the web that has a simple quick reference.
So without further ado, here’s my first stab at an Intel x86 Assembly to Ruby for JMP commands cheatsheet.
( Given there is a function/method called func0 & a register/variable named al)
Assembly
Ruby
1
jmpfunc0
1
func0
12
cmpal,07Bhjcfunc0
1
func0unlessal-0x7B>=0
12
cmpal,07Bhjncfunc0
1
func0ifal-0x7B>=0
12
cmpal,07Bhjnzfunc0
1
func0unlessal-0x7B==0
12
cmpal,07Bhjzfunc0
1
func0ifal-0x7B==0
12
testal,07Bhjnzfunc0
1
func0unlessal&0x7B==0
12
testal,07Bhjzfunc0
1
func0ifal&0x7B==0
12
andal,07Bhjnzfunc0
1
func0unlessal&=0x7B==0
12
andal,07Bhjzfunc0
1
func0ifal&=0x7B==0
If you see a mistake, have a query or a suggestion to update or just found this useful, please let me know.