Register
Type Instruction Format (R – Type)
This
is a group contains all instructions that do not require an immediate
value( a value, e.g. 5,-3,etc), target offset, memory address
displacement, or memory address to specify an operand. This includes
arithmetic and logic with all operands in registers, shift
instructions, and register direct jump instructions (jal and jr).
It
specify 3 registers(rs,rt,rd), a shift amount field(shamt), and a
function field(funct).Opcode for R- type is 000000.
Instruction
fields
op
|
rs
|
rt
|
rd
|
shamt
|
funct
|
Operation
code
|
Source
register specifier
|
Target
register specifier
|
Destination
register specifier
|
Shift
amount
|
Function
field
|
Instruction
coding
-immediate
from 0thbit
to 5thbit
( 6 bits )
-shamt
from 6thbit
to 10thbit
( 5 bits )
-rd
from 11thbit
to 15thbit
( 5 bits )
-rt
from 16thbit
to 20thbit
( 5 bits )
-rs
from 21thbit
to 25thbit
( 5 bits )
-op
from 26thbit
to 31thbit
( 6 bits )
Register type application
a. Non-Jump R -type
ALU Usage – add rd,rs,rt
b. Jump register
ALU Usage – jalr rd ,rs
Both:
-
No
update beyond the normal increment.
-
Source
operand fetch: rs and rt.
-
ALU
operation: determined by the function field.
-
Memory
access: none.
-
Result
from ALU write to rd.
add $t0 , $t1 , $t2 # $t0 = $t1 + $t2
sub $t1 , $t2 , $t3 # $t1 = $t2 + $t3
for unsigned value(positive no only) addu,subu, multu...
addu $t1 , $t6 , $t7 # $t1 = $t6 + $t7 subu $t1 , $t6 , $t7 # $t1 = $t6 + $t7
mul $t0,$t0, $t1 same as : mult $t0,$t1mfhi $t0
mfhi - move quantity in special register Hi to $t0: $t1 = HiWhy having hi and lo in multiplication and division?
bacause $t3 and $t4 both is 32 bits quantities, they need 2 registers to store it,put their results in MIPS registers Hi. Similar to division , Hi is remaider , Lo is quotient.div $t1,$t2 # t1 / t2
mflo $s0 #s0 = quotient
mfhi $s1 #s1 = remainder
Kee Hwaai Sziang B03121067
No comments:
Post a Comment