EECC250 - Shaaban #1 lec #14 Winter99 1-20-2000 68000 Binary Coded Decimal (BCD) Arithmetic Binary Coded Decimal (BCD) is a way to store decimal numbers.

Slides:



Advertisements
Similar presentations
EECC250 - Shaaban #1 Lec # 2 Winter Addressing Modes  Addressing modes are concerned with the way data is accessed  Addressing can be.
Advertisements

Week 3. Assembly Language Programming  Difficult when starting assembly programming  Have to work at low level  Use processor instructions >Requires.
Intro to CS – Honors I Representing Numbers GEORGIOS PORTOKALIDIS
9/20/6Lecture 3 - Instruction Set - Al Instruction Set.
EECC250 - Shaaban #1 Lec # 6 Winter Stack-Related Instructions PEA Push Effective Address Calculates an effective address and pushes it.
ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS
EECC250 - Shaaban #1 lec #16 Winter Estimation of Assembly Programs Execution Time For a CPU running at a constant clock rate: clock rate =
Number Systems Standard positional representation of numbers:
Level ISA3: Information Representation
Assembly Language for Intel-Based Computers Chapter 2: IA-32 Processor Architecture Kip Irvine.
EECC341 - Shaaban #1 Lec # 3 Winter Binary Multiplication Multiplication is achieved by adding a list of shifted multiplicands according.
Chapter Chapter Goals Know the different types of numbers Describe positional notation.
Data Representation in Computers
Copyright 2008 Koren ECE666/Koren Part.6a.1 Israel Koren Spring 2008 UNIVERSITY OF MASSACHUSETTS Dept. of Electrical & Computer Engineering Digital Computer.
Chapter 02 Binary Values and Number Systems Nell Dale & John Lewis.
The Binary Number System
COMP201 Computer Systems Number Representation. Number Representation Introduction Number Systems Integer Representations Examples  Englander Chapter.
Binary Number Systems.
The M68HC11 Basic Instruction Set Basic Arithmetic Instructions
Binary Addition Addition Rules: = = = = = carry 1 1 carry 1 Example 1: Example 2:
The Binary Number System
Data Representation Number Systems.
Arithmetic for Computers
CSCI-365 Computer Organization Lecture Note: Some slides and/or pictures in the following are adapted from: Computer Organization and Design, Patterson.
Computer Arithmetic Nizamettin AYDIN
How Computers Work Dr. John P. Abraham Professor UTPA.
#1 Lec # 2 Winter EECC341 - Shaaban Positional Number Systems A number system consists of an order set of symbols (digits) with relations.
Computer Science 111 Fundamentals of Programming I Number Systems.
Binary Arithmetic & Data representation
EX_01.1/46 Numeric Systems. EX_01.2/46 Overview Numeric systems – general, Binary numbers, Octal numbers, Hexadecimal system, Data units, ASCII code,
Lec 3: Data Representation Computer Organization & Assembly Language Programming.
ECEN2102 Digital Logic Design Lecture 1 Numbers Systems Abdullah Said Alkalbani University of Buraimi.
Number Systems Spring Semester 2013Programming and Data Structure1.
Digital Logic Design Lecture 3 Complements, Number Codes and Registers.
Introduction to Computer Design CMPT 150 Section: D Ch. 1 Digital Computers and Information CMPT 150, Chapter 1, Tariq Nuruddin, Fall 06, SFU 1.
9/20/6Lecture 3 - Instruction Set - Al Instruction Set (2)
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,
CPU Internal memory I/O interface circuit System bus
Cosc 2150: Computer Organization Chapter 2 Part 1 Integers addition and subtraction.
ECE 2110: Introduction to Digital Systems Signed Addition/Subtraction.
Chapter 2 Number Systems: Decimal, Binary, and Hex.
Data Representation, Number Systems and Base Conversions
AEEE2031 Data Representation and Numbering Systems.
Operators & Identifiers The Data Elements. Arithmetic Operators exponentiation multiplication division ( real ) division ( integer quotient ) division.
Chapter 4 Integer Data Representation. Unsigned Integers.
Chapter 2 Binary Values and Number Systems Chapter Goals Distinguish among categories of numbers Describe positional notation Convert numbers in.
©2010 Cengage Learning SLIDES FOR CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION Click the mouse to move to the next page. Use the ESC key to exit.
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.
Nguyen Le CS147.  2.4 Signed Integer Representation  – Signed Magnitude  – Complement Systems  – Unsigned Versus Signed Numbers.
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.
Binary Values. Numbers Natural Numbers Zero and any number obtained by repeatedly adding one to it. Examples: 100, 0, 45645, 32 Negative Numbers.
Binary Addition The simplest arithmetic operation in binary is addition. Adding two single-digit binary numbers is relatively simple, using a form of carrying:
Cosc 2150: Computer Organization
Programming and Data Structure
ECE 2110: Introduction to Digital Systems
Lec 3: Data Representation
Data Representation.
Status Register Status = system byte (supervisor only) + user byte = system status + condition code register usually, it is not important to know.
Data Representation Binary Numbers Binary Addition
Decimal Arithmetic (alternative to binary arithmetic)
Microcomputer Programming
IT 0213: INTRODUCTION TO COMPUTER ARCHITECTURE
TAO1221 COMPUTER ARCHITECTURE AND ORGANIZATION LAB 6
68000 Arithmetic Instructions
Lecture 3 - Instruction Set - Al
Arithmetic operations Programming
Chapter 11 © 2011, The McGraw-Hill Companies, Inc.
Fundamentals of Programming I Number Systems
Presentation transcript:

EECC250 - Shaaban #1 lec #14 Winter Binary Coded Decimal (BCD) Arithmetic Binary Coded Decimal (BCD) is a way to store decimal numbers in binary. This number representation uses 4 bits to store each digit from 0 to 9. For example: = in BCD BCD wastes storage space since 4 bits are used to store 10 combinations rather than the maximum possible 16. BCD is often used in business applications and calculators. The instruction set includes three instructions that offer some support for BCD arithmetic: –ABCDAdd BCD with extend –SBCDSubtract BCD with extend –NBCDNegate BCD BCD instructions use and affect the X-bit because they are intended to be used in chained calculations where arithmetic is done on strings of BCD digits. –For addition: the X-bit records the carry –For subtraction: the X-bit records the borrow

EECC250 - Shaaban #2 lec #14 Winter

EECC250 - Shaaban #3 lec #14 Winter

EECC250 - Shaaban #4 lec #14 Winter Effect of ABCD When X = 0 initially X N Z V C D D0 0 X-bit 2 8 D1 ABCD D0,D1 Add D0 to D1 with the X-bit Before After

EECC250 - Shaaban #5 lec #14 Winter Effect of ABCD When X = 1 initially X N Z V C D D0 1 X-bit 2 8 D1 ABCD D0,D1 Add D0 to D1 with the X-bit Before After

EECC250 - Shaaban #6 lec #14 Winter

EECC250 - Shaaban #7 lec #14 Winter

EECC250 - Shaaban #8 lec #14 Winter Effect of SBCD When X = 0 initially X N Z V C D D0 0 X-bit 2 8 D1 SBCD D1,D0 Subtract D1 from D0 with the X-bit Before After

EECC250 - Shaaban #9 lec #14 Winter Effect of SBCD When X = 1 initially X N Z V C D D0 1 X-bit 2 8 D1 SBCD D1,D0 Subtract D1 from D0 with the X-bit Before After

EECC250 - Shaaban #10 lec #14 Winter

EECC250 - Shaaban #11 lec #14 Winter Effect of NBCD When X = 0 initially X N Z V C D X-bit 2 8 D0 NBCD D0 Subtract D0 from 0 with the X-bit Before After

EECC250 - Shaaban #12 lec #14 Winter Effect of NBCD When X = 1 initially X N Z V C D X-bit 2 8 D0 NBCD D0 Subtract D0 from 0 with the X-bit Before After

EECC250 - Shaaban #13 lec #14 Winter BCD Addition Example Two BCD strings each with 12 BCD digits (six bytes) and stored in memory starting at locations: String1, String2, are to be added together with the result to be stored in memory starting at String2 ORG $1000 ADDBCD MOVE.W #5,D0 Loop counter, six bytes to be added ANDI #$EF,CCR Clear X-bit in CCR LEA String1+6,A0 A0 points at end of source string +1 LEA String2+6,A1 A0 points at end of destination string +1 LOOP ABCD -(A0),-(A1) Add pair of digits with carry-in DBRA D0,LOOP Repeat until 12 digits are added RTS. String1 DS.B 6 String2 DS.B 6 DBRA used here because it does not affect the X-bit needed in BCD arithmetic

EECC250 - Shaaban #14 lec #14 Winter BCD Subtraction Example Two BCD strings with 12 BCD digits (six bytes) each are stored in memory starting at locations String1, String2. String1 is to subtracted from String 2 with the result to be stored in memory starting at String2 ORG $1000 SUBBCD MOVE.W #5,D0 Loop counter, six bytes to be added ANDI #$EF,CCR Clear X-bit in CCR LEA String1+6,A0 A0 points at end of source string +1 LEA String2+6,A1 A0 points at end of destination string +1 LOOP SBCD -(A0),-(A1) Subtract pair of digits with borrow DBRA D0,LOOP Repeat until 12 digits are added RTS. String1 DS.B 6 String2 DS.B 6

EECC250 - Shaaban #15 lec #14 Winter Multiple-Precision Arithmetic For numerical values, precision refers to the number of significant digits in the numerical value.  If more precision is needed in a numerical value, more significant digits must be used to yield a more precise result. The maximum single-precision operand length supported by the is 32 bits. Thus, values with greater length cannot be handled as a single arithmetic operand by the CPU. To extend the precision, several 32-bit operands can be used and considered mathematically as a single value. The offers three special instructions to facilitate addition, subtraction, and negation of multiple-precision integers: –ADDXADD with eXtend –SUBXSUBtract with eXtend –NEGXNEGate with eXtend

EECC250 - Shaaban #16 lec #14 Winter

EECC250 - Shaaban #17 lec #14 Winter

EECC250 - Shaaban #18 lec #14 Winter

EECC250 - Shaaban #19 lec #14 Winter Addition Example Multiple-Precision Addition Example Two unsigned binary numbers each with 128 bits (16 bytes) and stored in memory starting at locations Num1, Num2 are to be added together with the result to be stored in memory starting at Num2 ORG $1000 MPADD MOVE.W #3,D0 Four long words to be added ANDI #$EF,CCR Clear X-bit in CCR LEA Num1,A0 A0 points at start of source ADDA #16,A0 A0 points to end of source + 1 LEA Num2,A1 A1 points at start of destination ADDA #16,A1 A1 points to end of destination + 1 LOOP ADDX.L -(A0),-(A1) Add pair of long words with carry-in DBRA D0,LOOP Repeat until 4 long words are added RTS. Num1 DS.L 4 Num2 DS.L 4 DBRA is used here because it does not affect the X-bit needed in multiple-precision arithmetic

EECC250 - Shaaban #20 lec #14 Winter Subtraction Example Multiple-Precision Subtraction Example Two unsigned binary numbers each with 128 bits (16 bytes) and stored in memory starting at locations Num1, Num2 Num1 to be is to subtracted from Num2 with the result to be stored in memory starting at Num2 ORG $1000 MPADD MOVE.W #3,D0 Four long words to be added ANDI #$EF,CCR Clear X-bit in CCR LEA Num1,A0 A0 points at start of source ADDA #16,A0 A0 points to end of source + 1 LEA Num2,A1 A1 points at start of destination ADDA #16,A1 A1 points to end of destination + 1 LOOP SUBX.L -(A0),-(A1) Subtract pair of long words with borrow DBRA D0,LOOP Repeat until 4 long words are subtracted RTS. Num1 DS.L 4 Num2 DS.L 4 DBRA is used here because it does not affect the X-bit needed in multiple-precision arithmetic