CIS 020 Assembly Programming Chapter 08 - Advanced Decimal Arithmetic Instructions © John Urrutia 2012, All Rights Reserved.5/27/20121.

Slides:



Advertisements
Similar presentations
Using Registers Ch.7 – p.158 Topic 1. Base - Displacement See page 159 PACKPDEC(3),ZDEC(3)
Advertisements

CIS 020 Assembly Programming Chapter 13 - Branching and Looping With Registers © John Urrutia 2012, All Rights Reserved.5/27/20121.
Lesson 5-4 Example Find 19 ÷ 3. Show the remainder. Step 1Rewrite the problem in vertical format.
Programs & Defining Data Ch.5 – pp Data in Computer Memory See page Byte locations in memory - One character per byte location.
Arithmetic in Computers Chapter 4 Arithmetic in Computers2 Outline Data representation integers Unsigned integers Signed integers Floating-points.
Number Systems & Operations
CMPT 334 Computer Organization Chapter 3 Arithmetic for Computers [Adapted from Computer Organization and Design 5 th Edition, Patterson & Hennessy, ©
4-8 Example 2 Divide. Multiply to make the divisor a whole number.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3: IT Students.
7-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
CIS 020 Assembly Programming Chapter 02 - Numbering Systems & Data Representation © John Urrutia 2012, All Rights Reserved.5/27/20121.
1 Lecture 8: Binary Multiplication & Division Today’s topics:  Addition/Subtraction  Multiplication  Division Reminder: get started early on assignment.
The decimal point helps us to keep track of where the "ones" place is.
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
Chapter 02 Binary Values and Number Systems Nell Dale & John Lewis.
4.5 Changing a Decimal or Fraction to a Percent 1 Converting a Decimal to a Percent To convert from a decimal to a percent, we will now multiply by “100”.
division algorithm Before we study divisibility, we must remember the division algorithm. r dividend = (divisor ⋅ quotient) + remainder.
ALGEBRA 1 Operations with Integers
Multiply and Divide Decimals
Arithmetic for Computers
Data Representation – Binary Numbers
Computer Arithmetic. Instruction Formats Layout of bits in an instruction Includes opcode Includes (implicit or explicit) operand(s) Usually more than.
Chapter 2.2 Scientific Notation. Expresses numbers in two parts: A number between 1 and 10 Ten raised to a power Examples: 2.32 x x
The Basic of Algebra BY Nathaniel Jefferson. The Number Line  |  0 Always start at zero.
How Computers Work Dr. John P. Abraham Professor UTPA.
PRESENTATION 1 Whole Numbers. PLACE VALUE The value of any digit depends on its place value Place value is based on multiples of 10 as follows: UNITS.
Copyright © 2010 Pearson Education, Inc. All rights reserved. R.1 – Slide 1.
Chapter 2- Decimals.
CH09 Computer Arithmetic  CPU combines of ALU and Control Unit, this chapter discusses ALU The Arithmetic and Logic Unit (ALU) Number Systems Integer.
CIS 020 Assembly Programming Chapter 07 - Decimal Arithmetic Operations © John Urrutia 2012, All Rights Reserved.5/27/20121.
Decimal place-value chart
When dividing a decimal by a whole number, place the decimal point in the quotient directly above the decimal point in the dividend. Then divide as you.
ASCII and BCD Arithmetic Chapter 11 S. Dandamudi.
L4-3 Notes: Dividing Decimals by Whole Numbers
 When dividing a decimal by a whole number, divide as with whole numbers. Then place the decimal in the quotient directly above its place in the dividend.
CIS 020 Assembly Programming Chapter 12 - RR-Format Instructions & more RX-Format Instructions © John Urrutia 2012, All Rights Reserved.5/27/20121.
7-1 Chapter 7.  Basic Arithmetic Verbs  Options Available with Arithmetic Verbs  COMPUTE Statement  Signed Numbers in Arithmetic Operations  Intrinsic.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
7-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
Cougar Time. Adding Negative Numbers  What are the two rules for adding integers?  Same Signs = Add and keep the sign  Different Signs = Find the absolute.
CIS 020 Assembly Programming Chapter 11 - Binary Operations Using RX-Format Instructions © John Urrutia 2012, All Rights Reserved.5/27/20121.
Warm-Up Find the value of each expression − (1.9) ÷ 0.3 Which One Doesn’t Belong? (Include your reasoning…)
Dividing Decimals by a Whole Number 3.6 ÷ 3.
Chapter 2 Number Systems Consists of a set of symbols called digits and a set of relations such as +, -, x, /.
CIS 020 Assembly Programming Chapter 06 - Comparisons & Logical control Procedures © John Urrutia 2012, All Rights Reserved.5/27/20121.
Addition, Subtraction, Multiplication, Division by a whole number, and Division by a decimal.
Division of decimals (by a whole number) When dividing a decimal by a whole number: Divide as you would for a whole number. There are NO remainders! If.
SCIENTIFIC NOTATION RULES. Rules for converting to Scientific Notation One non-zero number before the decimal One digit after the decimal If you are making.
Converting Fractions to Decimals 1.Arrange the numerator as the dividend and the denominator as the divisor. 4 3 ) ) DIVISOR DIVIDEND NUMERATOR.
Decimal Review. Adding decimals Rules Line up the decimal points 2. Make whole numbers look like decimals.
Chapter 1 Whole Numbers Digit – number from 0-9
Multiply and Divide Fractions and Decimals. Mixed Numbers, Improper Fractions, and Reciprocals Mixed Number: A number made up of a fraction and a whole.
Adding Decimal Numbers
Quick Guide to Adding, Subtracting, Multiplying, and Dividing Decimals
William Stallings Computer Organization and Architecture 8th Edition
Unit 0: Review Decimals and Fractions.
Convert Decimal to Binary
Lecture 8: Addition, Multiplication & Division
Lecture 8: Addition, Multiplication & Division
ZAP Zero and Add Packed.
CSCE 350 Computer Architecture
Microprocessor and Assembly Language
ECEG-3202 Computer Architecture and Organization
#1 Dividing by a Whole Number
Computing in COBOL: The Arithmetic Verbs and Intrinsic Functions
Morgan Kaufmann Publishers Arithmetic for Computers
Multiplying and Dividing Decimals by 10, 100, 1000
Chapter 1 Whole Numbers.
Dividing whole number by a decimal
Presentation transcript:

CIS 020 Assembly Programming Chapter 08 - Advanced Decimal Arithmetic Instructions © John Urrutia 2012, All Rights Reserved.5/27/20121

Objectives How to format and use the following decimal instructions: Zero and Add Pack – ZAP Multiply Packed – MP Divide Packed – DP Compare Packed – CP © John Urrutia 2012, All Rights Reserved.25/27/2012

ZAP – Zero and Add Packed Two step process 1 st initializes the receiving operand to packed zeros 2 nd add the sending operand to the receiving operand Syntax of Instruction Op Code – ZAP Operand 1 – label or address, will contain the value of 2 nd operand after execution. Operand 2 – label or address, must be a packed-decimal format value. Value is added right to left to operand 1 and padded, if necessary, with zeros on the left. © John Urrutia 2012, All Rights Reserved.35/27/2012

ZAP – Zero and Add Packed © John Urrutia 2012, All Rights Reserved.45/27/2012

ZAP – Zero and Add Packed © John Urrutia 2012, All Rights Reserved.55/27/2012

ZAP – Zero and Add Packed Most Decimal instructions set the Condition Code (reprised) ZAP – set the Condition Code 0 – 2 nd Operand value is zero 1 – 2 nd Operand value is negative 2 – 2 nd Operand value is positive 3 – 2 nd Operand length is > 1 st Operand (Overflow) Branching instructions BZ – on Zero, BM – on Negative, BP – on Positive, BO – on Overflow © John Urrutia 2012, All Rights Reserved.65/27/2012

MP – Multiply Packed Syntax of Instruction Op Code – MP Operand 1 – multiplicand (before execution) and product (after execution) Operand 2 – multiplier Both Operands must be in packed-decimal format Operand 1 should be twice larger than the size of Operand 2 to absolutely prevent overflow conditions. All packed-decimal instructions set the sign to X’C’ – Positive or X’D’ – Negative © John Urrutia 2012, All Rights Reserved.75/27/2012

MP – Multiply Packed Calculating decimal field size Maximum number of digits in the multiplicand + Maximum number of digits in the multiplier = Maximum number of digits in the product The receiving field (Operand 1) in bytes must be = the whole number in (Max product digits + 2) / 2 See chart next slide © John Urrutia 2012, All Rights Reserved.85/27/2012

MP – Multiply Packed © John Urrutia 2012, All Rights Reserved.95/27/2012 Multiplicand Multiplier Bytes

MP – Multiply Packed FLD1 – 2 digits © John Urrutia 2012, All Rights Reserved.105/27/2012 FLD2 – 3 digits

MP – Multiply Packed FLD1 – 2 digits © John Urrutia 2012, All Rights Reserved.115/27/2012 FLD2 – 2 digits

MP – Multiply Packed Example © John Urrutia 2012, All Rights Reserved.125/27/2012

DP – Divide Packed Syntax of Instruction Op Code – DP Operand 1 – dividend (before execution) and quotient & remainder (after execution) Operand 2 – divisor Both Operands must be in packed-decimal format Operand 1 length (quotient) should be equal to Divisor digits converted to packed bytes plus Dividend digits converted to packed bytes All packed-decimal instructions set the sign to X’C’ – Positive or X’D’ – Negative © John Urrutia 2012, All Rights Reserved.135/27/2012

DP – Divide Packed The Dividend (before execution) is stored in Operand 1 Dividend is 5 bytes – The Quotient & Remainder (after execution) is stored in Operand 1 Quotient is 3 bytes – Remainder is 2 bytes – Operand 1 must be 5 bytes – The Remainder is the same size as the Divisor © John Urrutia 2012, All Rights Reserved.145/27/ C 000C 99999C000C C

DP – Divide Packed Example © John Urrutia 2012, All Rights Reserved.155/27/2012

CP – Compare Packed Syntax of Instruction Op Code – CP Operand 1 – label or address Operand 2 – label or address Both Operands must be in packed-decimal format Operands are not changed Condition code is set to Operands are equal– BE 1 st operand is low– BL 1 st operand is high– BH © John Urrutia 2012, All Rights Reserved.165/27/2012

CP – Compare Packed Rules Comparison is algebraic & both operands are unchanged The sign of the second operand is changed The operands are added If the result is zero the operands are equal CC=0 If the result is negative operand 1 is low CC=1 If the result is positive operand 1 is high CC=2 Operands of unequal size are padded with zeros © John Urrutia 2012, All Rights Reserved.175/27/2012

CP – Compare Packed Example © John Urrutia 2012, All Rights Reserved.185/27/2012

Exercise Using the ADVDECSH shell write a program that will do a binary search for a number you pick between 1 and 32 inclusive. © John Urrutia 2012, All Rights Reserved.195/27/2012