0% found this document useful (0 votes)
21 views

Week5 L2 Chap6 Jump Instructions

Uploaded by

ishitasabrin.cse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Week5 L2 Chap6 Jump Instructions

Uploaded by

ishitasabrin.cse
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Chap-6

Flow Control
Instructions Part-1
Jump Instructions
1
Prepared by
Ahmed Al Marouf
Lecturer, Dept. of
CSE
Daffodil
International
University
2 Outline

🠶 Jump Instruction
🠶 Types of Jumps
🠶 Unconditional Jump
🠶 Conditional Jumps
🠶 Signed jumps
🠶 Unsigned jumps
🠶 Single Flag jumps

🠶 Compare (CMP)
Instruction
🠶 Examples
🠶 Execises
3 Jump Instructions

🠶 For assembly language programs to carry out useful


tasks, there must be a way to make decisions and
repeat sections of code.
🠶 Jump Instructions can help in this regard.
🠶 The jump and loop instructions transfer control to
another part of the program.
🠶 To control the general flow of the instructions,
jump instructions are used.
4 Types of Jump Instructions

Unconditional Signed
Jump jump
Jump
Instruction Unsigned
Conditional jump
Jump

Single
Flag
jump
5 Unconditional Jump
🠶 The JMP instruction causes an unconditional transfer of control.
🠶 As the name suggests, no condition is needed to jump to the
mentioned
destination label.
🠶 JMP
Syntax: destination_label
🠶 Here, the destination is usually a label in the same segment as the JMP
itself.
🠶 Example:
MOV AX, 5
MOV BX, 3
JMP L1
MOV BX,
1
L1: MOV
BX, 4
6 Conditional
Jumps
🠶 The syntax of conditional jump is:

Jxxx destination_label
🠶 If the condition for the jump is true, the next instruction to be
executed is the one at destination_label, which may precede or follow
the jump instructions itself.
🠶 If the condition is false, the instruction immediately following the jump
is done next.
🠶 Range of a Conditional Jump:
🠶 The structure of the machine code of a conditional jump requires that
destination_label must precede the jump instruction by no more that 126
bytes, or follow it by no more than 127 bytes.
7 Conditional Jump Example
Instruction ; general instruction
1 ; general instruction
Instruction ; general instruction
2
; general instructions
Instruction continues
3
CMP AX, BX ; general instructions
……………. continues
Jxxx L1
……………. ; Compare instruction
Instruction 7
; Conditional Jump
Instruction 8
If the condition If condition is true, it
is false, it will L1: MOV AX,
0 will
jump to the jump to “L1: MOV Ax,
next line. ……………
0”
……………
……………..
8 How CPU implements
a Conditional Jump
🠶 To implement a conditional jump, the CPU looks at the Flag registers.
🠶 You already know that flag register reflects the result of the last thing
the processor did. (In chapter 5)

🠶 If the conditions for the jump (expressed as a combination of status flag


settings) are true; the CPU adjusts the IP to point to the destination label,
so that the instruction at this label will be done next.
🠶 If the jump condition is false, then IP is not altered; this means the
next instruction in line will be done.
9 Types of Conditional
Jumps
🠶There are three category:
🠶Signed Jumps:
🠶 Us ed when a signed interpretation is being given to
results
🠶Unsigned Jumps:
🠶 Us ed for an unsigned interpretation
🠶Single-Flag Jumps:
🠶Operates on settings of individual flags.

Note: Jump instructions does not effects on


flags.
1 Signed
0
Jumps
1 Unsigned
1
Jumps
1 Single-Flag
2
Jumps
1 Conditional Jump
3
Examples
1
4

Thank
You

You might also like