Programming the Wang 600

Programs may be entered into the calculator memory in the "Learn", or "Learn and Print" modes. In Learn and Print mode, each program step entered will be printed. The printer must be "On" to use Learn and Print.

Each key pressed in Learn mode will be entered into the current program step, and the program step (Program Counter, or P.C.) will advance to the next step. Pressing PRIME will return to step 0000. The "Set P.C." key may be used to go directly to any program step. Press Set P.C. followed by 4 digits to select a program step. This calculator has 1848 program steps, numbered 0000 through 1847.

Listing a Program

A program may be listed by going to "List Program" mode and pressing "GO" (actually, almost any key will start the listing). The printer must be "On". The program listing will continue until an END PROG code is encountered (not printed). In addition, the calculator will stop listing every 100 steps (if you forgot to put an END PROG in your program, or your program is longer than 100 steps).

Simulator Note: A program listing may be saved to a file by using the Save menu option in the printer window. Note, a program listing cannot be loaded back into the calculator, only tape image files may be loaded.

Running a Program

A program may be run by going to "Run" mode (depressing the Run bushbutton) and pressing "GO". The display will normally be blank during program execution, however a program may use the codes "alpha STOP" (SHIFT PRINT, SHIFT GO) to pause for 0.5 second, allowing the current display contents to be seen.

Also, programs may use the STOP code (SHIFT GO) to cause the program to stop. The user must press GO to continue running the program. This technique is often used to let the user enter variables for the program. It is common to CLEAR DISPLAY before the STOP, in order to make the request for input obvious. Alternatively, a special, meaningful, value may be in the display.

A program will also stop when it encounters an END PROG code. however, the program cannot be resumed after that (only started over at beginning), as the program counter is reset to 0000.

Also note, having more than one END PROG code in a program can be a problem. Not the least of which is for the List Program mode, but also for recording programs to tape. Normally, if a program has multiple exit points they will all be branches to a single END PROG, and that is at the physical end of all program codes. (See SEARCH/MARK in Programming Techniques). In other words, there should not be any program codes after an END PROG. This also includes any extended register data that might be stored in the program. In addition, the INS and DEL functions for editing programs will depend on a single END PROG code, at the end of all valid code.

Also note that one of the extended registers has same number as the END PROG code (09 14). Accessing this register (using RECALL/STORE) in a program will confuse List Program and the tape functions (and INS/DEL). This also applies to Program Print codes, and any "two step" program code that might have 09 14 as the second code.

Debugging a Program

Programs may be traced by using the ALPHA LOGeX sequence to turn on tracing, and the ALPHA eX sequence to turn it off. These sequences may be used from the keyboard or may be embedded in programs.

Typically, the TRACE-ON sequence is keyed before pressing GO. Depending on the problem being debugged, the program may be canceled manually (pressing PRIME) or may stop on it's own. Then, the TRACE-OFF sequence is keyed to prevent accidental, unwanted, traces. The trace output is then examined to determine where the program goes off-plan. The STEP key may also be used to single-step the program while tracing.

Fine-grained debugging may require inserting steps in order to add TRACE-ON and TRACE-OFF codes. Be aware of what the presence of extra 09 14 (END PROG) codes in a program will do to the use of INS and DEL.

Replacing TRACE codes with GO codes is an easy way to temporarely change tracing, and strategically placed GO codes in a program may allow for easier adding of tracing later.

Simulator Note: On the original machine, tracing a program would often consume large amounts of paper. That is not a concern for virtual paper.