The Museum of HP Calculators

HP Forum Archive 14

[ Return to Index | Top of Index ]

Suggestion to extend tests for Free42
Message #1 Posted by Namir on 11 Nov 2004, 1:48 p.m.

Hi Thomas,

I have a suggestion regarding HP42s tests (like X=0?, x>y? and so on). How about allowing the test to execute a subsequent "BLOCK" or statement that appears after the test, if the test is true, or skip that block if teh test is flase. The block is enclose by { and }. The open brace appears right after the test.

Here is an example:

2 STO 00 0.01 STO 01 RCL 00 ABS 1 X>Y? { RCL 00 STO* 01 } <more commands here>

If the test X>Y? is true then the processor executes the block of commands (RCL 00 and STO* 01 that are in the block that appears after the test. If the tested condition is false the processor skips the block altogether. Of course a block MAY contain other tests with their own blocks, so there should be a counter to detect the appropriate }.

Namir

      
Re: Suggestion to extend tests for Free42
Message #2 Posted by Thomas Okken on 12 Nov 2004, 6:52 p.m.,
in response to message #1 by Namir

I'm not a big fan of that type of feature, I must admit. It seems like syntactic sugar that doesn't make anything easier that wasn't pretty easy to begin with.
My solution to skipping a block of instructions is usually to set aside a small number of labels for short-range forward-only jumps (so you can reuse them over and over within the same program), and then use X<=Y? GTO 00 RCL 00 STO* 01 LBL 00 (in your example; note that the sense of the test has been reversed). I think this has actually been HP recommended practice for a long time -- I seem to remember reading this in the HP-19C manual, or maybe it was the HP-41C manual? I personally think it's adequate.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall