cce department – faculty of engineering - islamic university of lebanon chapter 6 binary...

Download CCE Department – Faculty of engineering - Islamic University of Lebanon Chapter 6 Binary Arithmetic

If you can't read please download the document

Upload: morris-brooks

Post on 18-Jan-2018

221 views

Category:

Documents


0 download

DESCRIPTION

CCE Department – Faculty of engineering - Islamic University of Lebanon Binary Addition Binary addition is very simple. This is best shown in an example of adding two binary numbers… carries

TRANSCRIPT

CCE Department Faculty of engineering - Islamic University of Lebanon Chapter 6 Binary Arithmetic CCE Department Faculty of engineering - Islamic University of Lebanon Addition 1 CCE Department Faculty of engineering - Islamic University of Lebanon Binary Addition Binary addition is very simple. This is best shown in an example of adding two binary numbers carries CCE Department Faculty of engineering - Islamic University of Lebanon Binary addition example worked out Some terms are given here Exercise: what are these numbers equivalent to in decimal? (Carries) 1011(Augend) +1110(Addend) 11001(Sum) The initial carry in is implicitly 0 most significant bit (MSB) least significant bit (LSB) CCE Department Faculty of engineering - Islamic University of Lebanon Subtraction 4 CCE Department Faculty of engineering - Islamic University of Lebanon Binary Subtraction 5 We can also perform subtraction (with borrows in place of carries). Lets subtract (10111) 2 from ( ) 2 borrows CCE Department Faculty of engineering - Islamic University of Lebanon Negative Numbers 6 Subtract by adding s complement Ignore carry CCE Department Faculty of engineering - Islamic University of Lebanon Twos Complement Shortcuts Algorithm Simply complement each bit and then add 1 to the result. Finding the 2s complement of ( ) 2 and of its 2s complement N = [N] = CCE Department Faculty of engineering - Islamic University of Lebanon Negative Numbers 8 Subtract by adding s comp flip CCE Department Faculty of engineering - Islamic University of Lebanon 9 Signed Numbers 10 4-bit: 8H = -8 to 7H = to bit: 80H = -128 to 7F = bit: 8000H = -32,768 to 7FFFH = +32, bit: H = -2,147,483,648 to 7FFFFFFFH = +2,147,483,647 CCE Department Faculty of engineering - Islamic University of Lebanon Questions 11 What is the twos complement of ? What hex number represents the decimal number -40? CCE Department Faculty of engineering - Islamic University of Lebanon Multiplication 12 CCE Department Faculty of engineering - Islamic University of Lebanon Binary Multiplication Binary multiplication is much the same as decimal multiplication, except that the multiplication operations are much simpler X CCE Department Faculty of engineering - Islamic University of Lebanon ASCII CODES 14 CCE Department Faculty of engineering - Islamic University of Lebanon ASCII The most commonly used code for representing letters, numerals and punctuation characters (alphanumeric data) Each character is represented with a 7-bit string; for example: 3 = (hex 33) = (hex 20) An 8-bit extension of ASCII has also been defined 15 CCE Department Faculty of engineering - Islamic University of Lebanon ASCII Code American Standard Code for Information Interchange ASCII is a 7-bit code, frequently used with an 8 th bit for error detection (more about that in a bit). 16 CharacterASCII (bin) ASCII (hex) Decimal A B C Z a 1 CCE Department Faculty of engineering - Islamic University of Lebanon ASCII Properties 17 Q1: What is relationship between a decimal digit (0, 1, ) and its ASCII code? CCE Department Faculty of engineering - Islamic University of Lebanon ASCII Properties (2) 18 Q2: What is the difference between an upper-case letter (A, B, ) and its lower-case equivalent (a, b, )? CCE Department Faculty of engineering - Islamic University of Lebanon BCD 19 CCE Department Faculty of engineering - Islamic University of Lebanon Binary Coded Decimal Binary coded decimal (BCD) represents each decimal digit with four bits Ex = 329 BCD This is NOT the same as Why do this? Because people think in decimal. 20 DigitBCD CodeDigitBCD Code CCE Department Faculty of engineering - Islamic University of Lebanon Putting It All Together 21 BCD not very efficient Used in early computers (40s, 50s) Used to encode numbers for seven- segment displays. Easier to read?