View Single Post
Old 10 November 2021, 21:41   #5
jotd
This cat is no more
 
jotd's Avatar
 
Join Date: Dec 2004
Location: FRANCE
Age: 52
Posts: 8,303
status flags are useful to save cycles. Careful with to-memory operations, as they don't set the status flags. Operations to data registers (not address) do set the status flags.

bclr #0,d0 also sets D0 value before bit is cleared. Can be useful at times. In doubt: RTFM

note: in C, x ^= 1; (in-place xclusive or) is probably faster that x = 1 - x; but optimizers can detect such patterns and change the expression to the fastest one.

@mcgeezer your snippet has issues

Code:
  addq.l #1,FRAME_COUNTER

  move.l FRAME_COUNTER,d0  ; no  "#" there!!!
  and.l #1,d0
although I'd preload the counter value in D0 to save cycles, in this case

Code:
  move.l FRAME_COUNTER,d0
  addq.l #1,d0
  move.l  D0,FRAME_COUNTER
  and.b #1,d0
and and.b does the same there you only need byte value of D0 for the rest of your code probably, instruction fetch is faster (4 bytes instead of 6) although btst #0,d0 probably beats both in terms of speed unless you need the masked value.

Last edited by jotd; 10 November 2021 at 21:50.
jotd is offline  
 
Page generated in 0.05075 seconds with 11 queries