But this takes 12 bytes (I could do better with BCS/BCC instead of JMP) and (worse) up to 8 cycles between CMP and ROR. What I was hoping to find was a "magical trick" to do it in a single instruction (with some SBC for instance?), which would then be:

which would save the BCS cycle time, and takes 7 or 8 bytes instead of 12.
I was thinking, instead of CMP, using two consecutive SBC instructions (the accmuluator can be altered, no problem)
SBC #A4 (will set C)
SBC something (to try and reverse C)
but I'm in a hurry right now so no time to check this carefully !

I don't have the cycle count, it maybe counter productive. If the content of A doesn't matter you can remove the PHA/PLA.

Edit: added cycles counts;
23 cycles counting saving A, 16 without (I'm counting the CMP and ROR operation without them it 15 / 8
By the way, dbug maybe my source is wrong, but it says pushing to the stack is 3 cycles, pop-ing is 4..

=> this affects A in some cases (not important). 5B is FF-A4.
What do you guys think?

Now I'm going to look at your solutions (yes, I'm slow, still not very familiar with ASM).

EDIT: sorry I'm not very familiar with ASM syntax (I code in machine code directly !), and I notice I have probably confused some of you with #A4, which is actually the VALUE #A4, not the content of the memory in #A4. So I should probably have writtent somthing like #$A4 ?

Symoon wrote:EDIT: sorry I'm not very familiar with ASM syntax (I code in machine code directly !), and I notice I have probably confused some of you with #A4, which is actually the VALUE #A4, not the content of the memory in #A4. So I should probably have writtent somthing like #$A4 ?

Sorry it's me, reading code while not beeing fully waked mean reading incorrect things, I think I read $A4 instead of #A4, which is incorect in most assembler, but is clear that you want immediate value and not zero page based.

Still trying to find if the double SBC is OK - seems to be the shortest way (in time) to do it.
It seems that when the result of the 1st SBC is done (replacing the CMP), the 2nd SBC inverts C correctly - but this is strictly theoretical.

Edit: too bad, actually I'm not sure C is always =1 before the 1st SBC. So this method is not 100% correct. Sh*t

Indeed!
Thanks for your help guys, sorry I didn't come back on this in detail but it certainly helped me carrying on the project I'm focued on. Significant progress but the hardest part is there:
- complicated code and (very) complicated testing to finish
- back to work soon so no more spare time again...