SlideShare a Scribd company logo
Computer Organization and
Assembly Language
Lecture # 12
Conditional Control Flow Directives
 In 32-bit mode, MASM includes a number
of high-level conditional control flow
directives that help to simplify the coding
of conditional statements.
 These directives cannot be used in 64-bit
mode.
Creating IF Statements
 The .IF, .ELSE, .ELSEIF, and .ENDIF
directives are used for conditional jump.
 They cause the assembler to generate
CMP and conditional jump instructions in
the background.
syntax
.IF condition1
statements
[.ELSEIF condition2
statements ]
[.ELSE
statements ]
.ENDIF
Example
mov eax,6
.IF eax > val1
mov result,1
.ENDIF
Example contd.
 When the assembler reads the foregoing
lines, it expands them into the following
assembly language instructions
mov eax,6
cmp eax,val1
jbe @C0001
mov result,1
@C0001:
 The label name @C0001 was created by
the assembler.This is done in a way that
guarantees that all labels within same
procedure are unique.
Comparing Registers
mov eax,6
mov ebx,val2
.IF eax > ebx
mov result,1
.ENDIF
Compound Expressions
 When using the .IF directive, the || symbol
is the logical OR operator:
.IF expression1 || expression2
statements
.ENDIF
Compound Expressions contd.
 Similarly, the && symbol is the logical
AND operator:
.IF expression1 && expression2
statements
.ENDIF
Example
.data
TRUE = 1
FALSE = 0
gradeAverage WORD 275 ; test value
credits WORD 12 ; test value
OkToRegister BYTE ?
.code
mov OkToRegister,FALSE
Example contd.
.IF gradeAverage > 350
mov OkToRegister,TRUE
.ELSEIF (gradeAverage > 250) && (credits <= 16)
mov OkToRegister,TRUE
.ELSEIF (credits <= 12)
mov OkToRegister,TRUE
.ENDIF
Creating Loops with .REPEAT
and .WHILE
 The .REPEAT and .WHILE directives offer
alternatives to writing your own loops
with CMP and conditional jump
instructions.
.REPEAT
 The .REPEAT directive executes the loop
body before testing the runtime condition
following the .UNTIL directive:
.REPEAT
statements
.UNTIL condition
.WHILE
 The .WHILE directive tests the condition
before executing the loop:
.WHILE condition
statements
.ENDW
Example
.data
X DWORD 0
op1 DWORD 2 ; test data
op2 DWORD 4 ; test data
op3 DWORD 5 ; test data
.code
mov eax,op1
mov ebx,op2
mov ecx,op3
Example contd.
.WHILE eax < ebx
inc eax
.IF eax == ecx
mov X,2
.ELSE
mov X,3
.ENDIF
.ENDW

More Related Content

PPTX
Flow control instructions
PDF
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
PPTX
Flag control
PPT
1344 Alp Of 8086
PPTX
Lecture no 15
PPTX
Jump&Loop instruction
PPTX
Assembly jmp presentation
PPTX
Chapter3 program flow control instructions
Flow control instructions
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
Flag control
1344 Alp Of 8086
Lecture no 15
Jump&Loop instruction
Assembly jmp presentation
Chapter3 program flow control instructions

Similar to Conditional Flow Control Directive.pptxx (20)

PPTX
Chap3 program flow control instructions
PPT
microcontroller.ppt
PPTX
Microprocessor Week 7: Branch Instruction
PPT
Al2ed chapter8
PPTX
LECTURE_5 Program Control Instructions.pptx
PPT
Assembly Language Lecture 5
PPT
Chapt 06
PPT
Chapt 06
PPT
8086 microprocessor assembler directives.ppt
PPT
Jumps in Assembly Language.
PPT
chapt5 and 06assemblylanguagecodesandmachinelanguage.ppt
PPT
Chapter6-mikroprocessor
PPTX
Program control instructions
PPTX
Conditional jump
PPTX
Flag registers, addressing modes, instruction set
PPTX
Introduction to Microprocessor & Code
PPT
Assembly language programming_fundamentals 8086
PPTX
Introduction of 8086 micro processor .
PPTX
microprocessor presentation 8086 flags
Chap3 program flow control instructions
microcontroller.ppt
Microprocessor Week 7: Branch Instruction
Al2ed chapter8
LECTURE_5 Program Control Instructions.pptx
Assembly Language Lecture 5
Chapt 06
Chapt 06
8086 microprocessor assembler directives.ppt
Jumps in Assembly Language.
chapt5 and 06assemblylanguagecodesandmachinelanguage.ppt
Chapter6-mikroprocessor
Program control instructions
Conditional jump
Flag registers, addressing modes, instruction set
Introduction to Microprocessor & Code
Assembly language programming_fundamentals 8086
Introduction of 8086 micro processor .
microprocessor presentation 8086 flags
Ad

More from itxdevilmehar (11)

PPT
Lecture No-19.ppt lecture number 19 ppt .
PPTX
COAL-8.pptx lecture number 19 Ppt number
PPTX
Research-Ethics-ppt.pptx research ethics
PPTX
COAL-8.pptx coal assignment ppt number 2
PPTX
Procedure.lecture number pptx slide form
PPT
Management lecture number 14-3.ppt slide
PPTX
Lecture 9 (DS) - Tree, Tree Traversal.pptx
PPTX
Lecture No-14.pptx Lecture No-14.pptx xx
PPTX
Database ppt[}}.pptx database system and
PPTX
transaction management.pptx isolationand
PPT
Multimedia and ict projecg and assignmen
Lecture No-19.ppt lecture number 19 ppt .
COAL-8.pptx lecture number 19 Ppt number
Research-Ethics-ppt.pptx research ethics
COAL-8.pptx coal assignment ppt number 2
Procedure.lecture number pptx slide form
Management lecture number 14-3.ppt slide
Lecture 9 (DS) - Tree, Tree Traversal.pptx
Lecture No-14.pptx Lecture No-14.pptx xx
Database ppt[}}.pptx database system and
transaction management.pptx isolationand
Multimedia and ict projecg and assignmen
Ad

Recently uploaded (20)

PDF
22EC502-MICROCONTROLLER AND INTERFACING-8051 MICROCONTROLLER.pdf
PDF
Exploratory_Data_Analysis_Fundamentals.pdf
PDF
Abrasive, erosive and cavitation wear.pdf
PPTX
Graph Data Structures with Types, Traversals, Connectivity, and Real-Life App...
PDF
COURSE DESCRIPTOR OF SURVEYING R24 SYLLABUS
PDF
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
PPTX
Module 8- Technological and Communication Skills.pptx
PPTX
Management Information system : MIS-e-Business Systems.pptx
PPTX
Artificial Intelligence
PDF
August 2025 - Top 10 Read Articles in Network Security & Its Applications
PDF
Visual Aids for Exploratory Data Analysis.pdf
PPTX
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
PPTX
Information Storage and Retrieval Techniques Unit III
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPTX
Software Engineering and software moduleing
PDF
Soil Improvement Techniques Note - Rabbi
PDF
Design Guidelines and solutions for Plastics parts
PDF
distributed database system" (DDBS) is often used to refer to both the distri...
PDF
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
PPT
Total quality management ppt for engineering students
22EC502-MICROCONTROLLER AND INTERFACING-8051 MICROCONTROLLER.pdf
Exploratory_Data_Analysis_Fundamentals.pdf
Abrasive, erosive and cavitation wear.pdf
Graph Data Structures with Types, Traversals, Connectivity, and Real-Life App...
COURSE DESCRIPTOR OF SURVEYING R24 SYLLABUS
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
Module 8- Technological and Communication Skills.pptx
Management Information system : MIS-e-Business Systems.pptx
Artificial Intelligence
August 2025 - Top 10 Read Articles in Network Security & Its Applications
Visual Aids for Exploratory Data Analysis.pdf
6ME3A-Unit-II-Sensors and Actuators_Handouts.pptx
Information Storage and Retrieval Techniques Unit III
R24 SURVEYING LAB MANUAL for civil enggi
Software Engineering and software moduleing
Soil Improvement Techniques Note - Rabbi
Design Guidelines and solutions for Plastics parts
distributed database system" (DDBS) is often used to refer to both the distri...
Human-AI Collaboration: Balancing Agentic AI and Autonomy in Hybrid Systems
Total quality management ppt for engineering students

Conditional Flow Control Directive.pptxx