Review – Binary numbers Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff 1 Unsigned Binary Numbers • Representation • List the set of 3 bit numbers … __ __ _ _ _ _ 32 16 8 4 2 1 • Determining the value of an N-bit number B bn 1 2n 1 bn 2 2n 2 b1 21 b0 20 • Determine the value of 100101 • Largest and smallest N-bit numbers • Addition is done just like decimal Microcomputer Architecture and Interfacing Colorado School of Mines • Add: 101101 + 001110 Professor William Hoff 2 Twos Complement Binary • The most significant bit (MSB) is negative __ __ _ _ _ _ -32 16 8 4 2 1 • Determining the value of an N-bit number B bn 1 2n 1 bn 2 2n 2 b1 21 b0 20 • List the set of 3 bit numbers • Determine the value of 100101 • Largest and smallest N-bit numbers • Addition is done just like unsigned (ignore carry out of MSB position) Microcomputer Architecture and Interfacing Colorado School of Mines • Add: 101101 001110 Professor William Hoff 3 Binary Arithmetic • Negating twos complement numbers – Just flip all the bits and add 1 – Example: • +3: 011 • -3: • Detecting overflow when adding two N-bit numbers – Unsigned • Overflow occurs when there is a “1” carried out of the MSB – Twos complement • Overflow occurs when you add two positive numbers and get a negative number, or add two negative numbers and get a positive result Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff 4 Hexadecimal Numbers • Representation … ___ __ __ __ _ 65536 4096 256 16 1 • Determining the value of an (unsigned) N-digit hex number H hn 116n 1 hn 216n 2 h1161 h0160 Table 1.1 Prefixes for number bases Base Prefix Example Binary Octal Decimal Hexadecimal (shorthand hex) Microcomputer Architecture and Interfacing % @ $ %10001010 @123467 12345678 $392 Colorado School of Mines Professor William Hoff Value Digit 0 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 A 11 B 12 C 13 D 14 E 15 F 5 Examples • Which is the bigger number? Hex: AB Unsigned binary: 10100001 • Add these 2’s complement binary numbers, using 8-bit arithmetic: 0100 0000 1100 0000 Microcomputer Architecture and Interfacing Colorado School of Mines Professor William Hoff 6