The HP-42S is
keystroke-programmable, meaning that it can remember and later execute sequences of keystrokes to solve particular problems of interest to the user. The HP-42S uses a superset of the
HP-41CX FOCAL language. All programs are stored in one continuous program space, and may be created and edited by switching to programming mode, using the key. Subroutines are enclosed in /Label (name of subroutine) and /Return (halts execution unless it is in a subroutine in which case it returns to the caller). Keystrokes (of functions) are enclosed between and or . In a running program, a
label causes program execution to branch to the specified label and continue running at that line. Executing a GTO instruction from the keyboard moves the program pointer to the corresponding label. No program lines are executed. is used in much the same way with one important difference: after an instruction has transferred execution to the specified label, the next RTN (return) or END instruction causes the program to branch back to the instruction that immediately follows the XEQ instruction. Programs/Subroutines can also be executed with the help
label (Execute) key. The important difference between the and is that executes the label and returns to previous subroutine and continues execution from the line following ,whereas branches to the label specified and doesn't return. packs the current subroutines and moves to new program space.
nnnn can be used to reach a particular line of program.
Programming examples A simple program to calculate area of circle Program instructions like , , halt the program execution,which can be continued by pressing . is used to view contents of a register,For example R in the above example.
Using Integral and Equation Solver It is necessary to write a program or subroutine that evaluates f(x) for the function which needs to be solved or integrated. Variables used in program should be declared using Here is a sample program to solve the equation °F = (9/5×°C) + 32 After, accessing the solver using ( ), select program . In a similar way, expressions can be integrated. After selecting the variable of integration, enter the lower limit and then press on , similarly input (upper limit) and (accuracy). ==Emulators==