CHAPTER 3 JUMP, LOOP, AND CALL INSTRUCTIONS

Similar documents
ELEG3924 Microprocessor

Assembly Language programming (3)

ELEG3923 Microprocessor Ch.3 Jump, Loop, and Call

Control Transfer Instructions Jump, Loop, and Call. ECE473/573 Microprocessor System Design, Dr. Shiue

JUMP, LOOP AND CALL INSTRUCTIONS


ET2640 Microprocessors

8051 Microcontrollers

8051 Microcontroller Assembly Programming

Microcontroller Intel [Instruction Set]

Chapter Family Microcontrollers Instruction Set

Microprocessors 1. The 8051 Instruction Set. Microprocessors 1 1. Msc. Ivan A. Escobar Broitman

8051 Overview and Instruction Set

8051 Microcontroller

Q. Classify the instruction set of 8051 and list out the instructions in each type.

Module Contents of the Module Hours COs

Chapter 3 BRANCH, CALL, AND TIME DELAY LOOP

UNIT-III ASSEMBLY LANGUAGE PROGRAMMING. The CPU can access data in various ways, which are called addressing modes

Architecture & Instruction set of 8085 Microprocessor and 8051 Micro Controller

SN8F5000 Family Instruction Set

UNIT 2 THE 8051 INSTRUCTION SET AND PROGRAMMING

Digital Blocks Semiconductor IP

DR bit RISC Microcontroller. Instructions set details ver 3.10

CHAPTER ASSEMBLY LANGUAGE PROGRAMMING

Programming of 8085 microprocessor and 8051 micro controller Study material

Digital Blocks Semiconductor IP

Embedded Controller Programming

Digital Blocks Semiconductor IP

EEE3410 Microcontroller Applications Department of Electrical Engineering Lecture 4 The 8051 Architecture

UNIT THE 8051 INSTRUCTION SET AND PROGRAMMING

Unit I. Introduction Microcontrollers and Embedded processors Overview of the 8051 Inside the 8051 Addressing Modes

C51 Family. Architectural Overview of the C51 Family. Summary

Memory organization Programming model - Program status word - register banks - Addressing modes - instruction set Programming examples.

Dodatak. Skup instrukcija

Instruction Set Of 8051

ORG ; TWO. Assembly Language Programming

UNIT 1 REFERENCE 1 PREPARED BY S.RAVINDRAKUMAR, LECT/ECE, CHETTINAD COLLEGE OF ENGG AND TECH, KARUR

Introduction To MCS-51

Microcomputer Architecture and Programming

Introduction to uc & Embedded Systems

MICROPROCESSOR LABORATORY MANUAL

~: Simple Programs in 8051 assembly language :~

Programming Book Microcontroller Kit. Rev 3.0 January, Wichit Sirichote

ELEG3923 Microprocessor Ch.2 Assembly Language Programming

Highlights. FP51 (FPGA based 1T 8051 core)

ELEG3924 Microprocessor

Microcontroller. Instruction set of 8051

EXPERIMENT NO. 1 THE MKT 8085 MICROPROCESSOR TRAINER

TUTORIAL. Donal Heffernan University of Limerick May Tutorial D.Heffernan 2000,

II/IV B.Tech (Regular/Supplementary) DEGREE EXAMINATION. Microprocessors and Microcontrollers. Answer ONE question from each unit.

Dragonchip. Instruction Set Manual

What Registers are available? Programming in Assembler. Assembler Programming - like early Basic. Assembler Data Movement Instructions

MSMF GATE CENTRE. Sub: MICROPROCESSORS. Time: 50min Date: Marks:33

TUTORIAL Assembly Language programming (2)

Subject Code: Model Answer Page No: /25

8085 INSTRUCTION SET INSTRUCTION DETAILS

Interrupts. EE4380 Fall 2001 Class 9. Pari vallal Kannan. Center for Integrated Circuits and Systems University of Texas at Dallas

Three criteria in Choosing a Microcontroller

Question Bank Microprocessor and Microcontroller

Introduction to Assembly Language Programming (Instruction Set) 1/18/2011 1

EXPERIMENT NO.1. A Microcontroller is a complete computer system built on a single chip.



It is possible to define a number using a character or multiple numbers (see instruction DB) by using a string.

3.0 Instruction Set. 3.1 Overview

EC2304-MICROPROCESSOR AND MICROCONROLLERS 2 marks questions and answers UNIT-I

CPEG300 Embedded System Design. Lecture 3 Memory


2003 LXI H, 42F2H ; this instruction store 42F2 in to the HL pair POP H ; store data from top of the stack to HL pair

MODULE-1. Short Answer Questions

CEIBO FE-W7 Development System

Machine Cycle- 2 or (Machine Cycle-1 of next instruction):

Principle and Interface Techniques of Microcontroller

Assembly Language Programming of 8085

INSTRUCCIONES ARITMETICAS ERROR! MARCADOR NO DEFINIDO.

Assembly Language Programming of 8085

MASSEY UNIVERSITY PALMERSTON NORTH CAMPUS

Subroutines & Software Delay Routines

(2) Explain the addressing mode of OR What do you mean by addressing mode? Explain diff. addressing mode for 8085 with examples.

ELEG3923 Microprocessor Ch.9 Timer Programming

Application Brief D-005

The 8051 Microcontroller and Embedded Systems

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) MODEL ANSWER

CEIBO FE-5122 Development System


MAHALAKSHMI ENGINEERING COLLEGE TIRUCHIRAPALLI

Interfacing ahantronix 128x64 Graphic Module to an 8-bitMicrocontroller

Counters & Time Delays. Microprocessors & Interfacing 1

CEIBO FE-5131A Development System

م.م. ماجد عيدان. Introduction to microprocessor and microcomputer

Q. P. Code : b. Draw and explain the block dig of a computer with microprocessor as CPU.

INSTRUCTION SET OF 8085

UNIT MICROCONTROLLER AND ITS PROGRAMMING

Practical Course File For

MCS -51 Programmer s Guide and Instruction Set

LIST OF PROGRAMS. Prg. Name of the Program. 1 Study of Pin Diagram of Study of Architecture of Study of 8085 Kit.

Instruction set of 8085

MAHALAKSHMI ENGINEERING COLLEGE TIRUCHIRAPALLI UNIT I THE 8085 & 8086 MICROPROCESSORS. PART A (2 Marks)

8051 Core Specification

Today s Menu. >Use the Internal Register(s) >Use the Program Memory Space >Use the Stack >Use global memory

Transcription:

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.

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.) 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 inaddition 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 form 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