Assembly Language

An Assembler Language is a low level programming language which correspondes to a specific form of computer architecture.

High level programming languages (C,Java,etc) on the otherhand are portable across multiple architectures, however require compilers/interpreting.

I experimented with the Assembly Language MIPS, which is unique to the MIPS computer architecture.

The Code

This program will load the numbers 20 and 35 into the registers $t0 and $t1 , multiply the numbers together, and then returns both the 64-bit and 32-bit result into registers $t2 and $t3

The Code for this is below:

  1. main:
  2. addi $t0 $0 20;
  3. addi $t1 $0 35;
  4. mult $t0 $t1;
  5. mflo $t2;
  6. mfhi $t3;
  7. Exit:
  8. li $v0 10
  9. syscall

The Explanation

The Syntax is very different, simplistic and frankly quite painful to read.

Line 1: Keyword main indicates the start of the code.

Line 2: Keyword addi performs addition between $0 and 20 and stores the result into $t0.

Line 3: Keyword addi performs addition between $0 and 35 and stores the result into $t1.

Line 4: Keyword mult performs multiplication between whats stored in the registers $t0 and $t1 and stores it in Lo and Hi Registers.

Line 5: Keyword mflo moves the contents of the Lo special register to $t2.

Line 6: Keyword mfhi moves the contents of the Hi special register to $t3.

Line 7: Keyword Exit stops the program after the next 2 lines are completed.

Line 8: Keyword li loads 10 into the register $v0.

Line 9: Keyword syscall prints out $v0.

Gallery

1 / 3
Caption Text
2 / 3
Caption Two
3 / 3
Caption Three

I used a program called QtSpim to experiment with MIPS.

QtSpim Download