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 )
AssemblyRuby
1
jmp func0
1
func0
1
2
cmp al, 07Bh
jc func0
1
func0 unless al - 0x7B >= 0
1
2
cmp al, 07Bh
jnc func0
1
func0 if al - 0x7B >= 0
1
2
cmp al, 07Bh
jnz func0
1
func0 unless al - 0x7B == 0
1
2
cmp al, 07Bh
jz func0
1
func0 if al - 0x7B == 0
1
2
test al, 07Bh
jnz func0
1
func0 unless al & 0x7B == 0
1
2
test al, 07Bh
jz func0
1
func0 if al & 0x7B == 0
1
2
and al, 07Bh
jnz func0
1
func0 unless al &= 0x7B == 0
1
2
and al, 07Bh
jz func0
1
func0 if al &= 0x7B == 0

If you see a mistake, have a query or a suggestion to update or just found this useful, please let me know.

Comments