dbls

Decrement and branch until unsigned lower or same

Tests unsigned lower or same before deciding whether to decrement the counter and branch.

Size .w

XNZVC –––––
  • Changes no flag
  • Reads Z C

Forms

  • dbls ,

Operands

Dn
A data register, d0 to d7. More
label
A branch target, written as a label or address. The assembler calculates the relative displacement. More

If the condition is true, execution continues at the next instruction and the counter is unchanged. If it is false, the low word of the data register is decremented; the branch is taken unless that word becomes -1. The upper word is unchanged, and dbcc does not change the flags.

The suffix selects the condition. See condition codes. dbf and dbra always take the decrement path. Starting the low word at N repeats a loop body N + 1 times, up to 65,536 times when it starts at $FFFF.

* --- Loops d0+1 times (decrements THEN tests) ---
move.l #3, d0
move.l #0, d1
loop:
    addq.l #1, d1
    dbra d0, loop ; loop runs 4 times (3, 2, 1, 0)

* --- Stop early when the tested value reaches zero ---
move.l #10, d2
move.l #3, d3
loop2:
    subq.l #1, d3
    tst d3
    dbeq d2, loop2 ; Z set: stop with d3 = 0 and d2 = 8