Control flow in assembly allows conditional execution of code based on comparisons or unconditional jumps to other parts of the program.
jmp
: Unconditional jump to a label.je
: Jump if equal (zero flag is set).jne
: Jump if not equal (zero flag is not set).jg
: Jump if greater (sign and zero flags are clear).jl
: Jump if less (sign flag is set).loop
: Decrement rcx
and jump if rcx
is not zero.section .text global _start _start: jmp skip ; Jump to label "skip" mov rax, 1 ; This line is skipped skip: mov rax, 2 ; Execution continues here
section .text global _start _start: mov rax, 10 ; Load 10 into rax cmp rax, 5 ; Compare rax with 5 jg greater ; Jump if greater mov rbx, 0 ; This line executes if rax <= 5 jmp done greater: mov rbx, 1 ; This line executes if rax > 5 done:
In this example, the program checks whether rax
is greater than 5 and jumps accordingly.