SlideShare a Scribd company logo
1 of 11
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

Subroutine in 8051 microcontroller
Subroutine in 8051 microcontrollerSubroutine in 8051 microcontroller
Subroutine in 8051 microcontrollerbhadresh savani
 
Pic ppt 13104022(4th_year)
Pic ppt 13104022(4th_year)Pic ppt 13104022(4th_year)
Pic ppt 13104022(4th_year)Daman Singh
 
8086 microprocessor-architecture
8086 microprocessor-architecture8086 microprocessor-architecture
8086 microprocessor-architectureprasadpawaskar
 
Timer counter in arm7(lpc2148)
Timer counter in arm7(lpc2148)Timer counter in arm7(lpc2148)
Timer counter in arm7(lpc2148)Aarav Soni
 
Single Phase Induction Type Energy Meter
Single Phase Induction Type Energy MeterSingle Phase Induction Type Energy Meter
Single Phase Induction Type Energy MeterVishal Thakur
 
Seven Segment Display
Seven Segment DisplaySeven Segment Display
Seven Segment DisplayKshitij Wagle
 
Arithmetic & logical operations in 8051
Arithmetic & logical operations in 8051Arithmetic & logical operations in 8051
Arithmetic & logical operations in 8051Jay Patel
 
Branching instructions in 8086 microprocessor
Branching instructions in 8086 microprocessorBranching instructions in 8086 microprocessor
Branching instructions in 8086 microprocessorRabin BK
 
Combinational circuits
Combinational circuits Combinational circuits
Combinational circuits DrSonali Vyas
 
Stacks & subroutines 1
Stacks & subroutines 1Stacks & subroutines 1
Stacks & subroutines 1deval patel
 
Pulse width modulation (PWM)
Pulse width modulation (PWM)Pulse width modulation (PWM)
Pulse width modulation (PWM)amar pandey
 
Digital storage ocilloscope
Digital storage ocilloscopeDigital storage ocilloscope
Digital storage ocilloscopekajal8899
 

What's hot (20)

Subroutine in 8051 microcontroller
Subroutine in 8051 microcontrollerSubroutine in 8051 microcontroller
Subroutine in 8051 microcontroller
 
Pic ppt 13104022(4th_year)
Pic ppt 13104022(4th_year)Pic ppt 13104022(4th_year)
Pic ppt 13104022(4th_year)
 
8086 microprocessor-architecture
8086 microprocessor-architecture8086 microprocessor-architecture
8086 microprocessor-architecture
 
Adc interfacing
Adc interfacingAdc interfacing
Adc interfacing
 
program status word
program status wordprogram status word
program status word
 
Timer counter in arm7(lpc2148)
Timer counter in arm7(lpc2148)Timer counter in arm7(lpc2148)
Timer counter in arm7(lpc2148)
 
boolean 8051
boolean 8051boolean 8051
boolean 8051
 
8253ppt
8253ppt8253ppt
8253ppt
 
Single Phase Induction Type Energy Meter
Single Phase Induction Type Energy MeterSingle Phase Induction Type Energy Meter
Single Phase Induction Type Energy Meter
 
Interrupts in 8051
Interrupts in 8051Interrupts in 8051
Interrupts in 8051
 
Bias compensation
Bias compensationBias compensation
Bias compensation
 
Seven Segment Display
Seven Segment DisplaySeven Segment Display
Seven Segment Display
 
Arithmetic & logical operations in 8051
Arithmetic & logical operations in 8051Arithmetic & logical operations in 8051
Arithmetic & logical operations in 8051
 
Branching instructions in 8086 microprocessor
Branching instructions in 8086 microprocessorBranching instructions in 8086 microprocessor
Branching instructions in 8086 microprocessor
 
Combinational circuits
Combinational circuits Combinational circuits
Combinational circuits
 
Stacks & subroutines 1
Stacks & subroutines 1Stacks & subroutines 1
Stacks & subroutines 1
 
Pulse width modulation (PWM)
Pulse width modulation (PWM)Pulse width modulation (PWM)
Pulse width modulation (PWM)
 
Analog to digital converters, adc
Analog to digital converters, adcAnalog to digital converters, adc
Analog to digital converters, adc
 
Digital storage ocilloscope
Digital storage ocilloscopeDigital storage ocilloscope
Digital storage ocilloscope
 
Synchronous Counter
Synchronous Counter Synchronous Counter
Synchronous Counter
 

Recently uploaded

Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxsqpmdrvczh
 
Quarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayQuarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayMakMakNepo
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 

Recently uploaded (20)

Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptx
 
Quarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayQuarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up Friday
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 

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.