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

Similar documents
Assembly Language programming (3)

ELEG3924 Microprocessor

CHAPTER 3 JUMP, LOOP, AND CALL INSTRUCTIONS

ELEG3923 Microprocessor Ch.3 Jump, Loop, and Call

JUMP, LOOP AND CALL INSTRUCTIONS


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

Microcontroller Intel [Instruction Set]

ET2640 Microprocessors

Chapter Family Microcontrollers Instruction Set

SN8F5000 Family Instruction Set

8051 Microcontroller Assembly Programming

8051 Microcontroller

UNIT 2 THE 8051 INSTRUCTION SET AND PROGRAMMING

Digital Blocks Semiconductor IP

Programming of 8085 microprocessor and 8051 micro controller Study material

UNIT THE 8051 INSTRUCTION SET AND PROGRAMMING

Digital Blocks Semiconductor IP

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

Digital Blocks Semiconductor IP

Architecture & Instruction set of 8085 Microprocessor and 8051 Micro Controller

Dodatak. Skup instrukcija

Microcontroller. Instruction set of 8051

INSTRUCCIONES ARITMETICAS ERROR! MARCADOR NO DEFINIDO.

DR bit RISC Microcontroller. Instructions set details ver 3.10

Module Contents of the Module Hours COs

Instruction Set Of 8051

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

Programming Book Microcontroller Kit. Rev 3.0 January, Wichit Sirichote

Dragonchip. Instruction Set Manual

8051 Microcontrollers

C51 Family. Architectural Overview of the C51 Family. Summary

8051 Overview and Instruction Set

Introduction To MCS-51

~: Simple Programs in 8051 assembly language :~

Highlights. FP51 (FPGA based 1T 8051 core)

MASSEY UNIVERSITY PALMERSTON NORTH CAMPUS

MICROPROCESSOR LABORATORY MANUAL


Application Brief D-005

8051 Single Board Monitor Programming. Minmon - Yeralan & Ahluwalia. PaulMon1 & PaulMon2 - Paul Stoffregen

Introduction to uc & Embedded Systems


ELEG3923 Microprocessor Ch.4 I/O Ports

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

NAME as31 - An Intel 8031/8051 assembler. SYNOPSIS as31 [-h] [-l] [-s] [-v] [-Aarg] [-Ffmt] [-Ofile] infile.asm

Embedded Controller Programming

TUTORIAL Assembly Language programming (2)

2. Write an 8051 program to generate a square wave of 25 khz at pin P2.3 using XTAL = 12 MHz. Solution:

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

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

MCS -51 Programmer s Guide and Instruction Set

Arithmetic and Logic

ET355 Microprocessors Thursday 6:00 pm 10:20 pm

80C51 family programmer s guide and instruction set. 80C51 Family. PROGRAMMER S GUIDE AND INSTRUCTION SET Memory Organization. Philips Semiconductors

Principle and Interface Techniques of Microcontroller

Assembly Language programming (2)

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

AL8051S 8-BIT MICROCONTROLLER Application Notes

8051 Core Specification

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

Ex: Write a piece of code that transfers a block of 256 bytes stored at locations starting at 34000H to locations starting at 36000H. Ans.

Assembly Language Programming of 8085

ELEG3923 Microprocessor Ch.9 Timer Programming

Application Brief D-002

System & Program Developments of 8051

Assembly Language Programming of 8085

Contents. Join the Technical Community Today!

CPEG300 Embedded System Design. Lecture 6 Interrupt System

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

Microcontroller and Applications

8051 Timers. Class 7 EE4380 Fall Pari vallal Kannan. Center for Integrated Circuits and Systems University of Texas at Dallas

Interfacing ahantronix 128x64 Graphic Module to an 8-bitMicrocontroller

8051 Programming: Arithmetic and Logic

Chapter 3 BRANCH, CALL, AND TIME DELAY LOOP

Y51 Microcontroller. Technical Manual

Subroutines & Software Delay Routines

UNIT MICROCONTROLLER AND ITS PROGRAMMING

C51 Family. C51 Family Programmer s Guide and Instruction Set. Summary

Lecture 5. EEE3410 Microcontroller Applications Department of Electrical Engineering Assembly Language Programming (1)

Microcontroller and Embedded Systems:

Interrupt Programming: Interrupts vs. Polling Method:

FACULTY OF ENGINEERING LAB SHEET

Alexandria University Faculty of Engineering Communications & Electronics Department.

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

1. Write A Program to move a block of data within the internal RAM

Principle and Interface Techniques of Microcontroller

ELEG3923 Microprocessor Ch.6 Arithmetic and Logics

CoE3DJ4 Digital Systems Design. Chapter 6: Interrupts

8051 Programming using Assembly

MICROCONTROLLER BASED WATER LEVEL CONTROL SYSTEM

ENSC E-123: Final Exam: Digital Electronics. Spring 2014

D: arc SRC KUT51 KUT51LCD.LST KUT51LCD PAGE 1

Section Microcontroller Instruction Set

S.J.P.N Trust's. Hirasugar Institute of Technology, Nidasoshi.

Lecture Instruction Set

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

Legacy documentation refer to the Altium Wiki for current information. TSK52x MCU

UNIT MICROCONTROLLER

build_char macro P1,P2,P3,P4,P5,P6,P7,P8 ;Macro for building a custom character

Transcription:

Control Transfer Instructions Jump, Loop, and Call 1

Jump Instructions JZ label ; Jump if A=0 JNZ label ; Jump if A!=0 DJNZ reg, label ; Decrement and Jump if A (or reg.)!=0 CJNE A, byte ; Compare and Jump if A!=byte CJNE reg, #data ; Compare and Jump if byte!=data JC ; Jump if Carry=1 JNC ; Jump if Carry=0 JB ; Jump if bit =1 JNB ; Jump if bit =0 JBC ; Jump if bit=1 and clear bit 2

DJNZ Decrement and Jump if not zero (DJNZ) DJNZ register, label Ex1: Count from 1 to 20 and sent the count to P1. Ex2: Add 3 to the ACC ten times. Ex3: What is the maximum number of times that the loop in the Ex2 can be repeated? Ex4: Write a program to (a) add the ACC with the value 55H, and (b) complement the ACC 700 times. 3

JZ JZ: Jump if A=0 JZ label Ex1: MOV A, R0 JZ Over ; jump if A=0 MOV A, R1 JZ Over ; jump if A=0 Over: 4

JNZ, JNC, and JC JNZ: Jump if A!=0 JNZ label Ex1: Write a program to determine if R5 contains the value of 0. If so, put 55H in it. JNC: Jump if C=0 JNC label JC: Jump if C=1 JC label 5

JNC Examples JNC: Jump if C=0 JNC label Ex1: Find the sum of the values 79H, F5H, and E2H. Put the sum in registers R0 (low byte) and R5 (high byte) 6

LJMP: 3-byte instruction Uncondition Jump 0000 64KB ROM FFFF 7

Uncondition Jump SJMP: 2-byte instruction (Range: -128 (backward) ~ +127 (forward) bytes) 00 256B ROM FF 8

0006+03 Jump Forward and Backward Ex1: Using the following list file, verify the jump forward address calculation. lines 1 2 3 4 5 6 7 8 9 PC 0000 0000 0002 0004 0006 0007 0008 0009 000B Opcode 7800 7455 6003 08 04 04 2477 5005 Instructions ORG 0 MOV R0, #0 JZ Next INC R0 Again: INC A MOV A, #55H =0009 Jump forward! INC A Next: ADD A, #77H JNC Over Jump forward! 9

Jump Forward and Backward 000D+05 =0012 lines PC Opcode Instructions 10 000D E4 CLR A 11 000E F8 MOV R0, A 12 000F F9 MOV R1, A 13 0010 FA MOV R2, A 14 0011 FB MOV R3, A 0015+F2 =0107 15 16 0012 0013 2B 50F2 Over: ADD A, R3 JNC Again Jump backward! 0017+FE =0115 17 18 0015 0017 80FE Here: SJMP Here END Jump backward! 10

LCALL (Long Call) LCALL: 3-byte instruction When subroutine is called Control is transferred to that subroutine Processor saves the PC onto the Stack and begins to fetch instructions from new location. RET (return to caller) POP from Stack to PC 0000 FFFF 64KB ROM Ex1:Write a program to toggle all the bits of port 1 by sending to it the values 55H and AAH continuously. Put a time delay in between each issuing of data to port 1. (This program is used to test the ports of the 8051) 11

Main Program and Calls ORG 0 Main: LCALL Sub_1 LCALL Sub_2 LCALL Sub_3 Here: SJMP Here ; end of main Sub_1:. RET : end of Sub_1 Sub_2:. RET : end of Sub_2 Sub_3:. RET : end of Sub_3 END 12

ACALL (Absolute Call) ACALL: 2-byte instruction ACALL s target address must be with in a 2KB range 0000 2KB ROM =2*2 10 =2 11 07FF 13

Time Delay Generation and Calculation Crystal frequency (XTAL): 4MHz ~ 30MHz Using 11.0592MHz to make the 8051 compatible with the serial port of the IBM PC. Ex1: Find the period of the machine cycle (a) 11.0592MHz (b) 16MHz (c) 20MHz Ex2: For an 8051 system of 11.0592 MHz, find how long it takes to execute each of the following instructions MOV R3, #55H 1 DEC R3 1 DJNZ R2, target 2 LJMP 2 SJMP 2 NOP 1 MUL AB 4 14

Delay Calculation Ex3: Find the size of the delay in the following program if XTAL =11.0592MHz MOV A, #55H Again: MOV P1, A ACALL Delay CPL A SJMP Again Delay: MOV R3, #200 Here: DJNZ R3, Here RET 15

NOP NOP is used for increasing the delay Ex4: Find the time delay for the following subroutine, XTAL=11.0592MHz Delay: MOV R3, #250 Here: NOP NOP NOP NOP DJNZ R3, Here RET 16

Nested Loop Ex5: Find the time delay for the following subroutine Delay: MOV R2, #200 Again: MOV R3, #250 Here: NOP NOP DJNZ R3, Here DJNZ R2, Again RET 17