lec4-alu - H.-H. S. Lee1ECE3055 Computer Architecture and...

Info iconThis preview shows pages 1–9. 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

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: H.-H. S. Lee1ECE3055 Computer Architecture and Operating SystemsLecture 4 Numbers and ALU2ArithmeticWhere we've been:Performance (seconds, cycles, instructions)Abstractions:Instruction Set ArchitectureAssembly Language and Machine LanguageWhat's up ahead:Implementing the Architecture323232operationresultabALU3Bits are just bits (no inherent meaning) conventions define relationship between bits and numbersBinary numbers (base 2)0000 0001 0010 0011 0100 0101 0110 0111 1000 1001...decimal: 0...2n-1Of course it gets more complicated:numbers are finite (overflow)fractions and real numbersnegative numbers (e.g., no MIPS subi instruction; addi can add a negative number)How do we represent negative numbers? i.e., which bit patterns will represent which numbers?Numbers4Sign Magnitude: One's Complement Two's Complement000 = +0 000 = +0 000 = +0001 = +1 001 = +1 001 = +1010 = +2 010 = +2 010 = +2011 = +3 011 = +3 011 = +3100 = -0 100 = -3 100 = -4101 = -1 101 = -2 101 = -3110 = -2 110 = -1 110 = -2111 = -3 111 = -0 111 = -1Issues: balance, number of zeros, ease of operationsWhich one is best? Why? Possible Representations532 bit signed numbers:0000 0000 0000 0000 0000 0000 0000 0000two= 0ten0000 0000 0000 0000 0000 0000 0000 0001two= + 1ten0000 0000 0000 0000 0000 0000 0000 0010two= + 2ten...0111 1111 1111 1111 1111 1111 1111 1110two= + 2,147,483,646ten0111 1111 1111 1111 1111 1111 1111 1111two= + 2,147,483,647ten1000 0000 0000 0000 0000 0000 0000 0000two= 2,147,483,648ten1000 0000 0000 0000 0000 0000 0000 0001two= 2,147,483,647ten1000 0000 0000 0000 0000 0000 0000 0010two= 2,147,483,646ten...1111 1111 1111 1111 1111 1111 1111 1101two= 3ten1111 1111 1111 1111 1111 1111 1111 1110two= 2ten1111 1111 1111 1111 1111 1111 1111 1111two= 1tenmaxintminintMIPS6Negating a two's complement number: invert all bits and add 1remember: negate and invert are quite different!Converting n bit numbers into numbers with more than n bits:MIPS 16 bit immediate gets converted to 32 bits for arithmeticcopy the most significant bit (the sign bit) into the other bits0010 -> 0000 00101010 -> 1111 1010"sign extension" (lbu vs. lb)Two's Complement Operations7Just like in grade school (carry/borrow 1s, assume unsigned)0111 0111 0110+ 0110 - 0110 - 0101Two's complement operations easysubtraction using addition of negative numbers0111 + 1010Overflow (result too large for finite computer word):e.g., adding two n-bit numbers does not yield an n-bit number0111 + 0001 note that overflow term is somewhat misleading,1000it does not mean a carry overflowedAddition & Subtraction8No overflow when adding a positive and a negative numberNo overflow when signs are the same for subtractionOverflow occurs when the value affects the sign:overflow when adding two positives yields a negative or, adding two negatives gives a positiveor, subtract a negative from a positive and get a negative...
View Full Document

Page1 / 40

lec4-alu - H.-H. S. Lee1ECE3055 Computer Architecture and...

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