SlideShare a Scribd company logo
1 of 8
Microprocessor & its Applications
Module 3 Continued……
Dr. Girisha G S
Dept. of CSE
SoE, DSU, Bengaluru
1
Agenda
• Program Control Instructions
• Jump Group
- unconditional jump
- conditional jump
Program Control Instructions
- Program control instructions change or modify the flow of a program
Jump Group of instructions
Jump instructions are classified in to two groups
1. Unconditional Jump
- Control is transferred unconditionally to the
target label which points to the address of target
instruction
E.g. Jmp, call, ret
2. Conditional Jump
- Control is transferred to the target label if a certain
condition is met, otherwise execution continues
with next sequential instruction
- The condition are represented by flags
E.g. jc, jz, jnc, jnz
JMP - Unconditional Jump
• Three types : short jump, near jump, and far jump.
• The short jump is a two-byte instruction that allows jumps or branches
to memory locations within +127 and -128 bytes from the address
following the jump.
• A near jump is a three-byte instruction that allows a branch or jump
within ±32K bytes from the instruction in the current code segment.
• far jump is a 5 byte instruction that allows a jump to any memory
location within the real memory system.
• The short and near jumps are often called intrasegment jumps
• the far jumps are often called intersegment jumps.
The general form of the JMP instruction is
jmp label
where label is a program address indentifier
• This instruction unconditionally transfer control of the execution to the specified label
(address) using an 8 bit or 16 bit displacement or CS:IP.
• No flags are affected by this instruction.
• When this instruction is executed ,the CS & IP are unconditionally modified to a new
value of CS & IP corresponding to the location transferred
Short Jump
• Short jumps are called relative jumps because they can be moved to any
location in current code segment without a change
• A short jump to four
memory locations
beyond the address of
the next instruction.
• The short jump instruction appears in figure below.
• Example shows how short jump instructions
pass control from one part of the program
to another.
Example
jmp short next (use short directive to force short jump).
Near Jump
• The near jump is similar to the short jump, except that the distance is
farther.
• A near jump passes control to an instruction in the current code segment
located within ±32K bytes from the near jump instruction.
A near jump that adds the
displacement (0002H) to
contents of IP.
• The near jump is a 3-byte instruction that
contains an opcode followed by a signed
16-bit displacement.
E.g. jmp next
Far Jump
• A far jump instruction transfer control to the target location in different
code segment. This is performed by loading CS with segment address in
which the target exist & IP with the offset address of a instruction to
which control is to be transferred in the new code segment.
• The target address loaded in CS & IP are part of the instruction itself. This is a
5 byte instruction.
A far jump instruction replaces the contents of
both CS and IP with 4 bytes following the
opcode.
E.g. jmp far ptr skip
Conditional Jumps Instructions
• The conditional jump instruction transfer control to the address specified (target location)
if some condition is met or satisfied otherwise execution continues sequentially.
• The condition here means the status of the condition flags. The conditional jump
instructions test the following flag bits: sign(S), zero(Z), carry (C), parity(P), overflow(O).
Instruction Condition Tested Comment
JA C = 0 and Z = 0 Jump above
JAE C = 0 Jump above or equal to
JB C = 1 Jump below
JBE C = 1 or Z = 1 Jump below or equal to
JC C=1 Jump carry set
JE or JZ Z = 1 Jump equal to or jump zero
JG Z = 0 and S = 0 Jump greater than
JGE S = 0 Jump greater than or equal to
JL S ≠ 0 Jump less than
JLE Z = 1 or S ≠ 0 Jump less than or equal to
JNC C = 0 Jump carry cleared
JNE or JNZ Z = 0 Jump not equal to or jump not zero
JNO 0 = 0 Jump no overflow
JNS S = 0 Jump no sign
JNP/JPO P = 0 Jump no parity/jump parity odd
JO 0 = 1 Jump on overflow
JP/JPE P= 1 Jump on parity/jump parity even
JS S = 1 Jump on sign
If the condition under test is true, a branch to the label associated with the jump
instruction occurs..
If the condition is false, the next sequential instruction in the program executes.
For example, a JC will jump if the carry bit is set.

More Related Content

What's hot

Cache memory
Cache memoryCache memory
Cache memoryAnuj Modi
 
Floating point arithmetic operations (1)
Floating point arithmetic operations (1)Floating point arithmetic operations (1)
Floating point arithmetic operations (1)cs19club
 
program flow mechanisms, advanced computer architecture
program flow mechanisms, advanced computer architectureprogram flow mechanisms, advanced computer architecture
program flow mechanisms, advanced computer architecturePankaj Kumar Jain
 
Control Units : Microprogrammed and Hardwired:control unit
Control Units : Microprogrammed and Hardwired:control unitControl Units : Microprogrammed and Hardwired:control unit
Control Units : Microprogrammed and Hardwired:control unitabdosaidgkv
 
Virtual memory
Virtual memoryVirtual memory
Virtual memoryAnuj Modi
 
Data manipulation instructions
Data manipulation instructionsData manipulation instructions
Data manipulation instructionsMahesh Kumar Attri
 
Instruction Set Architecture (ISA)
Instruction Set Architecture (ISA)Instruction Set Architecture (ISA)
Instruction Set Architecture (ISA)Gaditek
 
Multiprocessor
MultiprocessorMultiprocessor
MultiprocessorNeel Patel
 
8086-instruction-set-ppt
 8086-instruction-set-ppt 8086-instruction-set-ppt
8086-instruction-set-pptjemimajerome
 
Pipeline hazard
Pipeline hazardPipeline hazard
Pipeline hazardAJAL A J
 
Computer architecture pipelining
Computer architecture pipeliningComputer architecture pipelining
Computer architecture pipeliningMazin Alwaaly
 

What's hot (20)

Cache memory
Cache memoryCache memory
Cache memory
 
Floating point arithmetic operations (1)
Floating point arithmetic operations (1)Floating point arithmetic operations (1)
Floating point arithmetic operations (1)
 
Program control
Program controlProgram control
Program control
 
pipelining
pipeliningpipelining
pipelining
 
program flow mechanisms, advanced computer architecture
program flow mechanisms, advanced computer architectureprogram flow mechanisms, advanced computer architecture
program flow mechanisms, advanced computer architecture
 
Control Units : Microprogrammed and Hardwired:control unit
Control Units : Microprogrammed and Hardwired:control unitControl Units : Microprogrammed and Hardwired:control unit
Control Units : Microprogrammed and Hardwired:control unit
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
addressing modes
addressing modesaddressing modes
addressing modes
 
Bus aribration
Bus aribrationBus aribration
Bus aribration
 
Data manipulation instructions
Data manipulation instructionsData manipulation instructions
Data manipulation instructions
 
Instruction Set Architecture (ISA)
Instruction Set Architecture (ISA)Instruction Set Architecture (ISA)
Instruction Set Architecture (ISA)
 
Multiprocessor
MultiprocessorMultiprocessor
Multiprocessor
 
Instruction format
Instruction formatInstruction format
Instruction format
 
8086-instruction-set-ppt
 8086-instruction-set-ppt 8086-instruction-set-ppt
8086-instruction-set-ppt
 
Pipeline hazard
Pipeline hazardPipeline hazard
Pipeline hazard
 
Computer architecture pipelining
Computer architecture pipeliningComputer architecture pipelining
Computer architecture pipelining
 
Arithmetic and logical instructions
Arithmetic and logical instructionsArithmetic and logical instructions
Arithmetic and logical instructions
 
Cache coherence ppt
Cache coherence pptCache coherence ppt
Cache coherence ppt
 
Flags registers
Flags registersFlags registers
Flags registers
 
Multiple access protocol
Multiple access protocolMultiple access protocol
Multiple access protocol
 

Similar to Program control instructions

Chap3 program flow control instructions
Chap3 program flow control instructionsChap3 program flow control instructions
Chap3 program flow control instructionsHarshitParkar6677
 
Chapter3 program flow control instructions
Chapter3 program flow control instructionsChapter3 program flow control instructions
Chapter3 program flow control instructionsHarshitParkar6677
 
Jumps in Assembly Language.
Jumps in Assembly Language.Jumps in Assembly Language.
Jumps in Assembly Language.NA000000
 
program-control-instruction.pdf
program-control-instruction.pdfprogram-control-instruction.pdf
program-control-instruction.pdfBapanKar2
 
Flow control instructions
Flow control instructionsFlow control instructions
Flow control instructionsProdip Ghosh
 
Control Structures.pptx
Control Structures.pptxControl Structures.pptx
Control Structures.pptxssuserfb3c3e
 
Data transfer and manipulation
Data transfer and  manipulationData transfer and  manipulation
Data transfer and manipulationPreethaPreetha5
 
Data transfer and manipulation
Data transfer and manipulationData transfer and manipulation
Data transfer and manipulationSanjeev Patel
 
ppt-U2 - (Instruction Set of 8086, Simple programs).pptx
ppt-U2 - (Instruction Set of 8086, Simple programs).pptxppt-U2 - (Instruction Set of 8086, Simple programs).pptx
ppt-U2 - (Instruction Set of 8086, Simple programs).pptxRaviKiranVarma4
 
Chapter 9 - Loops in C++
Chapter 9 - Loops in C++Chapter 9 - Loops in C++
Chapter 9 - Loops in C++Deepak Singh
 

Similar to Program control instructions (13)

Al2ed chapter8
Al2ed chapter8Al2ed chapter8
Al2ed chapter8
 
Chap3 program flow control instructions
Chap3 program flow control instructionsChap3 program flow control instructions
Chap3 program flow control instructions
 
Chapter3 program flow control instructions
Chapter3 program flow control instructionsChapter3 program flow control instructions
Chapter3 program flow control instructions
 
Jumps in Assembly Language.
Jumps in Assembly Language.Jumps in Assembly Language.
Jumps in Assembly Language.
 
program-control-instruction.pdf
program-control-instruction.pdfprogram-control-instruction.pdf
program-control-instruction.pdf
 
Flow control instructions
Flow control instructionsFlow control instructions
Flow control instructions
 
microcontroller.ppt
microcontroller.pptmicrocontroller.ppt
microcontroller.ppt
 
Branching
BranchingBranching
Branching
 
Control Structures.pptx
Control Structures.pptxControl Structures.pptx
Control Structures.pptx
 
Data transfer and manipulation
Data transfer and  manipulationData transfer and  manipulation
Data transfer and manipulation
 
Data transfer and manipulation
Data transfer and manipulationData transfer and manipulation
Data transfer and manipulation
 
ppt-U2 - (Instruction Set of 8086, Simple programs).pptx
ppt-U2 - (Instruction Set of 8086, Simple programs).pptxppt-U2 - (Instruction Set of 8086, Simple programs).pptx
ppt-U2 - (Instruction Set of 8086, Simple programs).pptx
 
Chapter 9 - Loops in C++
Chapter 9 - Loops in C++Chapter 9 - Loops in C++
Chapter 9 - Loops in C++
 

More from Dr. Girish GS

unix- Sort, uniq,tr,grep
unix- Sort, uniq,tr,grepunix- Sort, uniq,tr,grep
unix- Sort, uniq,tr,grepDr. Girish GS
 
unix- the process states, zombies, running jobs in background
unix-  the process states, zombies, running jobs in backgroundunix-  the process states, zombies, running jobs in background
unix- the process states, zombies, running jobs in backgroundDr. Girish GS
 
Customizing the unix environment
Customizing the unix environmentCustomizing the unix environment
Customizing the unix environmentDr. Girish GS
 
File systems and inodes
File systems and inodesFile systems and inodes
File systems and inodesDr. Girish GS
 
Basic regular expression, extended regular expression
Basic regular expression, extended regular expressionBasic regular expression, extended regular expression
Basic regular expression, extended regular expressionDr. Girish GS
 
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
 
Logic instructions part 1
Logic instructions part 1Logic instructions part 1
Logic instructions part 1Dr. Girish GS
 
Bcd arithmetic instructions
Bcd arithmetic instructionsBcd arithmetic instructions
Bcd arithmetic instructionsDr. Girish GS
 
Bcd and ascii arithmetic instructions
Bcd and ascii arithmetic instructionsBcd and ascii arithmetic instructions
Bcd and ascii arithmetic instructionsDr. Girish GS
 
Ascii arithmetic instructions
Ascii arithmetic instructionsAscii arithmetic instructions
Ascii arithmetic instructionsDr. Girish GS
 

More from Dr. Girish GS (14)

Unix- the process
Unix-  the processUnix-  the process
Unix- the process
 
unix- Sort, uniq,tr,grep
unix- Sort, uniq,tr,grepunix- Sort, uniq,tr,grep
unix- Sort, uniq,tr,grep
 
unix- the process states, zombies, running jobs in background
unix-  the process states, zombies, running jobs in backgroundunix-  the process states, zombies, running jobs in background
unix- the process states, zombies, running jobs in background
 
Unix - Filters
Unix - FiltersUnix - Filters
Unix - Filters
 
Customizing the unix environment
Customizing the unix environmentCustomizing the unix environment
Customizing the unix environment
 
File systems and inodes
File systems and inodesFile systems and inodes
File systems and inodes
 
Basic regular expression, extended regular expression
Basic regular expression, extended regular expressionBasic regular expression, extended regular expression
Basic regular expression, extended regular expression
 
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
 
Logic instructions part 1
Logic instructions part 1Logic instructions part 1
Logic instructions part 1
 
Bcd arithmetic instructions
Bcd arithmetic instructionsBcd arithmetic instructions
Bcd arithmetic instructions
 
Bcd and ascii arithmetic instructions
Bcd and ascii arithmetic instructionsBcd and ascii arithmetic instructions
Bcd and ascii arithmetic instructions
 
Ascii arithmetic instructions
Ascii arithmetic instructionsAscii arithmetic instructions
Ascii arithmetic instructions
 
Rotate instructions
Rotate instructionsRotate instructions
Rotate instructions
 
Memory interface
Memory interfaceMemory interface
Memory interface
 

Recently uploaded

Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
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
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 

Recently uploaded (20)

Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
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 )
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 

Program control instructions

  • 1. Microprocessor & its Applications Module 3 Continued…… Dr. Girisha G S Dept. of CSE SoE, DSU, Bengaluru 1
  • 2. Agenda • Program Control Instructions • Jump Group - unconditional jump - conditional jump
  • 3. Program Control Instructions - Program control instructions change or modify the flow of a program Jump Group of instructions Jump instructions are classified in to two groups 1. Unconditional Jump - Control is transferred unconditionally to the target label which points to the address of target instruction E.g. Jmp, call, ret 2. Conditional Jump - Control is transferred to the target label if a certain condition is met, otherwise execution continues with next sequential instruction - The condition are represented by flags E.g. jc, jz, jnc, jnz
  • 4. JMP - Unconditional Jump • Three types : short jump, near jump, and far jump. • The short jump is a two-byte instruction that allows jumps or branches to memory locations within +127 and -128 bytes from the address following the jump. • A near jump is a three-byte instruction that allows a branch or jump within ±32K bytes from the instruction in the current code segment. • far jump is a 5 byte instruction that allows a jump to any memory location within the real memory system. • The short and near jumps are often called intrasegment jumps • the far jumps are often called intersegment jumps. The general form of the JMP instruction is jmp label where label is a program address indentifier • This instruction unconditionally transfer control of the execution to the specified label (address) using an 8 bit or 16 bit displacement or CS:IP. • No flags are affected by this instruction. • When this instruction is executed ,the CS & IP are unconditionally modified to a new value of CS & IP corresponding to the location transferred
  • 5. Short Jump • Short jumps are called relative jumps because they can be moved to any location in current code segment without a change • A short jump to four memory locations beyond the address of the next instruction. • The short jump instruction appears in figure below. • Example shows how short jump instructions pass control from one part of the program to another. Example jmp short next (use short directive to force short jump).
  • 6. Near Jump • The near jump is similar to the short jump, except that the distance is farther. • A near jump passes control to an instruction in the current code segment located within ±32K bytes from the near jump instruction. A near jump that adds the displacement (0002H) to contents of IP. • The near jump is a 3-byte instruction that contains an opcode followed by a signed 16-bit displacement. E.g. jmp next
  • 7. Far Jump • A far jump instruction transfer control to the target location in different code segment. This is performed by loading CS with segment address in which the target exist & IP with the offset address of a instruction to which control is to be transferred in the new code segment. • The target address loaded in CS & IP are part of the instruction itself. This is a 5 byte instruction. A far jump instruction replaces the contents of both CS and IP with 4 bytes following the opcode. E.g. jmp far ptr skip
  • 8. Conditional Jumps Instructions • The conditional jump instruction transfer control to the address specified (target location) if some condition is met or satisfied otherwise execution continues sequentially. • The condition here means the status of the condition flags. The conditional jump instructions test the following flag bits: sign(S), zero(Z), carry (C), parity(P), overflow(O). Instruction Condition Tested Comment JA C = 0 and Z = 0 Jump above JAE C = 0 Jump above or equal to JB C = 1 Jump below JBE C = 1 or Z = 1 Jump below or equal to JC C=1 Jump carry set JE or JZ Z = 1 Jump equal to or jump zero JG Z = 0 and S = 0 Jump greater than JGE S = 0 Jump greater than or equal to JL S ≠ 0 Jump less than JLE Z = 1 or S ≠ 0 Jump less than or equal to JNC C = 0 Jump carry cleared JNE or JNZ Z = 0 Jump not equal to or jump not zero JNO 0 = 0 Jump no overflow JNS S = 0 Jump no sign JNP/JPO P = 0 Jump no parity/jump parity odd JO 0 = 1 Jump on overflow JP/JPE P= 1 Jump on parity/jump parity even JS S = 1 Jump on sign If the condition under test is true, a branch to the label associated with the jump instruction occurs.. If the condition is false, the next sequential instruction in the program executes. For example, a JC will jump if the carry bit is set.

Editor's Notes

  1. Controlling the program flow is a very important thing, this is where your program can make decisions according to certain conditions Program control instructions change or modify the flow of a program.i.e. transfers control from the normal sequential execution to the specified destination or target instruction. There are two type of program control instructions Unconditional - The JMP instruction transfers control unconditionally (independent of any condition)to another instruction.  Conditional Jump Instructions: Transfers the program sequence to the described memory address only if the condition in satisfied. Branches to a lable when specific flags condition are met  JMP is able to transfer control both forward and backward
  2. Control will go to the given address in any condition. Address for the jump instruction can be either sort, near or far After the jump the program will execute instructions at the jump label and will not return. Program instructions will not return to the next sequential instruction after the jup Near jump: a near jump passes control to an instruction in the current code segment located within +-32Kbytes from the near jump instruction Short jump address of the target must be within -128 to +127 bytes of the current IP Far address may be with in the same segment or in another segment
  3. Short jumps are called relative jumps because they can be moved to any location in current code segment without a change. This is because the jump address is not stored with the opcode. Instead of a jump address, a distance or displacement follows the opcode. The short jump displacement is a distance represented by a 1-byte signed number whose value ranges between +127 and -128. When the microprocessor executes a short jump, the displacement is sign extended and added to the instruction pointer (IP/EIP) to generate the jump address within the current code segment. The short jump instruction branches to this new address for the next instruction in the program;