Digital PDFs
Documents
Guest
Register
Log In
XX-9C54D-00
October 1978
84 pages
Original
3.4MB
view
download
Document:
UW FOCAL Manual V4E
Order Number:
XX-9C54D-00
Revision:
Pages:
84
Original Filename:
http://bitsavers.org/pdf/dec/pdp8/focal/UW_FOCAL_Manual_V4E_Oct78.pdf
OCR Text
UWFU\vFU WFU~vFUW UWFUWFU WFU~iFU\-J FU~vFU~.. F FUWFU\vF UWFUV;FU U\-JFU\~FU WFUWFU\-J WFUWFUW FUh'FUWF FUWFUWF UWFUWFU UWFUWFU WFUWFUW WFUWFUW FUWFUWF FUWFUWF UWFUWFU UWFUWFU WFUWFUW WFUWFUW FUWFUWF FUWFUWF UWFUWFU UWFUWFU WFUWFUW WFUWFUW FUWFUWFW WFUWFUWF UWFUWFUWFUWFUWFUWFUWFUWFU FUWFUWFUWFUWFUWFUWFUWFU WFUWFUWFUWFUWFUWFUWFU UWFUWFUwFUWFU U.vFU\-lFU WFUWFUW FUWFU\~F UWFU\-lFU· WFUWFUW FUWFU\vF UWFUWFU WFUWFUW FtJ\.vFU\vF UWFUWFU WFUWFUW FUWFU\vF UWFUWFU U ·U\vFU\~FU WFUWFUW UWF WFUWFUW FUWFUWF UWFUF FUWFUWF UWFUWFU WWFUWFU UWFUWFU WFUWFUW UWFUWFUWF WFUWFUW FUWFUWFUWFUWFUWFUWFUWFUWF UWFU\vFUWFUWFU\~FUWFU~'iFU~.. FU WFUWFUWFUWFU FUWFUWFUWFUW FUVJFU~'VFUWFU WFU\-JFU\vFUWF UWFUWFUWFU UWFUWFUWFU WFUWFUNFU Fu\~FU~vFUW FUWFU~vFU WFU\oJFUWF UWFUWFU UWFUWFU UWFUWFUWFUWFUWFUWFUWFUWF FU\'iF UwFU~ F U WFUWFU\iFUWFU~~ FtrwFUWFU~vFU~'~ FU,·IFU\.., FU~·j F(j,~ UWFUWFUWFUWFUWFUWFUriFUWF WFU\'JFUW FUwF{fwF UWFUWFU WFUWFUW FUWFUWFUWFUWFUWFUW UW FU~'J F ow FU\-JF U~-J PUW F WFUWFUWFUWFUWFUWFU FUWFUWFUWFOWFU\'JFUW UWFUWFU WFUWFUW . FUWFUWF U\'lFUWFU WFUwFUW FUWFUWF UWFUWFU INDEX TO MAJOR TOPICS IN THIS MANUAL Pages Abbreviations -12 Arithmetic operators 10-11 Break Key 4 Character Codes • 74 4,16 Control Keys Commands 14-50 53 Summary Direct, Indi rect 5 - ASK BREAK 19-25 41 COMMENT • 42 DO 29-30 ERASE FOR _ 15 37-39 GOTO 29 HESITATE 42 II IF 31-32 JUMP 33-34 KONTROL • -- LINK LOOK 49-50 34-35 18 MODIFY/MOVE 15-17 NEXT 39-41 ON 32 44-48 OPEN PUNCH QUIT RETURN SET _ • .. 43 ~ .. 35-36 31 26-27 TYPE 19-24 WRITE 14 XECUTE 28 ·YNCREMENT 28 ZERO 27 Editing • 13 Enclosures 12 Error Messages Formatting 51,75 21-22 • functions 55-73 Summary • Program Defined fABS 73 · 66-72 58 57 FATN 63-64 FBUF, FCOM FCOS 56-57 • FOIN 65 fEXP 56 FIN 61 FIND 62 F ITR 59 FLOG 56 FMIN, FMAX 60 FMQ 64 • 61-62 FOUl fRAC 59 • FRAN 60 • 58 FSGN fSIN 5~-57 • FSQT • • • fSR 58 • • FTRM • • • • 63 • Input echo 46-47 .. Input terminators I/O operators Patches 25 19~23· Line numbers Loops Numbers 64 • • 5-6 • 31 . . .7 76 . Punctuation Reading in programs Symbol table dump Trace feature Variables ,- · · • • • ·.7 43,,45 . ':'··20 .. . - ' 52-'5-3· • • • '_ &-~10 INTRODUCTION to U/W-FOCAL for the PDP/8 UWF is a powerful, interactive, language for the PDP/B* which combines ease of use with an extensive set of features, allowing one to perform complex calculations or control laboratory experiments with a minimum of effort. UWF is an advanced version of FOCAL*, a stack processing language which is somewhat similar to BASIC and FORTRAN, but much easier to use! Programmers who are familiar with either of these languages should be able to write programs for UWF almost immediately, who are just learning will find that while those UWF's simplified commands and built-in editor make their progress very rapid. HARDWARE REQUIREMENTS The minimum system configuration for running UWF is an 8K machine executing the POP8* instruction set, and some sort of terminal. capable of UwF will automati- cally take advantage of any additional memory present as well as permitting the use of high-speed I/O devices such as punched paper tape or an audio tape recorcer for program and data storage. There is also a much more elaborate version available for systems l ;censed to use the OS/8* operating system which provides compLete dev-ice- independent file support. ~fOCAL, POP8 and OS/8 are trademarks of Digital Equipment Corp., Maynard, Mass. LOADING UWF To load the binary tape containing UWf into your machine proceed as follows: 1) Make sure that the BIN loader is r"esident in Fie ld O. 2) Set the Switch Register to 7777 and hit 'ADDR LOAD', then reset Switch 0 if input is from the High Speed reader (leaving 3777), otherwise go to the next step. 3) Place the tape in the reader so that the read-head is positioned over the leader section and hit the 'START' (or 'CLEAR' and 'CONTINUE') switches~ UWf-=1 . The run light will go off when the tape has finished loading; check to be sure the display is zero, indicating a successful load. If not, to see if you get the same checksum error each time. repeat steps 1-3 above If you do, the tape you are using has probably been damaged and you should try again with another copy. STARTING THE PROGRAM In order to start UWF for the first time, do the following: 1) Set the Switch Register to 0100 2) Press the 'ADDR LOAD' and 'EXTD. ADDR LOAD' switches 3) Set switches 0-2 and 6-11 for any options desired (v.i.) Now set the 'RUN/HALT' switch to RUN, and hit 'CO~TINUE' 4) (UWF's Starting Address) UWF should respond immediate~y with a congratulatory message and indicate amount of memory available in your system. For installations with the more than 8K, here ;s how the additional memory space is used: 12K Expanded symbol storage or FCOM 16K One additional program area II 10 32K Five more program areas, or four plus ... FCOM If you wish to limit the amount of memory available for any reason, you should set switches 9-11 in the switch register before proceeding with Step 4: Switches 9-11 (octal): There are a number of O=All, 1=28K, 2=24K, 3=2OK, 4=16K, 5=12~ and 6 or 7=8K other • custom' features ~hich can be installed auto- matically when the program is first started up. These options are controlled by the setting of bits 0-2 and 6-8 in the switch register. The first group (0-2) selects various terminal options while the second group (6-8) controls additional features. S~itches 3-5 are ignored and may be set to any value. Once UWF has been started the first time step 3 is unnecessary and the switches may remain set to '100'. UWF-Z Switch 0: Use 'CRT-style' rubouts instead of 'backslashes' Switch 1 : Switch 2: Output four 'nulls' after every Carriage Return Print error messages on a new line Switch 6: Add three extra 'secret variables' (&,:,\) Switch 7: Switch 8: Add the 'KONTROL' command and the 'FDIN' function Add the 'FCOM' and 'FBUF' functions (requires 12K) Example: a switch setting of '4134' limits the program to 16K, adds FCOM, FBUF and the digital I/O routines, and installs 'scope rubouts'. The '100' bit is ignored. Some of these patches can also be installed (or removed) after the program has been started - see Appendix II for further details. Note that adding the 'FCOM' function reduces the effective memory size by 1 field, hence users with 16K who add this option will normally lose the first additional program area. desirable in this particular case to Since it might be more have FCOM replace the extra variable storage, there is a 'magic location' which can be changed (-before- you start things up!) to effect this arrangement. (16K configurations only - see Appendix II for details.) Note that UWF runs with the interrupt system -ON- which allows program execution to overlap certain I/O operations. The result is faster run times, a 'live' keyboard and the possibility of adding 'background' tasks which can be controlled by the program or 'high-level' interrupts in which an external event causes the execution of a specific group of statements within the program. With the interrupt system enabled, however, it is possible that an 'unknown' device wilt create a continuous interrupt and thus prevent UWF from running. If the 'RUN' light goes on but there is no output as soon as you hit the 'CONTINUE' switch halt the machine, hit the 'RESET' or '"CLEAR' switch a few times and then restart at location 100. If UWF still appears to be stuck in an endless loop:.You' will probably have to add an appropriate 'clear flag' instruction to the interrupt routine. See Appendix II for the proper locatione UWF-3 UWF's CONTROL KEYS UWF recognizes the foLlowing control keys: 1) CTRL/F is the master program break key - it will restart UWF at anytime, assuming that the program is still running. 2) CTRL/C is the monitor break key. It witl eventually trap to a resident 'ODT' package which ;s not yet implemented. 3) CTRL/S (XOFF) stops output to the terminal. This provides users with video terminals time to inspect their results. 4) CTRL/Q (XON) resumes output to the terminal. Some terminals issue XON/XOFF codes automdtically when the screen fills up. 5) The RETURN key is used to terminate all command lines. UWF will not recognize a command until the RETURN key is typed. 6) The RUBOUT or DELETE keys are used to cancel the previous character. On hard-copy terminals a " I is echoed for each character deleted. On video terminals they just disdppcar! 7) The LINE FEED key is used to retype a command line -beforetyping RETURN in order to verify that all corrections were made properly. This is mostly for hard-copy terminals. Remember: UWF can be interrupted at any time simply by typing CTRL/F. This is accomplished by holding down the CTRL key and then typing the letter If I. UWF will respond by typing a question mark (?) followed by the line number where the program was interrupted and then print an asterisk to indicate that it is ready for further instructions: ?@ 05.13 UWF was interrupted at line 5.13 UWF-4 DIRECT and INDIRECT COMMANDS UWF prints an asterisk instructions. whenever it is in (*) You can then type in command mode waiting for either 'direct commands' which are new executed immediately, or 'indirect commands' which are saved for e~ecution at a tater time. To use UWF as a fancy 'calculator' simply give it a 'direct command' and hit the RETURN key. For example, if you enter the command: *TYPE PI UWF will print the value '3.141592654E+OO', correct to 10 significant figures. Direct Command feature is the essence of interactive programming since it The permits one to work through a long calculation a step at a time, or to tryout several different ways of doing something. You can experiment with any of UWF's commands by simply typing them in as you read ~hrough this manual. Indirect Commands always begin with a line number which indicates the order in which they are to be executed. They may be ~ntered in -any- order, however,· and can be examined or changed at any time. Changes to indirect commands are facilitated by the use of UWF's built-in editor which allows lines to different part of the program, or deleted. tively executed by direct commands it;s be modified, moved to a Since indirect commands can be selec- possible to build a very powerful set of 'macros' which can then be called with just a few keystrokes. Line numbers in UWF have a 'dollar and cents' format: range from 00-31 (the 'group' number) and 'step' number). where 'XX, may may have any value from 00-99 (the Group 0 and Step 0 both have special meanings in some commands, so the first line of the program is usually trailing 'YY' 'XX.YY· zeros are not necessary, labeled " . " . Notice that but one must always include a leading and space after the line number to separate it from the commands on the rest of the line. Here are some sample indirect commands: *3.61 TYPE ! .12.7 COMMENT *1.99 QUIT UWF-5 A standard programming practice is to ment of either '.05' or '.1'. index sequential commands by an Thus line ".2' folLowing line '1.1' rather than line '1.11'. would be used to make room, but it is statement This leaves room to insert additional lines in case changes to the program are necessary. always be moved for the increup to 9 Of course lines can a nuisance to have to do this and such changes might require aLteration of other parts of the program as well. GROUP and RELATIVE LINE NUMBERS SeveraL UWF commands are capable of operating on all statements with the group number. same To reference an entire group of lines one simply specifies the group number without designating any particular program step: will list all the program steps in 'Group " . '1.00' are indistinguishable to UWF, for example, Since the number ", and the number it is no~ without writing the rest of the lines in the same the first line in a 'WRITE 1', possible to write just line 1.00 group as well. For this redson group is generally reserved for comments in order to avoid any complications with group operations. UWF can also designate a • sub-group' operation consisting of all the lines following a specified line in the same group. Such operations are indicated by a 'negative line number': 'WRITE -'.51~ for instance, will list all of the lines in Group 1 starting from line 1.5 (if it exists). line numbers in the range '.01-.99' are termed 'reLative tine numbers', i.e. they refer to lines in the -current group-, rather than to ~~nes in 'Group 0'. use of and such line numbers is encouraged aLso allows subroutines because it makes the program more to be moved easily from one part of another without having to worry about internal re'erences. than 1.00 -can- be saved executed when the program as part compact the program to Lines with numbers less of the indirect program, is started The but they can onLy be from the beginning since there ;s no way to branch to them at a Later time. Finally, references to line 'a' also have a special meaning. A few commands interpret such references to mean 'the -entire program', while most others regard 'line O' as a reference to 'the next command'. Line 0 itseLf is the permanent com- ment line (the 'Header Line') at the b~ginning of the prograffio PUNCTUATION It is a common practice to put several commands on the same line in order reduce the amount of paper required for listing the program as well as to to con- solidate related operations. A 'semicolon' (i) is used to separate such commands: *SET A=5; TYPE A Commands which the values. operate on more than one expression use a 'comm~' to separdte Thus the command 'TYPE A,B' is equivalent to 'TYPE Ai TYPE S'. Spaces may be included to improve the readability of a program, but one must remember that 'space' is a 'terminator' (equivalent to a comma) so the ·command 'TYPE A S' is interpreted as 'TYPE A,B', not as 'TYPE AB'. AND VARIABLES NUM~ERS UWF can handle up to 10-digit numbers with a magnitude range of 10-615. bers may be written fraction as well assigned as or unsigned quantities and Num- may include a decimal a 'power-of-ten' exponent indicated by the letter 'E'. All numbers are stored internally in a 'floating-point' format with 35 bits of mantissa and 11 bits of exponent. will respond with This is equivalent to more than 10-digit accuracy. an error message if a user attempts to enter a UWF number with too as numbers so that questions may be many digits. The following all represent the value 'sixty': 60 UWF also allows letters to answered with a 'YES' decoded in this manner, or 'NO' 60.00 be 6E1 treated response rather than with a numer;~ reply. the letters 'A-Z' have the ~alues '1-26', letter 'E' always means ·power-of-ten'. ical value '155' 600.0E-1 When except that the Thus the answer 'NO' would have the num~r and the number 'sixty' couLd also be written as 'ODT' or 'OFEA'. Note that the leading '0' is only required ~hen incorporating such 'numbers' into a program. It is not required as part of 'a user response. UWF-7 VARIABLE NAMES Variables are Variables used to are thus store input values like the storage registers or to save intermediate results. on a calcu~?tor except that the programmer may make up his own names to designate the values stored. UWF allows variable names of any length, but only the first two characters are retained internally. Thus the names JOHN and JOE would both refer to the variable 'JO'. The first 'character of a variable name must obviously not be a number, nor can it be the letter 'F' since that letter is used to designate functions. However UWF does allow symbols such as '$' and .... to be used as part of a variable name so quantities such as A$, A', and Aile you can have Variables are always stored as numeric quan- tities; UWF does not currently have ·string' variables. THE SYMaOL TABLE The names of the variables w~ich have been used (along with their values) by the program are saved in a region of memory called the ·Symbol Table'. This area is completely independent of the area used to store the program so changes to the text buffer do not affect any of the values stored in the symbol table. This is extremely convenient since it allows a program to be interrupted, then restarted somewhere in the middle, obtained will still be available. that simply by TYPEing them out, command before restarting the or he may change a program. few values such with a direct Variables are always assumed to ha~e the 'zero' until another value has been assigned. used to list all the values in the Symbol Table the program. and any intermediate results of course the programmer may examine any values value knowing modified, in the The 'TYPE some of the variables to zero. other, non-zero variables when the symbol table fills up. or to selectively set the value '0' may be replaced by This ;s transparent to the programmer since 'undefined' variables are always zero anyway. UWF-8 command can be order they were defined by The ZERO command is used to clear the table, Variables with $' PROTECTED VARIABLES The symbols {!,",#,$,i.} and optionally {&,:,\}, along with the value of 'PI', are 'protected' variables which cannot be replaced or removed This makes them useful for saving results which ZERO command. d are needed by a second Since they cannot be input or output directly and do not appear dump, by they are also sometimes called 'secret' variables. in a program. symbol table Note that UWf automatic- ally sets 'PI' equal to '3.141592654' so users should not use 'PI---' as a variable name or this value will be lost. The variabLe '!' ('bang') is used as the dimension constant for double subscripting (v.i.) and many of the remaining 'secret ables' serve as dummy arguments for Program De-fined Functions (see TYPE the values of these variables you must prefix a '+' page vari- 66). sign or enclose To them in parentheses: TYPE +! or TYPE (!) will output the value of the first one. SUBSCRIPTED VARIABLES Variables may be further identified by attaching a subscript enclosed in entheses immediately after the name, arithmetic expressions involving relations can be developed. e.g. 'A(1)'. Such subscripts may consist of other subscripted variables so quite intricate Unlike many other high-level languages, UWF does not require any 'dimension' statements for processing subscripted variables, the"subscripts limited to only positive however). integers par- (they are nor are limited to 12 A variable such as 'APPLE(-PIE), is thus perfectly acceptable bits, although UWF will view this more prosaicly as simply 'AP(-3)'. Non-subscripted variables are the same as those with a subscript of zero, i.e. 'AI = 'A(O)'. To handle double subscripting, UWF -does- require a small amount of additional information. Before using a double subscripted variabLe the programmer must store the maximum value of the ,first subscript in the protected variable '!'. This value may be greater than the actual maximum without incurring any storage penalty, but if it is too small more than one array element will be stored in the same location. Since this single 'dimension constant' is used for all arrays it should be chosen for the largest array in cases where the program uses several different sizes. UWF-9 To illustrate: suppose that operations on a 5x5 array were necessary. Then '!' ('bang') should be set to 5. If 3x3 arrays ~ere also needed simultaneously (which is not very likely) their elements would all be unique and only 9 storage locations would be used, not 25. Non-square arrays are handled just as easily: would still only require that '!' be set the -first- subscript. to 5 since that is the maximum value of This method of storing two-dimensional arrays convenient: for a ~ide range of linear algebra problems. a 5x20 array proves very The value of '!' is gen- erally.,used as a loop limit so that the routines can be used with any size array. ARITHMETIC OPERATORS UWF recognizes 6 basic arithmetic, and 1 special value' operator: Addition 1) + 2) - Subtraction 3) * 4) I 'chara~ter Mu l tip l ; cat; on Division 5) -- 6) = Signed Integer Powers Replacement 7) • Value of next character These 7 operators'maybe combined with explicit numbers and function or able names to create 'Arithmetic Expressions' such as: UWF-l0 vari- -Such expressions writeup. are can be used -anywhere- that explicit numbers appear in In particular, they may be used to compute line numbers. evaluated to '10-digit' accuracy, this All expressions independent of the format used for output. Intermediate results are generally rounded off rather than being truncated. Most commands use, or operate on, arithmetic expressions. If such expressions are -omitThis occurs frequently when evaluating ted- a value of 'zero' is always assumed. line numbers, hence you should recall the comments about line '00.00' mentioned on page 6. PRIORITY of ARITHMETIC OPERATIONS Arithmetic operations are performed in the following sequence: First priority - integer powers (A) Second priority - multiplication (*) Third priority - division (/) Fourth priority - subtraction and negation (-) Fifth priotiry - addition (+) Last priority - replacement (=) When UWF evaluates an expression which includes several operations, the order above is followed. For example, UWF evalutes the expression: leaving 'X' equal to 'zero' and 'Z' equal to 2.5 Notice that multiplication has a higher priority than division. ferent from the convention in equal priority. many other languages where these Thi s is dif- operations In most cases this difference is of no consequence. The effect of e.bedding replacement operators is to cause portions of the expression to uated in a cluded. somewhat different In the example above, order than would for instance, be the case if they have w~re be evalnot in- the quantity 'SA2' is divided by the Quantity '5*2' and then the quantity '2' which is equal to '5/2' is subtracted from the result. However, if one were to add a 'Y=' operator after the first '/' then the quantity '5-2' would be divided by 'Y' which would be equal to '5*2-Z'. UWF-11 ENCLOSURES The order of evaluation can also be changed by the use of different kinds are allowed by UWF: Angle Brackets '<>'. Three Square Brackets '[)', and Subscripts and function arguments are common examples of ex- pressions contained in enclosures. matched, Parentheses '()', enclosures. of course!), UWF treats all sets identically (they must be except in some of the monitor commands in the OS/8 version. If the expression contains nested enclosures, UWF will evaluate it starting with the innermost set and working outward. For example: is evaluated as 'four hundred' with 'A'=20 and IB'=5 ABBREVIATIONS doesn't care whether you tell it to 'TYPE' or 'TAKEOFF'! U~F that only the -first- letter of the command is recognized, The reason is just as only the first letters of a variable name have significancec So while we have been carefully -two~ spelling out all the commands in the examples so far, we could just as well have On the one hand it greatly abbreviated them to their first letters. This feature of the language is both good and bad. reduces the amount of typing required and at program steps possible. the same time increases the number of But on the other hand, a program containing hundreds of single letter commands looks more like a sheet of hieroglyphics than anything else. This makes it Quite difficult for the beginner to understand the program until he himself has become more familiar with the meaning of all the symbols. logic For maximum clarity the eXdmples in this writeup will generally be spelled out, but you should realize that the commands 'T PI' and 'TYPE PI' will produce -exactly- the same result. We will now turn to a detailed examination of all the commands available to the UWf programmer, beginning with the editing commands since they are required for further program development. UWF-1Z -' - COMMAND MODE EDITING When UWF is in any typing errors. command mode you can use correct Each time that you hit this key UWF will delete the precedeing character and echo a '" switch 0 up the RUBOUT or DELETE key to on the terminal. If you have a video terminal, and you set when you started UWF for the first time (or made the appropriate patch yourself), hitting DELETE wiLL actually remove the character from the screen. is obviously much nicer since 'what you see is what you've got l • users with a hard-copy terminal can always just hit current input line On This the other hand, the 'LINEFEED' key to have the retyped so that they can see just how it 'really' looks to UWF. There is no limit to the length of input lines, however if your terminal does not handle 'wrap-around' automatically, the practical limit is the width of paper. In addition to RUBOUT, newer terminals) the BACKARROW (or UNDERLINE key as it is identified on may be used to delete all characters to the left, line number of an indirect command~ necessary to margin again. echoing a '" You may then start over hit RETURN although you may wish to do so to including the again. get back It is not to the left Note that LINE FEED will not echo a blank link and RUBOUT will stop when it reaches the beginning-of the line. The use of 'BACKARROW' as a 'line-kill' character necessarily means that character (and RUBOUT, of course) cannot be part of the program, this but all remaining ASCII characters, both upper and lower case, can be used. Control codes can also be used, but they should be scrupulously avoided since they are non-printing and are therefore impossible to find when they are embedded in a program. In fact, if you ever have a mysterious error in what appears to be a perfectly good command, just try retying it in its entirety to eliminate any 'ghosts'. Once you hit the RETURN key, UWF will digest whatever you have typed, sequent changes require the use of the editing commands. The text buffer can hold approximately 7UOO (cecimdl) characters - typically 3-4 pages of printout. any or all of this material you use the WRITE command; so subTo list to eliminate some of it you use ERASE and to make changes without having to' retype the Ulchanged part, you use the MODIFY command. This command can also be used to MOVE parts of the program to a different location. UWF-13 WR I T E The WRITE command, without any modifier, mands currently saved in the text buffer. will list all of the indirect com- Lines are ence, no matter in what order they were entered, you have specified. and are separated into the groups For this reason it is very convenient to use a different group number for each major part of program the program even if such Using the first line (line XX.GO) steps. typed out in numerical sequ- a section only has a few for a COMMENT to describe the purpose of that section is also highly recommended. The WRITE command can also be qualified by a string of numbers to limit the listing to selected portions of the program. 'WRITE " , for example, will print out just the single commands belonging to line. Group 1, while 'WRITE 2.2' A command such as 'WR1TE 1,2,3.3,4.9,5' will will list list 3 only that groups and 2 single lines, in the order specified. Of course you shoulo try to plan your progrdm so that it executes smoothLy ~from top to bottom-, major section at the end, but if you do need to odd a the ~RITE command can be used to at least make a listing showing the logical program flow. Another convenient feature of the WRITE comm~nd is the ability to line and all lines following it within the same list a specific group. This is done by specifying a -negative- line number. Thus 'WRITE -1.5' will list line 1.5 (if it exists> plus the remainder of Group 1. 1ne WRITE command will not produce an error if the line or group you specified is missing - it will simply not list it: What you see is what you've got! UWF-1~ ERA S E .The ERASE command is used to delete parts of the program. qualifier deletes the entire program, 'ERASE 2' while which will half that single line, of Group 4. of Group O. way to erase lines such as '2.00' without erasing the entire group There is no the same time; this is one restriction on the use of such lines. only a single qualifier may be used with ERASE, command mode immediately after executing the commmand. and Since 'ERASE 0' you must use an 'ERASE -.01' command to erase all erases everything, command, eliminate the second a will delete just Group 2. Other possibilities are 'ERASE 9.1' which will only remove 'ERASE -4.5' 'ERASE' without at Unlike the WRITE and UWF will return to Typing in a new tine with the same number as an old one will effectively erase the previous version. Entry of just a line number by itself will result in a 'blank line' which may be used to separate sub-sections of a program. Note that this treatment of blank lines differs from that used by BASIC. Blank lines will be ignored during program execution. MOD I FYI M0 V E To change a program line or to move it to a different part of the program, you must use the MODIfY or MOVE commands. MODIFY· without a qualifier can examine the header line, but it cannot be used to change this line. single line number permits changes to the line specified while a ~ith -two- line numbers allows similar changes,· be used to MODIFY with a MODIFY (or MOVE) but saves the modified line ~ith the new number. The old line, in this case, remains just as it was. MODIFY only 'MODIFY" operates on single lines (at the moment), so a command such as will allow changes to line 1.00, not to all of Group 1. Similarly, 'MOVE 2,3' will move line 2.00 to line 3.00; it will not move all the lines in Group 2. Since UWF does not have a 're-number' command, old copy is the only to ~ay ~dd additional room between sequential line numbers. UWF-15 moving lines and then erasing the lines when you foryct to leave eno~9h After you have entered a MODiFY (or MOVE) command, UWF will optionally print out the line number and then pause until you enter a search character. As soon as you have done so, the line specified will be typed out through the first occurrence of this character. If you want to insert material at this point, just type it in; if you want to delete a few characters, simply use the RUBOUT or DELETE key. Other editing options may be invoked by typing one of the following control keys. Note: mistakes made while trying to modify a line often lead to embedded control codes, so if you do get confused, just type CTRL/F and try again. CTRL/F The ldst Aborts the command - the line is unchanged CTRL/G (BELL) Rings bell and waits for a new search char. CTRl/J elF) Copies the rest of the line without changes CTRL/L (FF) Looks for the next occurrence of search char. CTRL/M (CR) Terminates the line at this point 8KAROW, UNDRlN Deletes all chars to the left, except lineno. RUBOUT, DELETE Deletes previous chardcter, as in command mode two operations dre simiLar to those available during except that BACKARROW or UNDERLINE does not delete the line number. command To remove the first command on a line containing several commands, just enter a semicolon (;) the search character, wait for the first command to be typed out, mode as hit BACKARROW or UNDERLINE and then hit the LINE FEED key. CTRL/G and CTRL/L may be used to skip Quickly to the part of the line ing changes. If the change(s) (such as an '='), you can requir- you wish to make involve frequently used characters initially select a different symbol which occurs less frequently .and then use BELL to change to the character you really wish to find. Or In case your terminal happens to respond to a FF, you will be pleased to know that UWF does not echo this character! you can simply keep hitting the FORM FEED key to advance through the line. UWF-16 If you just want to move a line from one location to another, type a IF as the initial search character. If you are adding new commands in the middle of a line, be sure to use the LF key - not the RETURN key - to finish copying the rest of the line. Otherwise you will lose the commands at the end of the line and you will have to MODIFY the line a second time in order to re-enter them! If you have a hard-copy terminal you may wish to WRITE out the line after you have modified it to check for additional errors. With a video terminal, on the other hand, the corrected line will be displayed just as it is. If you have many lines to move (say all the lines in Group 5), slow terminal, things up. you can disable the printout during the Move in and you have a order to speed To do this, simply disable the keyboard echo by using the '0 II command (this is discussed on page 46). MOVE commands will be printed A disadvantage to this method is that not even the so you have to operate 'in the dark', still the best way to make such a major program change. To restore but this is the keyboard echo just hit CTRL/F. On video terminals the number of the line being modified is printed out at the beginning so that the changes will be properly hard-copy terminal, however, positioned on the screen. With a the line number is not normally printed in order to leave as much room as possible for rubouts and insertions. Appendix II indicates the location to change if you wish to add the line number printout in this case. UWf-17 EXPANDED TEXT STORAGE If your machine has more than 12K of memory, UWF wilL automatically use Fields 3-7 for additional text buffers. This alLows such systems to keep several different programs in memory at the same time which;s obviously a very convenient thing to do. The LOOK command ;s then used to select the desired 'area' for editing, program execution, etc. Programs in different areas are essentially independent and may use the same line numbers, but the symbol table and the 'stack' are shared by dll areasa The LOOK command has the form: 'LOOK Area', where 'Area' has the value '0' for the main text buffer and " ' , '2', '3', etc. (up to 5) for the additional fields. LOOK always returns to command mode and is normally only used 'L l' will switch to Area 1 while 'L 0' (or just 'L') as a direct commence will return to Area O. calls between program areas, see the LINK command described Later on page 34. UWF-18 For INPUT / OUTPUT COM~ANDS UWF's I/O commands are called 'ASK' and 'TYPE', respectively. The TYPE command has appreared previously in a few of the examples; of basically it converts the value an arithmetic expression to a string of ASCII characters which are then sent to the terminal, or to whatever output device has been appropriate 'OPEN' command (see page 44). selected as Similarly, a result of an the ASK command is used to input numeric values, either from the keyboard, or from another input device. Both of these commands 1/0 recognize 6 special operators for controlling the format of operations. These operators are, in fact, just the symbols previously identified dS 'protected variables' and it is because of ~heir special significance in ASK I TYPE commands that they cannot be input or output directly. These operators, and their meanings, are as follows: 2) .. Generate a new line by printing a CR/LF 3) # Generate a RETURN without a LINE FEED 4) $ Print the contents of the Symbol Table 5) X Change the output format 1) 6) .. Enclose character strings for labeling Tabulate to a given column or ignore input You will notice that these are mostly • output , operations. Nevertheless, they perform the same function during an ASK command that they do in a TYPE command. The '#' operator does not work on all 1/0 devices and is therefore seldom used. originally intended for overprinting on the same line, but may be easily patched (see Appendix 11) to generate a FORM FEED, should that be desirable. operators will now be discussed in greater detail. UWF-19 It was The remaining THE NEW LINE (BANG) OPERATOR The'!' operator is used to advance to a new line. function automatically, this 'Bang' operators can be 'piled together' to produce multiple blank lines: 'TYPE !!!!!', for example, produce a sing~e performs so output on a single line may actually be the result of severaL ASK or TYPE commands. to UWF never blank line may require would advance 5 lines. either 1 or 2 '!'s, Note that depending upon whether anything has been written on the first line. THE QUOTE II OPERATOR UWF uses the .... operator to enclose strings appear in the program. Thus the command: which are output TYPE "HELLO THERE, would simply print the message enclosed by the quote marks. just as they HOW ARE YOU TODAY?" The 'ASK' command uses such output for prompting: ASK "HOW OLD ARE YOU? ",AGE wilL print the question and then wait for a response. In some cases the TRACE operator (1) is also useful for printing labels during an ASK or TYPE command - see page 52. THE SYMBOL TABLE DUMP $ OPERATOR The Symbol Table Dump operator 8. ($) has already been mentioned briefly on page It prints all the symbols defined by the user's program in the order in which they were encountered. It does not print the values of the 'secret variables'. conserve paper and to permit as many symbols terminal, the listing normally has as possible to be three values per line. changed simply by specifying a different number after the '$'. change the default value to 5, To listed on a v;oeo This format can be Thus 'TYPE 55' witt which is convenient on terminals which can print up to 132 characters per line. The total number of symbols possible depends upon the amount of memory available. In an 8K machine there will only be room for about 120 a 12K machine one can have approximately 675. variables while in reasons, a Symbol Table Dump always terminates execution of the commana line it is on, hence commands following it on the same line will not be executed. UWF-20 For internal THE fORMAT 7. OPERATOR The format operator standard formats: tion). set (7.) integer, aLlows UWF to print numeric results in any of mixed decimal, or 'floating-point' (scientific nota- A format remains in effect until another one is selected. to print all Initially UWf is results in full-precision scientific notation so that all digits of a result will be output. style of three However for many calculations a 'decimal' or 'integer' output is more desirable. Such formats are selected by the value of an arithmetic expression following the 'i.' operator ~hich has the form: %t'J D. DP where 'NO' is the Number of Digits to be printed (the result will be rounded off to this precision), and 'opt is the requested number of Decimal Places. 'DP' should be smaller than 'NO' unless 'ND' is zero; 'integer' format and no decimal point X2,P!' will produce the result' Notice that the if top' will be is zero the printed. Thus result will be the an command 'TYPE 3'. form of the format specification is similar to that used line numbers. This may help to explain why it is necessary to use '7.5.03', than '7.5.3', when you wish to have 5 for rather digit.s printed with up to 3 decimal places. The number of decimal places actually printed may not be exactly requested. If UWf finds that the number being output is too big to fit the format you specified it will reduce the number of decimal places. what you have for example, if you try the command: iYPE %5.04, 123.456 you will actually get the value' 123.46' printed since it is not possible to show· 4 decimal places with only 5 digits. significant digits accustomed to Note however that UWF -did- print the 5 most in a format approximately like the one requested. dealing with large powerful computers which print only Progrdmmers a st ring of '*****'s under similar circumstances should find UWF's approach quite sensible. UWF-21 What happens if the number is so large that even the most significant part overflows the field specified? In that case UWF automatically switches to floatingpoint format for that value so you wiLL be able to see an unexpect~d result without . having to re-rLfl the entire program! value '123456' without changing the print: format try this out simply by typing the from the prev~ous setting. UWF will specify one with 1.2346E+05'. I To You can purposefully select to O. 'ND' equal Thus the a floating-point format you should format 'i..OS' will print 5-digit numbers in proper scientific notation (1 digit before the decimal point). The default format when UWF is first loaded is 'i..1' which prints all 10 digits. To return to this format you can simply specify 'i.', since the value '0' is treated the same as 'i..". Note that using an arithmetic fixed number, expression for the format permits the format to be specification, rather than just a changed dynamically while the program is running: 'r.VF' would select a format using the value of the variable IVF'. finally, note that UWF will never print more than 10 significant digits - the limit of its internal accuracy. ~ill If the quantity IND' is larger than this, be used to fill out the number. added. In any case, ahead of the first If the quantity lOP' is if the number is negative UWF digit. zeros will be will print a minus sign just A plus sign is never printed it anyway. larg~r, spaces (except as exponent), but a space is reserved for printed at the beginning in order to separate the number from any previous output. This space may be omitted (or changed to an '=' sign) An additional part of the space is also by making the patch shown in Appendix II. To summarize the various output format settings: %N 'N' digit integer format XN.O 'N' digits with up to '0' decimal places %.0 '0' digits in scientific (F.P.) notation X the same as 'X.1' - full precision f.P. UWf-22 THE TAB : OPERATOR The tab (:) operator provides a convenient way to create column output. The expression following the colon is used to set the column, i.e. ':10' specifies column 10. The tab routines do not attempt to go backward if the column specified is to the left of case. the current print position - the command is simply ignored in this 'Tabs' are recommended in place of a string of spaces so that changes in the output format will not affect subsequent columns. There are two special cases: tabbing to column 0 and tabbing to a negative column. Neither ;s possibLe since columns are numbered from 1 to 2047, but both are useful operations. Expressions which have the value zero can be evaluated by the tab operator within a TYPE command -without- producing any output. This is conven- ient occasionally, especially for calling the FOUT function (see page 61). Tabbing to a negative column has been given a quite different interpretation, however. Since the current version of UWf command, there output produced can only input numeric values is a need for a method to skip over by another program. ASK label fields when re-reading This facility is negative column number which causes no output, with the provided by 'tabbing' to a but instead reads and ignores the specified number of characters. Thus the command 'TYPE :-1' will -read- 1 character from the input device. This may well appear confusing, since we have an • output , command waiting for input, so the 'ASK' command may be used instead: performs the same function. This feature provides a simple way to get the program to wait for operator inter~ention. For example, 'ASK :-1' the command 'TYPE "TURN ON THE PUNCH":-1' would print the message and then wait for any keyboard character to be typed. An 'ASK :-2000' command will let a visitor type almost anything s-he likes into the computer without danger of destroying a .valuable program. UWF-25 Having ~iscussed all the ASK/TYPE operators, to explain about the evaluate a whole series of arithmetic expressions which are generally separated by commas or spaces or one of the above operators, commands themselves. there is really very little more while ASK TYPE can can input values for a whole list of variables, again separated by commas or spaces. Here are a few examples: TYPE !!:1U"TODAY 1S"7.2,15 i~4" OCTOBER"'978! ASK "TYPE A KEY WHEN YOU ARE READY TO GO":-1 TYPE !ltTHE ROOTS ARE:" i.S.02, R1 :20 R2 !! ASK !"WHAT IS THE INITIAL VALUE OF X? Notice that the TAB and NEW LINE operators can be II IX included in an ASK command to help format the input. Thus 'ASK X :10 Y !' would keep the input responses in two nicely aligned columns. It is quite convenient to be able to output the neces- sary prompting information with the ASK command; other languages frequently require separate commands (such as 'PRINT' followed by 'INPUT') trace operator described on page for these operations. The 52;s also useful in ASK and TYPE commands when one is interested in a 'minimal effort' I/O structure. One other feature of a TYPE command should be noted: the "value of a quantity being 'TYPEed' it is possible to save just by including a replacement operator in Thus 'TYPE X=5' will output the value '5' and also save it as the the expression. value of the variable ·X'. Numeric input for the ASK command can take any of the forms listed on page specifically: signed integers, alphabetic responses, containing a power-of-ten exponent. being input it ;s not possible acter. Rather, then re-enter the decimal values or numbers Because such numbers are processed as they are to use the RUBOUT key to delete an erroneous one must effectively hit the 'clear key' (as on a calculator> entire number. 7, The 'clear' function is indicated by charand typing a 'SACKARROW' or 'UNDERLINE' just as it is during command input. If you do attempt to use RUBOUT, no t\' will be echoed which ignored during an ASK command. UWF-24 serves as a reminder that this key is INPUT TERMINATORS UWF allows a variety of characters to serve as input terminators. to the RETURN key, one may use In addition a SPACE (spaces in front of a number are ignored, but may be used to format the input as desired - spaces following the number always act as a terminator), a CO~~A, QUESTION MARK or COLON. SEMICOLON, A 'period' is, or other punctu~tion marks such as a of course, recognized as a decimal point, Any of the arithmetic operators also serve as terminators; in particular, the and '-' characters are often convenient. This allows responses such as '1/2' or '1-5 1 for the values of -two~ifferent variables. but a second period also works as a terminator. I,' In fact, any character -except- 0-9, A-Z, RUaOUT and LINE- or fORM-fEED can be used to terminate the response to an ASK command. More to the point, however, is the fact that the program can test to see which terminator was used. very simple input loop to read an indefinite number terminator (a I?', for instance) is found. of This allows a items until a specific See the discussion of the FTRM function on page 63. The ALTMODE or ESCAPE key is a special case: typing either of these keys leaves the previous value of the variable unchanged. This allows quick responses to repeated requests for the same value. The program, of course, can pre-set the value of the vdriable so that an ALTMODE response will merely confirm the expected value. UWF-25 ARITHMETIC PROCESSING COMMANDS There are four commands in this group: SET, XECUTE, YNCREMENT and ZERO. 5 E T The most frequently used command in the UWF language is the SET command. command evaluates arithmetic This expressions without producing any output (except when the trace feature is enabled - see page 52). Such expressions typically have the form: SET Variable Name = Arithmetic Expression But more general expressions, particularly those containing sub-expressions, are perfectly acceptable. Thus a command such as 'SET A=B=C=5' could be used to set all three variables to the same value while 'SET I=J+K=1' would initialize the value of 'K' (to 1) as well as set 'I' to 'J+1'. Expressions used with the SET command do not need to contain replacement operators: the command 'SET fIN()' could be used, for instance, The value of the function would not be saved, to input a single character. however; this is sometimes useful when calling '1/0' functions for their 'side-effects'. Note that the word 'SET' (or its abbreviation 'S') is not optional as it is in some other languages. The flexible syntax employed by UWF makes it mandatory that every command begin with a command letter. One SET command, however, will process as many expression as can fit on a single line. The expressions should be separated by commas or spaces, for instance: 'SET A=1,B=2,C=A+S' Another point to which is equivalent to 'SET C=(A=1)+S=Z' remember is that the 'same variable may appear on both sides of an UWf-l6 '=' sign. Thus 'SET X=X+S' has the effect of redefining the value of 'X' to be 5 more than the initial value. This can get to be tricky if the Sdme variable appears several times rulE here in a single expression on both sides of replacement operators. is that in each The instance the variable will h~ve its current value until the entire expression to the -right- has been evaluated; then it will be replaced with the new value. To give a fairly simple, yet intriguing, example: SET A=8+A-8=A which is equivaLent to This will interchange the values of 'A' and'S'. same thing is: SET A=8+0*8=A. Another expression which does the Notice that the processing of this expression in- volves two different values of'S': right side of an '=', SET C=a+A,B=A,A=C-a The first time 'B, is encountered it is on the so its current value is used; the second time it is on the left side, so the rest of the expression is evaluated, then processing of the first p~rt is resumed. until the very end <when it is replaced by the the substitution made, and Thus 'A' retains its original value initial value of 'B', which was saved on the st a c k) • Z E R 0 The special case of 'SET Var=O' is conveniently handled by the ZERO command. A single ZERO command may be used to set several variables to zero, convenient for initializing sums 'ZERO va~iables to zero. and 'flags': As a special case, command clears the entire symbol table. making it very A,#,C' will set those three if no variables are specified, the ZERO This effectively sets -all- the variables to zero since this is the default value for 'undefined' Quantities. One other use of the ZERO command should be mentioned. fills up, UWF tries variables. This to replace any variables which When the Symbol Tdble have the value '0' with new procedure succeeds as long as there ;s at least 1 variable with this value, since that one will simply be renamed, and no matter what the name, ~ill always be zero. As a result of this scheme, programmers may regain table space by ZEROing unneeded variables when they are finished with them. UWF-27 it symbol Y NCR E MEN T Another special case of the SeT command - 'SET Var = Var + l' is handled by the YNCREMENT command. This command allows a list of variables to be either increment or decrementeq by the value " ' . The command 'Y K', for example, is equivalent to 'SET K=K+1' while 'Y -J' is the same as 'SET J=J-1'. Of course commands such as 'V N,O-P' are permitted; this one increments the variables 'N' and '0' and decrements 'pl. Either commas, spaces or minus signs may be used to separate the variable names. X E CUT E The XECUTE command has been included for compdtibility with of UWF. earLier versions Its purpose was to evaluate arithmetic expressions without setting useLess 'dummy' variables. This is now accomplished by omitting the replacment operator. on the terminal. the SET command itself simply by Thus 'SET FOUT(7)' may be used to ring the bell Internally 'SET' and 'XECUTE' are identical; that SET be used in new programs. UWF-Z8 it is recommended BRANCH and CONTROL COMMANDS This class of commands is used to test arithmetic results, otherwise control the sequence of command execution. catagory - UWF has a very rich control structure different types of transfers: .- set up loops There are 11 commands in this built around two fundamentally the 'GOTO' branch and the 'Du' call. the normal sequence of command execution, and Both interrupt but the GOTO is an unconditional branch while a DO call eventually returns to the next command following the call. The DO command is similar to the 'GOSUS' in BASIC, but is considerably more flexible. GOT 0 This command has the form 'GOTO line number'. to the line specified. The 'GO' command is the usual way of starting the indirect program at the lowest numbered line; other line as well: It causes an immediate trdnsfer it ma>" Je used to 'G 2.1' will start at line '2.1'. be replaced by an arithmetic expression start An the program at any explicit line number may to create what FORTRAN calls an 'Assigned Goto': 'SET X=S.1 • • • GOTO X'. D 0 The DO command is effectively a subroutine call. A DO command without a modi- fier (or equivalently, a 'DO 0' command) calls the entire stored program. be used as a Direct Command in additional commands, e.g. cases where you wish to follow such This may action ~ith 'DO;TYPE FTlM()' might be used to check the running time of a benchmark program. UWF-29 DO also accepts a list of line and group numbers such as 'DO -.7,8,9.1', which would call the subroutine starting at line XX.7U in the current group, then Group 8 and finally line 9.1. 100' is completely recursive: a DO may thus 'do' itself! Note that the commands called by a DO are not designated anywhere as subroutines - they may be, and usualLy are, just ordinary commands somewhere in the main program. This is one of the major differences between DO calls in UWf and GOSUBs in BASIC. Suppose, for example, that the program had a line such as: 1.3 ZERO A,B,C; SET 0=5, E=6 ·which occurred in Group 1 as part of an initialization sequence. If the same set of commands were needed later in Group 12, one would only need to write 'DO 1.3'. This facility for re-using common parts of the program is akin to writing 'macros' and is generally considered to be a good programming practice. The one feature missing from the 00 arguments to routine ; l command is the ability to explicitly pass this must be handled by the use of • common' variables. later on (page 66), Program Defined function calls provide this the 'sub- As you will see capability in a somewhat limited form. A DO call may be terminated in one of four ways: 1) There are no more lines to execute in the range specified 2) A RETURN command is encountered 3) A loop containing a DO is terminated by a NEXT or BREAK 4) A GO TO transfers to a line outside the range of the DO The first condition is the most common, especially for single line calls. second condition is explalned below, of the NEXT command. used to terminate while the third is explored in the discussion That leaves only the fourth possibility: GOTO branches can be a DO call simply by transfering to a line outside of the range; however the line transfered to will be executed first, unexpected results. The For instance, which can lead to slightly if the line branched to happens to immediately no exit will occur because UWf will firid itself back in the precede the group, proper group again when it finishes the line. Another somewhat similar case occurs when calling a 'sub-group-: GOTO transfers anywhere honored without cousing a return. Thus if you in wish to force a return from call, do it with the RETURN command (v.i.), not with a GOTO~ UWF-30 the same group will be a DO RET URN The RETURN command provides a way to selectively exit from a 00 call in cases where the entire subroutine is not required. Since a 'DO' call always specifies the implied range of the subroutine (a single line or an entire group), a RETURN command is normally not required. There are cases, however, especially when calling a 'sub-group', no in which a RETURN is necessary to force an early exit. subroutine call to return from, If there is RETURN will go back to command mode instead, i.e. it behaves just like a QUIT command. This is a useful feature, since programs which end with a RETURN can be run normally, but can also be called as subroutines via the LINK command (see page 34). RETURN can also designate a line number, for example: RETURN 5.3. ~ the normal return to the calling point is aborted (except for PDF calls, 68) and the program continues from the line specified. this case see page This is a very important feature since it effectively transforms a 00 call into a GOTO branch. It is all the more usefuL since it can be 'turned on and off' simply by making the return point an arithmetic expression which, when zero, indicates a normal return, but otherwise causes a branch to the line specified. This gives UWF a 'multiple return' feature which is found in only a few high-level languages. I F The form of the IF command is: IF (Arithmetic Expression) negative, zero, positive where 'negative', 'zero' and 'positive' are line number expressions not containing commas. Depending upon the sign of the v~lue being tested, the program will perform a 'GOTO' branch to one of the three possibilities. The expression being tested must be enclosed in parentheses and must be ,separated from the command word by a space. UWf-31 Not all of the branch options need to be specified, and relative line numbers are especially useful for those which are. Here are some examples of IF commands: IF (D=S"'2-4*A*C) .2,.3,.4 Tests for al L 3 possibilities IF (A-5) 5.1, 5.1 Branches if A is less than 5 IF (-X) .9 or IF (X)".9 Branches if X is greater than 0 IF· [I-JJ , .2 Branches only if I equals J IF <W> .4".4 Branches only if W ;s non-zero These examples illustrate the flexible nature of the IF command. with only 1 or 2 branch options, if the branch ;s -not- taken, In commands the next sequential command will be executed - whether this command is on the same Line or line (unless the IF is in a FOR loop, v.i.>. is interpreted as the 'next command'. on the next is a case where 'line O' Here, then, Also note (example 1 above) that the expres- sion being tested may contain replacement operators so that the value may be saved for use elsewhere in the program. oN The ON command is identical in form to the IF command: ON (exp) N,Z,P. The difference is that DO calls are used in place of GOTO transfers, so upon completion of the subroutine, the program will continue with the next command following the OM test.* This is often a very processing for specific cases. specified, convenient thing to do since it As with the IF command, so one can test just for eQuality (zero), alLows additional not all 3 calls need to be or for some other condition. Notice that an entire group can be called by the ON command. * The automatic further details. return can be aborted if desired see the RET~RN commdnd for J U M P The JUMP command has two distinct forms which have been designed to serve the needs of interactive programs: JUMP line number -or- JUMP (expression) S1, S2, S3, S4, S5, • • • The first form is a conditional GOTO in which the branch is taken -unless- there is a character waiting in the input buffer. This form is used to test the keyboard for input without interrupting the program if there isn't any_ This feature is essen- tial in interactive programs which allow program flow to be controlled dynamically from operator response. For example: 1.1 YNCR 1; JUMP .1; TYPE I ~ill hang in a loop incrementing the Variable 'I' until a key is struck, the number of cycles. then type The character used to interrupt the program can be read with the FIN function (see page 61) and so used to further control program flow. example above simply called FIN to read the character directly, hang in the input wait loop and nothing further If the the program would could be accomplished until the operator struck a key. The second form of the JUMP command provides a computed subroutine (00) which is -value- of essentially similar in form to the ON command except the arithmetic expression being tested is used (rather -si9n- bit) to determine which subroutine to call. to N, which do that the actual than just the The call list is indexed from 1 and any number of subroutines may be specified. not match specified call are up with a call Values of the expression ignored. In the example shown above, Subroutine No.4 will be called if the expression has the value 4.5, whereas if the expression has the value -1, called. As with the IF and ON 0, or commands, 12.3, no subroutine at all will be line numbers may be omitted (or set to zero) to avoid a call for certain values of the expression. UWf-33 Typically the expression is simply the ASCII value of a keyboard character which is used to select un appropriate subroutine. For eXdmple: JUMP (FI~()-'@) A,B,C"E will call subroutine 'A' if the letter 'A' is typed, etc. Notice that typing the As with letter 'DI is treateu as a 'NOP' by this particuLar command. the ON com- mand, the program normaLLy continues with the next sequential command following the subroutine call unless a RETURN command is Employed to transfer elsewhere. LIN K The LINK command allows systems with more than 12K to call subroutines in different text 'areas'*, stored thus 'linking' such areas together as part of a 'main' program. The command has the form: LINK Area, Subroutine Pointer where 1 Area' may have the values '0' or '1 '. in a sufficient memory is available. sub-group) number as described for the DO, 16K system, The 'Subroutine Pointer' and up to • 5' if is a line or group (or ON and JUMP commands. A value of • 0' specifies that the entire area is to be used as a subroutine. Examples: L,4 L 1,-8.5 L,.3 l 2,;T "DONE" Calls group 4 in Area 0 Calls sub-group starting at line 8.5 in Area 1 Calls line XX.30 in the same group in Area 0 Executes all of Area 2, then types 'DONE' Notice that the comma is required punctuation is zero, as in the lost example.*. even when the second parameter To avoid returning to the calling area at the end of the subroutine, use a RETURN command with a non-zero line number, such as 'R .9' to abort the normal return sequence. command the By using a computed line number in such a calling program can control th~ return. used to cancel all returns - see below. Uwf-j4 A 'QUIT' command can also be The variables created or used by d areas, so be c~reful to avoid conflicts. program area are shared in onE by all Also, since each LINK saves its return on the 'stack', watch out for calls which never return, but simply chain from one ared to another. This will eventually lead to a 'stack overflow' which can be cured by using a 'QUlT X' command to cancel all pending returns. The LINK command functions properly for calls from within the same orea, the DO command is clearly preferable since, caLls which the LINK commdnd cannot. for one thing, but it can handle multiple LINK can be used in direct commands; it ;s somewhat similar to the 'LIBRARY GOSUB' command in the 05/8 version. *For more information on storing programs in different areas, see the discus- sion on page 18. **LINK and LOOK differ only in the presence or absence of a second If only ~he area is specified UWf returns to command mode (LOOK), parameter. otherwise it pointers so executes a subroutine call (L1NK). QUI T The QUIT command stops program execution and resets the 'stack' that all pending operations (such as subroutine returns> are destroyed. well as any execution error performs an effective QUIT, thereby returning to com- mand mode. 'quit' There are rare occasions, and then simulate a however, when it is desirable to be able to keyboard restart so that running without actually returning to command mode. fying a non-zero line number as a 'restart' CTRL/f as the program will continue This is accomplished by speci- point. Thus 'QUIT 1.1' will stop execution, clear the stacks, and then restart at line 1.1. To restart at the lowest numbered line of the program, use a 'Q .001- command. stop the program and return to command mode. UWf-35 'QuIT 0' or just IQ' will It is also possible to use QUIT to specify a restdrt point for any error con- dition. This is accomplished by specifying a -negativc- line number, i.e. something Like 'QUIT -9.". This command will not stop the program when it is executed; it wilL merely remember the line number and then continue with the next command. If an error subsequently occurs, however, the program will be automatically restarted at Line 9.1 instead of returning to command mode. This provides UwF with a somewhat limited error recovery procedure, which can be' used to take care of certdin 'unexpected' but one conditions which might develop while the program was runnin9 unattended. Note that it ;s up to the user to determine which error caused the restart. is One way that this could be accomplished to select different restart points for differenct sections of the program where specific errors might be expected. perimlntal' in This feature shoulG be considered somewhat 'ex- the sense that it may not be included in later releases of UWF if other features appear to be more important. The error trap is automatically reset everytime UWF returns to command mode in order to prevent conditions set by one program at a later time. from causing an unexpected restart LOOP CuMMANDS UWF has j commands for constructing program loops. The FOR command sets up the lOOPi the NEXT command serves as an optional terminator, and the BREAK command provides a ~ay to exit from a loop before it runs to completion. UWF's loops are slightly different from those in other languages, but the differences, once recog- nized, are easy to accomodate. Basically, UWF uses 'horizontal' loops which consist of only the statements algebraic languages use following the FOR command on the 'vertical' loops which same line. Most other consist of a number of contiguous program steps with some way to designate the end of the loop. UWF's approach is convenient for short loops since the commands to be repeated are si mply coded on the same line wi th the nation is requ; red. easily by putting FOR command and no 'end-of-loop' desig- Loops which reQui re several lines of code are handled just as a '00' command in the main loop to call all the statements which cannot be placed on the same line. A NEXT command at the end of those statements then serves to designate both the end of the loop as well as the continuation point of the program. Symbolically, UWF's loops may thus have either of these two forms: FOR * * *i loop commands or FOR * * *i 00 -.yy xx.yy first loop command second loop command last loop command; NEXT The latter form is practically identical to that used by BASIC with the mere addition of the 'DO' call on the first line. UWF-37 or FORTRAN, fOR This command initializes a loop, assigning a 'loop varioble ' to count the number of iterations. The form is: FOR Var = Initial Value, Increment, Final Value; . or, more generally, FOR expression 1, expression 2, expre~sion 3 ; where the first variable to the left of a replacement operdtor in expression 1 will be used as the loop counter. The semicolon after expression 3 is required punctua- tion. An increment of +1 is assumed if only the initial and final values are given. Notice that the increment, if specified, is the -second- different from the convention used by BASIC and FORTRAN. expression! This is There are no restrictions on any of the expressions: they may be positive, negative or non-integer. Thus one can increment either 'forward' or 'backward', using any step size. The execution of the FOR command is such, however, that one pass will always occur 'initial value' is greater than the 'final value ' • the loop varidbte In any case, will be one increment more than even if the the exit value of the value it had in the final iteration. Here are some examples: 1) FOR I=J=1,10; 2) FOR l=1,N; FOR M=-L,L; 3) FOR X(I)= 10, -1, 1i 4) FOR A=O, P1/180, 2*PI; FOR Q= P/2, Q, S*Q; 5) Notice that loops may contain other loops (Ex. 2). Such 'nesting' is permitted to a depth of 1S or so, but in prdctice, Another point, loops are rarely nested more than 5 deep. illustrated in example 5, UWF-38 is th~t the initial value of the loop variable can be used by the expression for the increment and the final values; also notice that subscripted varidbles are permissible dS loop indices (Ex. 3). 'J' will be used as control variables. This is not the case: only the first variable (in this case 'I') will be In example 1 it may appear incremented. that both Other variables (such 'I' as 'J') and may be given values by replacement operators in any ot the three expressions, but these values will not change during the loop (unless commands ctlange them). venient to use the FOR within the loop It is often quite con- command to initialize several variables used in the loop along with the value of the loop index. The novice programmer who wishes to try writing a simple loop might begin with the following direct command: fOR I=1,10;TYPE 1,I 2,! A which wiLL print out the first 10 squares in some (unspecified) format. The more experienced programmer will quickly appreciate UWF's loop structure; for one thing, no rules regarding branches into the middl~ of a loop are necessary since there is no way to branch to the middle of a line! N EXT The normal termination for a loop is at the end of the Line containing the FOR command. If the loop contains a GOTO branch, however, the end of the line brdnched to becomes the terminator. mands, It is convenient at times, especially in direct com- to terminate the loop in the middle of a line so that other commancs which Logically follow the loop can be placed on the same line. The NEXT command serves this purpose, as shown in the following example: fOR * * *; ~hich loop commanci; NEXT; excludes 'other commands· from the Loop. UWF-39 other commands This construction also works in 'vertical' loops: FOR * * *; DO -.# commands # commands NEXT The commands executed by the 'DO' ~ill NEXT command. But more importantly, with the first c~mmand following be terminated upon when the loop is finished, encountering the UWF will continue the NEXT - thus skipping over the commands in the body of the loop. If this 'NEXT' command ~ere to be omitted or replaced 'RETURN', the program would simply 'fall through' to the first by statement in a the Loop (the one indicated by 1#' in the exampLe above). Notice that the NEXT command contains no references to the loop variable. This is a little different from the way most versions of BASIC implement this commdnd, but the effect is quite similar and since only the first letter of the command ~ord is decoded, grammers. variations such as 'NI' or 'NEXT-J' may prove helpful 'N;N·. Nested .loops, of course, may require 'nested NEXTs': example ~hich types out all the elements of a 5xS array a row to some proHere is an at a time with a CR/LF printed at the end of each row: FOR 1=1,5; FOR J=1,5; TYPE ACI,J); NEXT; TYPE NEXT has one other feature: continuation point other it than the may be uSed with a line number to specify next sequential command. Thus: 'FOR a * * *i commands; NEXT .S' will branch to line XX.80 when the loop runs to completion. Note 1: A NEXT command which is executed outside of a FOR loop is ignored unless it specifies a line number, in which case the branch will always be taken. A 'NEXT' command may thus be placed at the beginning of any line and used as a target for a 'do nothing' branch from within a loop without affecting the normal execution of that line. Note 2: Loops which contain conditional branches (i.e. be careful that all paths end 'IF' commands) should with an appropriate 'NEXT' if it is desired to skip UWF-40 over the statements in the loop under all conditions. Whichever 'NEXT' is executed on the final iteration will determine the program flow. B REA K Once a loop has been initiated it must normally run to completion. Branching to a line outside of the loop is not effective: that line will simply be treated as a continuation of the main loop (see comments about GOTO's in a loop in the preceding section). One way to force an exit variable to a value 'elegant', to say the least, difficulty. A BREAK causes an immediate exit from the loop (preserving the current greater than the final value of the loop index), command following the BREAK. value. would be to set This obviously not very is the loop so the BREAK command has been provided to solve this and the program then continues with the next sequential As you might expect, number so you can branch to a different you leave the loop. from a loop part of BREAK may also specify a line the program at the same time that A 'BREAK' without a line number. is ignored (just like the NEXT command) if it ;s encountered outside of a loop, so lines containing BREAKs can be used by other parts of the program. Each BREAK exits from only a single loop, so to exit from nested loops it would be necessary to use '8;8 15.1' will exit from 2 loops and then transfer UWF-41 t~ multiple line 15.1. BREAK commands: MISCELLANEOUS COMMANDS We will now finish the alphabet: ters. C,H,K,P,U,V are the remaining command let- 'u' and 'V' are not implemented in this version and may be used for whatever purpose the user desires. The '@' command is also available for expansion purposes. COM MEN T Any command beginning with a 'C' causes the rest of the line to be Such lines may thus be used for comments describing the operation In particular, line XX.DO (the first line in a group) for comments. Branching to a Comment line from within cycle of the loop. statement. of the ignored. program. should generally be reserved a loop will terminate that In this way a 'COMMENT' is equivalent to the fortran 'CONTINUE' A 'NEXT' command performs the same function and in addition may be used to designate the continuation of the program. H E SIT ATE The HESITATE command delays the program for a The argument (which must be an integer) is nominally in milliseconds, will generate approximately a 1 second delay. dependent upon the cycle time of the time specified by the machine, so 'H 1000' However, the exact deLay is directly so some calibration is necessary. Here is an example using the 'H' command: FOR T=1,9; TYPE It."; HESITATE 250*T UWf-42 command. PUN C H The PUNCH command allows the programmer to save a copy of the texL buffer and the symbol table in binary format, ready to reload with the standard Binary loader. This command requires either a Tapes created with the PU~CH High Speed punch or an audio (cassette) recorder. command can only be read with the Binary loader since they are not punched as ASCII characters. The advantage to punching tapes ;n this format shorter than ASCII tapes and they also is that they tend to be somewhat contain a checksum so there is less probability of an error going undetected. disadvantage however, The is that they are absolute memory dumps and so are not neces- sarily transportable between different versions of UWF. by UwF itself from a remote location, They also cannot be loaded but require access to the front panel of the the Binary loader as well as to restart UWF once the computer in order to activate tape is loaded. To use this command (assuming that you have a cassette recorder, procedure appLies to a HS papertape turn on the recorder and then punch), advance the tape to type 'P' followed by a RETURN. but the same an unused area, Approximately 5 seconds of leader code will be punched, followed by the contents of the text buffer and then the symbol table. To restore a program (and any symbols in use at the time it was dumped), leader, and while this section is being read, start the BIN loader from the front panel. If you start the loader before position the tape at the start of the reaching the leader section, the computer will halt with a checksum error (AC not zero); hit the CONTINUE switch quickly, leader, all will be well. and if you are still in the After reading in the program tape you must manudlly re- start UWF at location 100 (see page 2). The PUNCH command always returns to command mode (like MODIFY and ERASE), it cannot be followed by other commands, itself. so and should not be included in the program In systems with more than 12K the PUNCH command will dump the contents of the -current- program area, so to save the program in Area 3, for example, use a 'L 3' command to get to it and then type 'P' to punch it out. reloaded into the area that it came fro~; different area you must ~RITE A program can only be so if you wish to move a program to a it out (rather than PUNCHing it), and then read it in again as explained on page 45. UWF-43 THE 'OPEN' COMMANDS In addition to the PUNCH command described above, UWF has a series of 'OPEN' commands which aLlow ASK and TYPE (or other 1/0 operations) to use something other than the terminal. These commands consists of -two- words (or two single-letter abbreviations) been separated by a space. You may recall thdt the letter '0' has already used for the 'ON' command and wonder how it could 'OPEN' and 'ON' can be distinguished, however, an arithmetic expression. available. also be used for ·OPEN'. since ON must always be followed by Here is a short summary of the 'OPEN' commands currentLy The mnemonics, which were chosen in part to be compatible with the OS/8 version, are somewhat less than perfect! OPEN INPUT 0 I Selects the Terminal as the Input dev i ce OPEN OUTPUT 0 0 Selects the Terminal as the Output device OPEN READER 0 R Selects the High SpeEd Reader for Input o P OUTPUT TRAILER o T Selects the High Speed Punch for Output OPEN PUNCH OPEN ----,ECHO o -,E Punches It:aderltrailer code (ASCII 200) Connects the Input device to the Output Only the first two commands (O I and 0 0) and the ECHO option unless you have a high speed reader/punch (or an audio tape recorder). ,- 'OPEN' commands could also be expanded to include are useful The list of things like '0 L' (for selecting a Lineprinter) or '0 S· to send output to a 'scope display, etc. Such expansion is, however, entirely up to the user. I/O DEVICE SELECTION The Input and Output devices are always reset to the CTRL/f. To select a different device, ample, to read in a program from the High Speed Reader, command and henceforth, terminal when use the appropriate OPEN command. until this assignment is changed, come from the reader rather than from ~he keyboard. UWf-44 you hit For ex- simply type in an '0 R' all input to UWF wiLL In particular, even direct commands wiLL be taken from the reader, so you can set up a program tape to run the machine while you are gone. Also, if the tape contains a listing of a program it will be read into the text buffer just as though you were typing it in yourself. This is an alternative method for saving programs which has the advantage that- they are available as ASCII tapes which can be edited or processed by other programs. 'time-out' trap in the reader routine normally senses when A the end of the tape has been re~ched and then restores the terminal as the input device. A 'backarrow' or 'underline' is printed on the terminal to indicate that it is the active input (and output) device once more. If you need to manually restore the terminal to its usudl status, just hit CTRL/f. Similarly, to select the High Speed Punch (or Cassette Recorder) the output device, just use an '0 p' command. example, enter the commands: o P,T; W; 0 T,O for use as To dump the text buffer on tape, for (do not hit RETURN) and then start the punch or recorder. Hit RETURN anq then wait for the asterisk (*) to reappear on the terminal. To re-read such a tape at a later time, position it in the reader somewhere in the leader section, use the ERASE command to clear the progrdm area, and then type '0 R' followed by the RETURN key. If input is from Q~paper tape reader, the reader will If input is now begin to read the tape. actually start the tape moving (in key, otherwise the comes up to speed the leader section) first few characters are and UWf from an audio recorder you before hitting the RETURN likely to be may well conclude thdt should 'garbage' as the tape you have run out of the tape before you have even begun! It is also possible to use the reader/punch for data storage paper tape since purposes. This works best with the audio recorder lacks a 'stop-on-character' capability, making it difficult for UWf to keep up with the data once the tape has started moving. By way of an example, the following command will read in 50 numb€rs from the high-speed reader: o R; FOR 1=1,50; ASK DATA(l); NEXT; 0 1,E UWf-45 Notice thdt an '0 1,E' command is used at the the keyboard. end of the loop to restore If this command were omitted the H.S. reader would continue to be used for input, probably causing an error to occur since next on the data value input to it;s unlikely that the tape would correspond to anything expected from the key- board. The ',E' part of this command is explained more fully in the next section. THE ECHU OPTION The ',E' option mdY be added to either an '0 I' or '0 R' command that the input characters are to be 'echoed' to the output device. to specify Generally this option is -always- used with '0 I' and -never- used with '0 R'. The echo option may at first appear slightly confusing since UWF normally runs with the keyboard echo -on- and thus one comes typed will be printed on the to expect that ~hatever is terminal. This makes the -terminal appear much like a simple typewriter and tends to obscure the fact that if UwF were not sending back each character -nothing- would be printed! input device, keyboard it received, The 'ECHO' option must be specified when selecting "the or -NO ECHO- will be assumed. for input {it may already Thus an '0 I' command will select the -be- selected> and effectively turn the echo off. An '0 I,E' command is necessary to restore the echo under program controL. Of course any program error, or typing CTRL/F, wilL also restore the echo. The ability to disable the input echo is convenient at times since it allows a program to read one thing and possibly print something else. mode of operation occurs during command input: not get this character printed, An example of this when you type the RUBOUT key you do but rather a Ibackslash' (\), or on a video ter- minal, a three character sequence: 'backspace, space, backspace', which effectively removes the character from the screen. keyboard for program control, UWF programs can also be written to use the and in such cases it is often 'silent' input. You can try this out quickly by using disable the echo. Now type in '0', 'spacc', 'I', 'comma', the ccho will return again. UWF-46 desirable to have a direct '0 I' command to lEt and hit RETURN and Another time when you will want to disable the echo program tape on the • low-speed' reader. can avoid getting an unwanted is when reading in a If you turn off the echo in this case you listing while you relax to the rhythm of a quiet little Iburp,burp,burpl instead of a 'clackety clack clack'. Just hit CTRL/F at the end of the tape to turn on the echo again. Similarly, wh~n r~ading a data tape from the high-speed reader it is generally undesirable to have it all printed on the matically disables the echo; like, Thus the '0 R' command auto- but if you wc.nted to see what some of the data looked you could use an 10 R,E' command. you would first switch terminal. output to the To make a copy of a program or data tape punch and then turn on the echo to 'print' each character received on the output tape, e.g. o P;O R,E;S FINO() The device, 'FINO' function (described on page 62) looking for the character code specified. which will never be found, so the keeps reading from the input In this case a 'null' was used effect of this command is to continue reading until the end of the tape is reached at which point the terminal will automatically be restored as the 1/0 device, were to with the echo enabled. be copied you could use the FIND function to If only portions of a tape search for character and then switch 1/0 back to the terminal yourself. option to skip sections of the tape by an appropriate You can use the ECHO disabling the echo until you 'find' the right character and then turning it back on to copy some more. UWF-47 THE LEADER I TRAILER OPTION The 'T' option punches leader/trailer code (ASCII 200). (but not essential) portant when using for separating output on paper tape, This is convenient and somewhat more im- an audio recorder since there is no visual indication of breaks in the data. Blank tape may also be used as 'leader' and both are ignored each time the reader is selected as the input device. character has been ~ead these same cause both input and output to be However, after the first valid input codes are interpreted as the 'end-of-tape' and restored to the terminal. A 'backarrow' or 'underline' is also printed to indicate that the EaT was detected. serves the dual This character purpose of also removing any 'garbage' characters which might have been read after the last valid input. The 'T' option can be used alone ('a TI) or in conjunction with another 'OPEN' command. The number of L/T code~ punched is determined by an expression following the letter 'T' (and separated by a optional arithmetic space from it), with the previous specification being used as the default. The initial value is 512, is but somewhat ridiculous for paper about right for use with an audio recorder, tape (over 4 feet of leader!). case. or so is more appropriate in this You can always just repeat the 'T' option to get a slightly longer leader if you want to: 100. A value of 70 which 'a T 100,T' will punch out 200 LIT codes but leave the default set at Notice how this option was used in the example on page 45 for writing out all of the program buffer. The length specified by the 'T' option is also used by the 'PUNCH' command (see page 43). UWF-4S K 0 N T R 0 L This 1/0 module. is an optional command which may be used to program the DR8-EA parallel The 'K' command is used to set and clear individual bits in the output register while the FDIN function (described on page 65) is used to read the cor- responding bits in the input register. These options are added by the initialization routine if Switch 7 is -UP- (see page 3). The KONTROL command uses -positive- nunbers to turn bits on, numbers to turn them off. Each bit is directly controllable, setting of any of the others. -negative- independent of the Thus a 'K l' command, for example, '1' without changing the state of any of the other 11 bits, and will turn on bit while a 'K -1' command will turn it off again. In order for this scheme to work successfully the bits must be numbered from '1-12' rather than from '0-11' which is the usual convention. This is because '-0' is not distinguishable from 1+0'. In fact, 'a' is interpreted to mean 'clear all bits', so a 'K O' command (or just 'K' since 'a· is the default for all arithmetic expressions) can be used to quickly initialize this register. More than one bit position can be set at a time, e.g. a command such as: K 1,-2,3 will set bit 1, clear bit 2, and finally set bit 3 In this form, or so each operation occurs sequentially with perhaps 10 miLLiseconds between operations. This allows a command generate a short pulse on line 1. such as 'K 1,-1' to be used to If it is necessary for several signals to occur simultaneousLy, those operations can be encLosed in parentheses: K 1,(2,3,4),-1 will set bit 1, then bits 2,3,4, then clear bit 1 Since for some purposes it is more convenient to be able to specify various bit combinations with a singLe arithmetic expression rather than setting and clearing each bit individually, a third mode of operation is also available. mode, the last 4 bits (bits '9-12') by an ';' sign. In this are set to the value of an expression preceded The remaining 8 bits are not changed. IIUI=-I..O Thus a 'K,=S' command would first clear all bits (the comma indicates a '0'), then set bits missing argument which ;s the same '10' and '12' while clearing bits '9' and '11' already clear in this case). To summarize the 3 different forms of the KONTROL command: K N,-N Turns a single bit on or off N=O turns -all- bits off K (L,M,-N) Performs all operations in parentheses simultaneously, instead of sequentially Sets the 4 least-significant bits to the binary value of N; this form may not be used inside parentheses. UWF-50 as (whichwere ERROR MESSAGES UWF traps any 'illegal' operation such as command and prints a peculiar little division by zero or an message to tell you what the where in the program it occurcd. If you type in the command: '~ET unknown problem was dnd 2=3' for example, UWF will reply with: '107.44' which is its way of telling left side of an '=' sign. you that you have something besides a variable on the To decode the error message you should look at the back cover of this manual (or the summary card) which lists alL of the error diggnostics and their probabLe cause. If this same error had occure~ while the program was running (i.e. direct command), the error message would aLso indicate not from a the line in the program containing the erroneous statement: 107.44 @ 15.13 indiates 'operator missing or illegal use of an equal ~sign' in line 15.13. The program 'QUITS' whenever an error occurs, cancelled and interruption, in generaL it is impossible to but thus all pending operations are resume -precisely- at the it is often possible to make the necessary changes, point of perhaps update a few variabLes with direct commands, and then restart from a point close to where the error occured. This version also has an 'auto-restart' feature which allows the program continue after an error instead of returning to selected by and is described in greater detail on an option in the IQUIT' command page 35. UWf-S1 command mode. This to feature is THE TRACE fEATURE To further assist in finding the source of an error, UWF has d facility for printing out each program step as it tries to execute it. Thus when an error occurs you con see exactly where the problem is. occurrence of a '?' in the program (not €nclos~d The 'trace' feature-is turned on by the one ~hich is precedec by a single quote or in double quotes, however) and turned off again by another '?'. Thus only the portion of the program between pairs of question marks will be output while the program is running. The '?' may be given in a direct command, so to trace the entire program, just use a 'GO?' command to start it. Similarly a 'DO 5.2?' command will selectively trace that one line. As a further aid to finding logical errors (as opposed to simple programing UWF will print out the result of all expressions appearing in SET commands. Thus you can see the values of alL the variobles as well as the program steps which created those values. A video termin~l is obviously mistakes), when the trace is on, preferable for program traces since rather voluminous output can be generated in quite a short time. A somewhat secondary prompting. use of the TRACE feature is for simplified input/output Whenever variables have names closely resembling their usage, it is a bit of a waste to have commands such as: ASK "AGE? "AGE TYPE "COST="COST or when, with only a small sacrifice in the punctuation, the following will do just as well: ASK ?AGE ? TYPE ? COST? _ or UWF will print out just the characters enclosed by the '?'s. For this reason it is preferable to use 'spaces' as separators r~ther than 'commas', i.e. 'ASK ?A BCl) C(J,K) ?' will print out each variable name followed by UWf-5Z d spdce and then wait for its value to be input. One small disudvantage to this 'trick' is thdt are -actu3Lly- being traced, ~hen such statements the text enclosed by'?' marks will -not- be printed due to the 'toggling' nature of the trace switch. There is one other small anomoly associated with the trace feature: A command such as 'SET !=5,$=10' will not set those two 'secret variables' when it is traced, but wiLL instead first perform a CR/LF and then dump the symbol because during a program they were operators. trace all SET 'TYPEs' and hence the or Thi s i s commands are treated internalLy as though secret variables toke on their special roLes There is a simple solution to this problem, simply prefix a '+' sign, table! otherwise embed and that is to however, such variables arithmetic expression so that they are no longer recognized oS in the midst of an as ASK/TYPE operators. Thus the command 'SET +!=5,+$=10' would be trdced properLy. COMMAND SU~1MARY The following table provides a quick review of UWF's entire command reper- toire. FORM EXAMPLE Ql not implemented in this version ASK list of Variables, "prompts", formatting options A X,Y(I),Z(J,K) BREAK line number B COMMENT your programs \Jhenever possible B 11.45 or C FOR COiVlMENTS 00 list of lines, groups, or sub-groups ERASE FOR line, group, sub-group, or • all' Var = start, increment, finish GOTO line number .7, -9.5, 10 E 5 or E 9.1 0 F I=1,5;F J=I,-1,0 G 11.8 or G .3 HESTATE time delay desired H 1000 (K=l-J) , .5 IF (Arithmetic expression) negative, zero, positive 1 JUMP line number J .3;C WAIT LO()P JUMP (Arithmetic expression) one, two, three, four, ••• J UWF-5j (N) 1, .2, -3.4 KO~TROL bit positions K 1,(-1,2,3),=X LOUK program area L 1 LINK program area, subroutine pointer MODIfY line number MOVE old line number, new line number L 2,4.1 or L,10 M 5.1 M 3.3,6.3 NEXT line number F 1=1,10;N;T PI ON (Arithmetic expression) PUNCH punches program QUIT line number Q or Q RETURN line number R or R .2 SET list of arithmetic expressions S A=S, B=C=A/2 TYPE arithmetic expressions, "labels", formatting T !?A ?: 10"8="8 U available for user expansion V available for user expdnsion WRITE list of lines, groups, sub-groups, or lall' W or W -1.5,2,3.1 XECUTE list of arithmetic expressions (same as SET) X fSlN (II) I Feos (#) YNCR list of variables Y I-J,K L ZERO list of variables or lall' Z,#,A,B(I),CeJ,K) OPEN INPUT, ECHO neg~tive, ~nd vari~bles zero, positive in binary format 0 (A-S) -9.2, 9 p 5.1 normal terminal input 0 l,E OPEN READER selects high-speed reader 0 R OPEN PUNCH selects high-speed punch 0 P OPEN OUTPUT selects terminal for output 0 0 OUTPUT TRAILER punches leader/trailer code 0 T or o T 70 UWf-S4 INTERNAL FUNCTIONS In UWF, spite of the fact that only about 3.3K words have been used to implement there are nearly 20 built-in functions and a facility for adding a limitless number of Programeq Defined Functions. The 'internal' functions provide the user .~ith full-dccuracy C'10-digit') proximations for commonly used relations such as log, square root, etc. exponential, sine, ~p cosine, Also included are simple numerical functions such as absolute value, integer, sign and fractional parts, maximum/minimum, etc. And finally, are a few functions for character processing and redding the Switch Register and lOading the MG. special 1/0 All operations function nQmes th~re such as in UWF bEyin with the letter IF'; thus vdriables names may not bEgin with this letter. TRANCENDENTAL FU~CTIONS This class only be expressed of functions, dS infinite so named beCause the relations they represent series, includes the natural log functions and the three most common trignometric functions. tions used by UWF have been optimized by a constrained reduce the error over the principal argument range to at con and exponEntial The series approxima- least-squdres procEdure to worst a few parts in 10 billion. The trancendental functions can be removed if you wish to increase the of variables available in the 8K version. Removing them creates space for number anoth~r 55 variables - a total of 175 instead of only 120. Program Defined Functions can be incorporated in their place at the expense of greater execution time and slightly poorer accuracy. See page 71 and Appendix 11. UWF-55 FLO G FLOG(X) returns the natural logarithm of the absolute value of the argument. An error occurs if X is zero since the theorectical result is infinite. No error occurs if 'X' is negative, although the Log function is, in foct, only defined for positive arguments. This implementation facilitates the use of FLOG for extrQcting roots and raising values to non-integer powers. The Common (basc-10) logarithm is easily obtained from the FLOG function just by dividing by FLOG(10). Example: TYPE I.,"NATU({AL LN(Pl)="FLOG(PI) NATURAL LN{PI)= :45"CCM~ON 1.144729886E+00 LOG(PI)="FLOG(PJ.)/FLUG(10)! COi~~jON LOG{Pl)= 4.971498727E-01 F E X P FEXP{X) returns the value of eAX where 'e'= 2.718281828 ••• The value of Ie' is always available as FEXP(1). compute non-integer powers. This function is often used to extract roots and A ·X 3.S' is found from the expression: For example, FEXP(3.5*FLOG(X». Similarly, the cube root of 27 may be founa from the expression: FEXP(FLOG(27)/3). The absolute value of the argument must be less than approx- imately 1400 in order to avoid numeric overflow. f FSIN(A} dnd FCOS(A) SIN - F COS return the value of the sine and cosine of the angle 'A' when 'A' ;s measured in -radians-. ferred for scientific and engineering A 'radian' is ~ork a unit of angular measure pre- because it eliminates factors of PI in many formulae. One radian ;s 1/2PI of a full circle, or approximately 60 degrees. ·UWF-S6 To convert angLes from degrees to radians you simpLy multipLy by P1/180. The vdlue of 'PI' is a protected var;dble which is aLways avaiLable. Here is a short table of the values of FSIN and FCOS over the first qUdurant as produced by the command shown. Notice how the radian value was saved for use in the second function call: • FOR A=O,10,9U; TYPE i.2,A i.15.1, FSIN(R=A*PI/1bU), FCOS(R)! 0 O.OOUOOOOOOO 1.0000000000 10 0.1756481776 O.9848077)~O 20 0.3420201433 0.9396926207 30 0.5000000001 0.8660254037 40 0.6427ti76U96 0.7660444431 50 0.7660444431 0.6427876096 60 0.866025403(' 0.5LJOOOOOOO1 70 0.93969262G7 O.!J420l01433 80 0.98480775:)0 O.17-S64b1778 90 1.0000000000 0.0000000000 F TAN - FAT N The Tangent function is not provided as an intErnal function since it is the ratio of FSIN/FCOS dnd is thus easy enough to compute. his own FTAN function, however, just The user may implement as described in the discussion of Program Defined Functions on page 67. The inverse ('arc-I) tangent function is available, FATN acc~pts val- the -angle- (in radians) which would give that The range of answers ;s from -PI/2 (-90 degrees) to +PI/2 (+90 degrees). ues of any magnitude tangent. ho~ever. and returns To convert from radians to degrees, just multiply by 1S0/Pl. For example, to ch~ck that the angle ~hose tangent is -1 is, in fact, -45 degrees: TYPE 1SU*FATN(-1)/Pl UWf-S7 -45.00GOOOOO All other trig functions ccJn be der;,,~d from these primary functions. for eXampLe; Cotdngent FCOSCA)/FSIN(A) Arcsine FATN{A/FSGT(1-A*A» Arccosine FATNCFSQT(1-A*A)/A) HyperboLic sine (FEXP(A)-FEXP(-A»/2 HyperboLic cosine (FEXPCA)+FEX?(-A»/2 Consult any ~dv~nced Algebra book for other such id~ntities. F S Q T The fSQT function computes the square root of the argument using an approximution which guarantees that no Example: TYPE FSQTCZ), more than the last bit iterative will be in error. FSQT(2)~2! 2.0UOOOOOOO 1.414213562 F A 8 S FABS returns the absolute vaLue of the argument: TYPE FABSC-1), FABS(1) 1.00000000 1.0000000UO F S G N FSGN returns -1, a or +1 depending upon whether the argument was: zero or positive. U\iJF-5o negdtive, Example: TYPE FSGN(Pl), FSGN(PI-Pl), FSGN(-Pl) 1.000000000 0.000000000 -1.000000000 FIT R FITR returns the InTegeR part 'FITR(-5.S)' is '-5'. of the argument. Thus 'FITR(PI)' is '3 1 and Note that some languages have an 'entier' function which ;s the 'integer less than or equal to the argument'. duces the Sdme result as UWf's FITR function, For positive numbers this pro- but for negative values it gives the next lowest number. If you are converting a pro9r~m which was originally written in another language, be sure to watch for this subtlety! functions and commands in UWF convert values to an It should be noted that many integer form internally without requiring the programer to do so. Subscripts, for example, are always used in ger form, meaning that 'A(1.5)' is legal, but is no different from 'A(1)'. eral, a vaLue which is used as an index or is stored in a ;nt~ In gen- hardware register is always converted to an integer before use. F RAC FRAt returns the fractional part of a number - the part which FITR discards! This may be used to do 'modulo-Nt arithmetic or to check for a remainder. The user is cautioned, however, accuracy hence checks for 'exact' values computed from expressions containing and that the value returned by FRAC may the FRAt function should generally be avoided. of '.002' ;s .OOZ, have onLy limited To illustrate, the fractional vaLue but the fractional value of 1.002 is off in the 8th place while that of 1000000.002 is only correct to 3 digits. taking the difference between two large numbers. UWF-59 This is simply the result of F MIN - F M A X These functions compare two arguments, returning the algebraically smallest or largest value. Thus 'fMIN(+1,-2) These functions have several function allows one to would return 1-2' while fMAX would return '+1 '. uses. avoid A simple example in connection with the FLOG the 'log-of-zero' error with a call such as tFLOG{FMAX(1E-10,X». Simildfly, the FMIN function can be used to avoid ty~ing nonexistent vdlues when dumping an array in a multi-column format. In this example, 'C' is the number of columns and IN' the number of ddta values in the array: FOR I=1,C,N; FOR J=I,fMIN(N,C+I-1); TYPE Q{J); NEXT; TYPE As a final example, an entire array can be scanned for its extrema simply by com- paring each element with the previous best estimates: SET MIN=MAX=A(1); fOR 1=2,N; SET MIN=fMIN{A(I),MIN), MAX=fMAX(A(I),MAX) A disadvantage of this method for locating the extremes is that no information is available as to which element ;s biggest or smallest, only the values are returned. f RAN The FRAN function returns a different called. pseudo-random number each time it is The numbers are limited to the range 0-1 and have an approximately 'flat' distribution. Other distributions, for instance Gaussian or Lorentzian functions, can be ~reated as Program Defined Functions by using fRAN in an appropriate expression. The function is initialized by the input wait loop so the values you observe will appear to be truly random. The pair-wise and higher-order groupings do have a small correlation coefficient, but even so, a reasonable value of obtained using FRAN to generate a 2-dimensional sc~ttcr pattern. of FRAN appears to be for games. UWF-60 PI can be The principle use CHARACTER dnd 1/0 FUNCTIONS The remaining internal functions hdndle character manipulation and other special-purpose 1/0 ope:rations. The character functions include FIN, fOUT, fIND and fTRM, while FSR, FMQ and FDIN are 'I/O-type' functions. fBUF and fC0M provide access to extended memory for storing large data arrays. fIN The fIN function reads a single character from the Input Device the numerical value of that character. and returns A list of character values may be: found in Appendix I and the vaLue of any character can be obtained within the pre jram simply by preceding it with a single Quote mark. Thus the expression (IA) value of the letter 'A' ~ill 'A' and 'Z'. while ('A-'Z) (19~) will have the be the difference of the codes for Character strings can be read with the FIN function and later output with fOUT; this is a bit slow, but does provide UWF with a limited string-handling facility. F 0 U T The fOUT function generates a singLe character from the value of an arithmetic expression. It will thus output what FIN has input: 'FOUT(193)' ~iLl generate the letter 'At. More commonly, however, acters which wouLd otherwise be ........ command. For FOUT is used to output special control char- invisible if instance, 'FOUT(7)' is 'FOUT(140)' outputs a 'form-feed' character. which is used by many terminals to they were simply included in a 'TYPE used to ring the 'bell', while 'fOUT(~7)' generates an ESCAPE code initiate special functions such as reverse video, cursor movement, etc. UWF-6' FOUT expects arguments in the range O-l55; output, but should be avoided. values beyond this range will be Most terminals respond in the same ~ay to values in the range 0-127 and 128-255. UWF's input routines, however, always return values in the higher range (128-255) in keeping with the standard established for the PCM-12. The value returned by FOUT is always -zero-, code! This was done to instance, you can output a formfeed ahead of a program listing by using is ignored, character simplify calling the function as part of a commdnd. FOUT(12)' command instead of just 'WRITE'. zero not the value of the you can include them in 'tab expressions'. Si~ilarly, For a 'WkITE since 'tabbing' to column FOUT's in ASK or TYPE commands just by putting To print a 'double quote' mark, for instance, you coulu use the following: TYPE "THIS IS A ": FOUT (' ") II THIS IS A " MARK! which will produce MARK! II FIN D FIND searches for a character equal to its argument, characters it encounters until it finds setting of the input echo switch, which matches is -not- echoed, tion. To output this character too, Carriage Return: SET FINO(141). The echo is controlled by the as described earlier on page 46. however, where 'A' is the search character. a match. reading and echoing all The character but;s returned as the value of the func- you may use a call such as'S FOUT(FIND('A»)' To read in a comment line, just search for a To read the same line in from a paper tope, ever, you should search for the Linefeed following the CR: SET FINO(130). how- This is due to different conventions for the 'end-of-linc' chdracter. FINO also checks continually for a CTRL/Z. This is recognized as an 'End-of-File' mark and causes FIND to return with the value 'zero' instead of with the value of the scarch character. UWf-62 F T R M As discussed earLier on page 25, '0-9' and 'A-Z' as a terminator, the ASK command treats any input other than which means that data values may be conveniently 'flagged' by the use of a speciaL terminating character. The . function program so is to then pass this information back action may be taken if necessary. to the purpose of the FTR~ that special For instance, a program might need to be able to work with either metric or EngLish measurements, using an appropriate terminator to differentiate between them. which accepts forms the numbers Similarly one can devise a 'pocket calcuLator' program terminated by one of the arithmetic operators and then per- indicated function. One of the more common uses for this feature is to permit an indefinite number of data values to be read minator for the last value. A in, sensing a special ter- loop like the one in the exampl,-~eLow (which checks for a '?') is all that is required: 4.1 ZERO N;TYPE "ENTER QUIZ GRADES, TERMINATE THE LAST ONE WITH A'?'''! 4.2 ASK G(N=N+1); IF (FTRM()-'?) .2".2; TYPE X2"THERE WERE"N "GRADES"! F B U F - F COM These functions alLow UWF to use extra memory for data storage and are thus of interest only for systems with more that 12K. They may be added by setting SW1~~h.8 -UP- when UWF is started for the first time (see page handle 12-bit (signed) 3). FBUF is designed to integer data while FCOM may be used for storing either 24- bit integers or 48-bit floating-point values. Both functions are called in the same manner: the first argument specifies the relative location in the storage area and the second argument (if any) is the value to be stored at that location. function always returns the value at the location specified. Thus: FCOM(l) returns the 'Ith' value in the 'FCOM' area FBUF(l,V) stores the value of 'V' in the '1th' location. UWF-63 The The range of the index is typically 0-4095 for FBUF and 0-1023 for FCOM. FCOM has another mode however, in which data is stored as two-word integers (rather than four-word floating point values) thereby doubling the amount of storage available but limiting the range of the data to +/- 2-23. To use FCOM in this mode, specify a -negative- index (legal range is -1 to -2048). Here is a loop which stores the square root of all numbers from 0-1023: fOR 1=0,1023; SET fCOM(I,FSQT(I» Although FBUF and FCOM share the same field, FBUF starts from the 'bottom up' while fCOM stores from the 'top down', so both functions may be used simultaneously. Furthermore both functions are fully recursive, so calls such as 'FCOM(I,FCOM(J» may be used to move data from one location to another. F S R The FSR function reads the value of the Switch Register. control program options. This may be used to The value is treated as a signed number so the range is from -2048 (4000 octal) to +2047 (3777 octal). F MQ The FMQ function displays the integer part of the argument in the MQ register. This is quite handy for 'spying' on the displaying the value of a loop index. argument, progress of a long calculation simply by Since FMQ returns the integer part of the it can be incLuded in a subscript expression, such as 'A(FMQ(I»' which is functionally the same as 'A(I)' but also displays the index in the MQ. UWf-64 F 0 I N This is an optional function for reading the input register of a DR8-EA par- allel 1/0 module. It may be added (along with the Switch 7 -UP- the first time UWF is started. to either levels or pusles, 'KO~TROL' command) by setting The interface may be wired to respond the difference being that it will 'remember' a pulse, but 'forget' when a Level changes. Each bit is separately addressable, and each may be wired for pulse or level sensing. For use with the FDIN ('Digital INput') function, the bits are considered to be numbered from 1-12 (rather than from 0-11), just as they are for the 'KONTROL' command (page 49). The value of 'FDIN(O)' (or just 'FDIN()' since 'zero' is always value of an argument) the default is simply the weighted sum of all input bits which have been 'set'. Bit '1' has the value 2048, bit '2' 'weighs' 1024, etc. The maximum value ;s thus '4095' if all the bits are turned on. Any bits which are read by function will be reset if they are resettable, input. i.e. the FDIN if they are wired for 'pulse' This ensures that only one occurrence of an event will be detected by the program. FDIN can be made to respond to only a single bit, or to a collection of bits, by including various arguments as the programmer desires. For instance, will only sense the state of bit '1'. FOIN will have the value 2048, while if it is off, the value If bit 1 is on, 'FOIN(1)' 'a' will be returned, regardless of the setting of any other bits. Furthermore only bit 1 will be reset. The value of 'FDIN(-1)' on the other hand, will be the status of all bits -except- bit 1, i.e. bits 2-12. Any bits which are read will be reset as described above. More complicated masks can be constructed by specifying multiple bits. Thus 'FOIN{1,3)' will only look at bits ", and '3', while 'FDINC-2,-5)' will look at -all but- bits 2 and 5, etc. UWF-65 PROGRAM DEFINED FUNCTIONS UWF allows the user to define his o~n set of special functions within program. Such 'Program Defined Functions' ('PDFs') commands, ranging from a single program step to as much as an entire group. the may consist of any set of UWF A PDF is very similor to an ordinary subroutine ('DU') call, but with 3 importdnt differences: 1) a PDF may pass arguments to the subroutine 2) Q PDF returns a numeric value - the value of the function 3) a PDF may occur in any command, not just DO, eN, The last difference is esp~cially importcnt since it allows LI~K, etc. subroutine calLs in some circumstances when they might not otherwise be possible. The form of a PDF call is: F( line number, argument list) where the letter 'F' identifies this number identifies the function. variable so that (v.i.). one may as a function call ~nd the line This number can be r.cplaced by a use a 'named' function call The argument list is not required, rath~r (or group) suitably chosen than a 'numeric' une but may contain se~cral argum~nts. !ypically, only 1 or 2 are used although this is not a fundamental restriction. The arguments may consist of other PDF calls which do not any other internaL functions, calls containing an thcmselv~s hd~e with or without arguments. The arguments, or use of nested PDF argument list ;s restricted since the arguments are not storeo recursiyely. Here are few examples of Program Defined Functions: F{2,A*B) Calls Group 2, pdssing 'A*B' as the argument F{.9,X,Y) Calls line XX.90 in the current group F(-9.S) Calls sub-group ot line 9.5 with no arguments UWf-66 Coding a PDF is no different from writing an ordinary subroutine, but the mechanism for passing argument values and returning the function result needs to be explained. The value of each arithmetic expression appearing in the argument list is saved in a specific variable '#', 'X'. 'protected variabLe'. the second one in the variabLe '$', Additional arguments are possible, should The first argument is saved be defined when initiaLizing in the and the third in the variable and if necessary more protected variabLes UWF (see page 3). The ordinary variables created by the program may also be used as 'common' variables (those appearing in both the 'main' program and the definition of the function) for passing information to the subroutine. PDF calls are not required to always have the same number of arguments, infrequently used parameters can be placed after frequently used ones. not be changed unless they example, are modified by the subroutine itself. the value of 'A-times-B' is placed in the variable example, 'X' is placed in '#', and 'Y' goes into'S'. subsequently with only a single .argument, '#'. so These wiLL In the first In the second If this function were called the value placed in'S' would not be disturbed. No arguments are used in the third example, but any variables defined by the program may be used by the subroutine. This is the only reasonable way to handle arrays. The subroutine must then be written to use the appropriate protected variable whenever it needs the value of the corresponding argument. A routine to compute the length of a vector, for instance, might use an expression such as 'FSQT(#*#+$*$)'. The value returned by the function expression processed suitable command, by the is just the result of the last subroutine. arithmetic This expression may be evaluated by any but typically the SET command is employed. To begin with a very simple example, here is how you could code the tangent function: 9.9 SET FSIN(#)/FCOS(#)i COMMENT: THIS IS THE TANGENT FUNCTION You could also include a replacement operator to save the result in a vari- able, or you could use the TYPE command to output the result of the expression, or whatever. Since it is the function, however, the -last- result which is returned as the value of if other calculations are necessary for checking the result or UWF-67 performing ancilli~ry calcul6tions, th~ value desired must be saved ~nd then 'SET' again just before returning. There are a number of UWf commands which do not may be used without RETURN, Y~CRE~IENT c~ution disturb a in the definition of the function. PDF result and so These are COMMENT, and ZERO. On the other hand, branching commands always evaluate a line number (which may be zero), destroying the (expected) and so cannot be used to terminate a PDF without function resuLt. It should also be pointed out that the line number option in a RETURN command (see p3gC 31) will be ignored by a PDF call. This is necessary to Ensure that the program returns to complete"the function Call. While most PDF calls just use an expLicit line or group number to function, nicely it is possibLe to b~ somewhat more elegant! selected 'F(9.9)' function. name you can i~entify the By using a variable with a specify the 'F(TAN,X)' function rather than To do this, just set the variable 'TAN' 1'0 the value 9.9. th~ This has the additional advantage that you can easily move the subroutine to a different part of the program without having to change all the function calls. UWf-68 EXAMPLES OF PRUGRAM DEFI~ED FUNCTIONS Here are a few interesting PDF's which illustrate some of the things you can do. A symbolic name has been used in most cases; it must be set to the value of the line or group actually used to code the function • . 1) F<PWR,X,Y) - raises 'X' to the 'Y' power when ty, is non-integer: SET FEXP($*FLOG(#» Sample call: 2) TYPE F(PWR,27,1/3) 3.000000000 f(!,N) - computes the Nth factorial (maximum value of N is about 300) FOR 1=$=1,#; SET $=$*1 Sample call: 3) TYPE F(!,S) 120.0000000 f(SUM) - computes the sum of the subscripted array 'G(l)' ZERO $; fOR 1=1,N; SET $=$+G(I) Sample call: 4) SET AVE=F(SUM)/N f(PN,X) - evaluates the polynomial 'Y=CCO)+C(1)*X+C(2)*X-Z+ ••• +C(N)*X-N' FOR 1=N,-1,$=O; SET $=$*#+C(I) This function is useful for computing series approximations UWF-69 5) F(OCTAL,VALUE) - converts a number from decimal to octal FOR 1=N=O,4;SET N=N+(#-8*#=FITR{#/8»*10-1 Sample call: TYPE F(OCTAL,1000) 1750 This is the most interesting of the functions shown so far, than that it uses all the arithmetic operators in a single SET some fancy redefinitions within the loop. command as well as The technique employed is quite general for changing from one number base to another, and '10's' in the if for no other reason so simply by interchanging the 18's' definition you can construct a function to give you the decimal equivalent of an octal number: TYPE F(OECIMAL,1000) To be still more elegant you place of can 512 rewrite the function to use the value of '$' in the number'S' shown above and thus have a converting to any general-purpose routine for number base (less than or equal to 10). A fun thing to do once you have made this change, is to try it out with a direct command such as: FOR J=2,10; TYPE F{BASE, 99, J)! which will then type out the value of 'ninty-nine' ;n a'll number bases from 2-10. The loop limit represents the maximum number, with large numbers so if you try this number of digits required and to represent the small number bases you will probably need to increase the limit to something more than '4'. 6) PDF replacements for the trdncendental functions: These functions may be used in place of the internal functions that you wish to delete some of them in the event to increase the number of variables available on an 8K machine. F(EXP)= 25.1 IF (#*#-.01).2; SET #=F(EXP,#/2)Al EXP=25.1 25.2 SET t=1+#+#*#/2+#-3/6+#-4/24+#A5/120 F(lOG)= 26.1 IF (#*#-2.04*#+1).2; SET ~=2*F(LOG,FSQT(#» lOG=26.1 26.2 SET #=(#-1)/(#+1), #=2*(#+#-3/3+#-5/5+#-717) F(ATN)= 27.1 If (#*#-.01).2; SET #=2*F(ATN,#/(1+FSGT(1+#*#») ATN=27.1 27.2 SET #=#-#-3/3+#-5/5-#-7/7 F(SlN)= 28.1 If(#*#-.01).2; SET #=F(SlN,#/3), #=3*#-4*#-3 SIN=28.1 28.2 SET #~#-#-3/6+#-5/120 F(COS)= 28.3 SET f(SlN, Pl/2-#) FeTAN)= 29.1 IF (#*#-.01).2;5 #=F(TAN,#/2), #=2*#/(1-#*#+1E-99) TAN=29.1 29.2 SET #=#+#-j/~+#-5/7.5+#-7/315 F(ASIN)= 30.' If (#*#-.01).2;S #=2*F(.'~#/(FSQT(1+#)+FSQTC1-#») ASIN=~O.' 30.2 SET #=#+#-3/6+.075*#-5+#-7/22.4 FCACOS)= 30.3 SET Pl/2-F(ASIN) F(H5IN)= 31.' If (#*#-.01).2; SET #=F(HSIN,#/3), #=3*#+4*#-3 HSIN=31.1 31.2 SET #=#+#-3/6+#-5/120 F(HCUS)= 31.3 SET FSQT(F(HSIN)*#+1) The method used in these functions is to recursively reduce the argument to a value typically tess than .1, evaluate a series appro~imation which ;s f€dsonably accur- ate for an argument of this magnitude, ~nd then 'bootstrap' back using an identity such as ·c-ZX=(e-X)-2'. Thus the appro~imation ~or F(EXP) is evaluated after recucing the argument to the proper range and then the result is squared enough times to return to the original value. This clever method was devised by A.K. Head. UWf-71 7) In many cases a PDF call is parameter or value. t~o preferable to the subroutine at the to a simple 100' because it can pass a same time and can also return a 'status' As an example of such a use, consider a subroutine for finding the roots of a quadratic equation. There are three possible cases: roots are real, but unequal, the roots are equal, or the roots are complex numbers. the If the values pro- duced by the subroutine are stored in 'R1' and 'R2', then after calling the routine one must still decide how to interpret the results. If the subroutine were to return the value of the 'discriminant' this could be accomplished as follows: ON (f(QR» complex, equal, unequal ~ where 'QR' is the group number of the Quadratic Root subroutine, and 'complex', 'equal', 'unequal' are line or group numbers associated with ttle 'ON' command which serves both to call the subroutine and to test the result at the end. examples will undoubtedly occur to the redder. UWf-72 Other uch FU~CTION UWF. SUMMARY Here is a list of all the functions implemented in the standard version of Since up to 36 internal functions are possible, it should be clear that this list is not exhaustive. FABS Returns the absolute value of the argument FATN FBUF Returns the angle in radians whose tangent is given Optional: stores or retrieves 12-bit signed integers FCOM Optional: acceSSES ddditional memory for ddta storage FCOS Returns the cosine of an angle measured in radians FDIN Optional: returns value of digital input register FEXP Returns value of FIN Reads and returns the value of a single character F1ND Searches for a given character code FITR Returns integer value of the argument FLOG Returns the natural logarithm of the argument FMAX Returns the maximum value of two arguments FMIN FMQ Returns the minimum value of two arguments FOUT Outputs a single character value FRAC FRAN Returns the fractional part of the argument Returns a random number in the range 0-1 FSGN Returns the sign value of the argument: -1,0,+1 FSIN Returns the sine of an angle measured in radians FSQT Returns the square root of a positive number FSR Returns the signed value of the switch register FTRM Returns the value of the last ASK terminator Program Defined Functions F 'e~X' where IXI ;s less than 1418 Displays the argument in the M9, returns same UWF-7j DECIMAL VALUES r~R CODE 128 CHARACTER CTRL/@ NULL CD. CHAR 160 SPACE 129 CTRL/A SOH 161 130 CTRL/B 131 CTRL/C 1~2 CTRL/D STX ETX E(JT 162 163 164 133 CTRL/E ENQ 134 135 CTRL/F CTRL/G 136 ALL CHARACTER CODES CD. CHAR 192 @ 19j A 224 225 a B C 226 227 b II 194 195 $ 196 0 228 d 165 1- 197 E 229 e ACK BELL 166 167 & 198 F f 199 G 230 231 CTRL/H 8.S. 168 ( 200 H l32 h 137 CTRL/I TAB 169 ) 201 I 233 ; 138 CTRL/J L.F. 170 * 202 J 234 j 139 CTRL/K V. T• 171 + 205 K 235 k 140 CTRL/l F. F. 172 , 204 L 236 l 141 142 CTRL/M C. R. 173 - 205 M 237 m CTRL/N SO 174 206 N 238 n 143 CTRL/O S1 175 I 207 0 239 0 144 145 CTRL/P CTRL/Q OLE XON 176 177 0 P Q 240 241 p 1 208 209 146 CTRL/R DC2 178 2 210 R., 242 r 147 CTRL/S XOFF 179 .) 211 S 243 s 148 CTRL/T DC4 180 4 212 T 244 t 149 CTRL/U NAK 181 5 213 U 245 u 150 CTRL/V SYNC 6 214 V 151 CTRL/W ETB 182 183 7 215 W 246 247 v w 152 153 CTRL/X CAN 184 8 216 X 248 x CTRL/Y EM 185 9 217 y 249 y 154 155 CTRL/Z CTRL/[ SUB ESC 186 187 Z 250 251 z ; 218 219 156 FS 221 ] 158 CTRl/" RS 190 < = > \ GS 188 189 220 157 CTRL/\ CTRL/) 159 CTRLI US 191 1· It UWF-74 [ CD. CHAR c 9 Q { 252 253 } 222 254 - PREF IX 223 255 Xi AL TMODE DELETE FOUT(141) will output a RETURN/LINEFEED while FOUT(13) will just do a RETURN. Codes 225 through 255 are lower case letters, some of which serve other functions on "keyboards without lower case. Many keyboards use ISHIFT/K' for '[I, 'SHIFT/L' for '\' and 'SHIFT/M' for ']' and corresponding combinations for the control codes follow- ing 'CTRL/Z'. These symbols are often not printed on the key tops. the same as codes 128-255 except for the parity bit. Codes 0-127 are UWF always forces the parity bit during input. ERROR CODES FOR UWF (V4E) OCTOBER 1978 ? Keyboard interrupt (CTRL/F) or restart from location 10200 ?01.50 Group number greater than 31 ?01.93 ?03.10 Non-existant line number in a MODIFY or MOVE command Non-existant line called by GOTO, IF, NEXT, BREAK or QUIT ?03.30 ?03.47 Illegal command Non-existent line or group: DO, ON, JUMP, LINK or PDf call ?04.35 Missing or iLlegaL terminator in a FOR command ?06.03 IllegaL use of a function or number: ASK, YNCR or ZERO ?06.41 Too many variabLes (ZERO unnecessary ones to recover space) ?07.44 Operator missing or illegaL use of an equal sign ?07.67 Variable name begins with 'F' or improper function call ?07.76 Double operators or an unknown function ?08.10 ?10.50 Parentheses don't match Program too large (sorry, you'll have to erase some of it) 118.32 119.72 FCOM index out of range Logarithm of zero 121.57 Square root of a negative number 122.65 More than 10 digits in a number 125.02 127.90 Stack overflow: reduce nested subroutines and expressions 131.<7 Non-existant program area called by LOOK or LINK + or End of input sensed, 1/0 switched back to the terminal Zero divisor UWF-75 A P P'E N D I X I I Here is a list of patches for adding a number of special features to UWF. They are shown in the format: ory location, FLLLLI CCCC PPPP; QQQQ 'CCCC' is the original contents, where 'FLLLL' is the Field + Memand 'pppp' is the patch. where several succ~ssive locations are to be changed, lowed by the next patch IQQQQ'. In cases a semicolon is shown, fol- Note that the 'FCOM' patch shown below is for 16K versions only and must be added -before- UWF ;s started the first time. FIELD 0 000451 4463 4442 000611 7610 6213 Replace extra variable storage with FCOM (16K only - see page 3) Print a CR/LF before printing an error message FIELD 1 104021 4547 0000 Eliminate the line number printout in MODIFY 112161 7000 4533 Make the ASK command print a ':1 each time 112411 1377 7040 Use the '#' operator to output a Form Feed 124711 1000 1177; 4533 Change 'rubout' for video terminals 130701 7106 7107 Increase the delay after a Carriage Return 131341 7000 6xxx Clear an unwanted interrupt (next 3 locations too) 156651 1103 1213 156661 4534 7200 Make TYPE print an '=' ahead of each value Remove the initial space (or ':') printed by TYPE 145031 62X1 62Y1 Change the data field used by FCOM ('X,Y' may be 2-7) 145451 62X1 62Y1 Ditto for the FBUF function ('X' is set at startup) 100331 4566 5200 Remove the FLOG, FEXP and FATN functions to increase the 123711 5020 1754; 1754; 1754 size of the symbol table in the 8K version. 100331 5200 5303 Remove FSIN and FCOS to increase the symb9l table size a 123671 5205 1754; 1754 little .bit more (8K only). UWF-76 NOT E S (e) 1978 by LAB DATA SYSTEMS Seattle, Wdshington 9b'~5 All rights reserved (JvZ) UWF-77 ERROR CODES FOR UWF (V4E) OCTOBER 1978 ? Keyboard interrupt (CTRL/F) or restart from location 10200 ?01.50 ?01.93 Group number greater than ~1 Non-ex;stant line number in a MODIFY or MOVE command ?03.10 Non-existant line called by GOTO, IF, NEXT, BREAK or QUIT ?03.30 Illegal command ?03.47 Non-existent line or group: DO, ON, JU~P, LINK or PDF call ?04.35 Missing or illegal terminator in a FOR command ?06.03 Illegal use of a function or number: ASK, YNCR, or ZERO ?06.41 Too many variables (ZERO unnecessary ones to recover space) ?07.44 107.67 missing or illegal use of an equal sign Variable name begins with 'F' or improper function call 107.76 Double operators or an unknown function ?08.10 ?10.50 Parentheses don't match ?18.32 FCOM index out of range ?19.72 Logarithm of zero ?21.57 Square root of a negative number ?22.65 More than 10 digits in a number ?25.02 Stack overflow: reduce nested subroutines and expressions ?27.90 ?31.<7 Zero divisor Non-existant program area catled by LOOK o~ LINK -Eo- or End of input sensed, 1/0 switched back to the terminal Operat~r Program too large (sorry, you'll have to erase some of it) F PAL FPAL allows the user to code short 'machine language' functions directly into his program. This provides 'keyboard control' of special devices which are not supported by any of the normal functions or commands, and also permits operations requiring only 12-bit arithmetic to proceed at full machine speed. Routines as long as 32(10) instructions"can (in theory) be incorpot~ated) but in pl~ac1..ice, FPAL rou:" tines are seldom longer than about 5-10 instructions - just enough to execute a short sequence of lOTs to pulse a control line, for instance. The form oft he fun ct ion ca 11 is: FPA L (A C) ins t , i n5 t , ins t ••• ») v;h er' e •AC' i san arithmetic expression, the value of which will be placed in the AC prior to calling the routine, and the remaining arguments are construed as a list of -octal- numbers which represent the desired machine instructions. These are stored in Field) such that the first instruction is at 'page+l', the second at 'page+21, etc. After the 1 ast i nst ruct. i on has been tucked altJay, FPAL loads the AC wi th the i ntegf:f part of the first argument, clears the Link, and calls the routine. The final value of the AC is then returned to the program as the value of the functionc Note that the user does not have to worry about any of the 'calling' instructions - he only has to write the essential machine code~ Here are a few examples which may help clarify how the FPAL function works and illustrate some of the things it can do: Ex. 1: U~~F ha s an Fr~Q' funct i on for load i ng a number into the HQ reg i ster (where it is preserved by all internal arithmetic operations), but no corresponding The following FPAL function will function for finding out "~at is already there. not only do this, but will also increment the value in the MQ at the same time: I TYPE MQ=FPAL(,7501,7001,7521) Note that the first argument has been omitted in this example, since no information is being passed -to- the function. The first instruction (7501=MQA) reads the MQ, the next (7001=IAC) increments this value and the third (7521=SWP) interchanges the . new and old values, saving the new value for a subsequent call, and returning the old value to the program. Machines based on the 6100 microprocessor may not be able to display the MQ while UWF is running. Using this function however» the value of the hardware register can be saved in the variable IMQ', and output by the 'TYPE' command as well. So being able to actually 'see' this register is not a necessity. Ex. 2: Several variations of this routine come to mind almost immediately. For instance, we could use the hardware 'SWpl instruction to interchange two values: SET MQ=FPAL(AC,7521) or we could take advantage of the 'MQA' instruction to perform an 'inclusive OR' between a value in the MQ and one in the AC: SET FMQ(A),AB=FPAL(B,7501). Ex. 3: As a final example, suppose that we have constructed an AID converter interface which uses the same instruction set as the AD8-EA. In order to test it out we can use the following FPAL routine to implement the IFAOC' function: SET CH(N)=FPAL(N,6531,6532,6534,5203,6533) The channel number ('N') will be p1aced in the AC at the beginning and can be used to control the multiplexer via a 16031' (=ADLM) instruction. The converter is then started (6532=ADST) and we begin testing the 'done' flag (6534=ADSD) to see when it is finished. This involves a 'JMP .-1' instruction which mean~ that the location of the 'ADS0 instruction (relative to a page boundary) must be known. Since FPAL routines always start at 'page+l', (location 'page+O r can be used as a 'temporary'), a jump to the -third- instruction becomes '5203'. When the conversion is finally done the result is read into the AC (6533=ADRO), and returned to the program. 1 It goes almost without saying, that such easy access to machine-level code is both powerful - and - dangerous! No error checking can be performed, so a single 'typo' can lead to instant disaster! Always be sure, therefore~ to save a copy of a valuable program -before- you tryout any sort of 'wild' FPAL function, and be especially careful with ISZs, DCAs, JMPs and JMSs since they can modify memory or send the program off 'into the wild blue yonder'. Similarly, give special consideration to any lOT which might cause a hardware interrupt since UWF runs with the interrupt system enabled! Most interfaces have an 'interrupt disable' instruction, but if it is necessary to use an '10F in order to protect UWF from a spurious interrupt, be sure to clear the fiag and then issue an lION' before exiting from the function - otherwise it may be necessary to restart the interpreter in order to activate the interrupt system again (see page 2). t ADVANCED CONSIDERATIONS While it is clearly possible to use FPAL to implement patches to UWF itself, this practice is -strongly- discouraged (and no help with such folly will be offered) since this makes programs 'version dependent'. On the other hand~ there -are- a few 'tricks' which could prove usefu1 at various times: 1) The value of the first parameter is actually·converted into a 24-bit integer, of which only the lower 12-bits are loaded into the AC at the beginning of the routine. This means that the values '4095 and 1_1' will both load '77771(8) into the AC. The high-order part of the number can be accessed with a 'TAD 45 (1045) instruction, while the low-order half can always be recalled ~th a 'TAD 46' (I046) if it is needed later on in the function. 1 1 2) The value of the AC is normally returned as a signed number; if it is more desirable to have an 'unsigned' result you C2n simply code an 'lSI .+1' instruction as the last step of the routine. Thus: 'TYPE FPAL(4095) , will return I-I', whereas 'TYPE FPAL(4095,2202}' will return '4095'. The '2202' instruction is 'ISZ .+1' when located at 'page+ll. Notice that numbers appearing in the -first- argument of an FPAL call are treated as 'decimal' values and can be replaced by variables and/or other functions. The remaining arguments, however, are processed as character strings and so cannot be replaced by arithmetic expressions.
Home
Privacy and Data
Site structure and layout ©2025 Majenko Technologies