Assembly language that corresponds to machine instruction in MIPS

assemblybinarymips

I am working on a problem that asks for the assembly language that would correspond to the following machine instruction in MIPS:

OX3062FF80

Here is what I've done:

step 1: convert to binary

0011 0000 0110 0010 1111 1111 1000 0000

opcode: 000000 <--- im not sure about this part ( I thought it should always be zero)
rs: 00011
rt: 00010
rd: 11111
shamt: 11110
funct: 000000

add $15, $3, $2

Is this correct? I am going off an example but I am not entirely sure if its correct. Any help, advice would be appreciated. Thank you.

Best Answer

I believe it is a bitwise and immediate AND.

You had the first two steps right:

OX3062FF80
0011 0000 0110 0010 1111 1111 1000 0000

But not the rest.

First separate out the opcode, starting from the left. All opcodes are 6 bits.

So the opcode in binary, from the left, is:

001100

which is 0xC. This is an andi instruction.

Then you need to separate out the fields according to the MIPS I instruction format;

001100  00011  00010  1111 1111 1000 0000 

opcode    rs    rt        immediate

Opcode:     0xC
rs:         0x03
rt:         0x02
Immediate:  0xFF80

I wrote some code and checked that an adi instruction has the above format in a disassembly listing.

To convert this into a assembly instruction:

The assembly language format of an andi is:

andi,rs,rt,IMM

Looking up the MIPS registers for the rs and rt fields:

rs = 0x03 => $v1
rt = 0x02 => $v0

so the corresponding assembly instruction is:

andi $v1,$v0,0xFF80