Wang 700 Programming Techniques

In general, any key that can be used in Run mode may be entered into a program and used to perform the same function there. Exceptions are the keys PRIME, SET P.C., VERIFY PROG, RECORD PROG, and STEP. These all directly affect the calculator and cannot be used in a program.

Unless otherwise directed by program codes, the execution of a program continues through the steps in numerical order.

Example program: convert Fahrenheit to Celsius

Here is a simple program to convert degrees Fahrenheit to degrees Celsius. The basic formula being used is:
C = (F - 32) * 5 / 9

The program will assume that the user entered the degrees F before pressing GO. The following program will perform the conversion. Not, the "01 05" is a direct register number, and the code is entered by setting the "10" toggle switch ON (all others OFF) and pressing the 05 key. Since no other special codes are being entered in this program, the toggle switches need only be setup once and whenever the "01 05" code needs to be entered simply press the 05 key.

STORE DIRECT
01 05
3
2
- DIRECT
01 05
5
× DIRECT
01 05
9
÷ DIRECT
01 05
RECALL DIRECT
01 05
END PROG

Note, the above keys (except for END PROG) are the same ones that would be used to perform the conversion manually, using the Wang 700 as a simple calculator.

Place the calculator in Learn mode (or Learn and Print) and enter the above codes. If you used Learn and Print, or List Program after entering it, you should have the following listing on the printer:

 0000   04 04  
 000l   0l 05  
 0002   07 03  
 0003   07 02  
 0004   04 0l  
 0005   0l 05  
 0006   07 05  
 0007   04 02  
 0008   0l 05  
 0009   07 09  
 00l0   04 03  
 00ll   0l 05  
 00l2   04 05  
 00l3   0l 05  

Note, the END PROG code is not printed by the List Program function.

Now go back to Run mode, press PRIME, enter a number of degrees Fahrenheit, and press GO. You should see in the display the number converted to degrees Celsius.

This program is included with the distribution. You should be able to load it using the tape drive. It is named "celsius.w7t".

This example uses the DIRECT register access functions, however it is possible to use the X and Y display registers together in math operations, and that can simplify a program.

Changing Program execution Sequence

Branching (Goto) is accomplished with the SEARCH command. SEARCH is followed by an arbitrary code that corresponds to a previously MARK'ed step using the same code. For example, SEARCH 07 00 will cause the program to continue execution at step(s) after the MARK 07 00 in the program.

Subroutine calls are made by using codes 00 00 through 03 15, and require use of the toggle switches and keys 00 to 15. Executing one of these codes will cause a "call" (Search-and-Return) to the step MARK'ed with the same code. For example, 00 00 will make a subroutine call to MARK 00 00. A subroutine ends with a RETURN code, which causes the program to resume at the step after the call. Note, a complex subroutine may have multiple exit points, each with its own RETURN.

In addition, there are "Skip" codes that test some condition and then skip the next two program steps if that condition is true. Note, 2 programs steps is the number required for a SEARCH command. If less than 2 steps are required, the remaining may be filled with GO commands. The basic skip commands compare the X and Y display, or test the Program Error state.

SKIP
IF
ERROR
Skip the next 2 steps if the Program Error condition is true. This also clears the error condition.
SKIP
IF
Y≥X
Skip the next 2 steps if Y is greater than or equal to X
SKIP
IF
Y=X
Skip the next 2 steps if Y is equal to X
SKIP
IF
Y<X
Skip the next 2 steps if Y is less than X

There are additional jump codes:

WRITE ALPHA
GROUP2
Skip the next 2 steps if Y positive (Y ≥ 0)
WRITE ALPHA
WRITE
Skip the next 2 steps if Y zero (Y = 0)
WRITE ALPHA
SKIP IF ERROR
Skip the next 2 steps if Y negative (Y < 0)
WRITE ALPHA
RETURN
Skip the next 2 steps if Y not zero (Y ≠ 0)
WRITE ALPHA
LOG10X
Skip the next 2 steps if X positive (X ≥ 0)
WRITE ALPHA
LOGeX
Skip the next 2 steps if X zero (X = 0)
WRITE ALPHA
SET EXP
Skip the next 2 steps if X negative (X < 0)
WRITE ALPHA
CHANGE SIGN
Skip the next 2 steps if X not zero (X ≠ 0)