SlideShare a Scribd company logo
Program flow instructions in 8051
(Conditional and
Unconditional jump
Instructions)
A.Usha Rani
Faculty,
Department of Physics and Electronics
St.Ann’s College for Women.
Program flow instructions
These instructions are used to control the flow of
execution of the program or to change the sequence of
program execution.
 They are also called Branch instructions or Jump
Instructions.
Change the content of program counter to change
the program execution order.
Unconditional Jumps
Do not test any condition and Jump is taken always.
Short Jump
The program can jump to an instruction within 127 bytes
in forward direction or 128 bytes in reverse direction.
Also called relative jump because the address where the
jump can be taken is relative to the address where the
instruction is written.
The instruction is SJMP rel (Jump to relative address rel)
Long Jump
Used to jump to any location within entire program
address space i.e., anywhere from 0000H to FFFFH.
3 byte instruction and is mostly used in large programs.
The instruction is LJMP address
Absolute Jump
The entire program memory is divide into 32 pages each
of 2K bytes each.
AJMP can be used to jump within a page of 2K.
The instruction is AJMP address
Conditional Jumps
Test the condition before taking a jump. Jump is taken
only if the condition given in the instruction is satisfied.
Bit Jumps
Check the status of a bit specified in the instruction
before taking the jump.
Jump is taken only if the condition specified in the
instruction is satisfied.
Used to monitor the status of a specified bit.
JC rel // Jump to relative address rel if C=1(Jump if
Carry)
JNC rel // Jump to relative address rel if C=0(Jump if
No Carry)
JB rel // Jump to relative address rel if bit =1(Jump
if Bit)
JNB rel // Jump to relative address rel if bit=0
(Jump if No Bit)
JBC bit, rel // Jump to relative address rel if bit =1 and
then clear bit (Jump if bit then clear)
Byte Jumps
Check the byte of a data to make jump.
JZ rel //Jump to relative address rel if A is
0(Jump if Zero)
JNZ rel // Jump to relative address rel if A is
not 0(Jump if Not Zero)
CJNE A, direct,rel //Compare A with the contents
of address direct and jump to relative
address rel if they are not equal. If the
contents of A are less than contents of
address direct, set carry =1 otherwise
clear carry(Compare and Jump if Not Equal)
CJNE A, #data,rel //Compare A with immediate
value data and jump to relative
address rel if they are not equal. If the
contents of A are less than immediate
value data, set carry =1 otherwise
clear carry
CJNE Rn, #data,rel //Compare Rn with the immediate
value data and jump to relative
address rel if they are not equal. If
the contents of Rn are less than
immediate value data, set carry =1
otherwise clear carry
CJNE @Ri, #data,rel //Compare contents of
address in Ri with immediate
value data and jump to relative address
rel if they are not equal. If the contents
of address in Ri are less than
immediate value data, set carry =1
otherwise clear carry
DJNZ Rn,rel //decrement register Rn by 1 and jump
to relative address rel if the contents of
Rn are not zero after decrement
operation.(Decrement and Jump if Not Zero)
DJNZ direct,rel //decrement contents of address
direct by 1 and jump to relative
address if the contents of address
direct are not zero after decrement operation.
Thank you

More Related Content

What's hot

Memory organization of 8051
Memory organization of 8051Memory organization of 8051
Memory organization of 8051Muthu Manickam
 
Interrupts in 8051
Interrupts in 8051Interrupts in 8051
Interrupts in 8051
Sudhanshu Janwadkar
 
8051 Addressing Modes
8051 Addressing Modes8051 Addressing Modes
8051 Addressing Modes
Senthil Kumar
 
Addressing modes
Addressing modesAddressing modes
Addressing modes
karthiga selvaraju
 
Architecture of 8051
Architecture of 8051Architecture of 8051
Architecture of 8051
hello_priti
 
Addressing modes of 8051
Addressing modes of 8051Addressing modes of 8051
Addressing modes of 8051
Dr. AISHWARYA N
 
8051 assembly programming
8051 assembly programming8051 assembly programming
8051 assembly programming
sergeiseq
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 80869840596838
 
Interfacing adc
Interfacing adcInterfacing adc
Interfacing adcPRADEEP
 
Interfacing stepper motor
Interfacing stepper motorInterfacing stepper motor
Interfacing stepper motorPRADEEP
 
8051 addressing modes
8051 addressing modes8051 addressing modes
8051 addressing modes
Vima Mali
 
Microcontroller-8051.ppt
Microcontroller-8051.pptMicrocontroller-8051.ppt
Microcontroller-8051.ppt
Dr.YNM
 
I o ports and timers of 8051
I o ports and timers of 8051I o ports and timers of 8051
I o ports and timers of 8051SARITHA REDDY
 
Logical, Shift, and Rotate Instruction
Logical, Shift, and Rotate InstructionLogical, Shift, and Rotate Instruction
Logical, Shift, and Rotate Instruction
Badrul Alam
 
Pin diagram 8085
Pin diagram 8085 Pin diagram 8085
Pin diagram 8085
Siddhesh Palkar
 
8251 USART
8251 USART8251 USART
8251 USART
ShivamSood22
 
Architecture of 8086 Microprocessor
Architecture of 8086 Microprocessor  Architecture of 8086 Microprocessor
Architecture of 8086 Microprocessor Mustapha Fatty
 
8085 branching instruction
8085 branching instruction8085 branching instruction
8085 branching instruction
prashant1271
 
Architecture of 8085 microprocessor
Architecture of 8085 microprocessorArchitecture of 8085 microprocessor
Architecture of 8085 microprocessor
AMAN SRIVASTAVA
 

What's hot (20)

Memory organization of 8051
Memory organization of 8051Memory organization of 8051
Memory organization of 8051
 
Interrupts in 8051
Interrupts in 8051Interrupts in 8051
Interrupts in 8051
 
8051 Addressing Modes
8051 Addressing Modes8051 Addressing Modes
8051 Addressing Modes
 
Addressing modes
Addressing modesAddressing modes
Addressing modes
 
Architecture of 8051
Architecture of 8051Architecture of 8051
Architecture of 8051
 
Addressing modes of 8051
Addressing modes of 8051Addressing modes of 8051
Addressing modes of 8051
 
8051 assembly programming
8051 assembly programming8051 assembly programming
8051 assembly programming
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
Interfacing adc
Interfacing adcInterfacing adc
Interfacing adc
 
Interfacing stepper motor
Interfacing stepper motorInterfacing stepper motor
Interfacing stepper motor
 
8051 addressing modes
8051 addressing modes8051 addressing modes
8051 addressing modes
 
branch ins 8051
branch ins 8051branch ins 8051
branch ins 8051
 
Microcontroller-8051.ppt
Microcontroller-8051.pptMicrocontroller-8051.ppt
Microcontroller-8051.ppt
 
I o ports and timers of 8051
I o ports and timers of 8051I o ports and timers of 8051
I o ports and timers of 8051
 
Logical, Shift, and Rotate Instruction
Logical, Shift, and Rotate InstructionLogical, Shift, and Rotate Instruction
Logical, Shift, and Rotate Instruction
 
Pin diagram 8085
Pin diagram 8085 Pin diagram 8085
Pin diagram 8085
 
8251 USART
8251 USART8251 USART
8251 USART
 
Architecture of 8086 Microprocessor
Architecture of 8086 Microprocessor  Architecture of 8086 Microprocessor
Architecture of 8086 Microprocessor
 
8085 branching instruction
8085 branching instruction8085 branching instruction
8085 branching instruction
 
Architecture of 8085 microprocessor
Architecture of 8085 microprocessorArchitecture of 8085 microprocessor
Architecture of 8085 microprocessor
 

Recently uploaded

Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 

Recently uploaded (20)

Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 

Branch instructions in 8051 micrcocontroller

  • 1. Program flow instructions in 8051 (Conditional and Unconditional jump Instructions) A.Usha Rani Faculty, Department of Physics and Electronics St.Ann’s College for Women.
  • 2. Program flow instructions These instructions are used to control the flow of execution of the program or to change the sequence of program execution.  They are also called Branch instructions or Jump Instructions. Change the content of program counter to change the program execution order.
  • 3. Unconditional Jumps Do not test any condition and Jump is taken always. Short Jump The program can jump to an instruction within 127 bytes in forward direction or 128 bytes in reverse direction. Also called relative jump because the address where the jump can be taken is relative to the address where the instruction is written. The instruction is SJMP rel (Jump to relative address rel)
  • 4. Long Jump Used to jump to any location within entire program address space i.e., anywhere from 0000H to FFFFH. 3 byte instruction and is mostly used in large programs. The instruction is LJMP address Absolute Jump The entire program memory is divide into 32 pages each of 2K bytes each. AJMP can be used to jump within a page of 2K. The instruction is AJMP address
  • 5. Conditional Jumps Test the condition before taking a jump. Jump is taken only if the condition given in the instruction is satisfied. Bit Jumps Check the status of a bit specified in the instruction before taking the jump. Jump is taken only if the condition specified in the instruction is satisfied. Used to monitor the status of a specified bit.
  • 6. JC rel // Jump to relative address rel if C=1(Jump if Carry) JNC rel // Jump to relative address rel if C=0(Jump if No Carry) JB rel // Jump to relative address rel if bit =1(Jump if Bit) JNB rel // Jump to relative address rel if bit=0 (Jump if No Bit) JBC bit, rel // Jump to relative address rel if bit =1 and then clear bit (Jump if bit then clear)
  • 7. Byte Jumps Check the byte of a data to make jump. JZ rel //Jump to relative address rel if A is 0(Jump if Zero) JNZ rel // Jump to relative address rel if A is not 0(Jump if Not Zero) CJNE A, direct,rel //Compare A with the contents of address direct and jump to relative address rel if they are not equal. If the contents of A are less than contents of address direct, set carry =1 otherwise clear carry(Compare and Jump if Not Equal)
  • 8. CJNE A, #data,rel //Compare A with immediate value data and jump to relative address rel if they are not equal. If the contents of A are less than immediate value data, set carry =1 otherwise clear carry CJNE Rn, #data,rel //Compare Rn with the immediate value data and jump to relative address rel if they are not equal. If the contents of Rn are less than immediate value data, set carry =1 otherwise clear carry
  • 9. CJNE @Ri, #data,rel //Compare contents of address in Ri with immediate value data and jump to relative address rel if they are not equal. If the contents of address in Ri are less than immediate value data, set carry =1 otherwise clear carry DJNZ Rn,rel //decrement register Rn by 1 and jump to relative address rel if the contents of Rn are not zero after decrement operation.(Decrement and Jump if Not Zero)
  • 10. DJNZ direct,rel //decrement contents of address direct by 1 and jump to relative address if the contents of address direct are not zero after decrement operation.