DEV Community

Cover image for EasyASM, Ramping up in Assembly
Kevin J. Estevez
Kevin J. Estevez

Posted on

EasyASM, Ramping up in Assembly

I was remembering the time I was coursing Compiler lessons at my alma mater, and decided to check out an open-source project that helped me understand in a better way the core concepts of the compiling process, and even further in the Assembly languages.

Yeah! I know some might get scared by those lower-level programming languages but in the end they're just that: another language with its own complexity.

First thing we need to know is, there are different Assembly languages and we're going to list some of them here:

And a famous widely used assembler for X86 is NASM

But for education purposes

I came here to introduce to you all to this awesome open source project, an interpreter of the MIPS32 and X86 instruction set EasyASM.

GitHub logo ideras / EasyASM

MIPS32 and x86 simulator for easy learning of assembler language

EasyASM

EasyASM is a simple simulator for a subset of MIPS32 and x86 ISAs. The main purpose is make easy the process of learning the assembler language. For this purpose EasyASM provides a simple command line interface were the user can type assembler instructions and test them without the need of using some assembler program. The program provides instant feedback to user, in case of an error. Apart from that the simulator provides some useful commands which are described in the section commands.

Installation

To install the program you need a C++ compiler and the source code. Once you have both you just need to enter the directory with the source code and type the commands

Linux (Debian based distribution)

$ make deps
$ make
Enter fullscreen mode Exit fullscreen mode

Windows

It might work if you use msys

Usage

Once you have the simulator compiled, you can run it by typing ./EasyASM in the source…

It’s a project where you can play around with a vast instruction set for either MIPS32 or X86 and have good feedback of what’s going on. Also you have available some helper instructions to pre-fill a register with a desired value and then use it later in the code.

I've made very few contributions to it, the most recent being an easy way to set it up and running in your Debian based distribution.

A bit of History

The project was made by a professor I had during my major and was developed while we were having lessons with him, so we were pretty much like Beta Testers 😆 at the time.

A few of us made very few contributions back then, and it wasn't until recently that I came back to see if the project was still alive and noticed there were some changes which weren't quite well explained in the Readme.md file about:

  • specific i386 dependencies
  • custom version of Lemon

It really wasn't easy to set the project up and running at once, so I decided to figure out the needed dependencies and the custom version of Lemon myself.

I added a script to install all those dependencies easily just by executing one shell command... Yeah, I went through all that pain to simplify that process to future users.

Setup

$ git clone https://github.com/ideras/EasyASM.git
$ cd EasyASM
$ make deps
$ make
$ cp ./EasyASM /usr/bin/EasyASM
Enter fullscreen mode Exit fullscreen mode

The last command is optional. It is mostly there so that you can use it from any directory you are in, like any other CLI program or you could easily use it directly from the project folder.

Running

If you followed all the steps above just type:

$ EasyASM
Enter fullscreen mode Exit fullscreen mode

And if you skipped the last step:

$ cd </path/where/you/cloned/the/project>
$ ./EasyASM
Enter fullscreen mode Exit fullscreen mode

You should expect this output in your console:
(there's a blinking cursor waiting for you start typing)

--- EasyASM MIPS32 mode (big endian) ----

Global base address = 0x10000000
Stack pointer address = 0x7fffeffc
Global memory size = 256 words
Stack size         = 256 words

ASM> _
Enter fullscreen mode Exit fullscreen mode

Usage

The default mode is MIPS32 (big endian)

To run it as X86 (little endian): $ EasyASM --x86

EasyASM's own helper commands

  • #set store a value into a register or memory address
  • #show display what is stored in a register or memory address
  • #exec execute a whole assembler file
  • quit exit the command line prompt

Now let's see a simple example running in EasyASM

ASM> start:
ASM> #set $t0 = 10
ASM> #set $t1 = 20
ASM> lbl_add1: add $t2, $t0, $t1
$t2 = 0x1E 30 30
ASM> #show $t2
$t2 = 30
ASM> _
Enter fullscreen mode Exit fullscreen mode

We can see right after a calc operation, EasyASM will show us the result value stored in the register in three different formats:
[target register] = [HEX] [Signed Decimal] [Unsigned Decimal]

Note: We can add labels but we cannot jump to not existing labels, so if we want to jump to a label further down in the program, we'd better use a file.asm and execute it with the #exec command


I hope this can be helpful so that someone can really take full advantage of the power of this project.

Thanks for reading! 😊

Top comments (0)