Mips Assembly Language Syntax

Mips Syntax is pretty similar to x86 and Arm syntax. Below is the basic syntax of MIPS instruction set:

.data  #Declare or initialize variables
#Here main program goes (Instructions)
#End instruction to terminate the program

.Data Section

In data section variables are declared or initialize. See example below:

msg1: .asciiz  “Enter a value:\n“
msg2: .asciiz  “Sum of value and 100:\n”

   medianet_width = "200";
   medianet_height = "200";
   medianet_crid = "266336524";
   medianet_versionId = "111299";
   (function() {
       var isSSL = 'https:' == document.location.protocol;
       var mnSrc = (isSSL ? 'https:' : 'http:') + '//contextual.media.net/nmedianet.js?cid=8CUU7W7W5' + (isSSL ? '&https=1' : '');

In the above example msg1 and msg2 are the two variables initialized with sting data.

.Text Section

Text section include our main code. See example below:

li $v0,4    # prompt user (print string)
la $a0,msg1    # indicate the message!
li $v0,5    # read integer, X
addi $s0,$v0,100    # $s0 = X + 100
li $v0,4   # output message
la $a0,msg2    # indicate the message!
li $v0,1   # print integer!
move $a0,$s0   # value to print!
li $v0,10   # exit program!

Hope you understood the basic Syntax! If there any question let us know in the comment box.

Nauman Rehmat

Nauman Rehmat is the owner of Assembly Language Tuts.He is interested in Programming and SEO. He is also pursuing a degree in Computer Software Engineering from Comsats.