ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS

Slides:



Advertisements
Similar presentations
Parul Polytechnic Institute Subject Code : Name Of Subject : Microprocessor and assembly language programming Name of Unit : Introduction to Microprossor.
Advertisements

Week 3. Assembly Language Programming  Difficult when starting assembly programming  Have to work at low level  Use processor instructions >Requires.
MOV Instruction MOV destination, source ; copy source to dest. MOV A,#55H ;load value 55H into reg. A MOV R0,A ;copy contents of A into R0 ;(now A=R0=55H)
Msc. Ivan A. Escobar Broitman Microprocessors 1 1 The 8051 Instruction Set.
Addition and Subtraction. Outline Arithmetic Operations (Section 1.2) – Addition – Subtraction – Multiplication Complements (Section 1.5) – 1’s complement.
Chapter 6 Arithmetic Instructions and Programs
Dr Masri Ayob TK 2633: Microprocessor & Interfacing Lecture 5: Arithmetic and Logic Instructions.
Number Representation (1) Fall 2005 Lecture 12: Number Representation Integers and Computer Arithmetic.
Microcontroller Intel 8051
1.6 Signed Binary 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.
The 8051 Microcontroller and Embedded Systems
Chapter 6 Digital Arithmetic: Operations and Circuits ECE 221 Intro
1 CS/COE0447 Computer Organization & Assembly Language Chapter 3.
Binary Arithmetic & Data representation
Digital Arithmetic and Arithmetic Circuits
1.11, 1.12, 1.13, 1.14, 1.18, 1.20, 1.23, 1.24, 1.25, 1.32, 1.33.
CSE 241 Computer Organization Lecture # 9 Ch. 4 Computer Arithmetic Dr. Tamer Samy Gaafar Dept. of Computer & Systems Engineering.
Number Systems ELEC 311 Digital Logic and Circuits Dr. Ron Hayne Images Courtesy of Cengage Learning.
Embedded System Spring, 2011 Lecture 10: Arithmetic, Logic Instruction and Programs Eng. Wazen M. Shbair.
1 EENG 2710 Chapter 1 Number Systems and Codes. 2 Chapter 1 Homework 1.1c, 1.2c, 1.3c, 1.4e, 1.5e, 1.6c, 1.7e, 1.8a, 1.9a, 1.10b, 1.13a, 1.19.
Mohammad Amin Kuhail M.Sc. (York, UK) University of Palestine Faculty of Engineering and Urban planning Software Engineering Department Digital Logic Design.
University Of Engineering And Technology Taxila REF::NATIONAL TAIWANOCEAN UNIVERSITY 國立台灣海洋大學 Chapter 3 JUMP, LOOP and CALL Instructions.
Operations on Bits Arithmetic Operations Logic Operations
Microprocessor Technique Binary codes. Lecture 2 1/47 Binary codes in microprocessor technique Integer arithmetic Fix-point arithmetic Floating-point.
AEEE2031 Data Representation and Numbering Systems.
Ass. Prof. Dr Masri Ayob Lecture 5: Arithmetic and Logic Instructions TK 2633: Microprocessor & Interfacing.
Data Representation in Computer Systems. 2 Signed Integer Representation The conversions we have so far presented have involved only positive numbers.
Introduction to Microprocessors Chapter 2. Decimal or Base 10 Numbers  Have ten different digits (0-9)  It is a weighted number system. Each position.
COMPUTER ORGANISATION Sri.S.A.Hariprasad Sr.Lecturer R.V.C.E Bangalore.
CEC 220 Digital Circuit Design Binary Arithmetic & Negative Numbers Monday, January 13 CEC 220 Digital Circuit Design Slide 1 of 14.
Outline Binary Addition 2’s complement Binary Subtraction Half Adder
CEC 220 Digital Circuit Design Binary Arithmetic & Negative Numbers Fri, Aug 28 CEC 220 Digital Circuit Design Slide 1 of 14.
CHAPTER 6 ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS.
Arithmetic and Logic Chapter 5
ECE DIGITAL LOGIC LECTURE 3: DIGITAL COMPUTER AND NUMBER SYSTEMS Assistant Prof. Fareena Saqib Florida Institute of Technology Fall 2016, 01/19/2016.
In decimal we are quite familiar with placing a “-” sign in front of a number to denote that it is negative The same is true for binary numbers a computer.
Microprocessor & Assembly Language Arithmetic and logical Instructions.
MicroProcessors Lec. 4 Dr. Tamer Samy Gaafar. Course Web Page —
Nguyen Le CS147.  2.4 Signed Integer Representation  – Signed Magnitude  – Complement Systems  – Unsigned Versus Signed Numbers.
Microprocessor & Assembly Language
Arithmetic Circuits I. 2 Iterative Combinational Circuits Like a hierachy, except functional blocks per bit.
COSC2410: LAB 2 BINARY ARITHMETIC SIGNED NUMBERS FLOATING POINT REPRESENTATION BOOLEAN ALGEBRA 1.
Chapter 6. Digital Arithmetic: Operations and Circuits
Arithmetic Instructions and Programs. Outlines Range of numbers in 8051 unsigned data Range of numbers in 8051 unsigned data Addition & subtraction instructions.
11001 / 101, / ) Perform subtraction on the given unsigned binary numbers using the 2's complement of the subtrahend. Where the result.
Lecture 4: Digital Systems & Binary Numbers (4)
COMPUTER ORGANIZATION 4 TH LECTURE. ASCII Code  ASCII ( American Standard Code for Information Interchange).  Input and output devices that communicate.
Unit I From Fundamentals of Logic Design by Roth and Kinney.
Classification of Instruction Set of 8051
CHAPTER 1 INTRODUCTION NUMBER SYSTEMS AND CONVERSION
11001 / 101 , / ) Perform subtraction on the given unsigned binary numbers using the 2's complement of the subtrahend. Where the.
Negative Binary Numbers
Lecture Set 5 The 8051 Instruction Set.
Data Processing Instructions
Arithmetic and Logic Chapter 5
Instruction Groups The 8051 has 255 instructions.
Memory Organisation Source: under
Arithmetic operations Programming
The 8051 Assembly Language Arithmetic & Logic Instructions
Chapter 11 © 2011, The McGraw-Hill Companies, Inc.
Introduction to Micro Controllers & Embedded System Design Instruction set Department of Electrical & Computer Engineering Missouri University of Science.
University of Gujrat Department of Computer Science
CS/COE0447 Computer Organization & Assembly Language
CS/COE0447 Computer Organization & Assembly Language
Arithmetic and Logic Chapter 5
March 2006 Saeid Nooshabadi
ECE 331 – Digital System Design
ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS
Chapter 1 (Part c) Digital Systems and Binary Numbers
Presentation transcript:

ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS CHAPTER 6 ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS

Addition of Unsigned Numbers The instruction ADD is used to add two operands Destination operand is always in register A Source operand can be a register, immediate data, or in memory Memory-to-memory arithmetic operations are never allowed in 8051 Assembly language

ADDC and Addition of 16-Bit Numbers When adding two 16-bit data operands, the propagation of a carry from lower byte to higher byte is concerned

BCD Number System The binary representation of the digits 0 to 9 is called BCD (Binary Coded Decimal) Unpacked BCD The lower 4 bits of the number represent the BCD number, and the rest of the bits are 0 Ex. 00001001 and 00000101 are unpacked BCD for 9 and 5 Packed BCD A single byte has two BCD number in it, one in the lower 4 bits, and one in the upper 4 bits Ex. 0101 1001 is packed BCD for 59H

BCD Number System (cont.) Adding two BCD numbers must give a BCD result

DA Instruction The DA instruction is provided to correct the aforementioned problem associated with BCD addition

DA Instruction (cont.) After an ADD or ADDC instruction If the lower nibble (4 bits) is greater than 9, or if AC=1, add 0110 to the lower 4 bits If the upper nibble is greater than 9, or if CY=1, add 0110 to the upper 4 bits

Subtraction of Unsigned Numbers In many microprocessor, there are two different instructions for subtraction: SUB and SUBB (subtract with borrow) In the 8051 we have only SUBB The 8051 uses adder circuitry to perform the subtraction To make SUB out of SUBB, we have to make CY=0 prior to the execution Notice that we use the CY flag for the borrow

Subtraction of Unsigned Numbers (cont.) SUBB when CY = 0 Take the 2’s complement of the subtrahend Add it to the minuend (A) Invert the carry CY=0, the result is positive CY=1, the result is negative The destination has the 2’s complement of the result SUBB when CY = 1 Used for multi-byte numbers Take care of the borrow of the lower operand

Unsigned Multiplication The 8051 supports byte by byte multiplication only The byte are assumed to be unsigned data

Unsigned Division The 8051 supports byte over byte division only The byte are assumed to be unsigned data

Signed 8-bit Operands D7 (MSB) is the sign and D0 to D6 are the magnitude of the number If D7=0, the operand is positive If D7=1, it is negative Positive numbers are 0 to +127

Signed 8-bit Operands D7 (MSB) is the sign and D0 to D6 are the magnitude of the number If D7=0, the operand is positive If D7=1, it is negative Positive numbers are 0 to +127

Signed 8-bit Operands (cont.) Negative number representation (2’s complement) Write the magnitude of the number in 8-bit binary (no sign) Invert each bit Add 1 to it

Overflow Problem If the result of an operation on signed numbers is too large for the register An overflow has occurred

OV Flag In 8-bit signed number operations, OV is set to 1 if either occurs: There is a carry from D6 to D7, but no carry out of D7 (CY=0) There is a carry from D7 out (CY=1), but no carry from D6 to D7

OV Flag (cont.) In unsigned number addition, we must monitor the status of CY (carry) Use JNC or JC instructions In signed number addition, the OV (overflow) flag must be monitored JB PSW.2 or JNB PSW.2 To make the 2’s complement of a number