cs2100-13-MIPS-3

cs2100-13-MIPS-3 - CS2100Computer Organisation

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
CS2100 Computer  Organisation http://www.comp.nus.edu.sg/~cs2100/ MIPS Part III: Instruction Formats (AY2009/2010) Semester 2 This set of notes is adapted from Dan Garcia’s course CS61C at UC Berkeley.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS2100 MIPS III 2 MIPS PART III:  INSTRUCTION FORMATS MIPS Instructions Classification R-Format I-Format Instruction Address Branches: PC-Relative Addressing J-Format Addressing for Branch Addressing for Jump Addressing Modes
Background image of page 2
CS2100 MIPS III 3 MIPS INSTRUCTIONS  CLASSIFICATION Instructions are classified according to their operands; instructions with same operand types have same representation R-format (Register format) add , sub , and , or , nor , slt require 2 source registers and 1 destination register srl , sll also belong here I-format (Immediate format) addi , subi , andi , ori , slti , lw , sw , beq , bne require 1 source register, 1 immediate and 1 destination register J-format (Jump format) j instruction requires only one immediate
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS2100 MIPS III 4 REGISTERS We shall use register numbers ($0, $1, …, $31) instead of names to simplify association. Name Register number Usage $zero 0 Constant value 0 $v0-$v1 2-3 Values for results and expression evaluation $a0-$a3 4-7 Arguments $t0-$t7 8-15 Temporaries $s0-$s7 16-23 Program variables Name Register number Usage $t8-$t9 24-25 More temporaries $gp 28 Global pointer $sp 29 Stack pointer $fp 30 Frame pointer $ra 31 Return address $at (register 1) is reserved for the assembler. $k0-$k1 (registers 26-27) are reserved for the operation system.
Background image of page 4
CS2100 MIPS III 5 R-FORMAT (1/2) Define fields of the following number of bits each: 6 + 5 + 5 + 5 + 5 + 6 = 32 6 5 5 5 6 5 For simplicity, each field has a name: opcode rs rt rd funct shamt A field is viewed as 5- or 6-bit unsigned integer, not as part of 32-bit integer 5-bit fields can represent any number 0-31 6-bit fields can represent any number 0-63
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS2100 MIPS III 6 R-FORMAT (2/2) opcode partially specifies what instruction it is equal to 0 for all R-Format instructions funct combined with opcode exactly specifies the instruction rs ( S ource R egister) used to specify register containing first operand rt ( T arget R egister) used to specify register containing second operand (note that name is misleading) rd ( D estination R egister) used to specify register which will receive result of computation shamt amount a shift instruction will shift by. Shifting a 32-bit word by more than 31 is useless, so this field is only 5 bits (so it can represent the numbers 0-31) set to 0 in all but the shift instructions
Background image of page 6
CS2100 MIPS III 7 R-FORMAT: EXAMPLE (1/3) MIPS instruction: add $8, $9, $10 (or add $t0, $t1, $t2 ) opcode = 0 (textbook pg 60 - 68) funct = 32 (textbook pg 60 - 68) rd = 8 (destination) rs = 9 (first operand) rt = 10 (second operand) shamt = 0 (not a shift)
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CS2100 MIPS III 8 R-FORMAT: EXAMPLE (2/3)
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 45

cs2100-13-MIPS-3 - CS2100Computer Organisation

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online