Wang 700 Compiling

Wang 700 programs may be written in source code form and compiled using these tools. Each program must #include "wang600.h" (or "wang700.h", but not both) and also should wrap the code section in BEGIN() and END().

Use of this facility requires GNU Compiler tools, and probably Linux (unless GCC is available for your platform).

The sample Makefile targets/actions use the following program file name suffixes:

w7c
Program module not requiring pre-processing
w7h
Program header file (include) - usually defines the interface
w7e
Intermediate file already pre-processed
w7o
Object file (to be linked/loaded)
w7$
Tape image file, ready to load via tape drive
w7t
Tape image file, ready to load via tape drive
txt
Text data for Model 707 Teletype, ASCII.

Some additional special macros allow for abstraction of statement labels and extended register assignment. These are:

HW_FIXED_SR0(flabel)
Designate function 'flabel' as being assigned to "00 00", (SR 0000) which is the subroutine hard-coded by the Model 707 Teletype as the End Of Tape action. A "MARK(flabel)" must exist somewhere in the source module.

When a program is linked, a special statement label is generated followed by an END PROG code. The programmer should not place END PROG codes in the source files. Note, the END_PROG() macro produces a SEARCH(end_prog) and not an actual END PROG code.

Programming statements:

In general, these directly correspond to Wang 700 commands.

E(digit)
The codes E0 - E15 may be produced this way. This includes entering the digits 0-9 into X.
SET_EXP()
Shorthand for E(10)
CHANGE_SIGN()
Shorthand for E(11)
DP()
Decimal Point. Shorthand for E(12)
X_2()
Shorthand for E(13)
RE_RES()
Recall Residue. Shorthand for E(14)
CLR_X()
Shorthand for E(15)
ADD_DIR(longreg)
Add X to register
SUB_DIR(longreg)
Subtract X from register
MULT_DIR(longreg)
Multiply register by X
DIV_DIR(longreg)
Divide register by X
ST_DIR(longreg)
Store X in register
RE_DIR(longreg)
Recall X from register
EXCHG_DIR(longreg)
Exchange X with register
SEARCH(label)
Go To 'label'. 'label' should be declared with LABEL(), EXTERNAL(), or the F* or L* variants.
MARK(label)
Define 'label'. ('label' must be declared as above)
GROUP1(func)
I/O functions.
GROUP2(func)
I/O functions.
WRITE(func)
I/O functions, or formatted printing of display (or blanks) to OutputWriters.
WRITE_ALPHA(func)
For 2-step ALPHA commands. Use ALPHA_STRING or ALPHA_PLOT for printing characters to OutputWriters.
END_ALPHA(func)
Usually automatically generated by ALPHA_STRING or ALPHA_PLOT.
ST_Y_DIR(longreg)
Store Y in register
RE_Y_DIR(longreg)
Recall Y from register

ADD_IND(longreg)
Add X to register (Y)
SUB_IND(longreg)
Subtract X from register (Y)
MULT_IND(longreg)
Multiply register (Y) by X
DIV_IND(longreg)
Divide register (Y) by X
ST_IND(longreg)
Store X in register (Y)
RE_IND(longreg)
Recall X from register (Y)
EXCHG_IND(longreg)
Exchange X with register (Y)
SK_IF_GE()
Skip if Y ≥ X
SK_IF_LT()
Skip if Y < X
SK_IF_EQ()
Skip if Y = X
SK_IF_ERR()
Skip if Error
RETURN()
END_PROG()
SEARCH(end_prog), not actual END PROG
LOAD_PROG()
GO()
STOP()

ADD_Y()
Add X to Y
SUB_Y()
Subtract X from Y
MULT_Y()
Multiply Y by X
DIV_Y()
Divide Y by X
ST_Y()
Store X into Y
RE_Y()
Recall Y into X
EXCHG_Y()
Exchange X and Y
ABS()
Absolute value of X
INT()
Integer value of X
PI()
π in X
LOG_10_X()
Base-10 Log of X
LOG_E_X()
Natural Log of X
SQRT()
Square Root of X
E10_X()
Base-10 Exponent of X
E_X()
Natural Exponent of X
INV()
1/X

ADD_DIR100(longreg)
Add X to register+100
SUB_DIR100(longreg)
Subtract X from register+100
MULT_DIR100(longreg)
Multiply register+100 by X
DIV_DIR100(longreg)
Divide register+100 by X
ST_DIR100(longreg)
Store X in register+100
RE_DIR100(longreg)
Recall X from register+100
EXCHG_DIR100(longreg)
Exchange X with register+100
ST_Y_DIR100(longreg)
Store Y in register+100
RE_Y_DIR100(longreg)
Recall Y from register+100

Some helpful shorthands for WRITE_ALPHA commands:

POW10(n)
Multiply X by 10n
POW_10(n)
Divide X by 10n
SK_IF_YP()
Skip if Y is Positive
SK_IF_Y0()
Skip if Y is Zero
SK_IF_YM()
Skip if Y is Negative (Minus)
SK_IF_YN0()
Skip if Y is Not Zero
SK_IF_XP()
Skip if X is Positive
SK_IF_X0()
Skip if X is Zero
SK_IF_XM()
Skip if X is Negative (Minus)
SK_IF_XN0()
Skip if X is Not Zero
PAUSE()
Approximately 3/4 second pause
D180PI()
180/π to X
DPI180()
π/180 to X

Memory Layout:

Program memory is used as follows:

RegistersStepsUse
247...0000... Program steps from main and linked modules In tape image
Multiple of
2 registers
Multiples of
16 steps
Initialized registers (aligned as required) from *IREG_DATA()
Consumes
2 registers
Consumes
16 steps
END_PROG postample
Multiple of
2 registers
Multiples of
16 steps
Uninitialized registers (aligned as required) from *UREG() Not in tape image
  ...0    ...1983 (unused program steps - might have been assigned with RES_REG())

Utilities

The following utilities are provided, both for building program images and for general use:

w7lst
List a program image, similar to the built-in list function on the buildt-in drum printer.

Example: w7lst foo.w7t

w7verify
Compute the VERIFY PROG value, using the same method as the VERIFY PROG function on the calculator. This allows computing the VERIFY PROG value without actually loading the image on the calculator (simulator).

Example: w7verify foo.w7t

w7cpp
The preprocessor (not to be confused with, and in addition to, the "C" preprocessor included with the GNU tools).

Synopsis: w7cpp <in-file >out-file

symbols2labels
Shell script to convert output from FORDERED() directives into linkers scripts and function label file. Produces the two linker scripts (fnordering1.ld and fnordering2.ld) in the current directory.

Synopsis: symbols2labels base-name 700 >label-file