68080 asm: Loop-based counter
This code will make a loop to count from 0 to 100.
Final result can be checked in a shell with: echo $rc
# loop counter # credits to pisklak for the code move.w #0,d0 ; set register d0 with value zero loop1 add #1,d0 ; add 1 to register d0 cmp.w #100,d0 ; compare if register dO equals 100 bne loop1 ; if not equal then branch back to 'loop1' label rts ; exit loop
We compare (cmp) register D0 and value 100. Then next instruction is 'bne' which means 'branch not equal'. This instruction 'bne' says: if the result of the cmp is 'not equality' then go to label 'loop1'. This makes us loop until D0 equals 100.