cs3330-chap2-isa-2

cs3330-chap2-isa-2 - 1 Shift Operations op rs rt rd shamt...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 Shift Operations op rs rt rd shamt funct 6 bits 6 bits 5 bits 5 bits 5 bits 5 bits ¡ shamt: how many positions to shift ¡ Shift left logical ¡ Shift left and fill with 0 bits ¡ sll by i bits multiplies by 2i ¡ Shift right logical CS/ECE 3330 – Fall 2009 ¡ Shift right and fill with 0 bits ¡ srl by i bits divides by 2i (unsigned only) 26 AND Operations ¡ Useful to mask bits in a word ¡ Select some bits, clear others to 0 and $t0 $t1 $t2 and $t0, $t1, $t2 0000 0000 0000 0000 0000 1101 1100 0000 0000 0000 0000 0000 0011 1100 0000 0000 $t2 $t1 CS/ECE 3330 – Fall 2009 0000 0000 0000 0000 0000 1100 0000 0000 $t0 27 2 OR Operations ¡ Useful to include bits in a word ¡ Set some bits to 1, leave others unchanged or $t0 $t1 $t2 or $t0, $t1, $t2 0000 0000 0000 0000 0000 1101 1100 0000 0000 0000 0000 0000 0011 1100 0000 0000 $t2 $t1 CS/ECE 3330 – Fall 2009 0000 0000 0000 0000 0011 1101 1100 0000 $t0 28 NOT Operations ¡ Useful to invert bits in a word ¡ Change 0 to 1, and 1 to 0 ¡ MIPS has NOR 3-operand instruction ¡ a NOR b == NOT ( a OR b ) nor $t0, $t1, $zero Register 0: always read as zero CS/ECE 3330 – Fall 2009 0000 0000 0000 0000 0011 1100 0000 0000 $t1 1111 1111 1111 1111 1100 0011 1111 1111 $t0 29 3 Conditional Operations Branch to a labeled instruction if a condition is true (otherwise, continue sequentially) beq rs, rt, L1 ¡ if (rs == rt) branch to instruction labeled L1 bne rs, rt, L1 ¡ if (rs != rt) branch to instruction labeled L1 j L1 CS/ECE 3330 – Fall 2009 ¡ unconditional jump to instruction labeled L1 30 Compiling If Statements ¡ C code: if (i==j) f = g+h; else f = g-h; ¡ f, g, … in $s0, $s1, … ¡ Compiled MIPS code: bne $s3, $s4, Else add $s0, $s1, $s2 j Exit CS/ECE 3330 – Fall 2009 Assembler calculates addresses Else: sub $s0, $s1, $s2 Exit: … 31 4 Compiling Loop Statements ¡ C code: while (save[i] == k) i += 1; in $s3 k in $s5 address of save in $s6 ¡ i in $s3, k in $s5, address of save in $s6 ¡ Compiled MIPS code: Loop: sll $t1, $s3, 2 add $t1, $t1, $s6 lw $t0, 0($t1) CS/ECE 3330 – Fall 2009 bne $t0, $s5, Exit addi $s3, $s3, 1 j Loop Exit: … 32 Basic Blocks ¡ A basic block is a sequence of instructions with ¡ No embedded branches (except at end) ¡ No branch targets (except at beginning) ¡ A compiler identifies basic blocks for optimization CS/ECE 3330 – Fall 2009 ¡ An advanced processor can accelerate execution of basic blocks 33 5...
View Full Document

This note was uploaded on 11/04/2009 for the course CS 333 taught by Professor Stankovic during the Fall '08 term at UVA.

Page1 / 15

cs3330-chap2-isa-2 - 1 Shift Operations op rs rt rd shamt...

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

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