HP Forums
Suggestion to extend tests for Free42 - Printable Version

+- HP Forums (https://archived.hpcalc.org/museumforum)
+-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html)
+--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html)
+--- Thread: Suggestion to extend tests for Free42 (/thread-65680.html)

Suggestion to extend tests for Free42 - Namir - 11-11-2004

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:

STO 00
STO 01
RCL 00
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 }.


Re: Suggestion to extend tests for Free42 - Thomas Okken - 11-12-2004

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.