What is Assembly Language ?

What is Assembly Language ?
Post by Amina Delali, January 11th, 2023

Some Facts

The assembly programming language is a low level language, situated between a high level programming language, like Python for example, and the code machine. So, the high level programming code, is converted first to an assembly code then converted to code machine by an assembler.

The language uses mnemonics to represent the low level machine instructions, and it is usually used as the programming language for applications where speed is critical in general. Or for real time embedded systems in particular.

The assembly language is related to the architecture of the machine. So it is machine dependent, and it differs from an architecture to an other.

For example, there is the RISC, and the CISC architectures. For each of one of these, correspond an assembly language family:
  • CISC: Complex Instruction Set Computer Architecture. In this computer architecture (Instructions Set Architecure), the size of the assembly code will be small. This is possible because the processor is build in a way that enables the execution of complex instructions that are composed of multiple operations. But, the number of cycles per instructions will be high. One of the CISC families is the x86 architecture. And NASM (Netwide Assembler ), MASM (Microsoft Macro Assembler), and GAS (GNU Assembler) are assembly languages adapted for this class of architecture.
  • RISC: Reduced Instruction Set Computer Architecture. In this architecture, the size of the assembly code will be large. This is caused by the fact that the processor is build in a way that let him execute only simple instructions that can be run on one clock cycle . As a good consequence, the number of cycles per instructions will be low. One of the RISC families is the MIPS architecture (Microprocessor without Interlocked Pipelined Stages ), to which correspond the MIPS assembly language.

How to install it

The assembly language I selected is the MIPS language. To later run our code, we are going to use MARS (MIPS Assembler and Runtime Simulator) IDE environment. Which is; as you may already gest it, an assembler and at the same time a runtime simulator. We are not going to install MARS, we will just run it. But, to be able to do so, you have to install Java first. You can go to our Java page to see how.

  • on Windows:

    To download MARS, just go to this MissouriState University page, and click on the Download Mars button. You will download a jar archive. Now, to run MARS, just double click on the file (assuming that Java is already installed on your machine)

  • on ubuntu :

      Same thing for Ubuntu, just go the same download page we saw in the installation for Windows, and click on the download button. But, after saving the downloaded jar file, do the following:
      1. Right click on it, and click on properties.
      2. Click on the permissions tab, then check the "Allow executing file as program" box.
      3. Now, click on the Open with tab, and select the Java runtime installed on your computer. In my case, it was the "OpenJDK Java 11 Runtime". After that, click on the Set as default button, and close the properties window.
      4. All you have to do now, is to double click on the download jar file to run it.

The Hello World Code

To write and run your MIPS code using MARS, do the following:

  • After opening MARS by double clicking on it, click on New from the File menu.
  • Write the following code:

    out_string.asciiz "\nHello World!\n"
    li $v04            #the operation code
    la $a0out_string   #the operand
    syscall              #perform the operation
    li $v010 

    • Just to clarify something about the code. The prefixed lines with the hashtag(#) symbol are simply comments and not actual code.

  • To save the code, click simply on Save, from the File menu, and write hello.asm in the File Name area. After that click on the Save button.
  • To assemble the code, click on Assemble from the Run menu.
  • To run the code, click on Go from the same Run menu. You will see the "Hello World!" message printed in the Run I/O bottom window.

Something to say ?

If you want to add something about the Assembly language or about this post, please feel free to do it by commenting below 🙂 .