This article is more than 1 year old

AsmREPL: Wing your way through x86-64 assembly language

Assemblers unite

Ruby developer and internet japester Aaron Patterson has published a REPL for 64-bit x86 assembly language, enabling interactive coding in the lowest-level language of all.

REPL stands for "read-evaluate-print loop", and REPLs were first seen in Lisp development environments such as Lisp Machines. They allow incremental development: programmers can write code on the fly, entering expressions or blocks of code, having them evaluated – executed – immediately, and the results printed out. This was viable because of the way Lisp blurred the lines between interpreted and compiled languages; these days, they're a standard feature of most scripting languages.

Patterson has previously offered ground-breaking developer productivity enhancements such as an analogue terminal bell and performance-enhancing firmware for the Stack Overflow keyboard. This only has Ctrl, C, and V keys for extra-easy copy-pasting, but Patterson's firmware removes the tedious need to hold control.

We suspect that the Assembler REPL came out of Patterson's work on his own just-in-time compiler for Ruby, TenderJIT. He does such things for his day job. And like TenderJIT, the primary purpose of AsmREPL is educational.

Patterson explained: "I wrote it because I can never remember what the test instruction does to the zero flag. Every time I use the instruction I have to look up the docs. Looking up docs is fine, but running code in a REPL helps me remember things better."

AsmREPL works by assembling code into a shared memory buffer using Patterson's own Fisk, an x86-64 assembler written in Ruby, then using the Unix ptrace system call to monitor what the code is doing. Windows users will have to use WSL.

It's not quite the same as a machine-code monitor, as loved by coding pioneers in the early 8-bit days, but it looks like a fun tool if you're learning to write device drivers or other very low-level code. ®

More about

TIP US OFF

Send us news


Other stories you might like