Chapter Family Microcontrollers Instruction Set

Similar documents
Microcontroller Intel [Instruction Set]

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

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

ELEG3924 Microprocessor

ELEG3923 Microprocessor Ch.3 Jump, Loop, and Call

8051 Microcontroller Assembly Programming

Assembly Language programming (3)

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

Digital Blocks Semiconductor IP

Digital Blocks Semiconductor IP

SN8F5000 Family Instruction Set

Digital Blocks Semiconductor IP

Programming of 8085 microprocessor and 8051 micro controller Study material

CHAPTER 3 JUMP, LOOP, AND CALL INSTRUCTIONS

Dodatak. Skup instrukcija

ET2640 Microprocessors

Architecture & Instruction set of 8085 Microprocessor and 8051 Micro Controller

UNIT 2 THE 8051 INSTRUCTION SET AND PROGRAMMING

UNIT THE 8051 INSTRUCTION SET AND PROGRAMMING

Embedded Controller Programming

8051 Microcontroller


DR bit RISC Microcontroller. Instructions set details ver 3.10

C51 Family. Architectural Overview of the C51 Family. Summary

Dragonchip. Instruction Set Manual

8051 Overview and Instruction Set

Microcontroller. Instruction set of 8051

Module Contents of the Module Hours COs

Instruction Set Of 8051

Programming Book Microcontroller Kit. Rev 3.0 January, Wichit Sirichote

MASSEY UNIVERSITY PALMERSTON NORTH CAMPUS

Chapter 9. Programming Framework

MCS -51 Programmer s Guide and Instruction Set

Introduction To MCS-51

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

Introduction to uc & Embedded Systems

MICROPROCESSOR LABORATORY MANUAL

Y51 Microcontroller. Technical Manual

INSTRUCCIONES ARITMETICAS ERROR! MARCADOR NO DEFINIDO.

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

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

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

~: Simple Programs in 8051 assembly language :~

8051 Core Specification

Highlights. FP51 (FPGA based 1T 8051 core)

UNIT MICROCONTROLLER AND ITS PROGRAMMING

AL8051S 8-BIT MICROCONTROLLER Application Notes

JUMP, LOOP AND CALL INSTRUCTIONS

8051 Instruction Set

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

8051 Microcontrollers

MICROPROCESSOR & MICROCONTROLLER

Assembly Language programming (2)

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

Section Microcontroller Instruction Set

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

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

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

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

CPEG300 Embedded System Design. Lecture 6 Interrupt System


Application Brief D-005

Question Bank Microprocessor and Microcontroller

8-Bit Microcontroller with 1K Bytes Flash. AT89C1051U Preliminary. Features. Description. Pin Configuration

Lecture Instruction Set

UNIT MICROCONTROLLER

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

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

Principle and Interface Techniques of Microcontroller

MICROCONTROLLER BASED WATER LEVEL CONTROL SYSTEM

8051 Microcontroller. Ali Ziya Alkar 1

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

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

Application Brief D-002

Three criteria in Choosing a Microcontroller

MASSEY UNIVERSITY PALMERSTON NORTH CAMPUS

International Journal of Digital Application & Contemporary research Website: (Volume 1, Issue 2, September 2012)

MODULE-1. Short Answer Questions

TUTORIAL Assembly Language programming (2)

Microcontroller and Applications

8-Bit Microcontroller with 2K Bytes Flash AT89C2051. Features. Description. Pin Configuration

Assembly Language Programming of 8085

INTEGRATED CIRCUITS P89C669 USER MANUAL. Preliminary Supersedes data of 2003 Jul Sep 16

EE6502- MICROPROCESSOR AND MICROCONTROLLER

MicroConverter Technical Note - uc007 User Download (ULOAD) Mode

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

Assembly Language Programming of 8085

CPEG300 Embedded System Design. Lecture 8 Timer

8-bit Microcontroller with 1K Byte Flash AT89C1051

8-Bit CMOS Microcontorller

Interrupt Programming: Interrupts vs. Polling Method:

AT89C Bit Microcontroller with 2 Kbytes Flash. Features. Description. Pin Configuration

Mod-3: Interrupts,Timer operation,serial communication 1

The Microcontroller. Lecture Set 3. Major Microcontroller Families. Example Microcontroller Families Cont. Example Microcontroller Families

8085 INSTRUCTION SET INSTRUCTION DETAILS

Chapter 09. Programming in Assembly

Microcontroller and Embedded Systems:

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

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

VRS570 32K Flash, 1kB RAM, 25~40MHz, 8-Bit MCU VRS580 64K Flash, 1kB RAM, 25~40MHz, 8-Bit MCU

Transcription:

Chapter 4 8051 Family Microcontrollers Instruction Set

Lesson 5 Program Flow Control and Interrupt Flow Control Instructions 2

Branch instructions- Jump to new value of Program Counter (PC) LJMP address16 AJMP addr11 SJMP rel JMP A, @A + DPTR 3

8051 PC 2nd byte of instruction 3rd byte of instruction LJMP Addr16 lower Byte Higher byte 4

LJMP Instruction Execution STEP 1 Fetch opcode-bits 2 clock cycles STEP 2 STEP 3 PCL PCH Fetch lower byte for branch address Fetch higher byte for branch address Time 5

8051 AJMP Addr11 PC bit10-b0 3-bits from1st byte 2nd byte of instruction 3-bits lower byte Jump within same segment of 2 kb. Upper 5-bits 5 of PC unchanged 6

AJMP Instruction Execution STEP 1 Fetch five opcode-bits 2 clock cycles STEP 2 STEP 3 PCH 3-bits PCL Fetch branch address 3 bits b10- b9-b8 Fetch lower byte b7--... - b0 for branch address Time 7

SJMP rel 8051 Jump relative after adding a two s complement number which is within 128 to +127 of next instruction 2nd byte of instruction a number in 2 s complement form Add in Next instruction s PC PC bit15-b0 8

STEP 1 SJMP Instruction Execution Fetch opcodebits 2 clock cycles STEP 2 Fetch 8 bits b7--b0 for +or -ve number PCH PCL Branch to new address Add PCH PCL Next instruction Time 9

Example- SJMP F8H Rel = 11111000 mean number = 8 Let PC before the SJMP = 1F0CH Next instruction PC when no jump = 1F0EH PC PC 8. Therefore, when jump the new PC 1F06H 10

8051 JMP @ A + DPTR Pointed instruction PC bit15-b0 PC 8-bits from A 16-bit from DPTR Add; DPTR is pointer to the code block and A is offset Add offset at A in DPTR to find code address, jump to the memory address 11

PCH PCL JMP @ A + DPTR JMP Instruction Execution STEP 1 Add Fetch 8 opcode-bits A offset DPH DPL 2 clock cycles Time Branch to new address Pointed data block 12

Example- JMP@ A+ DPTR DPTR = 11ADH; A = 08H Let PC after the JMP = 1F0CH This PC replaces and gets new 16-bits PC A + DPTR. Therefore, new PC 11B5H 13

Conditional jumps JNZ rel; JZ rel; JC rel; JNC rel; 14

8051 JZ rel; jump on zero A If A= 00H No PC bit15-b0 Next instruction PC If A= 00H Yes 2nd byte of instruction Add in PC the 2 s complement number Jump relative after adding a two s s complement number within 128 to +127 of next instruction 15

8051 JNZ rel; jump on not zero A If A= 00H Yes PC bit15-b0 Next instruction PC If A= 00H No 2nd byte of instruction Add in PC the 2 s complement number Jump relative after adding a two s s complement number within 128 to +127 of next instruction 16

8051 JC rel; jump on C (PSW.7) not zero If C= 0 Yes PC bit15-b0 Next instruction PC If C= 1 Yes 2nd byte of instruction Add in PC the 2 s complement number Jump relative after adding a two s s complement number within 128 to +127 of next instruction 17

8051 JNC rel; jump on C (PSW.7) not 1 If C= 1 Yes PC bit15-b0 Next instruction PC If C= 0 Yes 2nd byte of instruction Add in PC the 2 s complement number Jump relative after adding a two s s complement number within 128 to +127 of next instruction 18

Example- JZ F8H Rel = 11111000 mean number = 8 Let PC before the JMP = 1F0CH Next instruction PC when no jump = 1F0EH PC PC 8. Therefore, new PC 1F06H if A = 00H,else 1F0EH 19

JB bit, rel JNB bit, rel JBC bit, rel; 20

JBbit, rel; jump on bit at address of bit is set 1; If bit at address of bit = 0 PC bit15-b0 Yes Next instruction PC If bit at address of bit = 1 Yes 8051 2nd byte of Add in PC the 2 s instruction complement number Jump relative after adding a two s s complement number within 128 to +127 of next instruction 21

JNBbit, rel; jump on bit at address of bit is reset 0; If bit at address of bit = 1 Yes PC bit15-b0 Next instruction PC If bit at address of bit = 0 Yes 8051 2nd byte of Add in PC the 2 s instruction complement number Jump relative after adding a two s s complement number within 128 to +127 of next instruction 22

JBCbit, rel; jump on bit is set 1 and then reset C = 0 If bit at address of bit = 0 Yes PC bit15-b0 Next instruction PC If bit at address of bit = 1 2nd byte of instruction 8051 No Add in PC the 2 s complement number and reset C Jump relative after adding a two s s complement number within 128 to +127 of next instruction and reset C = 0 23

Example JB 91H, F8H bit = 91H mean bit1 Port P1 Rel = 11111000 mean number = -8 Let PC before the JMP = 1F0CH Next instruction PC when no jump = 1F0EH PC PC 8. Therefore, new PC 1F06H if P1.1 = 1,else 1F0EH 24

Subroutine Call Instructions Save PC on stack and then call the instruction of the routine at new value of Program Counter (PC) LCALL address16 ACALL addr11 25

Execution of Subroutine Call Instructions Saving PC on stack before Branch instructioncall routine at new value of Program Counter (PC) Before call - (1) Increment SP and then move the next instruction PCL byte to SP pointed address (2) Increment SP and then move the next instruction PCH byte to SP pointed address 26

8051 LCALL Addr16 PC 2nd byte of instruction lower Byte Higher byte 3rd byte of instruction Next instruction PC saves on stack at address pointed by SP + 1 and SP + 2. New SP becomes SP+02H 27

LCALL Addr16 Instruction Execution STEP 1 Fetch opcode-bits 2 clock cycles Step 6:New PCL STEP 2 STEP 3 Step 7: New PCH Fetch lower byte for call address Time Fetch higher byte for call Step 4: Old PCL address after step 3 at SP +1 Step 5: Old PCH after step 4 at SP +2 28

Let SP = 07H Return from call instruction - RET Let PC before the CALL = 1F0CH. PC after the ACALL = 1F0FH. Call instruction stacks 1F0EH at 08-09H. 08H 0F and 09H 1F Return retrieves PC. PCH from 09H, PCL from 08H. PC again = 1F0FH 29

ACALL Addr11 Call within same segment of 2 kb. Upper 5-bits 5 of PC unchanged Next instruction PC saved on stack. SP is now SP+02H 30

ACALL Addr11 Instruction Execution STEP 1 STEP 2 Step 6: Replace 3 bits to get New PCH Step 7: Replace all 8 bits to get new PCL Fetch opcode-bits and 3 bits for PC Fetch lower byte for call address 2 clock cycles Time Step 4: Old PCL after step 2 at SP +1 Step 5: Old PCH after step 3 at SP +2 31

Example ACALL codes are 91H-F0H 3 higher bits in first byte = 100 and 8-bits in 2nd byte of instruction = 11111000. Let SP = 07H Let PC before the CALL = 1F0CH Next instruction PC= 1F0EH. It stacks 1F0CH at 08-09H. Five bits are 00011 PC PC + 00011 1001111 0000. Therefore, new PC 3BFEH 32

Let SP = 07H Return from call instruction - RET Let PC before the CALL = 1F0CH. PC after the ACALL = 1F0EH. Call instruction stacks 1F0EH at 08-09H. 08H 0E and 09H 1F Return retrieves PC. PCH from 09H, PCL from 08H. PC again = 1F0EH 33

Decrement and Jump conditional Combined instructions DJNZ Rn, rel; DJNZ direct, rel 34

DJNZ Rn, rel; jump on byte at Rn after decrement = not 0; Decrease Rn, If byte at Rn after decrement = 0 Yes PC bit15-b0 Next instruction PC If byte at Rn after decrement not 0 Yes 8051 2nd byte of Add in PC the 2 s instruction complement number Jump relative after adding a two s s complement number within 128 to +127 of next instruction 35

DJNZ direct, rel; jump on byte at direct address after decrement = not 0; Decrease byte at direct address, If byte becomes 0 Yes PC bit15-b0 Next instruction PC If byte remains not 0 Yes 2nd byte of instruction 8051 Add in PC the 2 s complement number Jump relative after adding a two s s complement number within 128 to +127 of next instruction 36

Compare and then conditional jump CJNE A, #data, rel; CJNE Rn, #data, rel; CJNE @Ri, #data, rel; CJNE A, direct, rel; 37

CJNE A, #data, rel; jump on byte at A on comparison not equal Compare A and data byte, if equal Yes PC bit15-b0 Next instruction PC Compare A and data byte, if not equal Yes 8051 2nd byte of Add in PC the 2 s instruction complement number Jump relative after adding a two s s complement number within 128 to +127 of next instruction 38

CJNE Rn, #data, rel; jump on byte at Rn on comparison not equal Compare Rn and data byte, if equal Yes PC bit15-b0 Next instruction PC Compare Rn and data byte, if not equal Yes 8051 2nd byte of Add in PC the 2 s instruction complement number Jump relative after adding a two s s complement number within 128 to +127 of next instruction 39

CJNE @Ri, #data, rel; jump on byte pointed by Ri on comparison not equal Compare byte pointed by Ri and data byte, if equal Yes PC bit15-b0 Next instruction PC Compare byte pointed by Ri and data byte, if not equal 2nd byte of Add in PC the 2 s Yes instruction complement 8051 number Jump relative after adding a two s s complement number within 128 to +127 of next instruction 40

CJNE A, direct, rel; jump on byte at direct on comparison not equal to A Compare byte at direct and byte at A, if equal Yes PC bit15-b0 Next instruction PC Compare byte at direct and byte at A, if not equal Yes 2nd byte of Add in PC the 2 s instruction complement 8051 number Jump relative after adding a two s s complement number within 128 to +127 of next instruction 41

Delay and Interrupt flow control NOP and RETI 42

NOP instruction Let PC before the NOP = 1F0CH After NOP, PC PC +1 1F0DH PC 1F0DH 43

NOP PC bit15-b0 Next to next instruction PC Add 0001H in PC 8051 NOP instruction executes delay = 1 cycle = 1 µs for 12 MHZ XTAL 44

8051 100 times executed in a loop NOP instruction delay = 100 cycle =100 µs for 12MHZ XTAL 45

STEP 1 NOP Instruction Execution Fetch opcode-bits = 00000000 1 clock cycle PCH PCL Add PCH- PCL Next instruction Time 0001H Branch is to next to next address after NOP 46

Return from interrupt ISR RETI Let SP = 77H Let PC before the ISR CALL = 1F0CH ISR call stacks 1F0EH at 08-09H. 78H 0E and 79H 1F Return retrieves PC of last interrupted ISR. Return retrieves PC if no interrupt arose during ISR running then the PCH from 79H, PCL from 78H. PC again = 1F0EH. SP = 77H. 47

Summary 48

We learnt 8051 family program flow control instructions AJMP,LJMO, SJMP rel, conditional jumps decrement and then test and jump increment and then test and jump LCALL,ACALL, RET NOP and RETI 49