04_Arithmetic_Operations

# 04_Arithmetic_Operations - Arithmetic and Logical...

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

CMPE12 Cyrus Bazeghi Arithmetic and Logical Operations (Ch 2 & 3)

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

View Full Document
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
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?

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

View Full Document
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
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)

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

View Full Document
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)
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### 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
Ask a homework question - tutors are online