Optimizing your source code from ST News v5.2
@DrWatson
Published in
atari
· 1 year ago
... 0 loop MOVE.W (A0)+,(A1) 12 LEA 160(A1),A1 8 DBRA D0,loop RTS A few remarks. As you can see, I use LEA DATA(PC),A0 instead of the more obvious MOVE.L #DATA,A0. Simple, LEA is faster. Also, I use MOVEQ wherever possible. And I used LEA 160(A1),A1 instead of ADD.W #160,A1. Faster again. But the real trick is in the DBRA. If you take a clockcycle sheet, you will see that DBRA takes 10 cycles if the branch is taken and 12 if it isn't. So that makes 15*10+12=162 cycles. Plus the 320 cycles of the other instructions, the whole loop will take 482 cycles. Imagine loosing the DBRA and the LEA instruction, saving 18 cycles per loop. Just repeat the MOVE ...