04_Arithmetic_Operations

04_Arithmetic_Operations - Arithmetic and Logical...

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

View Full Document Right Arrow Icon
CMPE12 Cyrus Bazeghi Arithmetic and Logical Operations (Ch 2 & 3)
Background image of page 1

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

View Full DocumentRight Arrow Icon
CMPE12 Cyrus Bazeghi 2 Logical Operations Operate on raw bits with 1 = true and 0 = false In1 In2 | ~(|) ^ ~(^) 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1 0 1 0 0 1 1 0 1 0 1 1 1 1 0 0 0 1 AND OR NAND NOR XOR XNOR
Background image of page 2
CMPE12 Cyrus Bazeghi 3 “bit - wise” logical operations are done in parallel for corresponding bits X = 0011 Y = 1010 X AND Y = ? Logical Operations Example: So how do an OR? How about an XOR?
Background image of page 3

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

View Full DocumentRight Arrow Icon
CMPE12 Cyrus Bazeghi 4 Shifts and Rotates Logical right Move bits to the right, same order Throw away the bit that pops off the LSB Introduce a 0 into the MSB 00110101 00011010 (shift right by 1 ) Logical left Move bits to the left, same order Throw away the bit that pops off the MSB Introduce a 0 into the LSB 00110101 11010100 (shift left by 2 ) Can do by adding number to it self Logical Operations
Background image of page 4
CMPE12 Cyrus Bazeghi 5 Logical Operations: Shifts and Rotates Arithmetic right shift Move bits to the right, same order Throw away the bit that pops off the LSB Reproduce the original MSB into the new MSB Alternatively, shift the bits, and then do sign extension 00110101 00011010 (right by 1) 1100 1111 (right by 2) Arithmetic left shift Move bits to the left, same order Throw away the bit that pops off the MSB Introduce a 0 into the LSB 00110101 01101010 (left by 1)
Background image of page 5

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

View Full DocumentRight Arrow Icon
CMPE12 Cyrus Bazeghi 6 Logical Operations: Shifts and Rotates Rotate left Move bits to the left, same order Put the bit(s) that pop off the MSB into the LSB No bits are thrown away or lost 00110101 01101010 (rotate by 1)
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/14/2009 for the course CMPE 12/l taught by Professor Bazeghi during the Fall '09 term at UCSC.

Page1 / 26

04_Arithmetic_Operations - Arithmetic and Logical...

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

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