Assembly Language Flow Control Trivial IF-THEN-ELSE in m68k Assembly


Example

; IF d0 == 10 GO TO ten, ELSE GO TO other
    CMP    #10,d0        ; compare register contents to immediate value 10
                         ; instruction affects the zero flag
    BEQ    ten           ; branch if zero flag set
other:
    ; do whatever needs to be done for d0 != 10
    BRA    afterother    ; unconditionally jump across IF case 
ten:
    ; do whatever needs to be done for d0 == 10
afterother:
    ; continue normal common program flow

Which instructions are affecting which flags, and which conditional branches (that might also be based on specific combinations of flags) are available, depends very much on your chosen CPU and should be looked up in the manuals.