Router Day04:MIPS32

MIPS Assembly language

I use the book(34-38) mentioned to learn this, while this url can also be learned:https://blog.csdn.net/ben_chong/article/details/51794392

Rs:First source operand register
Rt:Second source operand register
Rd: store destination operand for operation result

Pipeline Effect

(1)LOAD/STORE

Load Adress: load a addr or a label

1
la $Rd,Label //$Rd=Label;

Load Immediate: load a immediate into a register

1
li $Rd,imm //$Rd=imm;

Load Word: load a word type value from a given addr to a register

1
lw $Rt,offset($Rs) //$Rt=MEM[$Rs+0];

Store Word: save the value from source register to given addr

1
sw $Rt,offset($Rs) //Mem[$sp+0]=$a0;

Move: pass values from register to register

1
move $t5,$t1 //$t5=$t1;

(2)Arithmetic operation instructions

All these instructions only get register as operand No RAM addr or indirect addressing!!!
Image
For multiply and dive , HI&LO shall be used differently.

(3)Class comparison instruction

MIPS don’t get a flag register. But there is a series of instructions:SLT series of instructions.That can be used as a companion with branch instructions after compare set some register .

SLT:Signed$Rs<$Rt,$Rd=1 or $Rd=0

1
slt $Rd,$Rs,Rt

SLTI:Signed $Rs < Imm, $Rt=1 or $Rt=0

1
slti $Rt,$Rs,Imm

SLTU:Unsigned $Rs<$Rt , $Rd=1 or $Rd=0

1
sltu $Rd,$Rs,$Rt

SLTIU:UnSigned $Rs < Imm, $Rt=1 or $Rt=0

1
sltu $Rt,$Rs,Imm

In SLT when there goes 3 arguments , the first is always the one to be set 1 or 0?

(4)SYSCALL

Make a soft interrupt to make a sys call. The [system call number] puts in $v0 , arguments are in $a0~$a3.
Image

(5)Branch instruction

Jump by comparing the values between 2 registers. So to jump with imm, put imm into register first.
Image

(6)Jump instruction

Image