Page 2 of 2

Re: 6502 Carry Flag

Posted: Mon Nov 16, 2020 2:00 am
by wimoos
chysn wrote: Sun Nov 15, 2020 2:25 pm For some reason--don't ask me why because I don't know--I woke up this morning with the question, "What's the most efficient way to invert the Carry Flag?" That is, set it when it's unset and unset it when it's set. I did not wake up with any practical uses for inverting the Carry Flag, only the question.
I came across this situation while optimizing ExBasic to WimBasic. In ExBasic the EOR solution was applied.
I can tell you, in WimBasic it's no longer in there. It is an expensive way to patch something that should be redesigned elsewhere, was my conclusion.

Re: 6502 Carry Flag

Posted: Mon Nov 16, 2020 9:31 am
by chysn
wimoos wrote: Mon Nov 16, 2020 2:00 am It is an expensive way to patch something that should be redesigned elsewhere, was my conclusion.
That's my view as well. Any Carry Flag state is ephemeral, a throw-away, and there's hardly any reason to try to hang onto it for more than a few instructions. I guess I'm suggesting that the best way to invert the Carry Flag in code is to use BCC instead of BCS. :D