Skip to content

Instantly share code, notes, and snippets.

@sck
Last active December 22, 2015 18:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sck/6514608 to your computer and use it in GitHub Desktop.
Save sck/6514608 to your computer and use it in GitHub Desktop.
Super awesome recreative assembler. Execute with ruby and pipe into nasm
$pushed = []
def push(*args) $pushed = args; args.map {|r| "push #{r}" } end
def pop_pushed; $pushed.reverse.map {|r| "pop #{r}" } end
puts DATA.read.gsub(/^\s*jmp\s*[^\n]*/, '%error "Dijkstra said: No!"').gsub(/=([^\n]*)/) {|c| (eval $1).join("\n ") }
__END__
BITS 64
section .text
global math
math:
=push("rax", "rbx")
sub r12, r11
=pop_pushed
jmp math
ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment