JUMP, LOOP, AND CALL INSTRUCTIONS

Slides:



Advertisements
Similar presentations
Week 8 Stack and Subroutines. Stack  The stack is a section of data memory (or RAM) that is reserved for storage of temporary data  The data may represent.
Advertisements

Instruction Set Design
Parul Polytechnic Institute
The 8051 Microcontroller and Embedded Systems
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.
Processor Function Topic 3.
Msc. Ivan A. Escobar Broitman Microprocessors 1 1 The 8051 Instruction Set.
CSCI 4717/5717 Computer Architecture
TK 2633 Microprocessor & Interfacing
Room: E-3-31 Phone: Dr Masri Ayob TK 2633 Microprocessor & Interfacing Lecture 1: Introduction to 8085 Assembly Language.
8051 ASSEMBLY LANGUAGE 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.
Microcontroller Intel 8051
Part II: Addressing Modes
The 8051 Microcontroller architecture
MICROCONTROLLER INSTRUCTION SET
A Simple Tour of the MSP430. Light LEDs in C LEDs can be connected in two standard ways. Active high circuit, the LED illuminates if the pin is driven.
CoE3DJ4 Digital Systems Design Chapter 3: instruction set summary.
Lecture 3. Diff b/w RAM and Registers Registers are used to hold data immediately applicable to the operation at hand Registers are used to hold data.
Computer Architecture Lecture 13 – part 2 by Engineer A. Lecturer Aymen Hasan AlAwady 7/4/2014 University of Kufa - Information Technology Research and.
Chapter 4 - Implementing Standard Program Structures in 8086 Assembly Language from Microprocessors and Interfacing by Douglas Hall.
University Of Engineering And Technology Taxila REF::NATIONAL TAIWANOCEAN UNIVERSITY 國立台灣海洋大學 Chapter 3 JUMP, LOOP and CALL Instructions.
The 8051 Assembly Language Branching & Subroutines
The x86 PC Assembly Language, Design, and Interfacing By Muhammad Ali Mazidi, Janice Gillespie Mazidi and Danny Causey © 2010, 2003, 2000, 1998 Pearson.
Execution of an instruction
The 8051 Microcontroller and Embedded Systems
Today’s Lecture Unconditional branch instruction
Lecture Set 4 Programming the 8051.
EEL 3801 Part IV The Assembler. OFFSET Operator Returns address of variable used as operand. Actually, it represents the offset from the beginning of.
Computer Systems – Machine & Assembly code. Objectives Machine Code Assembly Language Op-code Operand Instruction Set.
Assembly Language Programming of 8085 BY Prof. U. V. THETE Dept. of Computer Science YMA.
Group 1 chapter 3 Alex Francisco Mario Palomino Mohammed Ur-Rehman Maria Lopez.
Structure and Role of a Processor
1 EKT 225 MICROCONTROLLER I CHAPTER ASSEMBLY LANGUAGE PROGRAMMING.
8085 INTERNAL ARCHITECTURE.  Upon completing this topic, you should be able to: State all the register available in the 8085 microprocessor and explain.
Digital Computer Concept and Practice Copyright ©2012 by Jaejin Lee Control Unit.
AMITY UNIVERSITY RAJASTHAN Present By M.Sc Applied Chemistry.
1 Contents: 3.1 Instruction format and Addressing Modes 3.2 Instruction Introduction Chapter 3 Instruction system.
Microprocessors I 8051 Addressing Modes CS Prof. Msc. Ivan A. Escobar
Assembly Language Programming of 8085
Edexcel GCSE Computer Science Topic 15 - The Processor (CPU)
The 8051 Microcontroller and Embedded Systems
Lecture Set 5 The 8051 Instruction Set.
Subroutines and the Stack
Microprocessor and Assembly Language
TAO1221 COMPUTER ARCHITECTURE AND ORGANIZATION LAB 3 & 4 Part 2
Microcomputer Programming
William Stallings Computer Organization and Architecture 8th Edition
The 8085 Microprocessor Architecture
Data Processing Instructions
An Introduction to Microprocessor Architecture using intel 8085 as a classic processor
SCHOOL OF ELECTRONICS ENGINEERING Electronics and Communication
Subroutine Call; Stack
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 Addressing Mode Department of Electrical & Computer Engineering Missouri University of Science.
Subroutines and the Stack
Processor Organization and Architecture
Conditional Jumps and Time Delays
Introduction to Micro Controllers & Embedded System Design Instruction set Department of Electrical & Computer Engineering Missouri University of Science.
Sequencing, Selection, and Loops in Machine Language
Important 8051 Features On chip oscillator 4K bytes ROM 128 bytes RAM
CNET 315 Microprocessor & Assembly Language
Conditional Jumps and Time Delays
8051 ASSEMBLY LANGUAGE PROGRAMMING
Subroutines and the Stack
Md. Atiqur Rahman Ahad PIC18… Ch. 3.1 Md. Atiqur Rahman Ahad
Computer Operation 6/22/2019.
Presentation transcript:

JUMP, LOOP, AND CALL INSTRUCTIONS CHAPTER 3 JUMP, LOOP, AND CALL INSTRUCTIONS

Looping Repeating a sequence of instructions a certain number of times is called a loop Loop action is performed by DJNZ reg, Label The register is decremented If it is not zero, it jumps to the target address referred to by the label Prior to the start of loop the register is loaded with the counter for the number of repetitions Counter can be R0 – R7 or RAM location A loop can be repeated a maximum of 256 times

Looping (cont.)

Nested Loop If we want to repeat an action more times than 256, we use a loop inside a loop, which is called nested loop We use multiple registers to hold the count

Conditional Jumps Jump only if a certain condition is met JZ (jump if A = 0) The content of register A is checked. If it is zero, it jumps to the target address. OVER:

Conditional Jumps (cont.) JNZ (jump if A ≠ 0) The content of register A is checked. If it is not zero, it jumps to the target address.

Conditional Jumps (cont.) JNC label ;jump if no carry, CY=0 If CY = 0, the CPU starts to fetch and execute instruction from the address of the label If CY = 1, it will not jump but will execute the next instruction below JNC All conditional jumps are short jumps The address of the target must within -128 to +127 bytes of the contents of PC

Unconditional Jumps The unconditional jump is a jump in which control is transferred unconditionally to the target location LJMP (long jump) 3-byte instruction First byte is the opcode Second and third bytes represent the 16-bit target address Any memory location from 0000 to FFFFH

Unconditional Jumps (cont.) SJMP (short jump) 2-byte instruction First byte is the opcode Second byte is the relative target address 00 to FFH Forward +127 and backward -128 bytes from the current PC To calculate the target address of a short jump (SJMP, JNC, JZ, DJNZ, etc.) The second byte is added to the PC of the instruction immediately below the jump If the target address is out of range, the assembler will generate an error

Calculating Short Jump Address

CALL INSTRUCTIONS Call instruction is used to call subroutine Subroutines are often used to perform tasks that need to be performed frequently This makes a program more structured in addition to saving memory space LCALL (long call) 3-byte instruction First byte is the opcode Second and third bytes are used for address of target subroutine Subroutine is located anywhere within 64K byte address space

CALL INSTRUCTIONS (cont.) ACALL (absolute call) 2-byte instruction 11 bits are used for address within 2K-byte range When a subroutine is called, control is transferred to that subroutine The processor saves on the stack the the address of the instruction immediately below the CALL It also begins to fetch instructions from the new location

CALL INSTRUCTIONS (cont.) After finishing execution of the subroutine The instruction RET transfers control back to the caller Every subroutine needs RET as the last instruction RET pops the address from the stack into the PC and resumes executing the instructions after the CALL

Calling Subroutines

ACALL The only difference between ACALL and LCALL is The target address for LCALL can be anywhere within the 64K byte address The target address of ACALL must be within a 2K-byte range The use of ACALL instead of LCALL can save a number of bytes of program ROM space

ACALL (cont.)

TIME DELAY FOR VARIOUS 8051 CHIPS CPU executing an instruction takes a certain number of clock cycles These are referred as to as machine cycles The length of machine cycle depends on the frequency of the crystal oscillator connected to 8051 In original 8051, one machine cycle lasts 12 oscillator periods

TIME DELAY FOR VARIOUS 8051 CHIPS (cont.)

Delay Calculation for Other 8051 Two factors can affect the accuracy of the delay: Crystal frequency The duration of the clock period of the machine cycle is a function of this crystal frequency 8051 design The original machine cycle duration was set at 12 clocks Advances in both IC technology and CPU design in recent years have made the 1-clock machine cycle a common feature