Lect 3 FNL
Lect 3 FNL
• MOV CX, 1
• JMP EndIf
• Lahore:
• MOV CX, 0
• EndIf:
Simple IF-ELSE Example
• MOV AL, 10
• MOV BL, 5
• CMP AL, BL
• JG Greater
• MOV CL, 0
• JMP EndIf
• Greater:
• MOV CL, 1
• EndIf:
Introduction to Loops
• Repeat a block of code multiple times.
• Methods:
• - Using LOOP instruction
• - Using Counter and Conditional Jumps
LOOP Instruction
• Syntax:
• MOV CX, count
• Label:
• ; Code
• LOOP Label
• Each LOOP:
• - Decrements CX
• - Jumps to Label if CX != 0
Simple LOOP Example
• MOV CX, 5
• PrintStar:
• ; Print '*'
• LOOP PrintStar
Loop Using Jumps Example
• MOV CX, 3
• Label:
• ; Do Something
• DEC CX
• JNZ Label
Summary
• Assembly uses CMP and Jumps instead of
direct IF-ELSE.
• Loops use LOOP or manual decrement + jump.
• Practice is key to mastering flow control.
Tips for 8086 Emulator
• - Step-by-step run (Trace)
• - Watch Registers and Flags
• - Set Breakpoints to debug
Thank You!
• Practice small examples.
• Visualize with Flowcharts.
• Questions?