The 8051 Assembly Language Arithmetic & Logic Instructions

Slides:



Advertisements
Similar presentations
Chapter 18 The 8051 Microcontroller
Advertisements

Embedded Software 1. General 8051 features (excluding I/O) CPU 8 bit microcontroller The basic registers include (more discussed later) The 8-bit A (accumulator)
EE/CS-352: Embedded Microcontroller Systems The 8051 Assembly Language.
The 8051 Assembly Language Stack, Bit Addressing, Arithmetic
Week4. Program Branching  From what we have covered so far, our assembly programs execute one instruction after another in sequence  Programs that solve.
Programming the 8051 Microcontroller Dr. Konstantinos Tatas
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.
ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS
COMP3221: Microprocessors and Embedded Systems--Lecture 7 1 COMP3221: Microprocessors and Embedded Systems Lecture 7: Arithmetic and logic Instructions.
COMP3221: Microprocessors and Embedded Systems--Lecture 7 1 COMP3221: Microprocessors and Embedded Systems Lecture 7: Arithmetic and logic Instructions.
© 2006 Pearson Education, Upper Saddle River, NJ All Rights Reserved.Brey: The Intel Microprocessors, 7e Chapter 5 Arithmetic and Logic Instructions.
Chapter 7 Logic Instructions and Programs
Room: E-3-31 Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.
8051 ASSEMBLY LANGUAGE PROGRAMMING
Microcontroller Intel 8051
Princess Sumaya Univ. Computer Engineering Dept. Chapter 2:
MICROCONTROLLER INSTRUCTION SET
Numerical Bases Used in Programming Hexadecimal Binary BCD.
The M68HC11 Basic Instruction Set Basic Arithmetic Instructions
The 8051 Microcontroller and Embedded Systems
CoE3DJ4 Digital Systems Design Chapter 3: instruction set summary.
8051 Programming (Addressing Mode-Instruction Set) Lec note 5
Prof. Cherrice TraverEE/CS-152: Microprocessors and Microcontrollers The 8051 Assembly Language.
Khaled A. Al-Utaibi  Introduction  Arithmetic Instructions  Basic Logical Instructions  Shift Instructions  Rotate Instructions.
CIT 673 Created by Suriyong1 MCS51 ASSEMBLY Language Resources
MICROCONTROLLERS 8051.
Microprocessor Dr. Rabie A. Ramadan Al-Azhar University Lecture 7.
University Of Engineering And Technology Taxila REF::NATIONAL TAIWANOCEAN UNIVERSITY 國立台灣海洋大學 Chapter 3 JUMP, LOOP and CALL Instructions.
Prof. Cherrice TraverEE/CS-152: Microprocessors and Microcontrollers The 8051 Assembly Language.
Microprocessors CSE 341 Lecture Md. Omar Faruqe UB 1228
CHAPTER 6 ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS.
Arithmetic and Logic Chapter 5
Assembly Language Programming of 8085 BY Prof. U. V. THETE Dept. of Computer Science YMA.
III] Logical Group 1)ANA r : LOGICAL AND REGISTER WITH ACCUMULATOR Format : [A] [A] Λ [r] Addressing : Register addressing Group : Logical group Bytes.
EE/CS-352: Embedded Microcontroller Systems Part V The 8051 Assembly Language Interrupts.
The 8051 Assembly Language. Overview Introduction Addressing modes Data processing (arithmetic and logic) Data transfer instructions Program flow instructions.
Microprocessor & Assembly Language Arithmetic and logical Instructions.
Universal College Of Engineering & Technology UCET 1/27.
Arithmetic Instructions and Programs. Outlines Range of numbers in 8051 unsigned data Range of numbers in 8051 unsigned data Addition & subtraction instructions.
1 Contents: 3.1 Instruction format and Addressing Modes 3.2 Instruction Introduction Chapter 3 Instruction system.
Unit 1 Instruction set M.Brindha AP/EIE
The 8051 Microcontroller.
CHAPTER ADDRESSING MODES.
Classification of Instruction Set of 8051
Assembly Language Programming of 8085
Microprocessor T. Y. B. Sc..
3.Instruction Set of 8085 Consists of 74 operation codes, e.g. MOV
Lecture Set 5 The 8051 Instruction Set.
ECE,JYOTHI ENGG COLLEGE
8051 Addressing Modes The way, using which the data source or destination addresses are specified in the instruction mnemonic for moving the data, is.
Overview Introduction General Register Organization Stack Organization
Data Processing Instructions
INSTRUCTION SET OF 8086 PAWAN KUMAR SINGH.
The 8051 Microcontroller.
Instruction Groups The 8051 has 255 instructions.
Boolean Operations This group of instructions is associated with the single-bit operations of the This group allows manipulating the individual bits.
Memory Organisation Source: under
SCHOOL OF ELECTRONICS ENGINEERING Electronics and Communication
8051 Single Board Computer (SBC) Version 1.0
Introduction to Micro Controllers & Embedded System Design Instruction set Department of Electrical & Computer Engineering Missouri University of Science.
Table Construction.
Introduction to Micro Controllers & Embedded System Design Instruction set Department of Electrical & Computer Engineering Missouri University of Science.
DMT 245 Introduction to Microcontroller
Logical Operations ANL / ORL
Arithmetic and Logic Chapter 5
Chapter 5 Arithmetic and Logic Instructions
Compiled by Dr. N.Shanmugasundaram, HOD, ECE Dept, SECE.
ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS
Immediate data Immediate operands : ADD r3, r3, #1 valid ADD r3, #1,#2 invalid ADD #3, r1,r2 invalid ADD r3, r2, #&FF ( to represent hexadecimal immediate.
Presentation transcript:

The 8051 Assembly Language Arithmetic & Logic Instructions Part III The 8051 Assembly Language Arithmetic & Logic Instructions EE/CS-352: Embedded Microcontroller Systems

EE/CS-352: Embedded Microcontroller Systems Subtract SUBB A, byte subtract with borrow Example: SUBB A, #0x4F ; A  A – 4F – C EE/CS-352: Embedded Microcontroller Systems

Increment and Decrement INC A increment A INC byte increment byte in memory INC DPTR increment data pointer DEC A decrement accumulator DEC byte decrement byte The increment and decrement instructions do NOT affect the C flag. EE/CS-352: Embedded Microcontroller Systems

Example: Increment 16-bit Word Assume 16-bit word in R3:R2 mov a, r2 add a, #1 ; use add rather than increment to affect C mov r2, a mov a, r3 addc a, #0 ; add C to most significant byte mov r3, a EE/CS-352: Embedded Microcontroller Systems

EE/CS-352: Embedded Microcontroller Systems Multiply When multiplying two 8-bit numbers, the size of the maximum product is 16-bits FF x FF = FE01 (255 x 255 = 65025) MUL AB ; BA  A * B EE/CS-352: Embedded Microcontroller Systems

EE/CS-352: Embedded Microcontroller Systems Division Integer Division DIV AB ; divide A by B A  Quotient(A/B), B  Remainder(A/B) EE/CS-352: Embedded Microcontroller Systems

EE/CS-352: Embedded Microcontroller Systems Decimal Adjust DA a ; decimal adjust a Used to facilitate BCD addition. Adds “6” to either high or low nibble after an addition to create a valid BCD number. Example: EE/CS-352: Embedded Microcontroller Systems

EE/CS-352: Embedded Microcontroller Systems Logic Instructions Bitwise logic operations (AND, OR, XOR, NOT) Clear Rotate Swap Logic instructions do NOT affect the flags in PSW EE/CS-352: Embedded Microcontroller Systems

EE/CS-352: Embedded Microcontroller Systems Bitwise Logic Examples: ANL – AND ORL – OR XRL – eXclusive OR CPL – Complement 00001111 10101100 ANL 00001111 10101100 ORL 00001111 10101100 XRL 10101100 CPL EE/CS-352: Embedded Microcontroller Systems

Address Modes with Logic ANL – AND ORL – OR XRL – eXclusive oR CPL – Complement a, byte direct, reg. indirect, reg, immediate byte, a direct byte, #constant a EE/CS-352: Embedded Microcontroller Systems

Uses of Logic Instructions Force individual bits low, without affecting other bits e.g. force bits 3&4 of PSW low Force individual bits high, without affecting other bits e.g., force bits 5&7 of PSW high Complement individual bits, without affecting other bits e.g., complement bit 6 of P1 EE/CS-352: Embedded Microcontroller Systems

Other Logic Instructions CLR - clear RL – rotate left RLC – rotate left through Carry RR – rotate right RRC – rotate right through Carry SWAP – swap accumulator nibbles EE/CS-352: Embedded Microcontroller Systems

EE/CS-352: Embedded Microcontroller Systems CLR – Set all bits to 0 CLR A CLR byte (direct mode) CLR Ri (register mode) CLR @Ri (register indirect mode) EE/CS-352: Embedded Microcontroller Systems

EE/CS-352: Embedded Microcontroller Systems Rotate Rotate instructions operate only on a rl a mov a, #0xF0 EE/CS-352: Embedded Microcontroller Systems

EE/CS-352: Embedded Microcontroller Systems Rotate through Carry rrc a mov a, #0A9h add a, #14h C EE/CS-352: Embedded Microcontroller Systems

EE/CS-352: Embedded Microcontroller Systems Swap swap a mov a, #72h EE/CS-352: Embedded Microcontroller Systems

EE/CS-352: Embedded Microcontroller Systems Bit Logic Operations Some logic operations can be used with single bit operands ANL C, bit ANL C, /bit ORL C, bit ORL C, /bit CLR C CLR bit CPL C CPL bit SETB C SETB bit “bit” can be any of the bit-addressable RAM locations or SFRs. EE/CS-352: Embedded Microcontroller Systems