COMPUTER ORGANIZATION AND. Edition. The Hardware/Software Interface. Chapter 3. Arithmetic for Computers

Size: px
Start display at page:

Download "COMPUTER ORGANIZATION AND. Edition. The Hardware/Software Interface. Chapter 3. Arithmetic for Computers"

Transcription

1 ARM D COMPUTER ORGANIZATION AND Edition The Hardware/Software Interface Chapter 3 Arithmetic for Computers Modified and extended by R.J. Leduc

2 In this chapter, we will investigate: How integer arithmetic operations are carried out: Addition and subtraction Multiplication and division Floating-point (real) numbers How they are represented in a computer How their arithmetic operations are performed 3.1 Introduction Arithmetic for Computers Chapter 3 Arithmetic for Computers 2

3 3.2 Addition and Subtraction Integer Addition Example: Overflow occurs if result out of range Adding +ve and ve operands, no overflow Adding two +ve operands Overflow if MSB of result is 1 Adding two ve operands Overflow if MSB of result is 0 Chapter 3 Arithmetic for Computers 3

4 Oversized Operands ARMv8 is set up to add two 64 bit numbers How do you handle the addition of two 128 bit numbers? You add the first 64 bits as normal You link the two additions using the carry out from this operation You add the upper 64 bits using the carry out of previous stage as the carry in of the current operation ARMv8 has instructions for this: see Section 2.19, Figure 2.41 (i.e. ADC, ADCS regular operation with added with carry ) Similar for subtraction The hardware that performs addition, subtraction and logical operations such as AND and OR is called an Arithmetic Logic Unit (ALU) Chapter 3 Arithmetic for Computers 4

5 Integer Subtraction To subtract, convert second operand to 2's complement version, and add the result to first operand Example: 7 6 = 7 + ( 6) +7: : : Overflow occurs if result is out of range Subtracting two +ve or two ve operands, no overflow Subtracting +ve from ve operand Overflow if MSB of result is 0 Subtracting ve from +ve operand Overflow if MSB of result is 1 Chapter 3 Arithmetic for Computers 5

6 n- Bit Ripple Carry Adder For each stage (called a full adder), we are adding xi + yi+ci to get si and ci+1 Normally the first carry in (c0) is set to zero could also be connected to the carry out (cn) from another n-bit adder, to form a 2n-bit adder Chapter 3 Arithmetic for Computers 6

7 Full Adder A full adder takes as input a carry from the previous stage (ci) and a bit from each n-bit number being added (xi and yi). It produces a sum bit (si) and a carry out to next stage (ci+1) Chapter 3 Arithmetic for Computers 7

8 Adder/ Subtractor If signal Add/Sub = 0, then we get X +Y + 0 If signal Add/Sub = 1, then we get X +Y + 1 = X Y Remember, 2's complement of Y is Y + 1, where Y is the bitwise complement of Y Chapter 3 Arithmetic for Computers 8

9 3.3 Multiplication Integer Multiplication We first look at base-10 longmultiplication Consider the calculation on right which we limited to only 0 and 1 digits For base-2, digits can be only 0 or 1 Means that at each step, we either get zero, or a shifted copy of multiplicand Final step is to add values from all steps together multiplicand multiplier product Length of product is the sum of operand lengths Chapter 3 Arithmetic for Computers 9

10 Integer Multiplication II The 64 bit multiplicand starts in right half of multiplicand register It is shifted left one bit on each step Multiplier is shifted right once on each step Product register is initialized to zero Control decides when to shift each register and when to load a new value into product register Chapter 3 Arithmetic for Computers 10

11 Multiplication Algorithm Multiplier0 is the least significant bit in the multiplier register Only add multiplicand to product and store in product if multiplier0 = 1, else do nothing Figure should have 64th repetition? as label, not 32 See textbook for more efficient version of multiplier See example on page 195 in text Chapter 3 Arithmetic for Computers 11

12 Signed Multiplication Method presented so far would only work on unsigned numbers For signed, convert all operands to magnitude (positive) version Do multiplication as normal If the signs of initial operands not the same, negate the final product. Chapter 3 Arithmetic for Computers 12

13 LEGv8 Multiplication Three LEGv8 multiply instructions: MUL: multiply SMULH: signed multiply high Gives the upper 64 bits of the product, assuming the operands are signed UMULH: unsigned multiply high Gives the lower 64 bits of the product Gives the upper 64 bits of the product, assuming the operands are unsigned LEGv8 multiply instructions do not set overflow condition code Chapter 3 Arithmetic for Computers 13

14 quotient dividend divisor remainder n-bit operands yield n-bit quotient and remainder We first consider base-10 division Consider the calculation on left which we limited to only 0 and 1 digits Dividend = Quotient x Divisor + Remainder Need to check that divisor is not zero As binary numbers only have 0 or 1, the divisor can only divide into dividend once or not at all at each spot 3.4 Division Integer Division Chapter 3 Arithmetic for Computers 14

15 Division Hardware We start with quotient set to zero Shifted to left one bit per iteration and new bit added Divisor starts on left side of register and is shifted to the right one bit each iteration Control decides when to shift divisor and quotient registers and when to store new value in remainder Initially divisor in left half Initially dividend Chapter 3 Arithmetic for Computers 15

16 Division Algorithm At step1, we calculate Remainder register Divisor register This is to determine if divisor is smaller than dividend If remainder was larger (result positive), then divisor can divide into dividend Shift quotient left, set LSB to 1 Otherwise, shift quotient left and set LSB to zero Chapter 3 Arithmetic for Computers 16

17 Signed Division For signed operands, do division using absolute values of the operands If divisor and dividend not originally same sign, then negate quotient Adjust the sign of the remainder by using the following rule: Dividend (original sign) and remainder must have same sign The signs of the divisor and quotient do not affect sign of remainder See example on page 200 of text Chapter 3 Arithmetic for Computers 17

18 LEGv8 Division LEGv8 has two instructions for division: SDIV (signed) UDIV (unsigned) Both instructions ignore overflow and division-by-zero Chapter 3 Arithmetic for Computers 18

19 Method to represent real numbers in digital hardware Number represented as an n-bit integer part, and a k-bit fractional part 3.5 Floating Point Fixed Point Numbers This means the decimal point is fixed For binary number: B = bn-1... b0.b-1b-2 b-k, its base-10 value is: V(B) = Σi=-k to n-1 (bi x 2i ) For B = , if n = 4, and k= 3, we would get Limited usefulness Chapter 3 Arithmetic for Computers 19

20 Floating Point Numbers To represent a number as fixed point, require a digit for each position Representing 2376 x would require many zeros... Floating point method represents numbers by a mantissa containing the significant digits plus an exponent of Radix R: Mantissa x RExponent Numbers are often normalized so that the decimal place is to the right of the leftmost digit. i.e x 1043 or 6.31 x Chapter 3 Arithmetic for Computers 20

21 IEEE Floating Point Formats Two main representations are the IEEE singleprecision 32 bit format and the IEEE doubleprecision 64-bit format Chapter 3 Arithmetic for Computers 21

22 Floating Point Numbers II Numbers are normalized so that mostsignificant bit of mantissa (fraction) is a 1 Base 10 value for single-precision number is: V = +/- 1.M x 2Exponent The exponent is stored in excess 127 format so that E is unsigned and ranges from 0 to 255. Thus: Exponent = E -127 Chapter 3 Arithmetic for Computers 22

23 Floating Point Numbers III The value of E = 0 is defined to be exact zero and E = 255 to be infinity. This means Exponent can go in range -126 to 127 Example: (13) 3 10 = (1101)2 = x 2, E = = 130 Single-precision: = 0 E M In C, types float and double Chapter 3 Arithmetic for Computers 23

24 Floating-Point Example II What number is represented by the singleprecision float S=1 Fraction = E = = 129 X = ( 1) (1.01)2 2( ) = ( 1) = 5.0 Chapter 3 Arithmetic for Computers 24

25 Overflow and Underflow With floating point numbers, overflow means that the exponent is too large to fit in the exponent field. Underflow occurs when the negative exponent is too small to fit in the exponent field. For single precision, exponents can go in range from -126 to 127 For double precision, the range is to 1023 Chapter 3 Arithmetic for Computers 25

26 Exceptions LEGv8 uses exceptions to inform the user when floating point overflow or underflow occurs An exception is an unscheduled procedure call The address of the instruction that overflowed/ underflowed is saved in a register Computer jumps to a predefined address to invoke the appropriate routine for that exception Chapter 3 Arithmetic for Computers 26

27 Infinities and NaNs IEEE standard defines some codes to identify special situations: Exponent = , Mantissa = Means the number is ±infinity This can be used in subsequent calculations, avoiding need for overflow check Exponent = , Mantissa Result is Not-a-Number (NaN) Indicates illegal or undefined result e.g., 0.0 / 0.0 Can be used in subsequent calculations Chapter 3 Arithmetic for Computers 27

28 FP Registers LEGv8 has 32 double-precision registers just for floating point operations Labeled: D0,, D31 LEGv8 has 32 single-precision registers just for floating point operations Labeled: S0,, S31 FP instructions operate only on FP registers Programs generally don t do integer ops on FP data, or vice versa Means more registers with minimal codesize impact Chapter 3 Arithmetic for Computers 28

29 FP Registers II FP load and store instructions LDURS - load single-precision LDURD - load double-precision STURS - store single-precision STURD - store double-precision See Elaboration on page 222 of text about ARMv8 difference from LEGv8 Figure 3.17 of text gives a listing of the new FP instructions plus some examples Chapter 3 Arithmetic for Computers 29

30 FP Instructions in LEGv8 Single-precision arithmetic FADDS, FSUBS, FMULS, FDIVS Double-precision arithmetic FADDD, FSUBD, FMULD, FDIVD FCMPS, FCMPD Sets or clears FP condition-code bits Branch on FP condition code true or false e.g., FADDD D2, D4, D6 Single- and double-precision comparison e.g., FADDS S2, S4, S6 B.cond (these are the B.LE etc. conditional branches discussed earlier) See the FP examples on page 222 and 223 of text Chapter 3 Arithmetic for Computers 30

31 Read Section 3.6 for own interest Contains some common terms (i.e. SIMD) that you should be aware of 3.6 Parallelism and Computer Arithmetic: Subword Parallelism Subword Parallellism Chapter 3 Arithmetic for Computers 31

32 Read Section 3.8 for own interest Useful if you wish to program in ARMv8 assembly in the future 3.8 the Rest of the ARMv8 Arithmetic Instructions REAL Stuff: The rest of ARMv8 Arithmetic Instructions Chapter 3 Arithmetic for Computers 32

33 Read Section 3.10 on own 3.10 Fallacies and Pitfalls Fallacies and Pitfalls Chapter 3 Arithmetic for Computers 33

34 Read Section 3.11 on own 3.11 Concluding Remarks Concluding Remarks Chapter 3 Arithmetic for Computers 34

Chapter 3. Arithmetic Text: P&H rev

Chapter 3 Arithmetic Text: P&H rev3.29.16 Arithmetic for Computers Operations on integers Addition and subtraction Multiplication and division Dealing with overflow Floating-point real numbers Representation

Module 2: Computer Arithmetic

Module 2: Computer Arithmetic 1 B O O K : C O M P U T E R O R G A N I Z A T I O N A N D D E S I G N, 3 E D, D A V I D L. P A T T E R S O N A N D J O H N L. H A N N E S S Y, M O R G A N K A U F M A N N

Divide: Paper & Pencil

Divide: Paper & Pencil 1001 Quotient Divisor 1000 1001010 Dividend -1000 10 101 1010 1000 10 Remainder See how big a number can be subtracted, creating quotient bit on each step Binary => 1 * divisor or

Chapter 3. Arithmetic for Computers

Chapter 3 Arithmetic for Computers Arithmetic for Computers Unsigned vs. Signed Integers Operations on integers Addition and subtraction Multiplication and division Dealing with overflow Floating-point

Chapter 3: Arithmetic for Computers

Chapter 3: Arithmetic for Computers Objectives Signed and Unsigned Numbers Addition and Subtraction Multiplication and Division Floating Point Computer Architecture CS 35101-002 2 The Binary Numbering

Number Systems and Computer Arithmetic

Number Systems and Computer Arithmetic Counting to four billion two fingers at a time What do all those bits mean now? bits (011011011100010...01) instruction R-format I-format... integer data number text

Chapter 5 : Computer Arithmetic

Chapter 5 Computer Arithmetic Integer Representation: (Fixedpoint representation): An eight bit word can be represented the numbers from zero to 255 including = 1 = 1 11111111 = 255 In general if an nbit

CPE300: Digital System Architecture and Design

CPE300: Digital System Architecture and Design Fall 2011 MW 17:30-18:45 CBC C316 Arithmetic Unit 10122011 http://www.egr.unlv.edu/~b1morris/cpe300/ 2 Outline Recap Fixed Point Arithmetic Addition/Subtraction

Floating-Point Data Representation and Manipulation 198:231 Introduction to Computer Organization Lecture 3

Floating-Point Data Representation and Manipulation 198:231 Introduction to Computer Organization Instructor: Nicole Hynes nicole.hynes@rutgers.edu 1 Fixed Point Numbers Fixed point number: integer part

Chapter 3 Arithmetic for Computers

Chapter 3 Arithmetic for Computers 1 Arithmetic for Computers Operations on integers Addition and subtraction Multiplication and division Dealing with overflow Floating-point real numbers Representation

COMPUTER ORGANIZATION AND DESIGN

COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition Chapter 3 Arithmetic for Computers Arithmetic for Computers Operations on integers Addition and subtraction Multiplication

VTU NOTES QUESTION PAPERS NEWS RESULTS FORUMS Arithmetic (a) The four possible cases Carry (b) Truth table x y

Arithmetic A basic operation in all digital computers is the addition and subtraction of two numbers They are implemented, along with the basic logic functions such as AND,OR, NOT,EX- OR in the ALU subsystem

Thomas Polzer Institut für Technische Informatik

Thomas Polzer tpolzer@ecs.tuwien.ac.at Institut für Technische Informatik Operations on integers Addition and subtraction Multiplication and division Dealing with overflow Floating-point real numbers VO

At the ith stage: Input: ci is the carry-in Output: si is the sum ci+1 carry-out to (i+1)st state

Chapter 4 xi yi Carry in ci Sum s i Carry out c i+ At the ith stage: Input: ci is the carry-in Output: si is the sum ci+ carry-out to (i+)st state si = xi yi ci + xi yi ci + xi yi ci + xi yi ci = x i yi

Organisasi Sistem Komputer

LOGO Organisasi Sistem Komputer OSK 8 Aritmatika Komputer 1 1 PT. Elektronika FT UNY Does the calculations Arithmetic & Logic Unit Everything else in the computer is there to service this unit Handles

COMPUTER ARITHMETIC (Part 1)

Eastern Mediterranean University School of Computing and Technology ITEC255 Computer Organization & Architecture COMPUTER ARITHMETIC (Part 1) Introduction The two principal concerns for computer arithmetic

Chapter 3 Arithmetic for Computers (Part 2)

Department of Electr rical Eng ineering, Chapter 3 Arithmetic for Computers (Part 2) 王振傑 (Chen-Chieh Wang) ccwang@mail.ee.ncku.edu.tw ncku edu Depar rtment of Electr rical Eng ineering, Feng-Chia Unive

ECE260: Fundamentals of Computer Engineering

Arithmetic for Computers James Moscola Dept. of Engineering & Computer Science York College of Pennsylvania Based on Computer Organization and Design, 5th Edition by Patterson & Hennessy Arithmetic for

Chapter 2 Data Representations

Computer Engineering Chapter 2 Data Representations Hiroaki Kobayashi 4/21/2008 4/21/2008 1 Agenda in Chapter 2 Translation between binary numbers and decimal numbers Data Representations for Integers

Homework 3. Assigned on 02/15 Due time: midnight on 02/21 (1 WEEK only!) B.2 B.11 B.14 (hint: use multiplexors) CSCI 402: Computer Architectures

Homework 3 Assigned on 02/15 Due time: midnight on 02/21 (1 WEEK only!) B.2 B.11 B.14 (hint: use multiplexors) 1 CSCI 402: Computer Architectures Arithmetic for Computers (2) Fengguang Song Department

COMP 303 Computer Architecture Lecture 6

COMP 303 Computer Architecture Lecture 6 MULTIPLY (unsigned) Paper and pencil example (unsigned): Multiplicand 1000 = 8 Multiplier x 1001 = 9 1000 0000 0000 1000 Product 01001000 = 72 n bits x n bits =

Computer Arithmetic Ch 8

Computer Arithmetic Ch 8 ALU Integer Representation Integer Arithmetic Floating-Point Representation Floating-Point Arithmetic 1 Arithmetic Logical Unit (ALU) (2) (aritmeettis-looginen yksikkö) Does all

Computer Arithmetic Ch 8

Computer Arithmetic Ch 8 ALU Integer Representation Integer Arithmetic Floating-Point Representation Floating-Point Arithmetic 1 Arithmetic Logical Unit (ALU) (2) Does all work in CPU (aritmeettis-looginen

Introduction to Computers and Programming. Numeric Values

Introduction to Computers and Programming Prof. I. K. Lundqvist Lecture 5 Reading: B pp. 47-71 Sept 1 003 Numeric Values Storing the value of 5 10 using ASCII: 00110010 00110101 Binary notation: 00000000

Data Representations & Arithmetic Operations

Data Representations & Arithmetic Operations Hiroaki Kobayashi 7/13/2011 7/13/2011 Computer Science 1 Agenda Translation between binary numbers and decimal numbers Data Representations for Integers Negative

Timing for Ripple Carry Adder 1 2 3 Look Ahead Method 5 6 7 8 9 Look-Ahead, bits wide 10 11 Multiplication Simple Gradeschool Algorithm for 32 Bits (6 Bit Result) Multiplier Multiplicand AND gates 32

Computer Organisation CS303

Computer Organisation CS303 Module Period Assignments 1 Day 1 to Day 6 1. Write a program to evaluate the arithmetic statement: X=(A-B + C * (D * E-F))/G + H*K a. Using a general register computer with

Lecture 8: Addition, Multiplication & Division

Lecture 8: Addition, Multiplication & Division Today s topics: Signed/Unsigned Addition Multiplication Division 1 Signed / Unsigned The hardware recognizes two formats: unsigned (corresponding to the C

CO212 Lecture 10: Arithmetic & Logical Unit

CO212 Lecture 10: Arithmetic & Logical Unit Shobhanjana Kalita, Dept. of CSE, Tezpur University Slides courtesy: Computer Architecture and Organization, 9 th Ed, W. Stallings Integer Representation For

Chapter 03: Computer Arithmetic. Lesson 09: Arithmetic using floating point numbers

Chapter 03: Computer Arithmetic Lesson 09: Arithmetic using floating point numbers Objective To understand arithmetic operations in case of floating point numbers 2 Multiplication of Floating Point Numbers

Arithmetic Processing

CS/EE 5830/6830 VLSI ARCHITECTURE Chapter 1 Basic Number Representations and Arithmetic Algorithms Arithmetic Processing AP = (operands, operation, results, conditions, singularities) Operands are: Set

Chapter 3 Arithmetic for Computers. ELEC 5200/ From P-H slides

Chapter 3 Arithmetic for Computers 1 Arithmetic for Computers Operations on integers Addition and subtraction Multiplication and division Dealing with overflow Floating-point real numbers Representation

CS 101: Computer Programming and Utilization

CS 101: Computer Programming and Utilization Jul-Nov 2017 Umesh Bellur (cs101@cse.iitb.ac.in) Lecture 3: Number Representa.ons Representing Numbers Digital Circuits can store and manipulate 0 s and 1 s.

TDT4255 Computer Design. Lecture 4. Magnus Jahre

1 TDT4255 Computer Design Lecture 4 Magnus Jahre 2 Chapter 3 Computer Arithmetic ti Acknowledgement: Slides are adapted from Morgan Kaufmann companion material 3 Arithmetic for Computers Operations on

Computer Architecture Chapter 3. Fall 2005 Department of Computer Science Kent State University

Computer Architecture Chapter 3 Fall 2005 Department of Computer Science Kent State University Objectives Signed and Unsigned Numbers Addition and Subtraction Multiplication and Division Floating Point

CPS 104 Computer Organization and Programming

CPS 104 Computer Organization and Programming Lecture 9: Integer Arithmetic. Robert Wagner CPS104 IMD.1 RW Fall 2000 Overview of Today s Lecture: Integer Multiplication and Division. Read Appendix B CPS104

Integer Arithmetic. Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

Integer Arithmetic Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu EEE3050: Theory on Computer Architectures, Spring 2017, Jinkyu Jeong (jinkyu@skku.edu)

EE260: Logic Design, Spring n Integer multiplication. n Booth s algorithm. n Integer division. n Restoring, non-restoring

EE 260: Introduction to Digital Design Arithmetic II Yao Zheng Department of Electrical Engineering University of Hawaiʻi at Mānoa Overview n Integer multiplication n Booth s algorithm n Integer division

UNIT-III COMPUTER ARTHIMETIC

UNIT-III COMPUTER ARTHIMETIC INTRODUCTION Arithmetic Instructions in digital computers manipulate data to produce results necessary for the of activity solution of computational problems. These instructions

COMP2611: Computer Organization. Data Representation

COMP2611: Computer Organization Comp2611 Fall 2015 2 1. Binary numbers and 2 s Complement Numbers 3 Bits: are the basis for binary number representation in digital computers What you will learn here: How

Data Representation Type of Data Representation Integers Bits Unsigned 2 s Comp Excess 7 Excess 8

Data Representation At its most basic level, all digital information must reduce to 0s and 1s, which can be discussed as binary, octal, or hex data. There s no practical limit on how it can be interpreted

Floating Point Arithmetic

Floating Point Arithmetic Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu EEE3050: Theory on Computer Architectures, Spring 2017, Jinkyu Jeong (jinkyu@skku.edu)

September, Saeid Nooshabadi. Overview IEEE 754 Standard COMP Microprocessors and Embedded Systems

COMP3221 lec20-fp-ii.1 COMP 3221 Microprocessors and Embedded Systems Lectures 20 : Floating Point Number Representation II http://www.cse.unsw.edu.au/~cs3221 September, 2003 Saeid@unsw.edu.au Overview

The ALU consists of combinational logic. Processes all data in the CPU. ALL von Neuman machines have an ALU loop.

CS 320 Ch 10 Computer Arithmetic The ALU consists of combinational logic. Processes all data in the CPU. ALL von Neuman machines have an ALU loop. Signed integers are typically represented in sign-magnitude

Arithmetic for Computers. Hwansoo Han

Arithmetic for Computers Hwansoo Han Arithmetic for Computers Operations on integers Addition and subtraction Multiplication and division Dealing with overflow Floating-point real numbers Representation

Chapter 3. Arithmetic for Computers

Chapter 3 Arithmetic for Computers Arithmetic for Computers Operations on integers Addition and subtraction Multiplication and division Dealing with overflow Floating-point real numbers Representation

EECS150 - Digital Design Lecture 13 - Combinational Logic & Arithmetic Circuits Part 3

EECS15 - Digital Design Lecture 13 - Combinational Logic & Arithmetic Circuits Part 3 October 8, 22 John Wawrzynek Fall 22 EECS15 - Lec13-cla3 Page 1 Multiplication a 3 a 2 a 1 a Multiplicand b 3 b 2 b

CHW 261: Logic Design

CHW 261: Logic Design Instructors: Prof. Hala Zayed Dr. Ahmed Shalaby http://www.bu.edu.eg/staff/halazayed14 http://bu.edu.eg/staff/ahmedshalaby14# Slide 1 Slide 2 Slide 3 Digital Fundamentals CHAPTER

Chapter 4. Operations on Data

Chapter 4 Operations on Data 1 OBJECTIVES After reading this chapter, the reader should be able to: List the three categories of operations performed on data. Perform unary and binary logic operations

carry in carry 1101 carry carry

Chapter Binary arithmetic Arithmetic is the process of applying a mathematical operator (such as negation or addition) to one or more operands (the values being operated upon). Binary arithmetic works

Internal Data Representation

Appendices This part consists of seven appendices, which provide a wealth of reference material. Appendix A primarily discusses the number systems and their internal representation. Appendix B gives information

Part 5 Adding Binary Integers Arithmetic Logic Unit = Adding Binary Integers Adding Base Numbers Computer's add binary numbers the same way that we do with decimal Columns are aligned, added, and "'s"

By, Ajinkya Karande Adarsh Yoga Introduction Early computer designers believed saving computer time and memory were more important than programmer time. Bug in the divide algorithm used in Intel chips.

Number Systems. Both numbers are positive

Number Systems Range of Numbers and Overflow When arithmetic operation such as Addition, Subtraction, Multiplication and Division are performed on numbers the results generated may exceed the range of

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC

CHAPTER V-1 CHAPTER V CHAPTER V NUMBER SYSTEMS AND ARITHMETIC CHAPTER V-2 NUMBER SYSTEMS RADIX-R REPRESENTATION Decimal number expansion 73625 10 = ( 7 10 4 ) + ( 3 10 3 ) + ( 6 10 2 ) + ( 2 10 1 ) +(

Floating-point Arithmetic. where you sum up the integer to the left of the decimal point and the fraction to the right.

Floating-point Arithmetic Reading: pp. 312-328 Floating-Point Representation Non-scientific floating point numbers: A non-integer can be represented as: 2 4 2 3 2 2 2 1 2 0.2-1 2-2 2-3 2-4 where you sum

Kinds Of Data CHAPTER 3 DATA REPRESENTATION. Numbers Are Different! Positional Number Systems. Text. Numbers. Other

Kinds Of Data CHAPTER 3 DATA REPRESENTATION Numbers Integers Unsigned Signed Reals Fixed-Point Floating-Point Binary-Coded Decimal Text ASCII Characters Strings Other Graphics Images Video Audio Numbers

COMPUTER ORGANIZATION AND ARCHITECTURE

COMPUTER ORGANIZATION AND ARCHITECTURE For COMPUTER SCIENCE COMPUTER ORGANIZATION. SYLLABUS AND ARCHITECTURE Machine instructions and addressing modes, ALU and data-path, CPU control design, Memory interface,

Number Systems CHAPTER Positional Number Systems

CHAPTER 2 Number Systems Inside computers, information is encoded as patterns of bits because it is easy to construct electronic circuits that exhibit the two alternative states, 0 and 1. The meaning of

MIPS Integer ALU Requirements

MIPS Integer ALU Requirements Add, AddU, Sub, SubU, AddI, AddIU: 2 s complement adder/sub with overflow detection. And, Or, Andi, Ori, Xor, Xori, Nor: Logical AND, logical OR, XOR, nor. SLTI, SLTIU (set

Number Systems and Their Representations

Number Representations Cptr280 Dr Curtis Nelson Number Systems and Their Representations In this presentation you will learn about: Representation of numbers in computers; Signed vs. unsigned numbers;

Topics. 6.1 Number Systems and Radix Conversion 6.2 Fixed-Point Arithmetic 6.3 Seminumeric Aspects of ALU Design 6.4 Floating-Point Arithmetic

6-1 Chapter 6 Computer Arithmetic and the Arithmetic Unit Chapter 6: Computer Arithmetic and the Arithmetic Unit Topics 6.1 Number Systems and Radix Conversion 6.2 Fixed-Point Arithmetic 6.3 Seminumeric

Arithmetic for Computers

MIPS Arithmetic Instructions Cptr280 Dr Curtis Nelson Arithmetic for Computers Operations on integers Addition and subtraction; Multiplication and division; Dealing with overflow; Signed vs. unsigned numbers.

(+A) + ( B) + (A B) (B A) + (A B) ( A) + (+ B) (A B) + (B A) + (A B) (+ A) (+ B) + (A - B) (B A) + (A B) ( A) ( B) (A B) + (B A) + (A B)

COMPUTER ARITHMETIC 1. Addition and Subtraction of Unsigned Numbers The direct method of subtraction taught in elementary schools uses the borrowconcept. In this method we borrow a 1 from a higher significant

Computer Architecture and IC Design Lab. Chapter 3 Part 2 Arithmetic for Computers Floating Point

Chapter 3 Part 2 Arithmetic for Computers Floating Point Floating Point Representation for non integral numbers Including very small and very large numbers 4,600,000,000 or 4.6 x 10 9 0.0000000000000000000000000166

CSE 141 Computer Architecture Summer Session Lecture 3 ALU Part 2 Single Cycle CPU Part 1. Pramod V. Argade

CSE 141 Computer Architecture Summer Session 1 2004 Lecture 3 ALU Part 2 Single Cycle CPU Part 1 Pramod V. Argade Reading Assignment Announcements Chapter 5: The Processor: Datapath and Control, Sec. 5.3-5.4

Number Systems Standard positional representation of numbers: An unsigned number with whole and fraction portions is represented as:

N Number Systems Standard positional representation of numbers: An unsigned number with whole and fraction portions is represented as: a n a a a The value of this number is given by: = a n Ka a a a a a

Tailoring the 32-Bit ALU to MIPS

Tailoring the 32-Bit ALU to MIPS MIPS ALU extensions Overflow detection: Carry into MSB XOR Carry out of MSB Branch instructions Shift instructions Slt instruction Immediate instructions ALU performance

9 Multiplication and Division

9 Multiplication and Division Multiplication is done by doing shifts and additions. Multiplying two (unsigned) numbers of n bits each results in a product of 2n bits. Example: 0110 x 0011 (6x3) At start,

NUMBER OPERATIONS. Mahdi Nazm Bojnordi. CS/ECE 3810: Computer Organization. Assistant Professor School of Computing University of Utah

NUMBER OPERATIONS Mahdi Nazm Bojnordi Assistant Professor School of Computing University of Utah CS/ECE 3810: Computer Organization Overview Homework 4 is due tonight Verify your uploaded file before the

UNIVERSITY OF MASSACHUSETTS Dept. of Electrical & Computer Engineering. Digital Computer Arithmetic ECE 666

UNIVERSITY OF MASSACHUSETTS Dept. of Electrical & Computer Engineering Digital Computer Arithmetic ECE 666 Part 4-A Floating-Point Arithmetic Israel Koren ECE666/Koren Part.4a.1 Preliminaries - Representation

Integer Multiplication and Division

Integer Multiplication and Division COE 301 Computer Organization Prof. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals Presentation Outline

Chapter 10 - Computer Arithmetic

Chapter 10 - Computer Arithmetic Luis Tarrataca luis.tarrataca@gmail.com CEFET-RJ L. Tarrataca Chapter 10 - Computer Arithmetic 1 / 126 1 Motivation 2 Arithmetic and Logic Unit 3 Integer representation

COMPUTER ARCHITECTURE AND ORGANIZATION. Operation Add Magnitudes Subtract Magnitudes (+A) + ( B) + (A B) (B A) + (A B)

Computer Arithmetic Data is manipulated by using the arithmetic instructions in digital computers. Data is manipulated to produce results necessary to give solution for the computation problems. The Addition,

An instruction set processor consist of two important units: Data Processing Unit (DataPath) Program Control Unit

DataPath Design An instruction set processor consist of two important units: Data Processing Unit (DataPath) Program Control Unit Add & subtract instructions for fixed binary numbers are found in the

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

Computer Organization and Structure Bing-Yu Chen National Taiwan University Arithmetic for Computers Addition and Subtraction Gate Logic and K-Map Method Constructing a Basic ALU Arithmetic Logic Unit

Number Systems and Conversions UNIT 1 NUMBER SYSTEMS & CONVERSIONS. Number Systems (2/2) Number Systems (1/2) Iris Hui-Ru Jiang Spring 2010

Contents Number systems and conversion Binary arithmetic Representation of negative numbers Addition of two s complement numbers Addition of one s complement numbers Binary s Readings Unit.~. UNIT NUMBER

Arithmetic Logic Unit

Arithmetic Logic Unit A.R. Hurson Department of Computer Science Missouri University of Science & Technology A.R. Hurson 1 Arithmetic Logic Unit It is a functional bo designed to perform "basic" arithmetic,

361 div.1. Computer Architecture EECS 361 Lecture 7: ALU Design : Division

361 div.1 Computer Architecture EECS 361 Lecture 7: ALU Design : Division Outline of Today s Lecture Introduction to Today s Lecture Divide Questions and Administrative Matters Introduction to Single cycle

Chapter 3. Arithmetic for Computers

Chapter 3 Arithmetic for Computers Arithmetic for Computers Operations on integers Addition and subtraction Multiplication and division Dealing with overflow Floating-point real numbers Representation

Computer Architecture Set Four. Arithmetic

Computer Architecture Set Four Arithmetic Arithmetic Where we ve been: Performance (seconds, cycles, instructions) Abstractions: Instruction Set Architecture Assembly Language and Machine Language What

Inf2C - Computer Systems Lecture 2 Data Representation

Inf2C - Computer Systems Lecture 2 Data Representation Boris Grot School of Informatics University of Edinburgh Last lecture Moore s law Types of computer systems Computer components Computer system stack

Chapter 3. Arithmetic for Computers

Chapter 3 Arithmetic for Computers Arithmetic for Computers Operations on integers Addition and subtraction Multiplication and division Dealing with overflow Floating-point real numbers Representation

Integer Multiplication. Back to Arithmetic. Integer Multiplication. Example (Fig 4.25)

Back to Arithmetic Before, we did Representation of integers Addition/Subtraction Logical ops Forecast Integer Multiplication Integer Division Floating-point Numbers Floating-point Addition/Multiplication

Review: MIPS Organization

1 MIPS Arithmetic Review: MIPS Organization Processor Memory src1 addr 5 src2 addr 5 dst addr 5 write data Register File registers (\$zero - \$ra) bits src1 data src2 data read/write addr 1 1100 2 30 words

UNIT - I: COMPUTER ARITHMETIC, REGISTER TRANSFER LANGUAGE & MICROOPERATIONS

UNIT - I: COMPUTER ARITHMETIC, REGISTER TRANSFER LANGUAGE & MICROOPERATIONS (09 periods) Computer Arithmetic: Data Representation, Fixed Point Representation, Floating Point Representation, Addition and

MACHINE LEVEL REPRESENTATION OF DATA

MACHINE LEVEL REPRESENTATION OF DATA CHAPTER 2 1 Objectives Understand how integers and fractional numbers are represented in binary Explore the relationship between decimal number system and number systems

CS/COE0447: Computer Organization

CS/COE0447: Computer Organization and Assembly Language Chapter 3 Sangyeun Cho Dept. of Computer Science Five classic components I am like a control tower I am like a pack of file folders I am like a conveyor

CS/COE0447: Computer Organization

Five classic components CS/COE0447: Computer Organization and Assembly Language I am like a control tower I am like a pack of file folders Chapter 3 I am like a conveyor belt + service stations I exchange

Numeric Encodings Prof. James L. Frankel Harvard University

Numeric Encodings Prof. James L. Frankel Harvard University Version of 10:19 PM 12-Sep-2017 Copyright 2017, 2016 James L. Frankel. All rights reserved. Representation of Positive & Negative Integral and

Floating Point Arithmetic

Floating Point Arithmetic CS 365 Floating-Point What can be represented in N bits? Unsigned 0 to 2 N 2s Complement -2 N-1 to 2 N-1-1 But, what about? very large numbers? 9,349,398,989,787,762,244,859,087,678

Floating-Point Arithmetic

ENEE446---Lectures-4/10-15/08 A. Yavuz Oruç Professor, UMD, College Park Copyright 2007 A. Yavuz Oruç. All rights reserved. Floating-Point Arithmetic Integer or fixed-point arithmetic provides a complete

COMP Overview of Tutorial #2

COMP 1402 Winter 2008 Tutorial #2 Overview of Tutorial #2 Number representation basics Binary conversions Octal conversions Hexadecimal conversions Signed numbers (signed magnitude, one s and two s complement,

Iterative Division Techniques COMPUTER ARITHMETIC: Lecture Notes # 6. University of Illinois at Chicago

1 ECE 368 CAD Based Logic Design Instructor: Shantanu Dutt Department of Electrical and Computer Engineering University of Illinois at Chicago Lecture Notes # 6 COMPUTER ARITHMETIC: Iterative Division

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 3. Arithmetic for Computers Implementation

COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition Chapter 3 Arithmetic for Computers Implementation Today Review representations (252/352 recap) Floating point Addition: Ripple

Arithmetic and Logical Operations

Arithmetic and Logical Operations 2 CMPE2c x +y + sum Or in tabular form Binary Addition Carry Out Sum B A Carry In Binary Addition And as a full adder a b co ci sum 4-bit Ripple-Carry adder: Carry values

FLOATING POINT NUMBERS

Exponential Notation FLOATING POINT NUMBERS Englander Ch. 5 The following are equivalent representations of 1,234 123,400.0 x 10-2 12,340.0 x 10-1 1,234.0 x 10 0 123.4 x 10 1 12.34 x 10 2 1.234 x 10 3

Chapter Three. Arithmetic

Chapter Three 1 Arithmetic Where we've been: Performance (seconds, cycles, instructions) Abstractions: Instruction Set Architecture Assembly Language and Machine Language What's up ahead: Implementing