Tuesday, 3 December 2013

MIPS(R-Format/ I-Format/ J-Format) by CHEOK LI LI B031310127



e. Instruction Type : Store
Example : sw rt , imm ( rs )
Type : I
Instruction Coding :





C.2. Immediate Addressing
Definition : A numeric value embedded in the instruction is the control operand .
·         the operand is a constant within the encoded instruction
·         instructions will be executed faster in comparison with other addressing modes
reason : does not involves with memory access
Ø  However , the size of operand is limited to 16 bits .
·         Example :
Consider the following instruction :
addi $t2 , $t2 , 1
where ; $t2 = rd , $t2 = r1 , 1 = immediate value
Thus ; $t2 = $t2 + $1
The figure below is the implementation of Immediate Addressing :




C.3. PC-Relative Addressing
Definition : A data or instruction memory location is specified as an offset relative to the incremented PC .
·         usually used in conditional branches
Ø  PC ( Program Counter ) – stores the address of the next instruction to be fetched .
·         the offset value can be an immediate value / an interpreted label value
·         I-Type instruction
·         effective address = PC + offsets value
Ø  The effective address determines the branch target .
·         implements position-independent codes
Ø  Only a small offset is adequate for shorter loops .
·         Example :
Consider the following instruction :
beqz $t0 , strEnd
where ; $t0 = rs , 100 = offset
Thus ; if ( $t1 == 0 ) goto PC + 4 + ( 4 * 2 )
Ø  beqz ( conditional instruction ) – branches to label in the code if the content of $t0 = zero .
Ø  if the current address = 0x4000000C , then the effective address = 40000018 .
Ø  the table below show the details of the example and the following figure show the implementation of PC-Relative Addressing :





































C.4. Base Addressing / Indirect Addressing
Definition : A data / instruction memory location is specified as a signed offset from a register .
·         where a register act as a pointer to an operand located at the memory location whose address is in the register .
·         operand address = offset value + base value ( rs )
Ø  However , the size of operand is limited to 16 bits because each MIPS instruction fits into a word .
·         offset value
Ø  signed number ( two’s complement format )
Ø  can be a negative value
·         Consider the following instruction :
lw $rt , offset ( $rs ) 
where $rs and $rt are any two registers .
Example :
lw $t1 , 4 ( $t2 )
Thus ; $t1 = Memory [ $t1 + 4 ]





























No comments:

Post a Comment