Lec05 - I-Format vs. R-Format Instructions Compare with...

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

View Full Document Right Arrow Icon
1 I-Format vs. R-Format Instructions Compare with R-Format offset 6 bits 5 bits 5 bits 16 bits I-Format op rs rt rd funct shamt 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits R-Format op rs rt Note similarity! What’s the difference?
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 I-Format Example Machine language for lw $9, 1200($8) op rs rt offset 6 bits 5 bits 5 bits 16 bits Binary Decimal 35 8 9 1200 100011 01000 01001 0000010010110000 0 31
Background image of page 2
3 MIPS Conditional Branch Instructions Conditional branches allow decision making beq R1, R2, LABEL if R1==R2 goto LABEL bne R3, R4, LABEL if R3!=R4 goto LABEL Example C Code if (i==j) goto L1; f = g + h; L1: f = f - i; Assembly beq $s3, $s4, L1 add $s0, $s1, $s2 L1: sub $s0, $s0, $s3
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 MIPS Instruction Encoding
Background image of page 4
5 Example: Compiling C if-then-else Example C Code if (i==j) f = g + h; else f = g - h; Assembly bne $s3, $s4, Else add $s0, $s1, $s2 j Exit; # new: unconditional jump Else: sub $s0, $s1, $s2 Exit: New Instruction: Unconditional jump j LABEL # goto Label
Background image of page 5

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

View Full DocumentRight Arrow Icon
6 Binary Representation - Branch Branch instructions use I-Format offset is added to PC when branch is taken beq r0, r1, offset has the effect: if (r0==r1) pc = pc + 4 + (offset << 2) else pc = pc + 4; Offset is specified in instruction words ( why? ) What is the range of the branch target addresses? op rs rt offset 6 bits 5 bits 5 bits 16 bits Conversion to word offset (PC+4)-2 17 <= target address <= (PC+4)+ 2 17
Background image of page 6
7 Branch Example Machine language for beq $s3, $s4, L1 add $s0, $s1, $s2 L1: sub $s0, $s0, $s3 op rs rt offset 6 bits 5 bits 5 bits 16 bits Binary Decimal 4 19 20 1 000100 10011 10100 0000000000000001 19 20 PC PC+4 Target of beq 1-instruction offset 0 31
Background image of page 7

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

View Full DocumentRight Arrow Icon
8 Comparisons - What about <, <=, >, >=? bne , beq provide equality comparison slt provides magnitude comparison slt $t0,$s3,$s4 # if $s3<$s4 $t0=1; # else $t0=0; Why not include a blt instruction in hardware? Supporting in hardware would lower performance
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.

This note was uploaded on 11/03/2009 for the course CS 20929 taught by Professor Taoxie during the Spring '09 term at San Diego State.

Page1 / 29

Lec05 - I-Format vs. R-Format Instructions Compare with...

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