Programming "AND" of two flags in the non RPL machines



how to program an "AND" of two flags? I can come up only with

FS? 0
FS? 1

Is there a better way?

Thanks, Peter.


Slightly smaller is:

FS? 0
IP ; Integer part
FS? 1
FP ; Fractional part

- Pauli


Hi, Peter:

Peter asked:

    "How to program an "AND" of two flags? I can come up only with [... (a 7-step solution) ...] Is there a better way?

      If your program is intended to run in an HP-41C/CV/CX, an HP42S, or some suitably compatible model or emulation, and you don't care for the status of flag 00 (or 01) after the test, I can come up with a 3-step solution, namely:
          FC? 01
      CF 00
      FS? 00

      You can exchange flag 00 for flag 01 in the above solution if you can't afford clearing flag 00 but don't mind clearing flag 01 instead.

      Also, not only is my solution shorter, but significantly faster as well and the cherry on top is that it also preserves the whole RPN stack, LASTX included.

Best regards from V.

Edited: 23 Aug 2007, 9:10 a.m. after one or more responses were posted


I guess I not understand something. What is flag checking?


Hi Vincze.

If you question arises from the "FC" or "CF" acronyms, then they stand for "Flag Clear" and "Clear Flag" respectively.

"Clearing" a flag basically means "unsetting" it (i.e., setting its value to "0");

"Setting" a flag, obviously, means the opposite ;-)

"Flag checking" is just the checking for the flag status (set/clear).

If you mean "what is this strange mess with flags?", then very synthetically: many functions and settings of HP calcs

(at least of the most recent and powerful ones) are customizable by means of those "flag settings", which "set" the "operational environment" of the calc itself.

Hope my humble explanation was not more confusing to you ;-)

Best regards.

Edited: 23 Aug 2007, 9:20 a.m.


I guess I more interested in what is flag setting all about. I know of 15C, there is flag setting to enter complex mode. But on 35s, I not understand when book says flags 0 - 4 mean whatever you want them to mean. Is it like it store boolean value for later use?


Exactly. Flags are just boolean values. On the 35s, flags 0-4 happen to have their state displayed in the annunciator area, which makes them useful to visually indicate some sort of status. Some flags are also used to control settings of the calculator, such as setting flag 10 to inhibit equation evaluation.



Another solution that preserves the stack and LASTx uses a third flag. So if you're testing flags 0 and 1, the following will set flag 2 to the AND of flags 0 and 1, and then test the result:

SF 2
FC? 0
CF 2
FC? 1
CF 2
FS? 2

Likewise, the following does OR:

CF 2
FS? 0
SF 2
FS? 1
SF 2
FS? 2

Alternatively, if all you're interested in is branching somewhere if the AND is true, you could write:

FC? 0
FC? 1
...stuff to do if flags 0 and 1 are set

...stuff to do if one or both of flags 0 and 1 are not set



Had one only FC? on the 3Xs machines... (where X=2,3,5).

Thanks for these answers! Learnt something for today and should go home.

Cheers, Peter.

Possibly Related Threads...
Thread Author Replies Views Last Post
  Writing RPL programs on OS X Sean Freeman 18 1,887 11-30-2013, 03:59 PM
Last Post: Sean Freeman
  48G vs 49G+ User RPL Speed Comparison John Colvin 7 838 11-16-2013, 10:07 PM
Last Post: Han
  RPL 32 David Hayden 4 708 11-11-2013, 11:34 AM
Last Post: David Hayden
  HHC / HP Museum Programming Contest for RPN and RPL machines Gene Wright 18 1,767 09-22-2013, 09:39 AM
Last Post: Miguel Toro
  RPN on other machines Palmer O. Hanson, Jr. 4 537 04-10-2013, 11:23 AM
Last Post: Palmer O. Hanson, Jr.
  RPL long vs. short names peacecalc 5 723 10-30-2012, 01:25 PM
Last Post: peacecalc
  Mini-challenge: HHC2012 RPL programming contest with larger input David Hayden 14 1,455 10-05-2012, 10:36 PM
Last Post: David Hayden
  HHC 2012 RPL Programming Contest Gene Wright 33 2,732 09-27-2012, 01:57 AM
Last Post: Werner
  HHC 2012 programming contests coming soon (RPN and RPL) Gene Wright 9 1,032 09-21-2012, 03:38 PM
Last Post: Paul Dale
  RPL prog for Fibonacci on HP 48G needs minor modification. help. wildpig 68 4,443 07-09-2012, 09:38 AM
Last Post: Gilles Carpentier

Forum Jump: