(15c)(35s)(some other RPN) Flags toggle / inverting
|
04-26-2018, 03:20 PM
(This post was last modified: 04-26-2018 03:23 PM by pinkman.)
Post: #1
|
|||
|
|||
(15c)(35s)(some other RPN) Flags toggle / inverting
I've been subject to terrible headaches while searching for the best method to toggle a flag, ie to invert it.
In any conventional language that implements booleans, the code would be : FLAG1 := NOT(FLAG1) But in RPN, there is no way to do this easily, while it would be very convenient. I tried the following four methods to toggle Flag1 (or Reg1 for the third one), each of them having pros and cons. Method 1: sacrifice another flag Desc: memorize the status of the first flag with a second one. Pros: stack or Regs unchanged, only 6 steps Cons: uses another flag Code:
Method 2: sacrifice the stack Desc: memorize the status of the flag on stack (X) Pros: preserves other flags Cons: modifies the stack, 7 steps Code:
Method 3: sacrifice a register (and the stack) Desc: use R1 to simulate a flag, with simple integers algebra Pros: also works on HP12c, only 6 steps Cons: modifies the stack, use a register, not a flag operation, assume to have R1 correctly initialized with 0 or 1 Code:
Method 4: sacrifice the labels Desc: use GTO instructions to branch Pros: preserves other flags, stack and registers, 5 steps on a 35s Cons: uses conditional branching, perfect on a 35s but consuming LBLs on a 15c Code:
What do you think? I'm sure some of you have other methods, or a favorite one. Thibault |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
(15c)(35s)(some other RPN) Flags toggle / inverting - pinkman - 04-26-2018 03:20 PM
RE: (15c)(35s)(some other RPN) Flags toggle / inverting - SlideRule - 04-26-2018, 04:02 PM
RE: (15c)(35s)(some other RPN) Flags toggle / inverting - Dieter - 04-26-2018, 05:46 PM
RE: (15c)(35s)(some other RPN) Flags toggle / inverting - Dieter - 04-26-2018, 06:21 PM
RE: (15c)(35s)(some other RPN) Flags toggle / inverting - pinkman - 04-26-2018, 09:11 PM
|
User(s) browsing this thread: 1 Guest(s)