Download presentation
Presentation is loading. Please wait.
Published byDaniela Dorsey Modified over 9 years ago
1
Introduction to Microprocessors Chapter 2
2
Decimal or Base 10 Numbers Have ten different digits (0-9) It is a weighted number system. Each position as you move to the left has a weight of the base (10 for decimal) raised to an integer power. The first position (from right to left) has power of zero, next position power of one……. Ex: 123 = (1 x 10 2 ) + (2 x 10 1 ) + (3 x 10 0 )
3
Binary numbers They have two digits (0 & 1) To convert it to decimal: ex1: 101 2 = (1 x 2 2 ) + (0 x 2 1 ) + (1 x 2 0 ) = 4 + 0 + 1 = 5 10 ex2: 1100 2 = (1 x 2 3 ) + (1 x 2 2 ) + (0 x 2 1 ) + (0 x 2 0 ) = 8+4+ 0 +0 =12 10 ex3: 11001 2 = (1 x 2 4 ) + (1 x 2 3 ) + (0 x 2 2 ) + (0 x 2 1 ) + (1 x 2 0 ) = 16+ 8+0+ 0 +1 =25 10
4
Convert Decimal to Binary Repeated division by 2 Ex: 18 10 = ? 2 18/2=9 and reminder is 0 9/2 = 4 and reminder is 1 4/2 =2 and reminder is 0 2/2 =1 and reminder is 0 ½ = 0 and reminder is 1 Therefore 18 10 = 10010 2
5
Hexadecimal (base 16) Need 16 digits. We use our ordinary decimal digits (0-9) and A-F
6
Hex to decimal ex1: 123 16 = (1 x 16 2 ) + (2 x 16 1 ) + (3 x 16 0 ) = 256 + 32 + 3 = 291 10 ex2: 1A 16 = (1 x 16 1 ) + (10 x 16 0 ) = 16 + 10 =26 10
7
Decimal to Hex Repeated division by 16 Ex1: 26 10 = ? 16 26/16=1 and reminder is 10 (A) 1/16 = 0 and reminder is 1 Therefore 26 10 = 1A 16 Ex2: 83 10 = 53 16
8
Determine next number in HEX 2E 9F 7CBF
9
Hex to Binary Convert each digit to 4 bits binary equivalent Example: AB35H 1010 1011 0011 0101
10
Binary to Hex Break binary number into 4-bit sections from LSB to MSB Convert the 4 bits binary to its hex equivalent Example: 1010111110110010 Add zeros to the left if necessary A F B 2
11
Two’s complement signed number Positive number ex: 00000101 2 = +5 10 Negative number is shown as 2’s complement of positive number Write number as 8 bits Complement each bit (0 ->1 and 1-> 0) Add 1 Ex: -5 10 = ? 00000101 2 (1’s complement) => 11111010 + 1 11111011
12
Signed & unsigned numbers 8 bit unsigned can represent 0 to 255 10 8 bit signed can represent -128 to +127 10 2’s complement of a negative number is it’s corresponding positive number. We do not have negative & positive zero! If you have a negative number, How do you get its decimal equivalent??
13
2’s complement application CPU do not need 2 separate hardware module to perform add & subtraction. Subtraction can be done as: a – b = a + (-b)
14
ASCII Code American Standard Code for Information Interchange 7 bits needed. Ex: code for Q is 51(01010001) One bit is added for Parity Parity is even or odd Even parity: Number of 1s are even ex: 11100001 Odd parity: Number of 1s are odd
15
Binary Coded Decimal (BCD) Each decimal digit is represented by 4 bits Example1: 53 Example 2: 9201 01010011 1001 001000000001
16
Application of BCD Most common application of BCD is with seven-segment displays BCD to seven segment decoder inputs one 4- bit BCD and outputs a segment pattern-code
17
Seven-segment The display consists of seven individual bar LEDs Displays decimal and hexadecimal values The LED segments are labeled “a” through “g” To illuminate a “0” on the display, segment “a” through “f” are illuminated
18
Overflow Whenever two signed numbers are added or subtracted and the result is too large for the number of bits allocated
19
No overflow when adding a positive and a negative number No overflow when subtracting numbers with the same sign Overflow occurs when the result has “wrong” sign (verify!): Operation Operand A Operand B Result Indicating Overflow A + B 0 0 0 A + B 0 0 0 A – B 0 0 0 A – B 0 0 0 Detecting Overflow
20
Computer Programming High level language Assembly Language Machine Language
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.