Microcomputers I - Electrical and Computer Engineering Dept. at Kettering.

Slides:



Advertisements
Similar presentations
Representing Numbers: Integers
Advertisements

HEXADECIMAL NUMBERS Code
Addition and Subtraction. Outline Arithmetic Operations (Section 1.2) – Addition – Subtraction – Multiplication Complements (Section 1.5) – 1’s complement.
Binary Arithmetic Binary addition Binary subtraction
Number Systems & Operations
COE 202: Digital Logic Design Signed Numbers
CHAPTER 2 Number Systems, Operations, and Codes
Digital Fundamentals Floyd Chapter 2 Tenth Edition
Assembly Language and Computer Architecture Using C++ and Java
Assembly Language and Computer Architecture Using C++ and Java
1 Binary Arithmetic, Subtraction The rules for binary arithmetic are: = 0, carry = = 1, carry = = 1, carry = = 0, carry =
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
ENGIN112 L3: More Number Systems September 8, 2003 ENGIN 112 Intro to Electrical and Computer Engineering Lecture 3 More Number Systems.
S. Barua – CPSC 240 CHAPTER 2 BITS, DATA TYPES, & OPERATIONS Topics to be covered are Number systems.
Signed Numbers CS208. Signed Numbers Until now we've been concentrating on unsigned numbers. In real life we also need to be able represent signed numbers.
1 Binary Numbers Again Recall that N binary digits (N bits) can represent unsigned integers from 0 to 2 N bits = 0 to 15 8 bits = 0 to bits.
© 2010 Kettering University, All rights reserved..
Information Representation and Number Systems BIL- 223 Logic Circuit Design Ege University Department of Computer Engineering.
Number Systems Lecture 02.
Chapter 3 Data Representation part2 Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2010.
Binary Representation - Shortcuts n Negation x + x = 1111…1111 two = -1 (in 2’s complement) Therefore, -x = x + 1 n Sign Extension o Positive numbers :
Chapter3 Fixed Point Representation Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2009.
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Fundamentals Tenth Edition Floyd.
1 Arithmetic and Logical Operations - Part II. Unsigned Numbers Addition in unsigned numbers is the same regardless of the base. Given a pair of bit sequences.
Numeral Systems Subjects: Numeral System Positional systems Decimal
Data Representation – Binary Numbers
#1 Lec # 2 Winter EECC341 - Shaaban Positional Number Systems A number system consists of an order set of symbols (digits) with relations.
Engineering 1040: Mechanisms & Electric Circuits Spring 2014 Number Systems.
Lecture 2 Bits, Bytes & Number systems
Cosc 2150: Computer Organization Chapter 2 Part 1 Integers addition and subtraction.
BR 8/99 Binary Numbers Again Recall than N binary digits (N bits) can represent unsigned integers from 0 to 2 N bits = 0 to 15 8 bits = 0 to 255.
Positional Number Systems
ECE2030 Introduction to Computer Engineering Lecture 2: Number System Prof. Hsien-Hsin Sean Lee School of Electrical and Computer Engineering Georgia Tech.
1 IT 231, CMPE 331 Digital Logic Design Week 2 Number systems and arithmetic.
Lecture 2 Binary Values and Number Systems. The number 943 is an example of a number written in positional notation. The relative positions of the digits.
Operations on Bits Arithmetic Operations Logic Operations
Computer Math CPS120 Introduction to Computer Science Lecture 4.
AEEE2031 Data Representation and Numbering Systems.
Data Representation in Computer Systems. 2 Signed Integer Representation The conversions we have so far presented have involved only positive numbers.
Number Systems & Operations
07/12/ Data Representation Two’s Complement & Binary Arithmetic.
WEEK #2 NUMBER SYSTEMS, OPERATION & CODES (PART 1)
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
Bits, Data types, and Operations: Chapter 2 COMP 2610 Dr. James Money COMP
CEC 220 Digital Circuit Design Binary Arithmetic & Negative Numbers Monday, January 13 CEC 220 Digital Circuit Design Slide 1 of 14.
CEC 220 Digital Circuit Design Binary Arithmetic & Negative Numbers Fri, Aug 28 CEC 220 Digital Circuit Design Slide 1 of 14.
DIGITAL SYSTEMS Number systems & Arithmetic Rudolf Tracht and A.J. Han Vinck.
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Logic Design Dr. Oliver Faust.
Introduction to Digital Electronics Lecture 2: Number Systems.
ECE DIGITAL LOGIC LECTURE 3: DIGITAL COMPUTER AND NUMBER SYSTEMS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 01/19/2016.
Chapter 1 Representing Data in a Computer. 1.1 Binary and Hexadecimal Numbers.
Lecture No. 4 Computer Logic Design. Negative Number Representation 3 Options –Sign-magnitude –One’s Complement –Two’s Complement  used in computers.
Computer Math CPS120 Introduction to Computer Science Lecture 7.
Number Systems. The position of each digit in a weighted number system is assigned a weight based on the base or radix of the system. The radix of decimal.
Dr. ClincyLecture 2 Slide 1 CS Chapter 2 (1 of 5) Dr. Clincy Professor of CS Note: Do not study chapter 2’s appendix (the topics will be covered.
Lecture 4: Digital Systems & Binary Numbers (4)
1 CE 454 Computer Architecture Lecture 4 Ahmed Ezzat The Digital Logic, Ch-3.1.
Cosc 2150: Computer Organization
Chapter 2 Binary Number Systems.
Number Systems and Codes (parte 1)
IT 0213: INTRODUCTION TO COMPUTER ARCHITECTURE
Addition and Substraction
ME 4447/6405 Microprocessor Control of Manufacturing Systems and
Digital Logic Design (ECEg3141) 2. Number systems, operations & codes 1.
Digital Electronics and Microprocessors
CPS120: Introduction to Computer Science
Decimal and binary representation systems
Binary to Decimal Conversion
ECE 331 – Digital System Design
Chapter3 Fixed Point Representation
Presentation transcript:

Microcomputers I - Electrical and Computer Engineering Dept. at Kettering

 Jaerock Kwon, Ph.D.  Computer Engineering from Texas A&M University   You may follow me  Twitter:  facebook:  YouTube: Microcomputers I - Electrical and Computer Engineering Dept. at Kettering

Lecture 2 Microcomputers I - Electrical and Computer Engineering Dept. at Kettering

 Review binary and hexadecimal number representation  Convert directly from one base to another base  Review addition and subtraction in binary representation  Determine overflow in unsigned and signed binary addition and subtraction. Microcomputers I - Electrical and Computer Engineering Dept. at Kettering

 Human: decimal number system  Radix-10 or base-10  Base-10 means that a digit can have one of ten possible values, 0 through 9.  Computer: binary number system  Radix-2 or base-2  Each digit can have one of two values, 0 or 1  Compromise: hexadecimal  Long strings of 1s and 0s are cumbersome to use  Represent binary numbers using hexadecimal.  Radix-16 or base-16  This is only a convenience for humans not computers.  All of these number systems are positional Microcomputers I - Electrical and Computer Engineering Dept. at Kettering

 Numbers are represented using the digits 0, 1, 2, …, 9.  Multi-digit numbers are interpreted as in the following example   = 7 x x  = 7 x x x 10 0 Microcomputers I - Electrical and Computer Engineering Dept. at Kettering

 Numbers are represented using the digits 0 and 1.  Multi-digit numbers are interpreted as in the following example   = 1 x x x x x 2 0  = 1 x x x x x 1  Bit: Each digit is called a bit(Binary Digit) in binary  Write all bits including leading 0s.  Ex: (8-bit binary) Microcomputers I - Electrical and Computer Engineering Dept. at Kettering

 Numbers are represented using the digits 0, 1, 2, …, 9, A, B, C, D, E, F where the letters represent values: A=10, B=11, C=12, D=13, E=14, and F=15.  Multi-digit numbers are interpreted as in the following example  76CA 16  = 7 x x C(=12) x A(=10) x 16 0  = 7 x x x  = 30, Microcomputers I - Electrical and Computer Engineering Dept. at Kettering

 Subscript is mandatory  We use all three number bases.  When a number is written out of context, you should include the correct subscript.  Pronunciation  Binary and hexadecimal numbers are spoken by naming the digits followed by “binary” or “hexadecimal.” ▪e.g., is pronounced “one zero zero zero hexadecimal.” ▪c.f., “one-thousand hexadecimal” refers the hexadecimal number corresponding (so, 3E8 16 ) Microcomputers I - Electrical and Computer Engineering Dept. at KetteringJ. Kwon

Microcomputers I - Electrical and Computer Engineering Dept. at Kettering

 Most microprocessors use 2’s complement numbers to represent number systems with positive and negative values.  Hardware performs addition and subtraction on binary values the same way whether they are unsigned or 2’s complement systems.  In signed systems, MSB(Most Significant Bit) has a weight of -2 (n-1). Microcomputers I - Electrical and Computer Engineering Dept. at Kettering

 We will use ‘2c’ subscript to indicate a 2’s complement number.  Examples  Convert c in decimal  = -2 (8-1) x =  Convert c in decimal  = -2 (5-1) x =  Convert c in decimal  = -2 (5-1) x = Microcomputers I - Electrical and Computer Engineering Dept. at Kettering

 To microprocessors, a group of bits are simply a group of bits.  Humans interpret the group as an unsigned, signed values or also as just a group of bits. Microcomputers I - Electrical and Computer Engineering Dept. at Kettering

 The leftmost bit (MSB) is a sign bit.  We can tell the number is negative or positive by simply inspecting the leftmost bit.  If MSB is 1, the number is negative. Otherwise, positive.  Why?  The leftmost column has a negative weight, and the magnitude of that weight is larger than the weights of all the positive columns added altogether, any number with a 1 in the leftmost column will be negative. Microcomputers I - Electrical and Computer Engineering Dept. at Kettering

 Negate a number:  Generate a number with the same magnitude but with the opposite sign.  Ex: 25  -25  Two steps in binary systems  1. Perform the 1’s complement (flip all the bits)  2. Add 1.  Ex: Negate c (41 10 ) ▪1. Flip all the bits: ▪2. Add 1:  c ( ) Microcomputers I - Electrical and Computer Engineering Dept. at Kettering

 We’ve covered  Binary to Decimal  Hexadecimal to Decimal  Decimal to Binary (or Hexadecimal)  1. Successively divide the decimal number by the new base and keep track of the remainders generated  2. Stop dividing once the quotient reaches 0.  3. Write the remainders in the opposite order of the generation of the numbers.  4. Add leading digits if necessary. Microcomputers I - Electrical and Computer Engineering Dept. at Kettering

 Ex: Convert to 8-bit unsigned binary. Microcomputers I - Electrical and Computer Engineering Dept. at Kettering

 Ex: Convert to 2-digit hexadecimal. Microcomputers I - Electrical and Computer Engineering Dept. at Kettering

 Converting a negative value  1. convert the magnitude to correct number of bits  2. negate the result.  Ex: to 8-bit signed binary Microcomputers I - Electrical and Computer Engineering Dept. at Kettering

 This conversion is the reason that hexadecimal is used.  We can group 4 bits since four bits can represent 16 (=2 4 ) different values.  Examples: ▪ = 9 5 E 16 ▪ = 6 A B 16  If a binary number is a multiple of 4bits, padding the number with zeros regardless of the sign of the number.  Examples: ▪ = = 1 5 E 16 ▪ = = 1 B 16 Microcomputers I - Electrical and Computer Engineering Dept. at Kettering

 Hexadecimal is not interpreted as signed or unsigned.  Converting hexadecimal to binary  Examples ▪B E F A 16 = ▪7 3 F C 16 =  We can specify a binary system with any number of bits.  Examples ▪0 7 B 16 to 9-bit signed = ▪1 F 16 = Microcomputers I - Electrical and Computer Engineering Dept. at Kettering

 Overflow occurs when two numbers are added or subtracted and the correct result is a number that is outside of the range of allowable numbers.  Example: ▪ = 264 (<255); overflow in unsigned 8-bit. ▪-100 – 30 = -130(<-128); overflow in signed 8-bit = 0, carry = 00 – 0 = 0, borrow = = 1, carry = 01 – 0 = 1, borrow = = 1, carry = 00 – 1 = 0, borrow = = 0, carry = 11 – 1 = 0, borrow = 0

 For unsigned:  It is simple.  A carry (or borrow) out of the most significant column indicates that overflow occurred.  For signed:  A carry does not mean overflow.  Ex: in 4-bit binary system ▪ = 1 ( = 0001 with carry = 1 (carry ignored) ▪-4 – 3 = -7 ( = 1001 with carry = -7 (carry ignored) ▪6 +3 = 9 (overflow), = 1001 (=-7), incorrect. ▪-7 – 3 = -10 (underflow), ( = 0110 (=6), incorrect. Microcomputers I - Electrical and Computer Engineering Dept. at Kettering

 For signed:  It is hard to detect overflow(underflow).  Addition: ▪Adding same sign numbers and the result with different sign  overflow. ▪No overflow in case if the two numbers have different sign.  Subtraction: ▪Minuend – subtrahend = difference ▪If sign(difference) == sign(minuend)  no overflow ▪If sign(difference) == sign(subtrahend)  overflow. Microcomputers I - Electrical and Computer Engineering Dept. at Kettering

 For signed: examples  Addition: ▪ = ▪Unsigned (no overflow), signed (overflow, because the sign of the result is different from numbers being added)  Subtraction: ▪ = ▪Unsigned(overflow), signed(overflow, because the sign of the result is same as that of the subtrahend) Microcomputers I - Electrical and Computer Engineering Dept. at Kettering

 Another way to visualize overflow.  Increasing a value moves us clockwise around the number lines  Decreasing a value moves us counter- clockwise.  If the “wrap-around” point is crossed during this move, overflow occurs. Microcomputers I - Electrical and Computer Engineering Dept. at Kettering

 The binary numbers must have the same number of bits when performing arithmetic operations.  It is necessary to extend the shorter number so that it has the same number of bits as the longer number.  For unsigned:  Always extend by adding zeros.  For signed:  Always extend by repeating sign bit. Microcomputers I - Electrical and Computer Engineering Dept. at Kettering

 Extend the binary numbers below to 16 bits.      C   C  Microcomputers I - Electrical and Computer Engineering Dept. at Kettering

 It is not possible to truncate binary numbers if it yields a shorter number that does not represent the same value as the original number.  Unsigned:  All bits discarded must be 0s.  Signed:  All bits discarded must be same as the new sign bit of the shorter number.  Examples: Truncate 16-bit values to 8 bits Microcomputers I - Electrical and Computer Engineering Dept. at Kettering

 Truncate 16-bit values to 8 bits     not possible  C  not possible  C  C  C  not possible  C  C Microcomputers I - Electrical and Computer Engineering Dept. at Kettering

 Binary and hexadecimal number representation  Convert directly from one base to another base  Addition and subtraction in binary representation  Determine overflow in unsigned and signed binary addition and subtraction. Microcomputers I - Electrical and Computer Engineering Dept. at Kettering