Annotation of researchv10no/cmd/basic/bite/doc/bite-user.m, revision 1.1.1.1

1.1       root        1: .de aH
                      2: .nr a +1
                      3: .nr P 0
                      4: .PH "'''APPENDIX \\na - \\\\\\\\nP'"
                      5: .SK
                      6: .HU "\\$1"
                      7: ..
                      8: .ND "September 6, 1979"
                      9: .TL "20239-7048" "40295-2"
                     10: BITE users guide.
                     11: .AU "J. P. Hawkins" JPH WH 2425 4610 8C-001
                     12: .TM 79-2425-
                     13: .AS 1
                     14: .I BITE
                     15: (BASIC Interpreter for Testing and Engineering)
                     16: is a BASIC language interpreter
                     17: designed for use in automated testing
                     18: controlled by PDP-11 microcomputers.
                     19: The interpreter implements an extended instruction set designed for
                     20: instrument control using the IEEE 488 Instrument Bus.
                     21: .P
                     22: This memo describes the syntax of the language and
                     23: describes useful programming techniques.
                     24: .AE
                     25: .OK "BASIC" "Interpreters" "BITE" "Automatic Testing"
                     26: .MT 1
                     27: .SA 0
                     28: .H 1 INTRODUCTION
                     29: .H 2 "General Description"
                     30: .I BITE
                     31: is a
                     32: .I BASIC
                     33: language interpreter designed for use with
                     34: automated test equipment. The interpreter runs on
                     35: PDP-11 mini- and micro-computers using the
                     36: UNIX*
                     37: .FS *
                     38: UNIX is a Trademark of Bell Laboratories.
                     39: .FE
                     40: operating system.
                     41: .I BITE
                     42: is distinguished from other
                     43: .I BASIC
                     44: interpreters in the following ways:
                     45: .BL 4
                     46: .LI
                     47: .I BITE
                     48: is written in the 'C' language.
                     49: It is, therefore, portable and can be installed and used
                     50: on any system with a standard 'C' compiler.
                     51: .LI
                     52: The interpreter provides an extended set of commands and functions
                     53: for controlling and reading electronic instruments using the IEEE 488
                     54: Buss. The extended instruction set can be expanded
                     55: by the user who is knowledgeable in 'C' programming by implementation
                     56: of "custom commands" \[ref Drake\].
                     57: .LI
                     58: .I BITE
                     59: can be executed from a script
                     60: running on the Bourne Shell of UNIX.
                     61: Thus the string manipulation of the Shell
                     62: and the control and computational capabilities
                     63: of
                     64: .I BITE
                     65: are combined to provide a uniquely powerful system.
                     66: .LI
                     67: .I BITE
                     68: accepts
                     69: .I BASIC
                     70: language programs using the original Dartmouth
                     71: syntax with little or no modification required.
                     72: Those features described above which differ from standard
                     73: .I BASIC
                     74: are extensions of
                     75: .I BASIC
                     76: rather than exceptions to the syntax rules.
                     77: .H 2 "Micro and Mini Versions"
                     78: There are two versions of
                     79: .I BITE.
                     80: One version is designed for the PDP-11/70 UNIX environment and
                     81: the other version is a "standalone" program which runs in the PDP-11/03
                     82: and is invoked from the LSX version of UNIX.
                     83: .BL 4
                     84: .LI
                     85: The PDP-11/70 version has complete interface capabilities with the
                     86: Bourne Shell as described below and all math functions are available.
                     87: .LI
                     88: The other version is designed for the PDP-11/03 micro-computer.
                     89: This version contains the extended instruction set for instrument control.
                     90: Differences between this and the host version include omission of verbose
                     91: error messages, Shell and system call facilities, omission of some math
                     92: functions and reduced user working storage. The omissions of features
                     93: are due to the drastically reduced memory availability on the PDP-11/03
                     94: as compared to that of the PDP-11/70 with memory management.
                     95: Since most core space is used up, the PDP-11/03 version is "standalone"
                     96: (operating system not resident) with a skeleton version of UNIX for
                     97: file I/O. This version must be loaded with a special loader program
                     98: .I BITEX
                     99: which is included with the software release package.
                    100: .H 2 "Scope of This memo"
                    101: In the following, the syntax of
                    102: .I BITE
                    103: is described. When a command differs in the two versions, this fact is noted
                    104: explicitly. Programming techniques, including control of
                    105: .I BITE
                    106: by the Shell, are described.
                    107: .H 1 Conventions
                    108: .VL 20 5
                    109: .LI "This Memo"
                    110: All things enclosed in [] are optional.
                    111: .LI expr
                    112: Any algebraic expression which could be a constant, variable, math
                    113: function or a combination of same, separated by arithmetic operators
                    114: as in: a+b*3.14*(4.4+c2*sin(b+s))+a(2,2)
                    115: See "variables" and "math functions" below.
                    116: .LI Operators
                    117: +,-,*,/ or ^ for addition, subtraction, multiplication, division or
                    118: exponentiation in order of lowest to highest precedence. + and - have
                    119: the same precedence and * and / have the same precedence.
                    120: Parenthesis () around expressions forces the contents to be higher precedence
                    121: than all parts of the expression outside those parenthesis.
                    122: Note also that when the - is used as a unary it maintains its low precedence,
                    123: hence the expression -2^2 yields -4 instead of 4. In all cases a good rule
                    124: of thumb to insure precedence is to enclose the part of high precedence in
                    125: parenthesis, thereby (-2)^2 yields 4.
                    126: .LI Relationals
                    127: <, >, =, <=, >=, <> for less than, greater than, equality, less or equal,
                    128: greater than or equal and not equal.
                    129: .LI "Source Path"
                    130: When reference is made to a
                    131: .I BITE
                    132: source file (i.e. the
                    133: .I old
                    134: and
                    135: .I load
                    136: command), two directories are searched, the first being the current
                    137: directory and then /usr/lib/bites which is a "pool" where shared programs
                    138: should be stored. The /usr/lib/bites directory is analogous to the
                    139: /usr/bin directory in
                    140: UNIX.
                    141: .LI "Source Program Name"
                    142: .br
                    143: The source program name is twelve or less characters suffixed by a .b .
                    144: .LI Statement
                    145: A basic statement consists of a line number (integer value between 1 and
                    146: 32767) followed by a command, space and operand which follows the
                    147: syntax governed by the command as in:
                    148: .br
                    149: 100 print "Hello World"
                    150: .br
                    151: A statement can be typed without a line number in which case it will
                    152: execute immediately. This is true for all commands, but doesn't make
                    153: sense for some commands such as
                    154: .I for.
                    155: Immediate execution is handy
                    156: for diagnostic purposes such as: print a, to find out what the value
                    157: of 'a'.
                    158: .LI Strings
                    159: Sequences of ASCII characters delimited by double quote characters
                    160: at the beginning and the end.
                    161: .LI Variables
                    162: All variable names are either a lower case alpha character (a-z)
                    163: or a lower-case alpha character followed by an integer (0-9).
                    164: Arrays have the same name convention as regular variables and take
                    165: the form varname(expr1,expr2,expr3....expr10) where expr1-expr10 are the
                    166: dimension
                    167: attributes of the array and can take the form of any legal expression
                    168: (including another array) as in a(b(2,2),x).
                    169: .SK
                    170: .H 1 Commands
                    171: .H 2 "Standard Commands"
                    172: .VL 20 5
                    173: .LI "bye or q"
                    174: Exit
                    175: the interpreter.
                    176: Typing the control/D key will also exit the interpreter.
                    177: .LI "call name,line#"
                    178: .br
                    179: .I "Call Overlay Subroutine."
                    180: Name is the name of a file (name.b) containing a subroutine.
                    181: The subroutine must be sequenced such that line# is the
                    182: first line# in the file.
                    183: The first line must be "line# rem name" where "name"
                    184: must match the one in the
                    185: .I call
                    186: statement.
                    187: .I Call
                    188: checks the line "line#" to see if the subroutine
                    189: has already been loaded. If it has, a "gosub line#" is
                    190: executed.
                    191: If the subroutine is not already loaded, it loads it
                    192: and then does a "gosub line#".
                    193: .LI com[mon]
                    194: Preserve
                    195: variables for subsequent
                    196: .I run.
                    197: Issue of the
                    198: .I run
                    199: command
                    200: otherwise de-allocates all variables.
                    201: .LI "con [line#]"
                    202: Continue normal execution from single step mode.
                    203: See
                    204: .I sing
                    205: command.
                    206: .LI "data (expr),(expr),(expr),........."
                    207: .br
                    208: The
                    209: .I data
                    210: statement is a string of defined constants or expressions referred
                    211: to by the "read" statement. Unlike most BASIC interpreters, the data is
                    212: stored only in the form of text strings which allows the read statement to
                    213: evaluate expressions as well as constants.
                    214: .LI "del[ete] lownum [, highnum]"
                    215: .br
                    216: Delete line-number specified if only lownum given. Delete all lines
                    217: between lownum and highnum if both are specified.
                    218: See the
                    219: .I undo
                    220: command.
                    221: .LI "dim variable(expr1,expr2,.......,expr10)"
                    222: .br
                    223: Allocate space and define the dimensional characteristics of
                    224: subscripted variable.
                    225: .LI end
                    226: Define logical end of program. Causes termination of current
                    227: .I run.
                    228: .LI expunge
                    229: Force all variable space, including subscripted variables to be freed.
                    230: Or de-allocate used variable space.
                    231: .LI f
                    232: Typing 'f' causes the currently referenced
                    233: file (if any) to be displayed.
                    234: .LI "for - next"
                    235: Cause code enclosed by this combination to be executed under the
                    236: conditions specified in the
                    237: .I for
                    238: statement as in: for variable = expr1 to expr2 [step expr].
                    239: .LI "gosub line#"
                    240: Goto subroutine, resume from following statement after
                    241: .I return
                    242: encountered.
                    243: .LI "goto line#"
                    244: Force execution to continue starting at the line# specified.
                    245: .LI "if (expr1) relational (expr2) then line#"
                    246: .br
                    247: .br
                    248: Redirect program flow to line# if expr1 is related to expr2 by the
                    249: specified relational.
                    250: The
                    251: .I then
                    252: in the
                    253: .I if
                    254: statement can be optionally replaced with
                    255: .I goto
                    256: .I "go to"
                    257: or
                    258: .I gosub.
                    259: The
                    260: .I if
                    261: statement can also take the form:
                    262: .br
                    263: if (expr1) relational (expr2) then var = (expr)
                    264: .LI "input [_fildes]var1[,var2,var3,....]"
                    265: .br
                    266: Prompt for input and assign inputed value to variable.
                    267: If 's' is typed program is halted.
                    268: .LI "[let] variable = expr"
                    269: .br
                    270: Assign the value of expr to variable.
                    271: The let is optional.
                    272: .LI "l[ist] [lownum [, highnum]]"
                    273: .br
                    274: List the text in working storage. If lownum is given then only that number
                    275: is listed. if lownum and highnum are specified, then a listing is
                    276: displayed between the given statement numbers.
                    277: .LI "load [program name]"
                    278: .br
                    279: Same as the
                    280: .I old
                    281: command, except working storage is not cleared.
                    282: .LI "mov startnum, endnum, newnum [,increm]"
                    283: .br
                    284: The mov command causes the lines beginning with
                    285: .I startnum
                    286: and ending with
                    287: .I endnum
                    288: to be moved (ie. resequenced) to the line beginning with
                    289: .I newnum
                    290: and incremented by
                    291: .I increm.
                    292: The default value for
                    293: .I increm
                    294: is 10.
                    295: All references to the moved lines are updated. The user is responsible to
                    296: see that line numbers associated with moved lines do not conflict with
                    297: existing lines which will cause loss of program text.
                    298: .I mov
                    299: is similar to
                    300: .I reseq
                    301: (see below) except that only the specified lines are resequenced.
                    302: .LI n
                    303: List the next 23 lines. Useful for paging through a listing on a CRT.
                    304: .LI new
                    305: Clear program working storage for new program to be typed.
                    306: .LI "old [program name]"
                    307: .br
                    308: Clear user space and load program. If old is typed with no argument
                    309: it will prompt the user for a program name if not defined or load
                    310: the last defined program name.
                    311: .LI "on (expr) goto line#, line#,....."
                    312: .br
                    313: Is a selective goto with multiple line number targets. The target
                    314: branched to depends on the value of expr which is truncated.
                    315: Control is passed to the first line# specified after goto if the
                    316: value of the expression is 1. Control passes to the second line#
                    317: if the value is 2, the third if 3 and so on.
                    318: .LI "on (expr) gosub line#, line#,......"
                    319: .br
                    320: Same action as
                    321: .I on-goto,
                    322: except action taken is that of
                    323: .I gosub.
                    324: .LI pause
                    325: Causes execution to be suspended until a "newline" or "return" is typed.
                    326: This is useful for programs which need to be continuously in
                    327: .I run,
                    328: but
                    329: need to allow a time for user action i.e. unit insertion.
                    330: .LI "pr[int] [_fildes](expr's, quoted strings or tab operators)"
                    331: .br
                    332: The print statement is a limited format display statement in which
                    333: expressions are evaluated and displayed along with quoted literals.
                    334: The tab(expr) operator causes the print head to move to the absolute
                    335: column position computed by expr provided the current head position
                    336: is smaller. The specifiers must be separated by one or more commas
                    337: or semicolons.
                    338: .LI "printf (format string)[,expr1,expr2,.....,expr10]"
                    339: .br
                    340: This is an interpretive implementation of the UNIX 'C' library
                    341: routine, printf. It is, however restricted to only the floating
                    342: point format control specifiers 'f' and 'g'. Use of any of the
                    343: other specifiers such as 'o', 'd' or 's' will give erroneous results.
                    344: Print controls such as \\b (backspace), \\n (newline), \\r (return)
                    345: or \\t can also be used. The printf format was chosen in lieu
                    346: of the usual
                    347: .I "print using"
                    348: command because it was felt that
                    349: printf is not only a 'C' language standard but easier to use
                    350: than
                    351: .I "print using".
                    352: .br
                    353: Usage Example:
                    354: .br
                    355: 100 printf "Var a=%2.2f\\tVar b=%g.\\n",a,b
                    356: .LI randomize
                    357: Causes
                    358: .I rnd
                    359: statement to start at an "unpredictable" value.
                    360: .LI "read var1,var2,var3,............"
                    361: .br
                    362: The
                    363: .I read
                    364: statement causes data to be assigned to each variable in the
                    365: list from the constants or expressions contained in
                    366: .I data
                    367: statements. The
                    368: reading starts at the location of the data pointer.
                    369: The data pointer
                    370: points to the last data field accessed if a read was done or to the first
                    371: data field in the first data statement if the
                    372: .I restore
                    373: statement is issued
                    374: or the program is re-run.
                    375: .SK
                    376: .LI rem
                    377: The remark statement causes no operation in 
                    378: .I BITE
                    379: but may be followed by any string of characters for the purpose of commenting
                    380: a program. Unlike compiler languages, remarks do take up program buffer space;
                    381: however, they are of paramount importance in making a program readable by
                    382: human beings and are therefore strongly recommended.
                    383: .LI "reseq [startnum [, increm]]"
                    384: .br
                    385: The resequence command causes the statement numbers and all references
                    386: to them (such as if's goto's, gosub's, etc) to be resequenced starting
                    387: at
                    388: .I startnum
                    389: and incremented by
                    390: .I increm.
                    391: If startnum and/or increm are omitted, the default values are 10 and
                    392: 10 respectively.
                    393: .LI restore
                    394: Restores the data pointer to the first field of the first
                    395: .I data
                    396: statement.
                    397: .LI return
                    398: Return from subroutine called by
                    399: .I gosub
                    400: statement.
                    401: .LI "run [program name]"
                    402: .br
                    403: Run basic program specified. If no argument is given,
                    404: .I run
                    405: attempts to
                    406: execute whatever is currently in working storage.
                    407: .LI "s line#/old-string/new-string[/]"
                    408: .br
                    409: Substitute in line line# the new-string for the old-string. The last delimiter
                    410: is optional, unless new-string is null in which case it is desired that
                    411: old-string merely be removed.
                    412: See the
                    413: .I undo
                    414: command.
                    415: .LI "sing [line#]"
                    416: Enter the single step mode starting at the line# specified or at
                    417: the first line of the program if no line# is specified.
                    418: In single step mode an instruction is executed and then the prompt '^'
                    419: is displayed.
                    420: At this time the user may enter
                    421: any command (i.e. print) or hit the "return" key to execute the next
                    422: instruction.
                    423: See the
                    424: .I con
                    425: command.
                    426: .LI size
                    427: Causes amount of storage used and remaining or free space in 
                    428: decimal number of bytes.
                    429: .LI stop
                    430: Stop execution of program.
                    431: .LI "save [program name]"
                    432: .br
                    433: Save the contents of working storage in file-name specified by program name.
                    434: If no program name is given, last referenced file-name is used. If no file
                    435: name was referenced, the user is prompted for a name.
                    436: .LI undo
                    437: Undo last
                    438: .I s
                    439: command or
                    440: .I "single line deletion"
                    441: .LI ! (any shell command string)
                    442: UNIX shell command invocation allows system commands to be
                    443: executed from the interpreter.
                    444: This command is
                    445: .I "not included"
                    446: in the LSI-11/03 versions of BITE.
                    447: .SK
                    448: .H 2 "File Commands"
                    449: The file commands: append, openi, and openo are followed by one or more
                    450: file-names separated by commas, each file-name being no more that
                    451: 14 characters long. Files are assigned to designators (integer values
                    452: between 1 and 4 inclusive) in the order that they are open.
                    453: All commands
                    454: such as
                    455: .I print
                    456: and
                    457: .I input
                    458: which refer to a file use the designator
                    459: number preceded by a '_' character to refer to that file
                    460: as in: 100 print _1"hello world" or 100 input _3a(x,y) .
                    461: .VL 20 5
                    462: .LI "append file1[,file2,.....,file4]"
                    463: .br
                    464: If file exists open for output cause new data to be appended. If file
                    465: does not exist, the named file is created.
                    466: .LI "openi file1[,file2,.....,file4]"
                    467: .br
                    468: Open file for input. File must exist.
                    469: .LI "openo file1[,file2,.....,file4]"
                    470: .br
                    471: Create named file(s) and open for output. If named files exist, the old
                    472: data is destroyed.
                    473: .LI "close _fildes"
                    474: .br
                    475: Close file associated with file designator.
                    476: .LI closeall
                    477: Close all files input and output.
                    478: .H 2 "ATS Instrument Commands (Extended Instruction Set)"
                    479: These instructions are those which were implemented for
                    480: the
                    481: .I "Production Test Set."
                    482: .VL 20 5
                    483: .LI "buspr 'busadr(text and expressions)"
                    484: .br
                    485: Buspr is merely an extension of the print statement which allows
                    486: the print string which would otherwise be displayed on the tty
                    487: to be sent via the IBV-11 bus to the bus address specified by "busadr".
                    488: The ' preceding busadr distinguishes the following character from anything
                    489: other than a single character to be interpreted as an address.
                    490: The address character can be
                    491: .I "any ASCII character"
                    492: except ones which are possibly interpreted by the system as control
                    493: characters such as back-space.
                    494: .br
                    495: Usage Example: 100 buspr '6"F2R";r
                    496: .LI "cmd string"
                    497: Send character string over IBV-11 command lines.
                    498: .LI delay num
                    499: Causes a delay of num 60ths of a second where num is an integer.
                    500: .br
                    501: Usage Example: 100 delay 120           (delay 2 minutes or 120/60ths sec)
                    502: .LI dvminit
                    503: Initialize Digital Voltmeter.
                    504: .LI "dvms function, range"
                    505: .br
                    506: (for HP 3455A digital voltmeter)
                    507: Digital voltmeter set command, where: function is 'ac', 'dc' or 'ohms'
                    508: and range is .1, 1, 10, 100, 1k, 10k or 'aut'. i.e.
                    509: .br
                    510: Usage Example: 100 dvms dc,1k
                    511: .LI "hprintf (format string)"[,expr1,expr2,...,expr10]"
                    512: .br
                    513: (for HP 5150A Thermal Printer)
                    514: Formated print to strip printer. Syntax rules are the same as
                    515: .I printf.
                    516: Strip printer is 20 columns wide, anything past the 20th column is
                    517: truncated.
                    518: .LI "lodset lodnum,mode,value"
                    519: .br
                    520: (for POWER DESIGNS  X-510 & TRANSISTOR DEVICES  DLP 50-60-1000
                    521: electronic loads)
                    522: Set load. Where lodnum an integer describing which load referred to,
                    523: mode is the manner in which the load is set and value is an expression
                    524: describing the current or resistance the load was set to depending on the
                    525: mode. Mode is a single character 'r', 'R', 'i' or 'I' where 'r' is resistance
                    526: mode (value in ohms) and 'i' is current mode (value in amperes). Small
                    527: letter causes a hunt for the value and capital causes set on first try.
                    528: .LI "relay function, relnum1[, relnum2, relnum3,...]"
                    529: .br
                    530: (for HP 6940B MULTIPROGRAMMER)
                    531: Set multiprogrammer relays. Function is m (make), b (break) or c (clear).
                    532: Function is followed by all relay numbers to be acted upon which may
                    533: be expressions or variables. The clear function when not followed by
                    534: anything, simply means open all relays. When followed by relay numbers,
                    535: clear means all relays are open EXCEPT the ones specified.
                    536: .br
                    537: Usage Example: 100 relay m,10,20,21,a,b,rnd(10)
                    538: .LI "ps psno,voltage,current limit,overvoltage"
                    539: .br
                    540: (for KEPCO ATE 75-15M, ATE 150-7M, ATE 55-1M & JQE Power supplies)
                    541: Set power supply parameters. Psno is an integer representing the
                    542: power supply number describing which power supply is to be used,
                    543: voltage, current limit and overvoltage are self explanatory. Each
                    544: one of the parameters may be a legal algebraic expression so that
                    545: they may be controlled by the program.
                    546: .br
                    547: Usage Example: 100 dvms 1,10,1,11 or 100 dvms n,v1,i1,v1+1
                    548: .LI "scan scanner-channel"
                    549: .br
                    550: (for HP 3495A SCANNER)
                    551: Set 3495A Scanner channel to number specified.
                    552: .H 1 Functions
                    553: .H 2 "Standard Functions"
                    554: .VL 20 5
                    555: .LI abs(expr)
                    556: Absolute value.
                    557: .LI atn(expr)
                    558: Arc-tangent.
                    559: .LI cos(expr)
                    560: Cosine.
                    561: .LI exp(expr)
                    562: Natural exponential.
                    563: .LI int(expr)
                    564: Integerize or truncate fractional part of result of expr.
                    565: .LI log(expr)
                    566: Natural log.
                    567: .LI rnd(expr)
                    568: Return random number between 0 and evaluated expr.
                    569: .LI sin(expr)
                    570: Sine.
                    571: .LI sqr(expr)
                    572: Square root.
                    573: .H 2 "Instrument Functions (Extended Set)"
                    574: .VL 20 5
                    575: .LI btn(expr)
                    576: Button function returns non-zero if control button number (expr) is
                    577: depressed.
                    578: .LI dvmr()
                    579: Return digital voltmeter reading.
                    580: .LI error()
                    581: Return 1 if last instrument command caused instrument error, otherwise
                    582: return 0.
                    583: .SK
                    584: .H 1 "Modes of Operation"
                    585: .H 2 "Editor or Idle Mode"
                    586: When the
                    587: .I BITE
                    588: interpreter is invoked with no argument, a prompt '*' appears meaning
                    589: that the interpreter is waiting for the user to enter something from
                    590: the keyboard.
                    591: .I BITE
                    592: is then said to be in the
                    593: .I "Editor or Idle mode."
                    594: .P
                    595: Editing is accomplished as it is in any BASIC language interpreter
                    596: in that lines are entered by typing a line-number followed
                    597: by the statement and removed or deleted by merely typing the line-number.
                    598: Listing is accomplished with the
                    599: .I list
                    600: command (explained under "Standard Commands").
                    601: In addition to the above, it is possible to list single lines by typing
                    602: the return key in which case the program is listed one line-at-a-time,
                    603: starting at the first. When the last one is reached, the sequence starts
                    604: at the first line again.
                    605: At any time it is also possible to type the '-' symbol to "backup" a
                    606: line-at-a-time.
                    607: Other editing facilities are
                    608: .I "s, delete,"
                    609: and
                    610: .I reseq
                    611: also explained
                    612: under "Standard Commands".
                    613: .P
                    614: .H 2 "Run Mode"
                    615: If the
                    616: .I run
                    617: command is typed and a program
                    618: is currently in user storage, the program begins execution,
                    619: starting with the first line of the program, then executing each
                    620: line in order of line numbered sequence. The sequence of execution
                    621: is altered by program flow control statements like
                    622: .I "if, for-next"
                    623: or any statement containing a
                    624: .I goto.
                    625: .H 2 "Immediate Execution Mode"
                    626: Immediate execution is accomplished by typing a command without
                    627: preceding it with a line number.
                    628: Although this is possible with all commands, it doesn't always
                    629: make sense.
                    630: For example, using commands that control program flow in
                    631: immediate mode is unlikely and often disastrous.
                    632: .P
                    633: Immediate mode is designed so that the user may get immediate action
                    634: as in the command
                    635: .I run
                    636: or
                    637: .I "print a".
                    638: Some commands are almost always used in immediate mode such as
                    639: .I "q, delete, expunge, load, list, old, reseq, save,"
                    640: etc.
                    641: .H 2 "Single Step Mode"
                    642: Single step mode is entered with the
                    643: .I sing
                    644: command and
                    645: exited with the
                    646: .I con
                    647: command.
                    648: During this mode, one may find "BUGS" in the program
                    649: by observing the program flow or sequence or examining the values
                    650: of variables at given points in the program
                    651: to see if they have the expected values. See
                    652: .I sing
                    653: or
                    654: .I con
                    655: under the "Standard Commands" section of this paper.
                    656: .H 1 "Interruption of program"
                    657: At times it becomes necessary to escape from an endless loop or
                    658: abort an
                    659: action such as
                    660: .I list
                    661: before it completes. To cause such an interruption,
                    662: the (DEL) or (RUB) key is typed.
                    663: .H 1 "Programming Techniques and Tools"
                    664: .H 2 "Program Segmentation"
                    665: In situations of limited memory space as in the case of the LSI-11/03
                    666: it becomes impossible to fit large programs in storage at any one time
                    667: time. It then becomes necessary to write the program in pieces or segments
                    668: each of which must be loaded separately as needed.
                    669: Segmented are handled by "chaining" or "overlaying".
                    670: .H 3 "Chaining"
                    671: .P
                    672: Chaining is accomplished by insertion of the
                    673: .I run
                    674: command in the
                    675: program text. If a program is to be split into say, program1 and
                    676: program2 then by simply inserting the line "run program2" as the
                    677: last executed statement of program1, program2 is now chained to
                    678: program1. Upon completion of program2, if it is desired to reload
                    679: program1, the last executed statement should be "old program1" which
                    680: will clear user space and reload program1.
                    681: 
                    682: .SK
                    683: It must be noted that execution of a
                    684: .I run
                    685: causes variables to be
                    686: wiped out. To preserve variables from one program to the next, the
                    687: statement
                    688: .I common
                    689: must be executed prior to the chaining
                    690: .I run
                    691: statement.
                    692: 
                    693: The chaining process may go on indefinitely, the only expense being
                    694: some time delay for each program load.
                    695: 
                    696: The chaining point must sometimes be strategically chosen so that
                    697: it will not occur during an instrument action or some time critical
                    698: part of the program.
                    699: .H 3 "Overlaying"
                    700: .P
                    701: Overlaying is best accomplished with the
                    702: .I call
                    703: command. This technique is particularly useful where core space is minimal
                    704: and lends itself to keeping programs modular. The
                    705: .I call
                    706: command has a built-in feature which prevents loading a module
                    707: which is already resident.
                    708: In a line numbered language, overlay segments are delimited by
                    709: line number boundries rather than address boundries as is true in
                    710: machine level programming. The following is an example of a simple
                    711: implementation of an overlay:
                    712: .nf
                    713: 
                    714: 100 rem THIS IS THE ROOT SEGMENT OF THE PROGRAM
                    715: 110 rem The "root" segment remains resident and usually contains
                    716: 120 rem all the commonly called subroutines
                    717: 130 call pscheck,2000          \fIcall in power supply check overlay\fR
                    718: 140 call loadck,2000           \fIcall in load check overlay\fR
                    719: 150 call loadck,2000           \fIcall load check again\fR
                    720: 150 rem THE REST OF THE "ROOT" SEGMENT
                    721:                |
                    722:                |
                    723:                |
                    724: 900 stop
                    725: 2000 rem oldstuff
                    726: 2010 rem THIS PART OF THE PROG IS DESTROYED WHEN OVERLAYS ARE CALLED
                    727: 2020 return
                    728: 
                    729: 2000 rem pscheck
                    730: 2010 rem This is the power supply check routine which is called in
                    731: 2020 rem the root segment
                    732: 2030 rem the first line (2000) must appear in the program as shown
                    733:                |
                    734:                |
                    735: 3000 return
                    736: 
                    737: 2000 rem loadck
                    738: 2010 rem This is the load check overlay. This occupies the same
                    739: 2020 rem line number space as pscheck and will therefor replace it
                    740:                |
                    741:                |
                    742: 3000 return
                    743: .fi
                    744: 
                    745: In the above example, two overlays (pscheck and loadck) are called.
                    746: If those routines are found on disk they will be loaded and replace
                    747: the old program text starting at line 2000.
                    748: Note that loadck is called twice in succession. The second call will
                    749: not cause a load since loadck is already resident. The interpreter
                    750: believes this to be true by virtue of the
                    751: .I rem
                    752: statement with the name of the overlay at line 2000.
                    753: .SK
                    754: .H 2 "System Shell Control"
                    755: Invoked by the Bourne shell,
                    756: .I BITE
                    757: can be a powerful tool which can add mathematical capabilities to the
                    758: shell. The following shell-script invokes
                    759: .I BITE
                    760: without running it, loading the program add.b, entering a data
                    761: statement with two numbers to be added, issuing the
                    762: .I run
                    763: command
                    764: and putting the result in file "result".
                    765: .sp
                    766: .nf
                    767: :
                    768: : shell script to add two numbers
                    769: :
                    770: bite - add <<! > result
                    771: 115 data $1,$2
                    772: run
                    773: !
                    774: 
                    775: .fi
                    776: The following is the add.b program invoked by the above shell script.
                    777: .nf
                    778: 
                    779: 90 rem BASIC PROGRAM TO BE RUN BY SHELL SCRIPT
                    780: 91 rem add numbers in data statement and output to standard output
                    781: 100 read a,b                   \fIget the values of the 2 numbers in the data\fR
                    782: 110 print a+b                  \fIoutput the result\fR
                    783: 115 rem This line is replaced by a shell script line data statement
                    784: 120 bye                                \fIexit\fR
                    785: .fi
                    786: 
                    787: .I BITE
                    788: gives the Bourne shell the complete ability to EXECUTE BASIC INSTRUCTIONS!
                    789: This is accomplished by putting all the command lines in the shell-script
                    790: and using the <<! device pass the program to BITE.
                    791: .P
                    792: Below is a shell script which adds two numbers passed to it as arguments.
                    793: Note that the statements need not be in numerical order, since
                    794: .I BITE
                    795: will order them as they are entered.
                    796: Type this program in, give it a name, say add and make it executable
                    797: via chmod. Then try it by typing "add 3.14 2.22".
                    798: .nf
                    799: 
                    800: bite <<!
                    801: 100 read a,b
                    802: 110 print a+b
                    803: 120 bye 
                    804: 115 data $1,$2
                    805: run
                    806: !
                    807: .fi
                    808: 
                    809: An example of a shell-script using the immediate mode of
                    810: .I BITE
                    811: to get the sine of an angle in degrees is:
                    812: .nf
                    813: 
                    814: bite <<!
                    815: print sin(((2*3.1415926)/360)*$1)
                    816: bye
                    817: !
                    818: .fi
                    819: 
                    820: By naming the above shell-script "sin", one can type "sin 45" from
                    821: the system level to get an immediate answer.
                    822: .SK
                    823: Strings can be manipulated by the Bourne shell and system
                    824: utilities then passed to a
                    825: .I "BITE program."
                    826: The following is a simple example:
                    827: .nf
                    828: 
                    829: a="Now is the time"
                    830: b="for all good men"
                    831: bite <<!
                    832: print "$a $b to come to the aid of their country."
                    833: q
                    834: !
                    835: .fi
                    836: .H 1 "Error Messages"
                    837: Diagnostic error messages are issued by the interpreter
                    838: which indicate syntax errors , system failure, illegal commands or expressions,etc.
                    839: The
                    840: .I LSI-11/03
                    841: Version of
                    842: .I BITE
                    843: does not issue explicit error messages, but displays an error number
                    844: in which the meanings are listed below. This is done to regain
                    845: approximatly
                    846: 2 kilobytes memory in an already tight
                    847: .I LSI-11/03
                    848: memory.
                    849: .H 2 "Standard Error Messages"
                    850: .nf
                    851:        NUMBER  MESSAGE TEXT
                    852:        --------------------
                    853:        0       REFERS TO A NON-EXISTING LINE NUMBER
                    854:        1       UNRECOGNIZABLE OPERATION
                    855:        2       CANNOT OPEN FILE
                    856:        3       ILLEGAL VARIABLE NAME
                    857:        4       BAD FILENAME
                    858:        5       WORKING STORAGE AREA EMPTY
                    859:        6       RUNS NESTED TOO DEEPLY
                    860:        7       UNASSIGNED VARIABLE
                    861:        8       EXPRESSION SYNTAX
                    862:        9       BAD KEYWORD IN STATEMENT
                    863:        10      IMPROPER OR NO RELATIONAL OPERATOR
                    864:        11      UNBALANCED QUOTES
                    865:        12      FILE EDITING NOT PERMITTED IN SINGLE STEP MODE
                    866:        13      MISSING OR ILLEGAL DELIMITER
                    867:        14      GOSUB WITH NO RETURN
                    868:        15      IS FATAL
                    869:        16      UNBALANCED PARENTHESIS
                    870:        17      UNKNOWN MATH FUNCTION
                    871:        18      NEXT WITH NO OR WRONG FOR IN PROGRESS
                    872:        19      CANNOT PROCESS IMAGINARY NUMBER
                    873:        20      WHAT ?
                    874:        21      BAD DIMENSION SYNTAX
                    875:        22      TOO MANY DIMENSIONS
                    876:        23      REDUNDANT DIM STATEMENT
                    877:        24      NOT ENOUGH WORKING STORAGE SPACE
                    878:        25      VARIABLE NOT DIMENSIONED
                    879:        26      WRONG NUM OF DIMS
                    880:        27      ONE OR MORE DIMS LARGER THAN ASSIGNED
                    881:        28      NEG. OR ZERO DIMENSION ILLEGAL
                    882:        29      DIVIDE BY ZERO
                    883:        30      BAD TAB SPEC. IN PRINT
                    884:        31      SYS CALL FAILED
                    885:        32      BAD FILE DECLARE SYNTAX
                    886:        33      OUT OF DATA
                    887:        34      FILE-NAME TOO LONG
                    888:        35      FILE DES. USED UP
                    889:        36      FILE NOT OPEN FOR OUTPUT
                    890:        37      FILE NOT OPEN FOR INPUT
                    891:        38      EXPRESSION YIELDS AN IMPOSSIBLE VALUE
                    892:        39      PRINTF: ARG COUNT MISMATCH
                    893:        40      PRINTF: MORE THAN 10 ARGS
                    894:        41      LINE TOO LONG FOR STRIP PRINTER
                    895:        42      MOV REQUIRES 3 LINE #'s, SPACING IS OPTIONAL
                    896:        43      BAD NAME OR LINE NUMBER AT BEGINNING OF SUBROUTINE
                    897: .H 2 "Test Set and Instrument Error Messages"
                    898: .nf
                    899:        100     MISSING ' DELIMITER BEFORE BUS ADDR
                    900:        101     PS: VOLTAGE OUT OF RANGE
                    901:        102     PS: CURRENT OUT OF RANGE
                    902:        103     PS: OVERVOLTAGE OUT OF RANGE
                    903:        104     RELAY ERR
                    904:        105     RELAY: INVALID FUNC.
                    905:        106     RELAY: INVALID NUMBER
                    906:        107     DVM: INVALID MODE
                    907:        108     DVM: INVALID RANGE
                    908:        109     LODSET: IMPROPER NUMBER OF ARGUMENTS
                    909:        110     LODSET: IMPROPER MODE
                    910:        111     LODSET: UNABLE TO SET LOAD
                    911: .H 1 Acknowledgement
                    912: .P
                    913: .I BITE
                    914: was written in the 'C' programming language by R. B. Drake
                    915: and myself. This memorandum was reviewed for accuracy and clarity by
                    916: R. B. Drake and J. D. McElroy.
                    917: The device drivers used for the extended instruction set are
                    918: a result of the efforts of R. B. Drake, R. E. Ellenbogen, L. W. Schaper
                    919: and myself.
                    920: Testing of the initial versions of
                    921: .I BITE
                    922: were made by N. P. Episcopo and D. J. Jackowski.
                    923: D. J. Jackowski performed extensive testing of
                    924: .I BITE,
                    925: made many helpful suggestions
                    926: and showed us how
                    927: .I BITE
                    928: could be used with the
                    929: .I "Bourne Shell".
                    930: N. P. Episcopo made some benchmark numerical comparisons between
                    931: .I BITE
                    932: and
                    933: .I BASIC
                    934: on
                    935: .I TSS.
                    936: Many helpful suggestions were contributed by R. Scuderi.
                    937: .fi
                    938: .SG UNIX
                    939: .SK
                    940: .PH """"
                    941: .sp 3
                    942: .ce
                    943: .ul
                    944: REFERENCES
                    945: .VL 8 4
                    946: .LI \[1\]
                    947: R. B. Drake "Customization of BITE", Bell Laboratories TM 78-2425-
                    948: .LI \[2\]
                    949: DEC, "introduction to BASIC",
                    950: Digital Equipment Corporation
                    951: .LI \[3\]
                    952: C. Joseph Sass, "BASIC Programming and Applications",
                    953: Allyn and Bacon, Inc.
                    954: .LI \[4\]
                    955: S. R. Bourne, "An Introduction to the UNIX Shell"
                    956: Bell Laboratories TM 78-1274-4
                    957: .LI \[5\]
                    958: R. E. Ellenbogen & John Tardy, "Automated Testing of Power Supplies"
                    959: Bell Laboratories TM 79-2425-1
                    960: .nr Hu 1
                    961: .nr a 0
                    962: .aH "SAMPLE FILE I/O PROGRAM"
                    963: The following is a sample of a program which opens a file for output,
                    964: writes values out to it, closes the file, re-opens the file for input,
                    965: reads the values from the file into an array and tabulates the
                    966: values.
                    967: 
                    968: The
                    969: .I comments
                    970: to the right of the statements are there
                    971: as an aid in this document. It is improper syntax to insert comments
                    972: or remarks in any other manner than by using the
                    973: .I rem
                    974: statement.
                    975: 
                    976: 
                    977: .nf
                    978: 100 dim d(100)                 \fIdimension a 100 variable array\fR
                    979: 110 openo junk                 \fIopen file junk for output\fR
                    980: 120 for a = 1 to 100           \fIfor values of 'a' from 1 to 100\fR
                    981: 130 pr _1a*10                  \fIoutput 10*a to file junk\fR
                    982: 140 next a                     \fIloop\fR
                    983: 150 closeall                   \fIclose file junk\fR
                    984: 160 openi junk                 \fIopen file junk for input\fR
                    985: 170 for x = 1 to 100           \fIfor 100 points points in array d(x)\fR
                    986: 180 input _1d(x)               \fIinput next value to d(x)\fR
                    987: 190 next x                     \fIloop\fR
                    988: 200 closeall                   \fIclose file junk\fR
                    989: 210 for x = 1 to 100           \fItabulate values of elements in d(100)\fR
                    990: 220 printf "d(%4.1f)=%4.2f\\n",x,d(x)
                    991: 230 next x
                    992: 
                    993: 
                    994: 
                    995: The output of the above program looks as follows:
                    996: 
                    997: d( 1.0)=10.00
                    998: d( 2.0)=20.00
                    999: d( 3.0)=30.00
                   1000: d( 4.0)=40.00
                   1001: d( 5.0)=50.00
                   1002: d( 6.0)=60.00
                   1003: d( 7.0)=70.00
                   1004: d( 8.0)=80.00
                   1005: d( 9.0)=90.00
                   1006: d(10.0)=100.00
                   1007:        |
                   1008:        |
                   1009: d(100.0)=1000.00
                   1010: .fi
                   1011: .SK
                   1012: .HU "SAMPLE PROGRAM TO STEP VOLTAGE ON POWER SUPPLY"
                   1013: 
                   1014: 
                   1015: .nf
                   1016: 100 for v = 1 to 30 step .5    \fIfor voltages of 1 - 30 in steps of .5 volts\fR
                   1017: 110 ps 1,v,1,30                        \fIset power supply number 1 to 'v' volts\fR
                   1018: 120 next v                     \fIloop again\fR
                   1019: 130 ps 0,0,0,0                 \fIshut down power supply\fR
                   1020: .fi
                   1021: 
                   1022: .HU "WAIT FOR BUTTON PRESS"
                   1023: 
                   1024: 
                   1025: .nf
                   1026: 100 if btn(1) = 0 then 100     \fIwait for button 1 to be pressed\fR
                   1027: 110 n = 2                      \fIset a button number\fR
                   1028: 120 if btn(n) = 0 then 120     \fIwait for button 2\fR
                   1029: 130 n = n + 1                  \fInext button\fR
                   1030: 140 if btn(n) = 0 then 140     \fIwait for button 3\fR
                   1031: .fi
                   1032: 
                   1033: 
                   1034: .HU "EXERCISE SCANNER AND RELAYS"
                   1035: 
                   1036: .nf
                   1037: 100 for s = 1 to 30            \fIfor 30 scanner channels\fR
                   1038: 120 scan s                     \fIset scanner channel s\fR
                   1039: 130 delay 30                   \fIwait 1/2 second\fR
                   1040: 140 next s                     \fIloop\fR
                   1041: 150 rem
                   1042: 160 rem exercise
                   1043: 170 rem
                   1044: 180 relay c                    \fIopen all relays\fR
                   1045: 190 relay m,10,20,30           \fIclose relay 10,20 and 30\fR
                   1046: 200 relay b,10,20              \fIopen only relays 10 and 20\fR
                   1047: 210 relay c                    \fIopen all relays\fR
                   1048: 220 for r = 1 to 60            \fIfor relays 1 through 60\fR
                   1049: 230 relay m,r                  \fIclose cumulatively\fR
                   1050: 240 next r                     \fIloop\fR
                   1051: 250 rem now 60 relays are closed
                   1052: 260 relay c,1                  \fIopen all but relay number 1\fR
                   1053: .fi
                   1054: .CS 12 2 14 0 0 4
                   1055: .TC

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.