Integer Representation for People Computer Organization and Assembly Language: Module 3.

Slides:



Advertisements
Similar presentations
ECE 331 – Digital System Design
Advertisements

DATA REPRESENTATION CONVERSION.
Number Theory and Cryptography
Digital Fundamentals Floyd Chapter 2 Tenth Edition
Assembly Language and Computer Architecture Using C++ and Java
Chapter Chapter Goals Know the different types of numbers Describe positional notation.
Converting Binary to Octal
Number Systems and Arithmetic
BASICS OF COMPUTER APPLICATIONS ASB 102. UNIT 1 Introducing computer system  Number system  What is number system?  Types of number system  Their.
Binary Numbers.
Number Systems Lecture 02.
Number Systems - Part I CS 215 Lecture # 5.
Binary and Hexadecimal Numbers
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Fundamentals Tenth Edition Floyd.
Simple Data Type Representation and conversion of numbers
Numbering systems.
February 24, 2015Applied Discrete Mathematics Week 4: Number Theory 1 Modular Arithmetic Let a be an integer and m be a positive integer. We denote by.
Number Systems - Part II
MATH 224 – Discrete Mathematics
Decimal Number System We are used to the decimal number system which is a positional number system The decimal number 4386 represents the value: 41000.
DECIMAL BASE Based on power of 10 In the number 2,468 – from right to left -- the 8 represents the ones, the 6 represents the tens, the 4 represents the.
#1 Lec # 2 Winter EECC341 - Shaaban Positional Number Systems A number system consists of an order set of symbols (digits) with relations.
Chapter 3 Data Representation
Data Representation - Part I. Representing Numbers Choosing an appropriate representation is a critical decision a computer designer has to make The chosen.
Comp Sci 251 Intro 1 Computer organization and assembly language Wing Huen.
Representing Data. Representing data u The basic unit of memory is the bit  A transistor that can hold either high or low voltage  Conceptually, a tiny.
Data Representation in Computer Systems. 2 Objectives Understand the fundamentals of numerical data representation and manipulation in digital computers.
NUMBER SYSTEM.
CompSci 102 Discrete Math for Computer Science February 16, 2012 Prof. Rodger.
Chapter 2 Binary Values and Number Systems. 2 2 Natural Numbers Zero and any number obtained by repeatedly adding one to it. Examples: 100, 0, 45645,
Number systems, Operations, and Codes
CPS120: Introduction to Computer Science Computer Math: Converting to Decimal.
Positional Notation 642 in base 10 positional notation is:
Digital Electronics Octal & Hexadecimal Number Systems.
1 Data Representation Characters, Integers and Real Numbers Binary Number System Octal Number System Hexadecimal Number System Powered by DeSiaMore.
AEEE2031 Data Representation and Numbering Systems.
Binary01.ppt Decimal Decimal: Base 10 means 10 Unique numerical digits ,00010,000 Weight Positions 3,
Number Systems by Dr. Amin Danial Asham. References  Programmable Controllers- Theory and Implementation, 2nd Edition, L.A. Bryan and E.A. Bryan.
Digital Fundamentals Tenth Edition Floyd Chapter 2 © 2008 Pearson Education.
Octal & Hexadecimal Number Systems
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Logic Design Dr. Oliver Faust.
CPEN Digital Logic Design Binary Systems Spring 2004 C. Gerousis © Digital Design 3 rd Ed., Mano Prentice Hall.
Integer Operations Computer Organization and Assembly Language: Module 5.
Number Systems. Topics  The Decimal Number System  The Binary Number System  Converting from Binary to Decimal  Converting from Decimal to Binary.
ECE DIGITAL LOGIC LECTURE 2: DIGITAL COMPUTER AND NUMBER SYSTEMS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 01/14/2016.
The Hexadecimal System is base 16. It is a shorthand method for representing the 8-bit bytes that are stored in the computer system. This system was chosen.
Number Systems and Binary Arithmetic Quantitative Analysis II Professor Bob Orr.
© 2009 Pearson Education, Upper Saddle River, NJ All Rights ReservedFloyd, Digital Fundamentals, 10 th ed Digital Fundamentals Tenth Edition Floyd.
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.
Digital logic COMP214  Lecture 2 Dr. Sarah M.Eljack Chapter 1 1.
Fall’ 2014 Number System CSE Number System How Computers Represent Data Binary Numbers The Binary Number System Bits and Bytes Text Codes Binary.
Binary Values. Numbers Natural Numbers Zero and any number obtained by repeatedly adding one to it. Examples: 100, 0, 45645, 32 Negative Numbers.
Chapter 2 Binary Number Systems.
COMPUTING FUNDAMENTALS
Number Theory and Cryptography
Chapter 3 Data Representation
Number System conversions
IT 0213: INTRODUCTION TO COMPUTER ARCHITECTURE
Number Systems and Binary Arithmetic
Introduction to IT By: Muhammed s. anwar.
Chapter 2: Number Systems
Digital Logic Design (CSNB163)
Numeral systems (radix)
William Stallings Computer Organization and Architecture 10th Edition
Computer Organization and Architecture Designing for Performance
Information Representation
Presentation transcript:

Integer Representation for People Computer Organization and Assembly Language: Module 3

Motivation u The representation of numbers is made difficult because of the discrete nature of computer representation u Not all numbers can be represented in a computer u The chosen method of representation affects the ease by which arithmetic operations are performed

Weighted Positional Notation u Use the position of the symbol to indicate the value u By assigning each position the appropriate power of the base, we can get a unique representation of numbers in that base Decimal System (Base 10) Given a sequence of n digits d 0,d 1,…,d n-1 d n-1.10 n-1 + … + d d

Weighted Positional Notation u In general, given a sequence of n digits s 0,s 1,…,s n-1 and a base b, s n-1.b n-1 + … + s 1.b 1 + s 0.b 0 yields a unique integer N u s 0 is the least significant digit u s n-1 is the most significant digit u The most significant symbol can not be zero

Weighted Positional Notation u Any positive integer value can be used as the base or radix for a weighted positional notation u For bases less than or equal to 10, a subset of the ten decimal digits can be used  binary (base 2)  octal (base 8) u For bases more than 10, new symbols will have to be introduced  hexadecimal (base16)  a=10, b=11, c=12, d=13, e=14, f=15

Weighted Positional Notation u A subscript is used to indicate the base of the number in typeset  A number without a subscript is assumed to be base 10  Not an option while programming in MAL u In MIPS assembly language, hexadecimal representation begins with 0x  0x10 (= decimal 16) u So the following instructions are identical  li $v0, 0x12  li $v0, 18

Representations in Different Radices binary hexdecimalbinaryhexdecimal a b c d e f15

Binary and Hexadecimal u Discriminating between two symbols is currently cheaper in digital circuitry than three or more, thus binary is the representation for computers u Since bits can be grouped into three to obtain octal value and into four to obtain hexadecimal value, it is much easier for humans to work with octal or hexadecimal representations.  Octal is no longer very common; we will focus on hexadecimal u Binary to hexadecimal conversion is more direct than binary to decimal conversion.  Reason: 16 is a power of 2

Binary to Hexadecimal u To convert from binary to hexadecimal:  Starting with the least significant bit, partition the bits of the binary representation into groups of 4  The most significant group may have fewer than 4 members  Add zeroes to the left of the most significant group until it contains 4 bits  Convert each group of four bits into the hexadecimal symbol corresponding to that bit pattern

Binary and Hexadecimal Example: Convert to hexadecimal. binary hexadecimal 1 b hence: = 1b 16

Hexadecimal to Binary u To convert from binary to hexadecimal:  Convert each hexadecimal symbol to a group of 4 bits corresponding to that value  Eliminate leading zeroes Example: Convert 2bc1 16 to binary. hexadecimal 2 b c 1 binary hence: 2bc1 16 =

Conversion to Decimal Given a sequence of base-r digits s n-1... s 1 s 0 convert the sequence into a decimal number N using: N = s n-1 *b n-1 + … + s 1 *b 1 + s 0 *b 0

Conversion to Decimal Convert to decimal. N = 1* * * * * *2 0 = 38 Convert 3b2 16 to decimal. N = 3* * *16 0 = 946 Convert to decimal. N = 3* * *8 0 = = 248

Decimal  Binary or Hexadecimal Repeated division by 2 or 16 Example: Convert 292 to hexadecimal. 292/16 = 18 R 4 18/16 = 1 R 2 1/16 = 0 R = Conversion from Decimal When the quotient is less than 16, the process ends

Conversion from Decimal u Convert 42 to hexadecimal  42/16 = 2 R 10 (but 10 = a 16 )  2/16 = 0 R 242 = 2a 16 u Convert 109 to binary  109/2 = 54 R 1  54/2 = 27 R 0  27/2 = 13 R 1  13/2 = 6 R 1  6/2 = 3 R 0  3/2 = 1 R 1  1/2 = 0 R 1109 =

Shortcut: convert to hexadecimal u It is sometimes easier to convert from binary to hexadecimal, then to decimal, instead of converting directly to decimal = = 3 a b 6 = 3*16^3 + 10*16^2 + 11* = 3* * = = = 14940

Shortcut: convert to hexadecimal u The converse is also true: converting from decimal to hexadecimal, then to binary generally requires far fewer steps than converting directly to binary 278/16 = 17 R 6 17/16 = 1 R 1 1/16 = 0 R = = =

Representing Numbers u Choosing an appropriate representation is a critical decision a computer designer has to make u The chosen representation must allow for efficient execution of primitive operations u For general-purpose computers, the representation must allow efficient algorithms for  addition of two integers  determination of additive inverse

Representing Numbers u With a sequence of N bits, there are 2 N unique representations u Each memory cell can hold N bits u The size of the memory cell determines the number of unique values that can be represented u The cost of performing operations also increases as the size of the memory cell increases u It is reasonable to select a memory cell size such that numbers that are frequently used are represented

Binary Representation u The binary, weighted positional notation is the natural way to represent non-negative numbers. u MAL numbers the bits from right to left, beginning with 0 as the least significant digit

Modulo Arithmetic u Consider the set of number {0, …,7} u Suppose all arithmetic operations were finished by taking the result modulo 8 u = 9, 9 mod 8 = 1  = 1 u 3*5 = 15, 15 mod 8 = 7  3 * 5 =

Modulo Arithmetic: Additive Inverse u What is the additive inverse of 7? u 7 + x = 0 u = 0 u 0 and 4 are their own additive inverses u Does each number also have a multiplicative inverse?