EasyASM, Ramping up in Assembly
Tags: opensource, programming, learning
Published: 2020-10-06 23:17:16

---
title: EasyASM, Ramping up in Assembly
published: true
description: Open-Source MIPS32 and X86 Assembly Interpreter for Education
tags: opensource, programming, learning
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/0vrbj1iqyt6vgyjr8lfn.png
---

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:
* [MIPS32](https://www.mips.com/products/architectures/mips32-2/)
* [X86](https://www.cs.virginia.edu/~evans/cs216/guides/x86.html)
* [ARM](https://developer.arm.com/documentation/dui0473/m/writing-arm-assembly-language)
* [X64](https://software.intel.com/content/www/us/en/develop/articles/introduction-to-x64-assembly.html)
* newly added to the family [WebAssembly](https://webassembly.org/)

And a famous widely used assembler for X86 is [NASM](https://www.nasm.us/)

## 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](https://github.com/ideras/EasyASM).

{% github https://github.com/ideras/EasyASM %}

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 :satisfied: 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
```shell
$ git clone https://github.com/ideras/EasyASM.git
$ cd EasyASM
$ make deps
$ make
$ cp ./EasyASM /usr/bin/EasyASM
```

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:
```shell
$ EasyASM
```

And if you skipped the last step:
```shell
$ cd </path/where/you/cloned/the/project>
$ ./EasyASM
```

You should expect this output in your console:
*(there's a blinking cursor waiting for you start typing)*
```console
--- EasyASM MIPS32 mode (big endian) ----

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

ASM> _
```

## 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
```shell
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> _
```
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! :blush: