CSCI341 Lecture 11, Logical Operations Image courtesy of - - PowerPoint PPT Presentation

csci341
SMART_READER_LITE
LIVE PREVIEW

CSCI341 Lecture 11, Logical Operations Image courtesy of - - PowerPoint PPT Presentation

CSCI341 Lecture 11, Logical Operations Image courtesy of http://debsbookbag.blogspot.com/ vs PERFORMANCE CPU Time = (Instruction Count x CPI) / Clock Rate Clock Rate CPI class A CPI class B CPI class C CPI class D Watermelon 1.5 GHz 1


slide-1
SLIDE 1

CSCI341

Lecture 11, Logical Operations

slide-2
SLIDE 2

Image courtesy of http://debsbookbag.blogspot.com/

slide-3
SLIDE 3

PERFORMANCE

vs CPU Time = (Instruction Count x CPI) / Clock Rate

Clock Rate CPI class A CPI class B CPI class C CPI class D Watermelon 1.5 GHz 1 2 3 4 Sour Apple 2 GHz 2 2 2 2

Given a program with 100 instructions, with 10% as class A, 20% class B, 50% class C and 20% class D, which implementation is faster?

slide-4
SLIDE 4

WHERE WE’VE BEEN

  • Understanding & Calculating Computer Performance
  • The Power Wall
  • Amdahl’s Law
  • Fallacies / Pitfalls
  • Heat, Costs and the Rise of Parallelism
slide-5
SLIDE 5

WHERE WE’VE BEEN

  • Binary numbers
  • Two’s complement (signed) binary numbers
  • Addition & Subtraction of signed/unsigned binary numbers
  • Binary to decimal to hex representations
  • Shortcuts & tricks (negation, sign extension)
slide-6
SLIDE 6

WHERE WE’VE BEEN

  • Fundamental MIPS operations
  • Operands and registers $zero, $t*, $s*
  • add, sub, addi, lw, sw
  • Base addresses and offsets (x4)
slide-7
SLIDE 7

INSTRUCTIONS (REVIEW)

R-type I-type

(no, not this)

Register operations eg, add, sub Immediate operations eg, addi, and data transfer

slide-8
SLIDE 8

INSTRUCTION FORMATS

  • p

rs rt rd shamt funct 18 8 8 32 $s2 $t0 $t0 add

R

  • p

rs rt constant / address 35 9 8 1200 lw $t1 $t0 1200

I

lw $t0, 1200($t1) add $t0, $s2, $t0

slide-9
SLIDE 9

R-TYPE VS. I-TYPE

slide-10
SLIDE 10

LOGICAL OPERATIONS

slide-11
SLIDE 11

LOGICAL SHIFTING

0000 1001 1001 0000 << 1011 0000 0000 1011 >>

slide-12
SLIDE 12

LOGICAL SHIFTING

0000 1001 1001 0000

sll $t2, $s0, 4

1011 0000 0000 1011

srl $t2, $s0, 4

$s0 $s0 $s0 $s0 $t2 $t2

slide-13
SLIDE 13

sll, srl Instructions

  • p

rs rt rd shamt funct 16 10 4

sll $t2, $s0, 4 What is shamt for srl?

slide-14
SLIDE 14

WHY GIVE A SHIFT?

  • ptimized version of multiplying or dividing by

powers of two! (among other things)

slide-15
SLIDE 15

and $t0, $t1, $t2 perform bitwise AND operation on values in $t1 and $t2

AND and OR

  • r $t0, $t1, $t2

perform bitwise OR operation on values in $t1 and $t2

slide-16
SLIDE 16

32-bit words.... But what if I want just part of that word?

MASKING

slide-17
SLIDE 17

MASKING

Given a byte 1011 0100 How might you ‘extract’ or ‘isolate’ the second nibble?

slide-18
SLIDE 18

MASKING WITH AND

1011 0100 0000 1111 AND 0000 0100 “bit masking”

slide-19
SLIDE 19

HOMEWORK

  • Reading 9: section 2.6
  • Problem Set 6 (Instruction formats)
  • Project 2 (a simple program)