MIPS - Basic Instructions, Various Formats of Machine code representation

The syntax of MIPS is quite simple in comparison to a standard high-level language.Each statement starts with what type of operation you are planning to implement.Then the required number of argument for that operation follows it.Generally return values of operation are sent to the first argument.Suppose you wanted to add two numbers.In C this would look something like:

V = f + s

The equivalent MIPS would look something like:

Add v,f,s

Notice that the return value is the first.It follows the left to right reading conventions.

You can also create label.These are used for control structures.I won’t into the detail but in general they are just defined with an alphanumeric phrase that is different from any of the control statements.Example:

…

…

…

Label_one:

…

…

…

Laundry List of Basic Operations

Operation

Description

Example

Notes

add

Adds two numbers

add v, s, d

There are a number of different varations depending on the nature of the inputs and output.Such as unsigned, or constants

sub

Subtract two numbers

sub v, s, d

There are a number of different varations depending on the nature of the inputs and output.Such as unsigned, or constants

mult

Multiply two numbers

mult v, s, d

There are a number of different varations depending on the nature of the inputs and output.Such as unsigned, or constants

div

Divide two numbers

div v, s, d

There are a number of different varations depending on the nature of the inputs and output.Such as unsigned, or constants

and

Bit wise and two numbers

and v, s, d

or

Bit wise or two numbers

or v, s, d

lw

Load value from memory to register

lw v, 100(m)

Notice how memory is represented.There is a more complete usage in section 6 and/or 8

sw

Store value from register to memory

sw v, 100(m)

Notice how memory is represented.There is a more complete usage in section 6 and/or 8.Also notice that this operation doesn't follow the usual left to right representation because the value of v (register) is sent to 100(m) (memory)

beq

Branch on equal

beq v1,v2, 25

This is for control structure operations which are discussed in section 3

j

jump to target address

j 2500

This is for control structure operations which are discussed in section 3, There are also conditional jumps which are further defined in section 3

There are many more operations that extend from this list.Refer to the back of the text book for a more complete listing.


MIPS Home