University Of Engineering And Technology Taxila REF::NATIONAL TAIWANOCEAN UNIVERSITY 國立台灣海洋大學 Chapter 3 JUMP, LOOP and CALL Instructions.

Slides:



Advertisements
Similar presentations
Chapter 18 The 8051 Microcontroller
Advertisements

Microprocessors.
Programming the 8051 Microcontroller Dr. Konstantinos Tatas
The 8051 Microcontroller and Embedded Systems
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)
Suranaree University Of Technology มทส  2002 Anant Oonsivilai 2002/2/25 Microcomputers and Microprocessors 1 Chapter 4 I/O Port Programming.
1 Chapter 3 Jump, Loop, and Call Instructions. 2 Sections 3.1 Loop and Jump Instructions 3.2 Call Instructions 3.3 Time Delay Generation and Calculation.
Real time DSP Professors: Eng. Julian S. Bruno Eng. Jerónimo F. Atencio Sr. Lucio Martinez Garbino.
Msc. Ivan A. Escobar Broitman Microprocessors 1 1 The 8051 Instruction Set.
ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS
Chapter 6 Arithmetic Instructions and Programs
Chapter 7 Logic Instructions and Programs
Digital Arithmetic Wen-Hung Liao, Ph.D.. Objectives Perform binary addition, subtraction, multiplication, and division on two binary numbers. Add and.
Dr Masri Ayob TK 2633: Microprocessor & Interfacing Lecture 5: Arithmetic and Logic Instructions.
8051 ASSEMBLY LANGUAGE PROGRAMMING
Microcontroller Intel 8051
MICROCONTROLLER INSTRUCTION SET
Numerical Bases Used in Programming Hexadecimal Binary BCD.
1 EKT 225 MICROCONTROLLER I CHAPTER 3 I/O PORT PROGRAMMING.
ECE 447 Fall 2009 Lecture 5: TI MSP430 Software Development in C and Assembly pt. 2.
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
Machine Instruction Characteristics
Lecture 05: Assembly Language Programming (2). The 80x86 IBM PC and Compatible Computers Chapter 3 Arithmetic & Logic Instructions and Programs Chapter.
CPU Internal memory I/O interface circuit System bus
ASCII and BCD Arithmetic Chapter 11 S. Dandamudi.
MICROCONTROLLERS 8051.
ICS312 Set 9 Logic & Shift Instructions. Logic & Shift Instructions Logic and Shift Instructions can be used to change the bit values in an operand. The.
Prof. Cherrice TraverEE/CS-152: Microprocessors and Microcontrollers The 8051 Assembly Language.
Microprocessor Technique Binary codes. Lecture 2 1/47 Binary codes in microprocessor technique Integer arithmetic Fix-point arithmetic Floating-point.
The 8051 Microcontroller and Embedded Systems
Ass. Prof. Dr Masri Ayob Lecture 5: Arithmetic and Logic Instructions TK 2633: Microprocessor & Interfacing.
Lecture Set 4 Programming the 8051.
The 8051 Assembly Language. Overview Data transfer instructions Addressing modes Data processing (arithmetic and logic) Program flow instructions.
CHAPTER 6 ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS.
EE/CS-352: Embedded Microcontroller Systems Part V The 8051 Assembly Language Interrupts.
JUMP, LOOP, AND CALL INSTRUCTIONS
MICROPROCESSOR DETAILS 1 Updated April 2011 ©Paul R. Godin prgodin gmail.com.
1 EKT 225 MICROCONTROLLER I CHAPTER ASSEMBLY LANGUAGE PROGRAMMING.
The 8051 Assembly Language. Overview Introduction Addressing modes Data processing (arithmetic and logic) Data transfer instructions Program flow instructions.
Microprocessor & Assembly Language
Arithmetic Instructions and Programs. Outlines Range of numbers in 8051 unsigned data Range of numbers in 8051 unsigned data Addition & subtraction instructions.
Classification of Instruction Set of 8051
Assembly Language Programming of 8085
Microprocessor T. Y. B. Sc..
Microprocessor Systems Design I
Digital Arithmetic Wen-Hung Liao, Ph.D..
Microprocessor Systems Design I
Lecture Set 5 The 8051 Instruction Set.
Chapter 3 Bit Operations
ECE,JYOTHI ENGG COLLEGE
Data Processing Instructions
The 8051 Microcontroller.
Instruction Groups The 8051 has 255 instructions.
SCHOOL OF ELECTRONICS ENGINEERING Electronics and Communication
The 8051 Assembly Language Arithmetic & Logic Instructions
8051 Single Board Computer (SBC) Version 1.0
Branching Instructions
Introduction to Micro Controllers & Embedded System Design Instruction set Department of Electrical & Computer Engineering Missouri University of Science.
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
ARITHMETIC, LOGIC INSTRUCTIONS, AND PROGRAMS
Chapter 10 Instruction Sets: Characteristics and Functions
Presentation transcript:

University Of Engineering And Technology Taxila REF::NATIONAL TAIWANOCEAN UNIVERSITY 國立台灣海洋大學 Chapter 3 JUMP, LOOP and CALL Instructions

Outlines  Loop instructions  Conditional jump instructions  Conditions determining conditional jump  Unconditional long & short jumps  Calculate target addresses for jumps  Subroutines  Using stack in subroutines  Crystal frequency vs. machine cycle  Code programs to generate time delay

Looping

Loop inside a Loop (Nested Loop)

8051 Conditional Jump Instructions

Conditional Jump Example

Unconditional Jump Instructions  All conditional jumps are short jumps –Target address within -128 to +127 of PC  LJMP (long jump): 3-byte instruction –2-byte target address: 0000 to FFFFH –Original 8051 has only 4KB on-chip ROM  SJMP (short jump): 2-byte instruction –1-byte relative address: -128 to +127

Call Instructions  LCALL (long call): 3-byte instruction –2-byte address –Target address within 64K-byte range  ACALL (absolute call): 2-byte instruction –11-bit address –Target address within 2K-byte range

LCALL

CALL Instruction & Role of Stack

Calling Subroutines

ACALL (absolute call)

Programming Efficiently

Time Delay Generation & Calculation  1 instruction = n  machine cycle  1 machine cycle = 12 clock cycles

Delay Calculation

Delay Calculation Example

Increasing Delay Using NOP

Large Delay Using Nested Loop

University Of Engineering And Technology Taxila REF::NATIONAL TAIWANOCEAN UNIVERSITY 國立台灣海洋大學 Chapter 6 Arithmetic Instructions and Programs

Outlines  Range of numbers in 8051 unsigned data  Addition & subtraction instructions for unsigned data  BCD system of data representation  Packed and unpacked BCD data  Addition & subtraction on BCD data  Range of numbers in 8051 signed data  Signed data arithmetic instructions  Carry & overflow problems & corrections

Addition of Unsigned Numbers  ADDA, source; A = A + source

ADDC & Addition of 16-bit Numbers 1 3CE7 3B8D

BCD Number System  Unpacked BCD: 1 byte  Packed BCD: 4 bits

Adding BCD Numbers & DA Instruction MOVA,#17H ADDA,#28H MOVA,#47H;A=47H first BCD operand MOVB,#25H;B=25 second BCD operand ADDA,B;hex (binary) addition (A=6CH) DAA;adjust for BCD addition (A=72H) HEXBCD AC=

Subtraction of Unsigned Numbers  SUBBA, source; A = A – source – CY  SUBB when CY = 0 –Take 2’s complement of subtraend (source) –Add it to minuend –Invert carry

Example (Positive Result)

Example (Negative Result)

SUBB When CY = 1  For multibyte numbers

Multiplication of Unsigned Numbers  MULAB; A  B, place 16-bit result in B and A MOVA,#25H;load 25H to reg. A MOVB,#65H;load 65H in reg. B MULAB;25H * 65H = E99 where ;B = 0EH and A = 99H Table 6-1:Unsigned Multiplication Summary (MUL AB) Multiplication Operand 1 Operand 2 Result byte  byte AB A=low byte, B=high byte

Division of Unsigned Numbers  DIVAB; divide A by B MOVA,#95H;load 95 into A MOVB,#10H;load 10 into B DIVAB;now A = 09 (quotient) and ;B = 05 (remainder) Table 6-2:Unsigned Division Summary (DIV AB) DivisionNumeratorDenominatorQuotientRemainder byte / byte ABAB

Example ( 1 of 2 )

Example ( 2 of 2 )

Signed 8-bit Operands  Covert to 2’s complement –Write magnitude of number in 8-bit binary (no sign) –Invert each bit –Add 1 to it

Example

Example

Example

Byte-sized Signed Numbers Ranges DecimalBinaryHex ….………… FE FF …………… F

Overflow in Signed Number Operations

When Is the OV Flag Set?  Either: there is a carry from D6 to D7 but no carry out of D7 (CY = 0)  Or: there is a carry from D7 out (CY = 1) but no carry from D6 to D7

Example

Example

Example

University Of Engineering And Technology Taxila REF::NATIONAL TAIWANOCEAN UNIVERSITY 國立台灣海洋大學 Chapter 7 LOGIC INSTRUCTIONS AND PROGRAMS

Outlines  Define the truth tables for logic functions AND, OR, XOR  Code 8051 Assembly language logic function instructions  Use 8051 logic instructions for bit manipulation  Use compare and jump instructions for program control  Code 8051 rotate and swap instructions  Code 8051 programs for ASCII and BCD data conversion

AND XY X AND Y ANL destination, source ;dest = dest AND source

OR ORL destination, source ;dest = dest OR source XY X AND Y

XOR XRL destination, source ;dest = dest XOR source XY X AND Y XRLA,#04H;EX-OR A with

XOR

XOR

CPL (complement accumulator) MOVA,#55H CPLA;now A=AAH ; (55H) becomes ; (AAH)

Compare instruction CJNE destination, source,relative address

Table 7-1:Carry Flag Setting For CJNE Instruction Compare Carry Flag destination > source CY = 0 destination < source CY = 1 CJNER5,#80,NOT_EQUAL;check R5 for 80 ….;R5=80 NOT_EQUAL:JNCNEXT;jump if R5>80 ….;R5<80 NEXT:….

Rotating the bits of A right and left RRA;rotate right A MOVA,#36H;A= RRA;A= RRA;A= RRA;A= RRA;A= RLA;rotate left A

MOVA,#72H;A= RLA;A= RLA;A=

Rotating through the carry RRC A;rotate right through carry CLRC;make CY=0 MOVA,#26H;A= RRCA;A= CY=0 RRCA;A= CY=1 RRCA;A= CY=1 RLCA;rotate left through carry

SETBC;make CY=1 MOVA,#15H;A= RLCA;A= CY=0 RLCA;A= CY=0 RLCA;A= CY=0 RLCA;A= CY=1

SWAPA

RRCA;first bit to carry MOVP1.3,C;output carry as data bit RRCA;second bit to carry MOVP1.3,C;output carry as data bit RRCA;third bit to carry MOVP1.3,C;output carry as data bit …..

BCD AND ASCII APPLICATION PROGRAM

Packed BCD to ASCII conversion Packed BCDUnpacked BCDASCII 29H02H & 09H32H & 39H & &

ASCII to packed BCD conversion Key ASCII Unpacked BCDPacked BCD or 47H MOVA,#’4’;A=34H, hex for ASCII char 4 MOVR1,#’7’;R1=37H, hex for ASCII char 7 ANLA,#0FH;mask upper nibble (A=04) ANLR1,#0FH;mask upper nibble (R1=07) SWAPA;A=40H ORLA,R1;A=47H, packed BCD

University Of Engineering And Technology Taxila REF::NATIONAL TAIWANOCEAN UNIVERSITY 國立台灣海洋大學 Chapter 8 SINGLE-BIT INSTRUCTIONS AND PROGRAMMING

Outlines  List the 8051 Assembly language instructions for bit manipulation  Code 8051 instructions for bit manipulation of ports  Explain which 8051 registers are bit-addressable  Describe which portions of the 8051 RAM are bit-addressable  Discuss bit manipulation of the carry flag  Describe the carry flag bit-related instructions of the 8051

Single-bit instructions

I/O ports and bit-addressability The 8051 has four I/O ports, each of which is 8 bits

Checking an input bit JNB (jump if no bit) ; JB (jump if bit = 1)

Registers and bit-addressability

Figure 8-2. Bits of the PSW Register

Bit-addressable RAM

Single-bit operations with CY

Instructions for reading input port READING INPUT PINS VS. PORT LATCH In Reading a port: 1.Read the status of the input pin 2.Read the internal latch of the output port

Reading latch for output port