Date post: | 15-Feb-2017 |
Category: |
Engineering |
Upload: | prodip-ghosh |
View: | 258 times |
Download: | 0 times |
WELCOMETO MY
PRESENTATION
PRODIP GHOSH
Flow Control Instructions
Flow Control Instructions
Program using the different instruction :- Conditional and Unconditional Jump InstructionsCompare InstructionLoop Instruction
Conditional Jump
Syntax: Jxxx destination_label Where xxx represents the condition
If condition is true, the next instruction to be executed is the one at destination_label.
If condition is false, the instruction immediately following the jump is done next.
Conditional Jump
The destination_label must precede the jump instruction by no more than 126 bytes.
To implement a conditional jump, the CPU looks at the FLAG register (set by last instruction executed by the processor).
JMP instructions themselves do not affect flags.
Unconditional JumpSyntax:
JMP destination_labelPurpose: To Transfer control to another part of the program.
Example: MOV AX, 5 MOV BX, 2 JMP LABEL_SUB ADD AX, BX ;this instruction will never execute LABEL_SUB: SUB AX, BX
Categories of Conditional Jump
Signed Jumps: This is used when a signed interpretation is being given to result.
Symbol Description Condition for Jumps
JG/JNLE Jump if greater thanJump if not less than or equal to
ZF = 0 and SF = OF
JGE/JNL Jump if greater than or equal toJump if not less than
SF = OF
JL/JNGE Jump if less thanJump if not greater than or equal to
SF <> OF
JLE/JNG Jump if less than or equal toJump if not greater than
ZF = 1 and SF <> OF
Categories of Conditional Jump
Unsigned Jumps: This is used for an unsigned interpretation of result
Symbol Description Condition for Jumps
JA/JNBE Jump if above thanJump if not below than or equal to
ZF = 0 and CF = 0
JAE/JNB Jump if above than or equal toJump if not below than
CF = 0
JB/JNAE Jump if below thanJump if not above than or equal to
CF = 1
JBE/JNA Jump if below than or equal toJump if not above than
ZF = 1 and CF = 1
Categories of Conditional JumpSingle-Flag Jumps: Which operate on settings of individual flags.
Compare InstructionCMP (compare) instruction performs an implied subtraction of a
source operand from destination operand. Neither operand is modified. CMP destination, source
Compare Instruction maintain three condition: Destination < Source Destination = Source Destination > Source
Examples
OUTPUT
High Level Language Structures
Branching Structure IF-THEN IF-THEN-ELSE CASE
IF-THEN
IF-THEN-ELSE
CASEA case is a multiway branch structure that tests a register,
variable, or expression for particular values or range of values. The general form is as follows:
Case Expression values_1: statements_1 values_2: statements_2
………….. values_n: statements_n END_CASE
CASE Examples
High Level Language Structures
Branching with Compound Conditions AND CONDITIONS OR CONDITIONS
AND CONDITION An AND condition is true if and only if condition_1 and
condition_2 are both true. If any condition is false, then the whole thing is false.
AND CONDITION EXAMPLES
OR CONDITION
If condition_1 OR condition_2 is true then an OR conditions is true. If both conditions are false, then the whole thing is false.
OR CONDITION EXAMPLES
High Level Language Structures
Looping StructuresFOR LOOPWHILE LOOPREPEAT LOOP
LOOPING STRUCTURES
FOR LOOP Executed at least once. If CX contains 0, the loop instruction decrements CX (CX = FFFFh) To prevent this, use instruction JCXZ before the loop. ;initialize CX JCXZ SKIP TOP: ;body of the loop LOOP TOPSKIP:
Examples For Looping Structures
LOOPING STRUCTURESWHILE LOOP
WHILE condition DO ;statements
END_WHILE
WHILE LOOP checks the terminating condition at the top of the loop, so don’t forget to initialize variables.
EXAMPLES WHILE STRUCTURES
LOOPING STRUCTURES
REPEAT LOOP REPEAT
;statements UNTIL condition
First statements are executed, then the condition is checked.If true, the loop terminates; if false, control branches to the top of the loop
Examples Repeat Structures
Any Question?
ThankYou!!!