SlideShare a Scribd company logo
1 of 33
MICROCONTROLLER
MCS-51:
BRANCH INSTRUCTION
Arkhom JODTANG
Civil Aviation Training Center
Branch Instruction
Contents
 Flowchart
 Branch Instructions
 Design program
2
Flowchart
 A flowchart is a diagrammatic representation that
illustrates the sequence of operations to be
performed to get the solution of a problem.
 Flowcharts are generally drawn in the early stages
of formulating computer solutions.
 Flowcharts facilitate communication between
programmers and business people.
 These flowcharts play a vital role in the
programming of a problem and are quite helpful in
understanding the logic of complicated and
lengthy problems.
3
Flowchart Symbols
 Terminator
 The start or end of program flow
 Initial / Preparation
 Setting a value at the beginning of the
process or initialize the routine
 Process
 Any kind of processing function, such as a
variable assignment or mathematical
operation.
 Predefined Process
 A named process, such as a subroutine, a
module, Procedure or Function.
Start
4
Flowchart Symbols
Condition  Decision
 Select flow direction from condition
 Connector
 Jumping destination
 Flow line
connect the flowchart symbols and
show the sequence of operations
during the program execution.
True
False
5
Flowchart Sample
Start
A = 30H
Process
End
MainLoop:
A = 0
6
Jump to MainLoop
 Labels are destination point that program (flowline) able to join.
 One program able to contain unlimited number of labels.
 Name of Labels follow the standard identifier rule
 Start with Letter
 Only Letter, Number and Underscore
 Case sensitive
 All label follow by colons
 Labels name, such as
 Loop:
 Delay:
 Multipli4X4Bytes:
 CheckOnes:
Label (Relative address)
MainLoop:
7
Sample of Branch Instruction
(Unconditional Jump)
ORG 0H
MOV R1,#40H
Loop:
MOV @R1,#22H
INC R1
JMP Loop
END
8
Sample of Branch Instruction
(Conditional Jump)
ORG 0H
MOV R1,#40H
Loop:
MOV @R1,#11H
INC R1
CJNE R1, #50H, Loop
END
9
JMP rel., SJMP rel.
 Jump to specified relative address
 -128 to +127 locations (Short Jump)
 No condition.
 Sample
 SJMP NO_Task
 Jump to label name is No_Task
10
AJMP adr11
 Jump to any specific location
 Long distance. (211 = 2kByte long)
 No condition.
 Sample
 AJMP Loop3
 Jump to label name is Loop3
11
LJMP adr16
 Jump to any specific location
 Long distance. (216 = 64kByte long)
 No condition.
 3 Bytes instruction
 4 Machine cycles
 Sample
 LJMP Program5
 Jump to label name is Program5
12
JC rel
 Condition: Jump if carry bit is set
 Jump to specific destination
 Short Jump
 3 Machine cycles
 Sample
 JC Store_It
 If Carry bit = Set, Jump to label “Store_It”
13
JNC rel
 Condition: Jump if carry bit is clear
 Jump to specific destination
 Short Jump
 3 Machine cycles
 Sample
 JNC EasyTask
 If Carry = 0, Jump to EasyTask
14
JNC Sample
 Example 3: Program to make summation of Timer0 and Timer1 registers.
Store the result in R0 (Highest Byte), R1 and R2 (Lowest Byte).
15
 To assign value of
Carry Flag to R0
ORG 00H
MOV R0, #00H
JNC CarryIsZero
MOV R0,#01H
CarryIsZero:
END
Timer0
Timer1
+
TL0TH0
R1 R2R0
Bit
16
 Any bit in memory
 Carry
 Acc.0
 PSW.4
 20h.0
 00h
 7Fh
 P3.3
Addres
s
.7 .6 .5 .4 .3 .2 .1 .0 Name
19h
20h 07 06 05 04 03 02 01 00
21h 0F 0E 0D 0C 0B 0A 09 08
2Fh 7F 7E 7D 7C 7B 7A 79 78
JB bit, rel
 Condition: Jump if addressed bit is set
 Jump to specific destination
 Short Jump
 2 Machine cycles
 Sample
 JB 00h, EasyTask
 If bit address 00h is set, Jump to label EasyTask:
 JB P3.4, NOTPressedS4
 If bit P3.4 = set. Jump to label PressedS4
17
JNB bit, rel
 Condition: Jump if addressed bit is clear
 Jump to specific destination
 Short Jump
 2 Machine cycles
 Sample
 JNB 00h, EasyTask
 If bit address 00h is clear, Jump to label EasyTask:
18
JBC bit, rel
 Condition: Jump if addressed bit is set
 Clear bit
 Jump to specific destination
 Short Jump
 4 Machine cycles
 Sample
 JBC 00h, EasyTask
 If bit address 00h is set, jump to label EasyTask:, Clear bit
00h
 JBC PSW.4, EasyTask
 If bit address PSW.4 is set, jump to label EasyTask:, Clear
bit PSW.4
19
JZ rel
 Condition: Jump if Acc equal to zero
 Jump to specific destination
 Short Jump
 3 Machine cycles
 Sample
 JZ EmptyNow
 If ACC = 0, Jump to label EmptyNow:
20
JNZ rel
 Condition: Jump if Acc not equal zero
 Jump to specific destination
 Short Jump
 3 Machine cycles
 Sample
 JNZ SomeValue
 If ACC > 0, Jump to label Somevalue:
21
CJNE A, Rx, rel
 Condition: Jump if Acc not equal to Rx
 Jump to specific destination
 Short Jump
 4 Machine cycles
 Effect to carry flag
 Sample
 CJNE A, 30h, Loop2
 If ACC ≠ 30h, Jump to label Loop2:
22
CJNE A, #X, rel
 Condition: Jump if Acc not equal to #X
 Jump to specific destination
 Short Jump
 4 Machine cycles
 Sample
 CJNE A, #3Eh, Loop3
 If ACC ≠ #30h, Jump to label Loop3:
23
CJNE Rn, #X, rel
 Condition: Jump if Rn not equal to #X
 Jump to specific destination
 Short Jump
 4 Machine cycles
 Sample
 CJNE R4, #40h, Loop4
 If R4 ≠ #40h, Jump to label Loop4:
24
CJNE @Ri, #X, rel
 Condition: Jump if register addressed by Ri
not equal to #X
 Jump to specific destination
 Short Jump
 4 Machine cycles
 Sample
 CJNE @R0, #0E0h, Loop5
 If register which is addressed by R0 ≠ #E0h, Jump to
label Loop5:
25
Comparison Conditional tips
Most of conditional jumps are Not Equal Condition
JZ ( A = 0 ) JNZ
CJNE A, Rx, rel
CJNE A, #X, rel
CJNE Rn, #X, rel
DJNZ Rn, rel
Example 1
 Write program to fill the memory area
address 30h to 4Fh with counting number
start from 1H
27
Example 1: Result needed
 Write program to fill the memory area
address 30h to 4Fh with counting number
start from 1H
28
Example 1: Solution
 Write program to
fill the memory
area address 30h
to 4Fh with
counting number
start from 1H
29
CJNE (Homework)
 Write program to fill the memory area address 30h to 6Fh
with Decimal (BCD) counting number start from 0H
 The code must less than 15 line of assembly code
30
DJNZ Rn, rel
 Process: Decrease Rn by one, then
 Condition: Jump if Rn not equal to zero
 Jump to specific destination
 Short Jump
 3 Machine cycles
 Sample
 DJNZ R5, Loop6
 Decrease R5 then check, If R5 ≠ 0, Jump to label
Loop6:
31
DJNZ Rx, rel
 Process: Decrease Rx by one, then
 Condition: Jump if Rx not equal to zero
 Jump to specific destination
 Short Jump
 4 Machine cycles
 Sample
 DJNZ R5, Loop6
 Decrease R5 then check, If R5 ≠ 0, Jump to label
Loop6:
32
DJNZ (Sample)
 ; DJNZ is very convenion for
 ; specified number of turn for
some process.
 ORG 0H
 MOV R5,#10D
 Loop:
 ; Process here
 DJNZ R5, Loop
 END
33
Start
R5 =10D
Process
End
Loop:
DJNZ R5, Loop

More Related Content

What's hot

8085 logical instruction
8085 logical instruction8085 logical instruction
8085 logical instructionprashant1271
 
8085 stack & machine control instruction
8085 stack & machine control instruction8085 stack & machine control instruction
8085 stack & machine control instructionprashant1271
 
The 8051 assembly language
The 8051 assembly languageThe 8051 assembly language
The 8051 assembly languagehemant meena
 
Loop instruction, controlling the flow of progam
Loop instruction, controlling the flow of progamLoop instruction, controlling the flow of progam
Loop instruction, controlling the flow of progamDr. Girish GS
 
The 8051 microcontroller
The 8051 microcontrollerThe 8051 microcontroller
The 8051 microcontrollerPallaviHailkar
 
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...Bilal Amjad
 
Welcome to International Journal of Engineering Research and Development (IJERD)
Welcome to International Journal of Engineering Research and Development (IJERD)Welcome to International Journal of Engineering Research and Development (IJERD)
Welcome to International Journal of Engineering Research and Development (IJERD)IJERD Editor
 
Instructionsetof8086 180224060745(3)
Instructionsetof8086 180224060745(3)Instructionsetof8086 180224060745(3)
Instructionsetof8086 180224060745(3)AmitPaliwal20
 
implementation of data instrucions in emu8086
implementation of data instrucions in emu8086implementation of data instrucions in emu8086
implementation of data instrucions in emu8086COMSATS Abbottabad
 
NFA Converted to DFA , Minimization of DFA , Transition Diagram
NFA Converted to DFA , Minimization of DFA , Transition DiagramNFA Converted to DFA , Minimization of DFA , Transition Diagram
NFA Converted to DFA , Minimization of DFA , Transition DiagramAbdullah Jan
 
Nondeterministic Finite Automat
Nondeterministic Finite AutomatNondeterministic Finite Automat
Nondeterministic Finite AutomatAdel Al-Ofairi
 
Csa ic
Csa icCsa ic
Csa icPCTE
 
Flow control instructions
Flow control instructionsFlow control instructions
Flow control instructionsProdip Ghosh
 
1347 assemblylanguageprogrammingof8051-100523023308-phpapp01
1347 assemblylanguageprogrammingof8051-100523023308-phpapp011347 assemblylanguageprogrammingof8051-100523023308-phpapp01
1347 assemblylanguageprogrammingof8051-100523023308-phpapp01bvenkanna
 
Verilog Lecture2 thhts
Verilog Lecture2 thhtsVerilog Lecture2 thhts
Verilog Lecture2 thhtsBéo Tú
 

What's hot (20)

8085 logical instruction
8085 logical instruction8085 logical instruction
8085 logical instruction
 
Automata
AutomataAutomata
Automata
 
mup
mupmup
mup
 
8085 stack & machine control instruction
8085 stack & machine control instruction8085 stack & machine control instruction
8085 stack & machine control instruction
 
The 8051 assembly language
The 8051 assembly languageThe 8051 assembly language
The 8051 assembly language
 
Hima1
Hima1Hima1
Hima1
 
Compiler Design Unit 5
Compiler Design Unit 5Compiler Design Unit 5
Compiler Design Unit 5
 
8051assembly language
8051assembly language8051assembly language
8051assembly language
 
Loop instruction, controlling the flow of progam
Loop instruction, controlling the flow of progamLoop instruction, controlling the flow of progam
Loop instruction, controlling the flow of progam
 
The 8051 microcontroller
The 8051 microcontrollerThe 8051 microcontroller
The 8051 microcontroller
 
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
 
Welcome to International Journal of Engineering Research and Development (IJERD)
Welcome to International Journal of Engineering Research and Development (IJERD)Welcome to International Journal of Engineering Research and Development (IJERD)
Welcome to International Journal of Engineering Research and Development (IJERD)
 
Instructionsetof8086 180224060745(3)
Instructionsetof8086 180224060745(3)Instructionsetof8086 180224060745(3)
Instructionsetof8086 180224060745(3)
 
implementation of data instrucions in emu8086
implementation of data instrucions in emu8086implementation of data instrucions in emu8086
implementation of data instrucions in emu8086
 
NFA Converted to DFA , Minimization of DFA , Transition Diagram
NFA Converted to DFA , Minimization of DFA , Transition DiagramNFA Converted to DFA , Minimization of DFA , Transition Diagram
NFA Converted to DFA , Minimization of DFA , Transition Diagram
 
Nondeterministic Finite Automat
Nondeterministic Finite AutomatNondeterministic Finite Automat
Nondeterministic Finite Automat
 
Csa ic
Csa icCsa ic
Csa ic
 
Flow control instructions
Flow control instructionsFlow control instructions
Flow control instructions
 
1347 assemblylanguageprogrammingof8051-100523023308-phpapp01
1347 assemblylanguageprogrammingof8051-100523023308-phpapp011347 assemblylanguageprogrammingof8051-100523023308-phpapp01
1347 assemblylanguageprogrammingof8051-100523023308-phpapp01
 
Verilog Lecture2 thhts
Verilog Lecture2 thhtsVerilog Lecture2 thhts
Verilog Lecture2 thhts
 

Viewers also liked

Lec3 instructions branch carl hamcher
Lec3 instructions branch carl hamcher Lec3 instructions branch carl hamcher
Lec3 instructions branch carl hamcher Venkata Krishnakanth P
 
Concept of Pipelining
Concept of PipeliningConcept of Pipelining
Concept of PipeliningSHAKOOR AB
 
Lec18 pipeline
Lec18 pipelineLec18 pipeline
Lec18 pipelineGRajendra
 
Instruction pipeline: Computer Architecture
Instruction pipeline: Computer ArchitectureInstruction pipeline: Computer Architecture
Instruction pipeline: Computer ArchitectureInteX Research Lab
 
Instruction pipelining
Instruction pipeliningInstruction pipelining
Instruction pipeliningTech_MX
 
Instruction set of 8085
Instruction set  of 8085Instruction set  of 8085
Instruction set of 8085shiji v r
 
8085 microprocessor ramesh gaonkar
8085 microprocessor   ramesh gaonkar8085 microprocessor   ramesh gaonkar
8085 microprocessor ramesh gaonkarSAQUIB AHMAD
 

Viewers also liked (10)

Lec3 instructions branch carl hamcher
Lec3 instructions branch carl hamcher Lec3 instructions branch carl hamcher
Lec3 instructions branch carl hamcher
 
Pipelining In computer
Pipelining In computer Pipelining In computer
Pipelining In computer
 
Concept of Pipelining
Concept of PipeliningConcept of Pipelining
Concept of Pipelining
 
Lec18 pipeline
Lec18 pipelineLec18 pipeline
Lec18 pipeline
 
pipelining
pipeliningpipelining
pipelining
 
Instruction pipeline: Computer Architecture
Instruction pipeline: Computer ArchitectureInstruction pipeline: Computer Architecture
Instruction pipeline: Computer Architecture
 
Instruction pipelining
Instruction pipeliningInstruction pipelining
Instruction pipelining
 
Instruction set of 8085
Instruction set  of 8085Instruction set  of 8085
Instruction set of 8085
 
pipelining
pipeliningpipelining
pipelining
 
8085 microprocessor ramesh gaonkar
8085 microprocessor   ramesh gaonkar8085 microprocessor   ramesh gaonkar
8085 microprocessor ramesh gaonkar
 

Similar to Microprocessor Week 7: Branch Instruction

Https _doc-0o-c4-apps-viewer.googleusercontent
Https  _doc-0o-c4-apps-viewer.googleusercontent Https  _doc-0o-c4-apps-viewer.googleusercontent
Https _doc-0o-c4-apps-viewer.googleusercontent vijaydeepakg
 
Microcontroladores: introducción a la programación en lenguaje ensamblador AVR
Microcontroladores: introducción a la programación en lenguaje ensamblador AVRMicrocontroladores: introducción a la programación en lenguaje ensamblador AVR
Microcontroladores: introducción a la programación en lenguaje ensamblador AVRSANTIAGO PABLO ALBERTO
 
Programming basic computer
Programming basic computerProgramming basic computer
Programming basic computerMartial Kouadio
 
Lecture05 abap on line
Lecture05 abap on lineLecture05 abap on line
Lecture05 abap on lineMilind Patil
 
Chapter 6 - Introduction to 8085 Instructions
Chapter 6 - Introduction to 8085 InstructionsChapter 6 - Introduction to 8085 Instructions
Chapter 6 - Introduction to 8085 Instructionscmkandemir
 
Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051logesh waran
 
Algorithm analysis and design
Algorithm analysis and designAlgorithm analysis and design
Algorithm analysis and designMegha V
 
EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5PRADEEP
 
Virtual Machine for Regular Expressions
Virtual Machine for Regular ExpressionsVirtual Machine for Regular Expressions
Virtual Machine for Regular ExpressionsAlexander Yakushev
 

Similar to Microprocessor Week 7: Branch Instruction (20)

Https _doc-0o-c4-apps-viewer.googleusercontent
Https  _doc-0o-c4-apps-viewer.googleusercontent Https  _doc-0o-c4-apps-viewer.googleusercontent
Https _doc-0o-c4-apps-viewer.googleusercontent
 
Microcontroladores: introducción a la programación en lenguaje ensamblador AVR
Microcontroladores: introducción a la programación en lenguaje ensamblador AVRMicrocontroladores: introducción a la programación en lenguaje ensamblador AVR
Microcontroladores: introducción a la programación en lenguaje ensamblador AVR
 
OptimizingARM
OptimizingARMOptimizingARM
OptimizingARM
 
Computer Architecture Assignment Help
Computer Architecture Assignment HelpComputer Architecture Assignment Help
Computer Architecture Assignment Help
 
MES_MODULE 2.pptx
MES_MODULE 2.pptxMES_MODULE 2.pptx
MES_MODULE 2.pptx
 
Programming basic computer
Programming basic computerProgramming basic computer
Programming basic computer
 
Chapt 06
Chapt 06Chapt 06
Chapt 06
 
Assembly language programs
Assembly language programsAssembly language programs
Assembly language programs
 
Lecture05 abap on line
Lecture05 abap on lineLecture05 abap on line
Lecture05 abap on line
 
Arm instruction set
Arm instruction setArm instruction set
Arm instruction set
 
Instruction types
Instruction typesInstruction types
Instruction types
 
Chapter 6 - Introduction to 8085 Instructions
Chapter 6 - Introduction to 8085 InstructionsChapter 6 - Introduction to 8085 Instructions
Chapter 6 - Introduction to 8085 Instructions
 
6.pptx
6.pptx6.pptx
6.pptx
 
Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051
 
ARM Fundamentals
ARM FundamentalsARM Fundamentals
ARM Fundamentals
 
[ASM]Lab6
[ASM]Lab6[ASM]Lab6
[ASM]Lab6
 
Algorithm analysis and design
Algorithm analysis and designAlgorithm analysis and design
Algorithm analysis and design
 
EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5
 
Virtual Machine for Regular Expressions
Virtual Machine for Regular ExpressionsVirtual Machine for Regular Expressions
Virtual Machine for Regular Expressions
 
Flow chart programming
Flow chart programmingFlow chart programming
Flow chart programming
 

More from Arkhom Jodtang

MCS51 Training board Model CATC2016A
MCS51 Training board Model CATC2016AMCS51 Training board Model CATC2016A
MCS51 Training board Model CATC2016AArkhom Jodtang
 
Microprocessor Week 10: Applications
Microprocessor Week 10: ApplicationsMicroprocessor Week 10: Applications
Microprocessor Week 10: ApplicationsArkhom Jodtang
 
Microprocessor Week 9: Timer and Counter
Microprocessor Week 9: Timer and CounterMicroprocessor Week 9: Timer and Counter
Microprocessor Week 9: Timer and CounterArkhom Jodtang
 
Microprocessor Week 8: Subroutine
Microprocessor Week 8: Subroutine Microprocessor Week 8: Subroutine
Microprocessor Week 8: Subroutine Arkhom Jodtang
 
Microprocessor Week2: Data Transfer
Microprocessor Week2: Data TransferMicroprocessor Week2: Data Transfer
Microprocessor Week2: Data TransferArkhom Jodtang
 
Microprocessor Week 2: CH2 Circuit and Operation
Microprocessor Week 2: CH2 Circuit and OperationMicroprocessor Week 2: CH2 Circuit and Operation
Microprocessor Week 2: CH2 Circuit and OperationArkhom Jodtang
 
Microprocessor Week1: Introduction
Microprocessor Week1: IntroductionMicroprocessor Week1: Introduction
Microprocessor Week1: IntroductionArkhom Jodtang
 
Microprocessor laboratory 03 Arithmetic Operation (Additional and Subtraction)
Microprocessor laboratory 03 Arithmetic Operation (Additional and Subtraction)Microprocessor laboratory 03 Arithmetic Operation (Additional and Subtraction)
Microprocessor laboratory 03 Arithmetic Operation (Additional and Subtraction)Arkhom Jodtang
 
Microprocessor Week 4-5 MCS-51 Arithmetic operation
Microprocessor Week 4-5 MCS-51 Arithmetic operationMicroprocessor Week 4-5 MCS-51 Arithmetic operation
Microprocessor Week 4-5 MCS-51 Arithmetic operationArkhom Jodtang
 
Use of Computer & IT, Laboratory MS Word
Use of Computer & IT, Laboratory MS WordUse of Computer & IT, Laboratory MS Word
Use of Computer & IT, Laboratory MS WordArkhom Jodtang
 
Microprocessor Laboratory 2: Logical instructions
Microprocessor Laboratory 2: Logical instructionsMicroprocessor Laboratory 2: Logical instructions
Microprocessor Laboratory 2: Logical instructionsArkhom Jodtang
 
Microprocessor: Delay technique
Microprocessor: Delay techniqueMicroprocessor: Delay technique
Microprocessor: Delay techniqueArkhom Jodtang
 
Distance Measuring Car
Distance Measuring CarDistance Measuring Car
Distance Measuring CarArkhom Jodtang
 
Tamech 2013 Presentation
Tamech 2013 PresentationTamech 2013 Presentation
Tamech 2013 PresentationArkhom Jodtang
 
Electronics & Avionics project
Electronics & Avionics projectElectronics & Avionics project
Electronics & Avionics projectArkhom Jodtang
 

More from Arkhom Jodtang (15)

MCS51 Training board Model CATC2016A
MCS51 Training board Model CATC2016AMCS51 Training board Model CATC2016A
MCS51 Training board Model CATC2016A
 
Microprocessor Week 10: Applications
Microprocessor Week 10: ApplicationsMicroprocessor Week 10: Applications
Microprocessor Week 10: Applications
 
Microprocessor Week 9: Timer and Counter
Microprocessor Week 9: Timer and CounterMicroprocessor Week 9: Timer and Counter
Microprocessor Week 9: Timer and Counter
 
Microprocessor Week 8: Subroutine
Microprocessor Week 8: Subroutine Microprocessor Week 8: Subroutine
Microprocessor Week 8: Subroutine
 
Microprocessor Week2: Data Transfer
Microprocessor Week2: Data TransferMicroprocessor Week2: Data Transfer
Microprocessor Week2: Data Transfer
 
Microprocessor Week 2: CH2 Circuit and Operation
Microprocessor Week 2: CH2 Circuit and OperationMicroprocessor Week 2: CH2 Circuit and Operation
Microprocessor Week 2: CH2 Circuit and Operation
 
Microprocessor Week1: Introduction
Microprocessor Week1: IntroductionMicroprocessor Week1: Introduction
Microprocessor Week1: Introduction
 
Microprocessor laboratory 03 Arithmetic Operation (Additional and Subtraction)
Microprocessor laboratory 03 Arithmetic Operation (Additional and Subtraction)Microprocessor laboratory 03 Arithmetic Operation (Additional and Subtraction)
Microprocessor laboratory 03 Arithmetic Operation (Additional and Subtraction)
 
Microprocessor Week 4-5 MCS-51 Arithmetic operation
Microprocessor Week 4-5 MCS-51 Arithmetic operationMicroprocessor Week 4-5 MCS-51 Arithmetic operation
Microprocessor Week 4-5 MCS-51 Arithmetic operation
 
Use of Computer & IT, Laboratory MS Word
Use of Computer & IT, Laboratory MS WordUse of Computer & IT, Laboratory MS Word
Use of Computer & IT, Laboratory MS Word
 
Microprocessor Laboratory 2: Logical instructions
Microprocessor Laboratory 2: Logical instructionsMicroprocessor Laboratory 2: Logical instructions
Microprocessor Laboratory 2: Logical instructions
 
Microprocessor: Delay technique
Microprocessor: Delay techniqueMicroprocessor: Delay technique
Microprocessor: Delay technique
 
Distance Measuring Car
Distance Measuring CarDistance Measuring Car
Distance Measuring Car
 
Tamech 2013 Presentation
Tamech 2013 PresentationTamech 2013 Presentation
Tamech 2013 Presentation
 
Electronics & Avionics project
Electronics & Avionics projectElectronics & Avionics project
Electronics & Avionics project
 

Recently uploaded

(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 

Recently uploaded (20)

(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 

Microprocessor Week 7: Branch Instruction

  • 2. Branch Instruction Contents  Flowchart  Branch Instructions  Design program 2
  • 3. Flowchart  A flowchart is a diagrammatic representation that illustrates the sequence of operations to be performed to get the solution of a problem.  Flowcharts are generally drawn in the early stages of formulating computer solutions.  Flowcharts facilitate communication between programmers and business people.  These flowcharts play a vital role in the programming of a problem and are quite helpful in understanding the logic of complicated and lengthy problems. 3
  • 4. Flowchart Symbols  Terminator  The start or end of program flow  Initial / Preparation  Setting a value at the beginning of the process or initialize the routine  Process  Any kind of processing function, such as a variable assignment or mathematical operation.  Predefined Process  A named process, such as a subroutine, a module, Procedure or Function. Start 4
  • 5. Flowchart Symbols Condition  Decision  Select flow direction from condition  Connector  Jumping destination  Flow line connect the flowchart symbols and show the sequence of operations during the program execution. True False 5
  • 6. Flowchart Sample Start A = 30H Process End MainLoop: A = 0 6 Jump to MainLoop
  • 7.  Labels are destination point that program (flowline) able to join.  One program able to contain unlimited number of labels.  Name of Labels follow the standard identifier rule  Start with Letter  Only Letter, Number and Underscore  Case sensitive  All label follow by colons  Labels name, such as  Loop:  Delay:  Multipli4X4Bytes:  CheckOnes: Label (Relative address) MainLoop: 7
  • 8. Sample of Branch Instruction (Unconditional Jump) ORG 0H MOV R1,#40H Loop: MOV @R1,#22H INC R1 JMP Loop END 8
  • 9. Sample of Branch Instruction (Conditional Jump) ORG 0H MOV R1,#40H Loop: MOV @R1,#11H INC R1 CJNE R1, #50H, Loop END 9
  • 10. JMP rel., SJMP rel.  Jump to specified relative address  -128 to +127 locations (Short Jump)  No condition.  Sample  SJMP NO_Task  Jump to label name is No_Task 10
  • 11. AJMP adr11  Jump to any specific location  Long distance. (211 = 2kByte long)  No condition.  Sample  AJMP Loop3  Jump to label name is Loop3 11
  • 12. LJMP adr16  Jump to any specific location  Long distance. (216 = 64kByte long)  No condition.  3 Bytes instruction  4 Machine cycles  Sample  LJMP Program5  Jump to label name is Program5 12
  • 13. JC rel  Condition: Jump if carry bit is set  Jump to specific destination  Short Jump  3 Machine cycles  Sample  JC Store_It  If Carry bit = Set, Jump to label “Store_It” 13
  • 14. JNC rel  Condition: Jump if carry bit is clear  Jump to specific destination  Short Jump  3 Machine cycles  Sample  JNC EasyTask  If Carry = 0, Jump to EasyTask 14
  • 15. JNC Sample  Example 3: Program to make summation of Timer0 and Timer1 registers. Store the result in R0 (Highest Byte), R1 and R2 (Lowest Byte). 15  To assign value of Carry Flag to R0 ORG 00H MOV R0, #00H JNC CarryIsZero MOV R0,#01H CarryIsZero: END Timer0 Timer1 + TL0TH0 R1 R2R0
  • 16. Bit 16  Any bit in memory  Carry  Acc.0  PSW.4  20h.0  00h  7Fh  P3.3 Addres s .7 .6 .5 .4 .3 .2 .1 .0 Name 19h 20h 07 06 05 04 03 02 01 00 21h 0F 0E 0D 0C 0B 0A 09 08 2Fh 7F 7E 7D 7C 7B 7A 79 78
  • 17. JB bit, rel  Condition: Jump if addressed bit is set  Jump to specific destination  Short Jump  2 Machine cycles  Sample  JB 00h, EasyTask  If bit address 00h is set, Jump to label EasyTask:  JB P3.4, NOTPressedS4  If bit P3.4 = set. Jump to label PressedS4 17
  • 18. JNB bit, rel  Condition: Jump if addressed bit is clear  Jump to specific destination  Short Jump  2 Machine cycles  Sample  JNB 00h, EasyTask  If bit address 00h is clear, Jump to label EasyTask: 18
  • 19. JBC bit, rel  Condition: Jump if addressed bit is set  Clear bit  Jump to specific destination  Short Jump  4 Machine cycles  Sample  JBC 00h, EasyTask  If bit address 00h is set, jump to label EasyTask:, Clear bit 00h  JBC PSW.4, EasyTask  If bit address PSW.4 is set, jump to label EasyTask:, Clear bit PSW.4 19
  • 20. JZ rel  Condition: Jump if Acc equal to zero  Jump to specific destination  Short Jump  3 Machine cycles  Sample  JZ EmptyNow  If ACC = 0, Jump to label EmptyNow: 20
  • 21. JNZ rel  Condition: Jump if Acc not equal zero  Jump to specific destination  Short Jump  3 Machine cycles  Sample  JNZ SomeValue  If ACC > 0, Jump to label Somevalue: 21
  • 22. CJNE A, Rx, rel  Condition: Jump if Acc not equal to Rx  Jump to specific destination  Short Jump  4 Machine cycles  Effect to carry flag  Sample  CJNE A, 30h, Loop2  If ACC ≠ 30h, Jump to label Loop2: 22
  • 23. CJNE A, #X, rel  Condition: Jump if Acc not equal to #X  Jump to specific destination  Short Jump  4 Machine cycles  Sample  CJNE A, #3Eh, Loop3  If ACC ≠ #30h, Jump to label Loop3: 23
  • 24. CJNE Rn, #X, rel  Condition: Jump if Rn not equal to #X  Jump to specific destination  Short Jump  4 Machine cycles  Sample  CJNE R4, #40h, Loop4  If R4 ≠ #40h, Jump to label Loop4: 24
  • 25. CJNE @Ri, #X, rel  Condition: Jump if register addressed by Ri not equal to #X  Jump to specific destination  Short Jump  4 Machine cycles  Sample  CJNE @R0, #0E0h, Loop5  If register which is addressed by R0 ≠ #E0h, Jump to label Loop5: 25
  • 26. Comparison Conditional tips Most of conditional jumps are Not Equal Condition JZ ( A = 0 ) JNZ CJNE A, Rx, rel CJNE A, #X, rel CJNE Rn, #X, rel DJNZ Rn, rel
  • 27. Example 1  Write program to fill the memory area address 30h to 4Fh with counting number start from 1H 27
  • 28. Example 1: Result needed  Write program to fill the memory area address 30h to 4Fh with counting number start from 1H 28
  • 29. Example 1: Solution  Write program to fill the memory area address 30h to 4Fh with counting number start from 1H 29
  • 30. CJNE (Homework)  Write program to fill the memory area address 30h to 6Fh with Decimal (BCD) counting number start from 0H  The code must less than 15 line of assembly code 30
  • 31. DJNZ Rn, rel  Process: Decrease Rn by one, then  Condition: Jump if Rn not equal to zero  Jump to specific destination  Short Jump  3 Machine cycles  Sample  DJNZ R5, Loop6  Decrease R5 then check, If R5 ≠ 0, Jump to label Loop6: 31
  • 32. DJNZ Rx, rel  Process: Decrease Rx by one, then  Condition: Jump if Rx not equal to zero  Jump to specific destination  Short Jump  4 Machine cycles  Sample  DJNZ R5, Loop6  Decrease R5 then check, If R5 ≠ 0, Jump to label Loop6: 32
  • 33. DJNZ (Sample)  ; DJNZ is very convenion for  ; specified number of turn for some process.  ORG 0H  MOV R5,#10D  Loop:  ; Process here  DJNZ R5, Loop  END 33 Start R5 =10D Process End Loop: DJNZ R5, Loop