HP Forums
FC?C and FS?C usefulness - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: General Forum (/forum-4.html)
+--- Thread: FC?C and FS?C usefulness (/thread-17715.html)



FC?C and FS?C usefulness - JoJo1973 - 11-16-2021 10:14 PM

A couple questions for the gurus:

1) what's the usefulness of the FC?C and FS?C apart from their obvious meaning? Is there some neat trick they can be used to accomplish?
2) why aren't there their counterparts FC?S and FS?S ?


RE: FC?C and FS?C usefulness - Paul Dale - 11-16-2021 10:37 PM

These instructions let you test a flag and then clear it. The alternative would be code like:

Code:
FS? 0
GTO 00
CF 0
...
LBL 00
CF 0
...

I.e. they save steps and simplify understanding the logic.


The WP 34S introduced the extra flavours and more.


Pauli


RE: FC?C and FS?C usefulness - JoJo1973 - 11-16-2021 10:49 PM

Thanks Pauli, I didn't realize that the instructions originate from RPN so I haven't specified that I was referring to RPL language.

I can see why they're useful in RPN context but their utility in RPL escapes me, since at user level the conditionals don't follow the skip-if-true logic.

And then, why no FC?S and FS?S ? It's evident that whoever proposed these commands gave greater importance to flags being cleared than set... probably the reason is obvious to those versed in RPN, but I'm not one of the lot!


RE: FC?C and FS?C usefulness - JoJo1973 - 11-16-2021 10:54 PM

(11-16-2021 10:49 PM)JoJo1973 Wrote:  Thanks Pauli, I didn't realize that the instructions originate from RPN so I haven't specified that I was referring to RPL language.

I can see why they're useful in RPN context but their utility in RPL escapes me, since at user level the conditionals don't follow the skip-if-true logic.

And then, why no FC?S and FS?S ? It's evident that whoever proposed these commands gave greater importance to flags being cleared than set... probably the reason is obvious to those versed in RPN, but I'm not one of the lot!

Hmmm, now that I think about it maybe they're useful if you're testing an exception flag...


RE: FC?C and FS?C usefulness - Sylvain Cote - 11-17-2021 02:51 AM

(11-16-2021 10:14 PM)JoJo1973 Wrote:  1) what's the usefulness of the FC?C and FS?C apart from their obvious meaning?
... Is there some neat trick they can be used to accomplish?
These are great for error handling.

FOCAL example:
Code:
...
SF 25     // set "Ignore Error" flag
/         // do something that can produce an error, here a division by zero
FS?C 25   // did we had an error ? ... and reset "Ignore Error" flag for next operations
GTO 01    // no error, branch to the success code
...       // handle error
LBL 01    // success code
...

(11-16-2021 10:14 PM)JoJo1973 Wrote:  2) why aren't there their counterparts FC?S and FS?S ?
There was no more space left in the ROMs or in the functions tables I would assume.

Edit: Doh! I should have know better, they had 256 entries in the functions table.
Half of them are 1 byte functions and the rest are 2 and 3 bytes functions, labels and text.
So they had to make a choice about what functions to keep and what functions to leave out.
Most of the missing test functions can be simulated with the others.

SYNTHETIX Card: SIDE #1 & SIDE #2

Missing from FOCAL:
Code:
X>=0?
Simulated with
Code:
X<0?
X=0?
Example: flag 00 is set if test is successfull and clear if test fail
Code:
LBL "X>=0?"
CF 00
X<0?
X=0?
SF 00
RTN

Sylvain


RE: FC?C and FS?C usefulness - Werner - 11-17-2021 07:48 AM

Imagine you want to toggle a flag.
Without these functions, that would look like

Code:
FS? 00
GTO 00
SF 00
GTO 01
LBL 00
CF 00
LBL 01

instead of simply

Code:
FC?C 00
SF 00

I never missed the FC?S and FS?S counterparts - you just switch the flag meaning and you can use FC?C and FS?C..

(11-16-2021 10:37 PM)Paul Dale Wrote:  
Code:
FS? 0
GTO 00
CF 0
...
LBL 00
CF 0
...

The first CF 0 is not needed ;-)

Cheers, Werner