ProCalc++ Programming Tips

Before starting, a few concepts ...

Programming ProCalc++ is as easy as entering function keystrokes on the program editor.

You enter and leave the program editor with the PROG key, and scroll up and down with the RDOWN AND RUP keys. To enter a commmand in the current insert point just type it, and to delete the currently selected command, press the BACK key (the one with the back arrow).

Once your program is written down, you can execute it with the R/S (RUN/STOP) key. If it is taking too long due to some error, you can quit it with the same R/S key.

Program Banks

In ProCalc++ you can store 16 simultaneous programs, named 0,1,2...,A,B,C,D,E,F. :)

You can select the current program bank with f+PROG (PRG BANK) and you can query for it with g+PROG (PROG BANK?).

LBL,GTO,GSB and RTN

You can use LBL (label) to identify a certain section of your program. After that, you can transfer control to it with GTO or GSB.

GTO has two forms. It can just jumps to the specified Label (with GTOL) or line number (with GTO). Pressing repeatedly the GTO key swithes between them while editing your program.

GSB is used to call a subroutine. The adddress next to the currently executing on is pushed onto the address stack (not the RPN one!) a>nd the program control is transfered to the subroutine. Whenever a RTN is found, the original pushed address is pulled from the address stack and the program control is restored to the original point, right after the GSB instruction.

The index register (I), DSZ and ISZ

The index register (I) whose value can be stored with STOI and recalled with RCLI has two main uses.

First, it can be used to indirectly access any of the 256 memory registers, via STO[i] and RCL[i].

Second, it can be used to control loops, together with the instructions DSZ and ISZ

DSZ decreases the current value stored on the I register by one, and then compares it with zero. If it's equal to zero, the next instruction (usually a GTO to the start of the loop) is skipped.

ISZ increases the current value stored on the I register and then compares it with zero. If it's equal to zero, the next instruction is skipped.

Some examples

Factorial Function

This first example shows how to program a factorial function on ProCalc++.

It uses the Index register to keep track of the number to multiply, which gets decreased in a loop with DSZ, which also is used to test the exit condition (I=0.)

      000   addr  {16 bytes}
      001   000   STOi
      002   001   LBL 1
      003   002   DSZ
      004   003   GTOL 2
      005   006   GTOL 3
      006   009   LBL 2
      007   00A   RCLi
      008   00B   *
      009   00C   GTOL 1
      010   00F   LBL3
      011         .END.
    

Some more examples will follow :)