TK2633 : MICROPROCESSOR & INTERFACING Lecture 10: Fixed Point Arithmetic Lecturer: Ass. Prof. Dr. Masri Ayob.

Slides:



Advertisements
Similar presentations
Week 3. Assembly Language Programming  Difficult when starting assembly programming  Have to work at low level  Use processor instructions >Requires.
Advertisements

Intro to CS – Honors I Representing Numbers GEORGIOS PORTOKALIDIS
CMPT 334 Computer Organization Chapter 3 Arithmetic for Computers [Adapted from Computer Organization and Design 5 th Edition, Patterson & Hennessy, ©
TK 2633 Microprocessor & Interfacing
Chapter 3 Arithmetic for Computers. Multiplication More complicated than addition accomplished via shifting and addition More time and more area Let's.
Room: E-3-31 Phone: Dr Masri Ayob TK 2123 COMPUTER ORGANISATION & ARCHITECTURE Lecture 5: CPU and Memory.
TK 2633 Microprocessor & Interfacing Lecture 3: Introduction to 8085 Assembly Language Programming (2) 1 Prepared By: Associate Prof. Dr Masri Ayob.
Room: E-3-31 Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.
Room: Timbalan Pengarah Pusat Komputer Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 4: Introduction.
Level ISA3: Information Representation
TK2633: MICROPROCESSOR & INTERFACING
TK 2633 Microprocessor & Interfacing
Room: E-3-31 Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.
1 Lecture 8: Binary Multiplication & Division Today’s topics:  Addition/Subtraction  Multiplication  Division Reminder: get started early on assignment.
Dr Masri Ayob TK 2633: Microprocessor & Interfacing Lecture 5: Arithmetic and Logic Instructions.
TK I/O Peripherals Interface DR MASRI AYOB.
Lecture – 5 Assembly Language Programming
Operations on data CHAPTER 4.
ADDING INTEGERS Positive + Positive = Positive Positive + Positive = Positive ( +3) + (+2) = +5 ( +3) + (+2) = +5 When a number is positive, you do not.
Rules of Integers. Positive numbers are numbers that are above zero. Negative numbers are numbers below zero.
The Binary Number System
Data Representation Number Systems.
Arithmetic for Computers
Simple Data Type Representation and conversion of numbers
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.
ECE 4110– Sequential Logic Design
Computer Architecture Lecture 3: Logical circuits, computer arithmetics Piotr Bilski.
CMPE 325 Computer Architecture II Cem Ergün Eastern Mediterranean University Integer Representation and the ALU.
Khaled A. Al-Utaibi  Introduction  Arithmetic Instructions  Basic Logical Instructions  Shift Instructions  Rotate Instructions.
ILLUSTRATING INTEGERS INTRODUCTION TO INTEGERS Integers are positive and negative numbers. …, -6, -5, -4, -3, -2, -1, 0, +1, +2, +3, +4, +5, +6, … Each.
1 Lecture 5 Floating Point Numbers ITEC 1000 “Introduction to Information Technology”
ECE232: Hardware Organization and Design
Multiplication of signed-operands
Computer Arithmetic and the Arithmetic Unit Lesson 2 - Ioan Despi.
Lecture 6: Multiply, Shift, and Divide
CSC 221 Computer Organization and Assembly Language
Operations on Bits Arithmetic Operations Logic Operations
Ass. Prof. Dr Masri Ayob TK 6123 Lecture 13: Assembly Language Level (Level 4)
05/03/2009CA&O Lecture 8,9,10 By Engr. Umbreen sabir1 Computer Arithmetic Computer Engineering Department.
Fixed & Floating Number Format Dr. Hugh Blanton ENTC 4337/5337.
Ass. Prof. Dr Masri Ayob Lecture 5: Arithmetic and Logic Instructions TK 2633: Microprocessor & Interfacing.
Integer Multiplication and Division ICS 233 Computer Architecture and Assembly Language Dr. Aiman El-Maleh College of Computer Sciences and Engineering.
Csci 136 Computer Architecture II – Multiplication and Division
Mohamed Younis CMCS 411, Computer Architecture 1 CMSC Computer Architecture Lecture 11 Performing Division March 5,
Ass Prof Dr Masri Ayob TK 2633: Microprocessor & Interfacing Lecture 6: Control Instructions.
Introduction To Number Systems Binary System M. AL-Towaileb1.
Ass. Prof. Dr Masri Ayob TK 2123 Lecture 14: Instruction Set Architecture Level (Level 2)
ECE DIGITAL LOGIC LECTURE 15: COMBINATIONAL CIRCUITS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2015, 10/20/2015.
Integer Multiplication and Division COE 301 Computer Organization Dr. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University.
Ch. 4 Computer Arithmetic
Integer Multiplication and Division ICS 233 Computer Architecture & Assembly Language Prof. Muhamed Mudawar College of Computer Sciences and Engineering.
Arithmetic for Computers Chapter 3 1. Arithmetic for Computers  Operations on integers  Addition and subtraction  Multiplication and division  Dealing.
More Binary Arithmetic - Multiplication
Lecture – 5 Assembly Language Programming
Integer Multiplication and Division
Dr. Clincy Professor of CS
Digital Logic & Design Dr. Waseem Ikram Lecture 02.
MIPS mul/div instructions
Lecture 8: Binary Multiplication & Division
CDA 3101 Spring 2016 Introduction to Computer Organization
Lecture 8: Addition, Multiplication & Division
King Fahd University of Petroleum and Minerals
Lecture 8: Addition, Multiplication & Division
CDA 3101 Summer 2007 Introduction to Computer Organization
Digital Logic & Design Lecture 02.
Shift & Rotate Instructions)
TK2633: MICROPROCESSOR & INTERFACING
Digital System Design II 数字系统设计2
Binary to Decimal Conversion
Presentation transcript:

TK2633 : MICROPROCESSOR & INTERFACING Lecture 10: Fixed Point Arithmetic Lecturer: Ass. Prof. Dr. Masri Ayob

June 4, 2016 Written by: Ramizi Mohamed, Edited by:Dr Masri Ayob2 Fixed Point Arithmetic. 8-bit binary addition. Suppose that the ten 8-bit numbers, stored at memory locations 2800H through 2809H, are added. To sum these data, an 8-bit instructions are chosen. The ADD M instruction is chosen. Since this is to add 10 numbers, the programme loop construct is ideal for this problem. Figure illustrates the flowchart to tackle the problem.

June 4, 2016 Written by: Ramizi Mohamed, Edited by:Dr Masri Ayob3 The 8-bit binary addition listed in the example below, results in a problem that the largest sum can be only 0FFH. This sum is appropriate only if 10 numbers are small, therefore to avoid overflow for bigger sum operation, the 16-bit sum operation will take place. 8-bit binary addition

June 4, 2016 Written by: Ramizi Mohamed, Edited by:Dr Masri Ayob4 Example of 16-bit summation. 8-bit binary addition

June 4, 2016 Written by: Ramizi Mohamed, Edited by:Dr Masri Ayob5 Suppose that two lists of numbers, each 10H bytes long, appear in the memory to be subtracted. A programme must take the number stored at LIST2 and subtract it from the number stored at LIST1. The difference must be stored at a location in LIST2. This operation repeats 10H times until all sets of numbers are subtracted. Figure illustrates the process. 8-bit binary subtraction

June 4, 2016 Written by: Ramizi Mohamed, Edited by:Dr Masri Ayob6 8-bit binary subtraction: Exercise There are two lists of numbers (LIST1 and LIST2), each 10H bytes long, appear in the memory. Write a program to take the number stored at LIST2 and subtract it from the number stored at LIST1. The difference must be stored at a location in LIST2.

June 4, 2016 Written by: Ramizi Mohamed, Edited by:Dr Masri Ayob7 Repeated addition is the simplest method of multiplication to understand. Suppose to multiply two 8- bit numbers, one number can be used as the loop counter. The other number can be added the number of times stored in the loop counter. Figure illustrates how the number 6 can be multiplied by 3. Unsigned Multiplication by Repeated Addition

June 4, 2016 Written by: Ramizi Mohamed, Edited by:Dr Masri Ayob8 Unsigned Multiplication by Repeated Addition

June 4, 2016 Written by: Ramizi Mohamed, Edited by:Dr Masri Ayob9 Unsigned Constant Multiplication Instead of using the repeated addition technique presented earlier, another technique often results in a much faster multiplication, which using DAD instruction. The easiest way to multiply by 4 is by using the DAD H instruction. Remember that if double HL twice, it is multiplied by 4. Example :

June 4, 2016 Written by: Ramizi Mohamed, Edited by:Dr Masri Ayob10 The most flexible version of multiplication is the unsigned multiplication shift and add algorithm. Observe the example below, the unsigned multiplication is a combination of shifting the number followed by addition for every shifted number. Figure below, illustrates the process of shifting and adding number 9 and 15. Unsigned Multiplication Algorithm

June 4, 2016 Written by: Ramizi Mohamed, Edited by:Dr Masri Ayob11 The flowchart example to perform the algorithm. Unsigned Multiplication Algorithm

June 4, 2016 Written by: Ramizi Mohamed, Edited by:Dr Masri Ayob12 Unsigned Multiplication Algorithm

June 4, 2016 Written by: Ramizi Mohamed, Edited by:Dr Masri Ayob13

June 4, 2016 Written by: Ramizi Mohamed, Edited by:Dr Masri Ayob14 Modified Flowchart diagram to perform signed multiplication. Signed Multiplication

June 4, 2016 Written by: Ramizi Mohamed, Edited by:Dr Masri Ayob15 To do the signed multiplication, the multiplicand and multiplier are exclusive ORed together. The result, which indicates the sign of the product, is saved in the B register. Both numbers are then adjusted so that they are positive before the MULT subroutine is called. Upon returning from the MULT subroutine, the sign of the B register shows the sign of the product. For a negative result, the product in the HL register pair must be negated to form a negative product. For a positive result, the product does not change. Signed Multiplication

June 4, 2016 Written by: Ramizi Mohamed, Edited by:Dr Masri Ayob16 Signed Multiplication: Modification of the previous program

June 4, 2016 Written by: Ramizi Mohamed, Edited by:Dr Masri Ayob17 If data are shifted to the left, they multiply by 2 for each bit position of the shift. If data are shifted to the right, they divide by 2 for each bit position of the shift. Knowing this as a technique used to multiply by a constant, a technique can be developed so that a number can be divided by any power of 2. Division by a constant

June 4, 2016 Written by: Ramizi Mohamed, Edited by:Dr Masri Ayob18

June 4, 2016 Written by: Ramizi Mohamed, Edited by:Dr Masri Ayob19 Example shows how the signed contents of the accumulator are divide by 4 with the result rounded. Notice that a shift left copies the sign bit into the carry flag before shifting right twice. Signed division by a constant

June 4, 2016 Written by: Ramizi Mohamed, Edited by:Dr Masri Ayob20 To divide a number by any integer value, a division algorithm is normally used to develop a subroutine. The division algorithm uses a combination of shifting left, comparing, subtracting, and setting bits to perform binary division. Below is an illustration of division algorithm. Unsigned division algorithm

June 4, 2016 Written by: Ramizi Mohamed, Edited by:Dr Masri Ayob21 Unsigned division algorithm

June 4, 2016 Written by: Ramizi Mohamed, Edited by:Dr Masri Ayob22 Unsigned division algorithm

June 4, 2016 Written by: Ramizi Mohamed, Edited by:Dr Masri Ayob23 Signed binary division is treated in the same manner as signed multiplication. Signed division algorithm

June 4, 2016 Written by: Ramizi Mohamed, Edited by:Dr Masri Ayob24 Thank you Q&A