The X?0 And X?Y Sub-Menus - HP -42S Manual

An alternative: hp-42s calculator and free42 simulator for palmos
Hide thumbs Also See for HP-42S:
Table of Contents

Advertisement

This program does nothing. It just runs until you press EXIT. By the way, to run it you can use R/S
when the calculator's "pointer" is over the program or you can use XEQ "label". In the present case
you would use XEQ "AA". The XEQ function calls a program (which must have a label) and runs it.
You can use the XEQ function both in programming mode and also out of programming mode.
When in programming mode the XEQ function is programmed, and when the program finds the XEQ
function, it changes to the given program which must finish with the RTN function. So LBL "label"
and RTN makes a kind of procedure and after the procedure is run it goes back to the previous
position. For example:
01 LBL S
02 +
03 RTN
04 LBL A
05 5
06 ENTER
07 7
08 XEQ S
09 1
10
11 .END.
This program called "A" creates a procedure "S" which does only a simple addition. In the line 07
the XEQ "S" makes the program to go to the procedure "S" and after that it goes back to the line
next line 07 which is of course the line 08. The calculation is 5+7-1 which gives 11.
You can use programmed GTO and XEQ even to call a label in another program space but this is
not exactly a good use.

6.3 The X?0 and X?Y sub-menus

Up to now we saw nothing about how we could do a IF instruction, like what we have in computer
programming languages like BASIC, Pascal or C. In fact there is no IF, THEN, ELSE, ELSEIF, etc in
the HP-42S programming language but there are 12 test functions which are:
X=0? X≠0? X<0? X>0? X≤0? X≥0?
and
X=Y? X≠Y? X<Y? X>Y? X≤Y? X≥Y?
The first group of functions involving the number 0 is accessed by the X?0 sub-menu which is
available in the second line of the
menu also in the second line of the
How do these functions work? Let's consider the first function "X=0?". If the number in the x register
of the stack is zero then the program works normally and it goes to the next line after the "X=0?"
instruction. But if the condition is not true then the program jumps the next line and goes to the
second line after the instruction. Usually the line after the instruction has a GTO "label" command
and this makes the difference in the program flow.
All the other functions involving the 0 work in the same way. If the condition is true the program
works normally and if not the program jumps one line. The X?Y functions work in the same way but
now the condition is about the registers x and y of the stack and not only about register x.
PGN.FCN
menu. The second group is accessed by the X?Y sub-
PGN.FCN
menu.

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

42sFree42

Table of Contents