Lecture 03-arithmetic - 1048: Computer Organization Lecture...

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

View Full Document Right Arrow Icon
Lecture03 - arithmetic (cwliu@twins.ee.nctu.edu.tw) 3-1 1048: Computer Organization 1048: Computer 1048: Computer Organization Organization Lecture 3 Lecture 3 Arithmetic for Arithmetic for Computers Computers
Background image of page 1

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

View Full DocumentRight Arrow Icon
Lecture03 - arithmetic (cwliu@twins.ee.nctu.edu.tw) 3-2 Bits vs. Numbers Bits are just bits (no inherent meaning) conventions define relationship between bits and numbers Eg. binary numbers (base 2) 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001. .. decimal: 0...2 n -1 Of course, using binary numbers get more complicated: numbers are finite (overflow) how about fractions and real numbers? how do we represent negative numbers? how does the hardware know which convention is being used? i.e., which bit patterns will represent which numbers?
Background image of page 2
Lecture03 - arithmetic (cwliu@twins.ee.nctu.edu.tw) 3-3 Outline • Signed and unsigned numbers (Sec. 3.2) • Addition and subtraction (Sec. 3.3) • Constructing an arithmetic logic unit (Appendix B.5, B6) • Multiplication (Sec. 3.4, CD: 3.23 In More Depth) • Division (Sec. 3.5) • Floating point (Sec. 3.6)
Background image of page 3

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

View Full DocumentRight Arrow Icon
Lecture03 - arithmetic (cwliu@twins.ee.nctu.edu.tw) 3-4 Binary Representation of Integers • Number can be represented in any base • Hexadecimal/Binary/Decimal representations ACE7 hex = 1 010 1100 1110 011 1 bin = 44263 dec –m ost s ignificant b it, MSB , usually the leftmost bit –l east s ignificant b it, LSB , usually the rightmost bit • Ideally, we can represent any integer if the bit width is unlimited • Practically, the bit width is limited and finite… – for a 8-bit byte Î 0~255 (0~2 8 –1) –f o r a 1 6 - b i t h a l f w o r d Î 0~65,535 (0~2 16 – for a 32-bit word Î 0~4,294,967,295 (0~2 32
Background image of page 4
Lecture03 - arithmetic (cwliu@twins.ee.nctu.edu.tw) 3-5 Signed Number • Unsigned number is mandatory – Eg. Memory access, PC, SP, RA • Sometimes, negative integers are required in arithmetic operation – a representation that can present both positive and negative integers is demanded Î signed integers 3 well-known methods • Sign and Magnitude •1 s c o m p l e m e n t •2 s c o m p l e m e n t
Background image of page 5

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

View Full DocumentRight Arrow Icon
Lecture03 - arithmetic (cwliu@twins.ee.nctu.edu.tw) 3-6 Sign and Magnitude • Use the MSB as the sign bit – 0 for positive and 1 for negative • If the bit width is n –r a n g e Î –(2 n–1 –1)±~ ±2 n–1 –1;±2 n – 1 different numbers – e.g., for a byte Î –127 ~ 127 •E x a m p l e s –0 0000110 Î + 6 –1 0000111 Î 7 • Shortcomings – 2 0’s; positive 0 and negative 0; 0 0000000 and 1 0000000 – relatively complicated HW design (e.g., adder)
Background image of page 6
Lecture03 - arithmetic (cwliu@twins.ee.nctu.edu.tw) 3-7 1’s Complement +7 Î 0000 0111 –7 Î 1111 1000 (bit inverting) • If the bit width is n –r a n g e Î –(2 n–1 –1)±~ ±2 n–1 –1;±2 n – 1 different numbers – e.g., for a byte Î –127 ~ 127 • The MSB implicitly serves as the sign bit – except for –0 • Shortcomings – 2 0’s; positive 0 and negative 0; 00000000 and 11111111 – relatively complicated HW design (e.g., adder)
Background image of page 7

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

View Full DocumentRight Arrow Icon
Lecture03 - arithmetic (cwliu@twins.ee.nctu.edu.tw) 3-8 2’s Complement +7 Î 0000 0111 –7 Î 1111 100 1 (bit inverting first then add 1 ) The MSB implicitly serves as the sign bit
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.

This note was uploaded on 08/23/2009 for the course DEE 4641 taught by Professor Cwliu during the Fall '08 term at National Chiao Tung University.

Page1 / 109

Lecture 03-arithmetic - 1048: Computer Organization Lecture...

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