6502 Carry Flag

Basic and Machine Language

Moderator: Moderators

wimoos
Vic 20 Afficionado
Posts: 348
Joined: Tue Apr 14, 2009 8:15 am
Website: http://wimbasic.webs.com
Location: Netherlands
Occupation: farmer

Re: 6502 Carry Flag

Post 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.
VICE; selfwritten 65asmgen; tasm; maintainer of WimBasic
User avatar
chysn
Vic 20 Scientist
Posts: 1205
Joined: Tue Oct 22, 2019 12:36 pm
Website: http://www.beigemaze.com
Location: Michigan, USA
Occupation: Software Dev Manager

Re: 6502 Carry Flag

Post 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
Post Reply