CSE230_Set03_Arithmetic

CSE230_Set03_Arithmetic - CSE230/EEE230 Computer...

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

View Full Document Right Arrow Icon
Arizona State University Tempe, AZ 85287 Instructor: Dr. Baoxin Li baoxin.li@asu.edu Office: Brickyard 502 CSE230/EEE230 Computer Organization and Assembly Language Fall 2006
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 Numbers Bits are just bits (no inherent meaning) conventions define relationship between bits and numbers Binary numbers (base 2) 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001. .. Of course it gets more complicated: numbers are finite (overflow) fractions and real numbers negative numbers How do we represent negative numbers? which bit patterns will represent which numbers?
Background image of page 2
3 Number and Base Data Representation --- a number and its base (radix) decimal : base = 10; e.g. (12345) 10 binary: base = 2; e.g. (011011) 2 In general, 2 8 8 0 0 1 2 3 0 1 2 0 1 2 3 4 5 2 0 1 2 3 8 0 0 1 1 2 - n 2 - n 1 - n 1 - n b 0 1 2 - n 1 - n ) 010 , 111 , 110 , 101 ( ) 5672 ( (33) = 2 ) 2 1 2 1 2 0 ( 2 ) 2 1 2 1 2 0 ( = 2 1 2 1 2 0 2 1 2 1 2 0 ) 011011 ( 8 2 8 7 8 6 8 5 ) 5672 ( b d + b d . . . . + b d + b d = ) d d . . . . d d ( = × × + × + × + × × + × + × × + × + × + × + × + × = × + × + × + × = × × × ×
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 Data Representation Hexadecimal -- 16 digits: 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f 0x037ff = (037ff) 16 =(0000,0011,0111,1111,1111) 2 = Conversion from one base to the other a decimal number to binary representation 0 1 2 3 4 16 15 16 15 16 7 16 3 16 0 × + × + × + × + × 225 112 56 28 14 7 3 1 1 0 0 0 0 1 1 2 2 2 2 2 2 2 225 = ( 11100001 ) 2
Background image of page 4
5 Binary Representation Consider a 4-bit binary number Examples: 3 + 2 = 5 3 + 3 = 6 0 0 1 1 0 0 1 0 + 0 1 0 1 1 0 0 1 1 0 0 1 1 + 0 1 1 0 1 1 Binary Binary Decimal 0 0000 1 0001 2 0010 3 0011 Decimal 4 0100 5 0101 6 0110 7 0111
Background image of page 5

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

View Full DocumentRight Arrow Icon
6 Negative Binary Numbers 2’s complement representation of negative numbers (bitwise inverse and add 1) The MSB is always “1” for negative number => sign bit 16-bit binary: -2 15 (-32768) ---- 0 ---- 2 15 -1 (32767) 32-bit binary: -2 31 (-2,147,483,648) ---- 0 ---- 2 31 -1 (2,147,483,647) decimal positive negative sign-magnitude 1’s compl. 2’s compl. 0 0000 1000 1111 0000 1 0001 1001 1110 1111 2 0010 1010 1101 1110 3 0011 1011 1100 1101 4 0100 1100 1011 1100 5 0101 1101 1010 1011 6 0110 1110 1001 1010 7 0111 1111 1000 1001 8 1000
Background image of page 6
7 0000 0000 0000 0000 0000 0000 0000 0000 two = 0 ten 0000 0000 0000 0000 0000 0000 0000 0001 two = + 1 ten 0000 0000 0000 0000 0000 0000 0000 0010 two = + 2 ten ... 0111 1111 1111 1111 1111 1111 1111 1110 two = + 2,147,483,646 ten 0111 1111 1111 1111 1111 1111 1111 1111 two = + 2,147,483,647 ten 1000 0000 0000 0000 0000 0000 0000 0000 two = – 2,147,483,648 ten 1000 0000 0000 0000 0000 0000 0000 0001 two = – 2,147,483,647 ten 1000 0000 0000 0000 0000 0000 0000 0010 two = – 2,147,483,646 32 bit signed numbers in MIPS
Background image of page 7

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

View Full DocumentRight Arrow Icon
8 Negating a two's complement number: invert all bits and add 1 remember: “negate” and “invert” are quite different! Converting n bit numbers into numbers with
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 34

CSE230_Set03_Arithmetic - CSE230/EEE230 Computer...

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