







                                     BASIC11



                             Written by Gordon Doughman

                        Copyright 1986-1990 Gordon Doughman

                         Modified by New Micros, Inc.  1993



                                  COPYRIGHT NOTICE


               The  entire  contents  of  this  manual  and  the   software
          described  herein  are  copyrighted with all rights reserved.  No
          part of this manual or the software may be copied in whole or  in
          part without the express permission of the author.

                                       WARRANTY

               Even  though  many  hours of works went into the writing and
          testing of BASIC11 and it is believed to be "bug  free",  BASIC11
          is  supplied AS-IS and without warranty.  The author makes no ex-
          press or implied warranties as to the fitness of use and merchan-
          tability of the product.  The user assumes the entire risk as  to
          its quality, performance and fitness of use.

               In no event will the author be liable for direct,  indirect,
          incidental,  or consequential damages resulting from the  use  of
          this  product.  Including  but not limited to loss of sales,  in-
          comes, service, profits, or potential profits.

               In the event a situation is found where the program does not
          function as the manual describes, the author will attempt to cor-
          rect any errors brought to his attention,  however  he  makes  no
          guarrantee to do so.













                                          1






                                      Table of Contents

          Section Number         Title                          Page Number

               1.0            Introduction                            4

               2.0            The Basics of BASIC11                   5
                    2.1            Lines                              5
                    2.2            Integer Constants                  5
                    2.3            String Constants                   5
                    2.4            Variables                          5
                    2.5            Variable Assignment                6
                    2.6            Operators                          7
                    2.7            Operator Precedence                8
                    2.8            Operating Modes                    8
                    2.9            Remarks                            8

               3.0            Commands                                9
                                 CLEAR                                9
                                 CONT                                 9
                                 LIST                                 9
                                 LLIST                                9
                                 NEW                                  9
                                 RUN                                  9
                                 ESAVE                                9
                                 ELOAD                               10
                                 AUTOEE                              10
                                 NOAUTO                              10
                                 FREE                                10

               4.0            Statements                             10
               4.1            Assignment                             10
                                 DATA                                10
                                 LET                                 11
                                 READ                                11
                                 RESTORE                             11
                                 EEP()                               12
                                 PORTA                               12
                                 PORTB
                                 PORTC
                                 PORTD
                                 TIME                                12
                                 RTIME                               13
                                 PACC                                13

               4.2            Control Transfer                       13
                                 GOSUB                               13
                                 RETURN                              13
                                 GOTO                                13
                                 ON GOSUB                            14
                                 ON GOTO                             14


                                          2






          Section Number                 Title                 Page Number

               4.3            Conditional tests                      14
                                 IF THEN                             14
                                 IF THEN ELSE                        15

               4.4            Input/Output                           15
                                 INPUT                               15
                                 PRINT                               16
                                 ?                                   16
                                 INPUT#                              17
                                 PRINT#                              17
                                 INBYTE                              17

               4.5            Looping Constructs                     18
                                 FOR TO STEP                         18
                                 NEXT                                18
                                 WHILE                               19
                                 ENDWH                               19

               4.6            Program Termination                    20
                                 STOP                                20
                                 END                                 20

               4.7            Real Time Event Statements             20
                                 ONTIME                              20
                                 ONIRQ                               22
                                 ONPACC                              22
                                 RETI                                23
                                 SLEEP                               23

               4.8            Miscellaneous Statements               23
                                 DIM                                 23
                                 REM                                 24
                                 POKE                                24
                                 PEEK()                              24
                                 TRON                                24
                                 TROFF                               25

               5.0             Built in Functions                    25

               5.1             Mathematical Functions                25
                                  ABS()                              25
                                  FDIV()                             25
                                  RND()                              26
                                  SGN()                              26

               5.2             Print Functions                       26
                                  CHR$()                             26
                                  HEX()                              26
                                  HEX2()                             26
                                  TAB()                              26

                                          3






          Section Number                    Title            Page Number

               5.3             Hardware  Related Functions           27
                                  ADC()                              27
                                  CALL()                             27
                                  EEP()                              27
                                  PORTA                              28
                                  PORTB
                                  PORTC
                                  PORTD
                                  PORTE
                                  TIME                               28
                                  RTIME                              28
                                  PACC                               29
                                  POKE                               29
                                  PEEK()                             29

               6.0             Error Reporting                       29

          Appendix A           BASIC11 and the M68HC11EVB            32
          



          1.0 INTRODUCTION

          BASIC11 is a very fast and complete control oriented BASIC inter-
          preter  for  the  Motorola M68HC11 single chip microcomputer.  It
          provides all the functions of standard BASIC along with a  number
          of  enhancements  that  allow  direct  control  of  some  of  the
          MC68HC11's hardware features using BASIC statements.

          The only limitations of BASIC11 ( which  usually  aren't  limita-
          tions    in a control environment ) are that is only supports in-
          teger variables. Also strings are only supported in PRINT and IN-
          PUT statements.

          Lines entered into a BASIC11 program must begin with a line  num-
          ber and must be terminated by a carriage return.  Lines may be no
          longer than 80 characters.  All lines are  automatically  put  in
          numerical  order  by  BASIC11 as they are typed in.  Lines may be
          deleted from a program by simply typing the line number  followed
          immediately by a carriage return.

          The syntax of each line in a BASIC11 program is cheked as soon as
          a  CARRIAGE  RETURN  is  entered  and any errors are reported im-
          mediately. This prevents the interpreter from having to check syn-
          tax at runtime and is one  of  the  things  that  contributes  to
          BASIC11's speed.




                                          4






          2. THE BASICS OF BASIC11

          2.1 Lines

          Each  line  of  a  BASIC11 program must begin with a line number.
          Lines may be numbered from 1 through 32767 and each line must  be
          terminated by a CARRIAGE RETURN. Lines may contain multiple state-
          ments that are separated by colons.  Spaces may be used freely in
          BASIC11 statements to improve their readability with  one  excep-
          tion.  Assignment  statements and arithmetic/logic statements may
          contain no imbedded blanks. Some examples follow:

                           10  PRINT X, X*X, RND(0)-5
                           20  X=5 : Y=10 : Z=15

          2.2 Integer Constants:

          All integer constants are represented internally as 16 bit  two's
          complement  numbers  with a decimal range of -32768 to 32767.  In
          the source program and input statements numbers  may  represented
          in either decimal or hexadecimal form.  All hexadecimal constants
          must be prefixed by a dollar sign ($).  Some examples of  integer
          constants are :
                           50   X=1000
                           60   Y=-55
                           70   Z=PEEK ($E010)

          2.3 String Constants:

          As mentioned earlier, BASIC11 does not suupport string variables.
          However,  it  does  support string constants in both PRINT state-
          ments and INPUT statements to allow for prompting of input  data.
          Some examples of string constants follow:
                           100  PRINT "Please enter your name"
                           200  INPUT "Enter a number",N

          2.4 Variables:

          BASIC11  currently  supports only integer variables ( it may sup-
          port string and floating point variables inthe future ).  Integer
          variable names can consist of a single alphabetic letter or a let-
          ter  followed  by  another letter or number.  Example of variable
          names are :

                            AB, XZ, R1, TO, IF

          Notice in the above example that two of  the  variables  are  the
          same  as the BASIC11 keywords TO and IF.  IN many BASIC's this is
          illegal but in BASIC11 it is perfectly legal.




                                          5






          Any legal integer variable name may also be subcripted or  dimen-
          sioned using the DIM statement. A variable is dimensioned by fol-
          lowing  any  legal  integervariable name by an expression that is
          enclosed in parentheses.  Note that when a variable is declare in
          a  DIM statement storage is not allocated until runtime.  This is
          because all array storage is allocated  dynamically.  All  dimen-
          sioned variables start with 0. For example:

                               300  DIM  AX(4)

          Will create the following five variables:

                               AX(0), AX(1), AX(2), AX(3), AX(4)

          Again,  the  same  variable  name  may  be  used  for both a non-
          dimensioned and dimensioned variable.  All dimensioned  variables
          must be declared in a DIM statement before they can be referenced
          in  an  expression or Error # 24 will result when the variable is
          referenced during a program run.

          2.5 Variable Assignment

          By using the LET, INPUT,  INBYTE or the READ statements variables
          may be assigned values.  The most common way to assign a value to
          a variable is through the use of the LET statement.  For example,
          the statement:

                               90  LET  GD=7

          Would  assign the integer value of 7 to the variable "GD" so that
          is time the variable "GD" was used in an expression,  the numeri-
          cal value of 7 would actually be substituted.

          An  INPUT statement,  when executed,  will cause BASIC11 to stop,
          print a question mark on the terminal,  and wait for the user  to
          enter a numerical constant. For example, the statement:

                               40  INPUT  A1

          will assign whatever number is typed at the terminal to the vari-
          able "A1".

          The  INBYTE  statement  is  similar to the input statement except
          that instead of expecting an  ASCII  formatted  number  from  the
          specified input device, it assigns the value of the ASCII byte to
          the variable that follows it. For example if the statement INBYTE
          AX were executed and the character "Y" were typed at the terminal
          the variable AX would contain the value 89 which is the numerical
          value  of  the ASCII character "Y".  The INBYTE statement is very
          useful for obtaining data from input devices other than the  con-
          trol terminal.


                                          6






          The  READ  statement works almost like the INPUT statement except
          that the numerical constant is taken from a  DATA  statement  in-
          stead  of  being typed in by a user from the terminal (more about
          the READ and DATA  statements later).



          2.6 Operators:

          There are three classes of operator available in BASIC11. The one
          most are familiar with is the mathematical  operators.  Addition,
          subtraction,   multiplication,  and  division.  The  mathematical
          operators are:

               SYMBOL    EXAMPLE        MEANING

                  +        A+B     Add A to B
                  -        A-B     Subtract B from A
                  *        A*B     Multiply A and B
                  /        A/B     Divide A by B
                  \        A\B     Remainder of (A/B)

          The next class of operators is the logical  operators.  They  are
          used  to  perform  "bitwise"  operations.  They  can  be  used to
          "ignore" certain bits within a word or in conditional tests  when
          more then one condition needs to be tested.  THe logical operator
          are:

               SYMBOL    EXAMPLE        MEANING

                .AND.    A.AND.B   Bitwise logical AND of A and B.
                .OR.     A.OR.B    Bitwise logical OR of A and B.
                .EOR.    A.EOR.B   Bitwise logical EXCLUSIVE OR of A and B.

          The last class of operators is the  relational  operators.  These
          are  used  in the IF and WHILE statements to test whether one ex-
          pression is less than, greater than,  or equal to another expres-
          sion. The relational operators are:

               SYMBOL    EXAMPLE        MEANING

                 =         A=B     True if A is equal to B
                 <>        A<>B    True if A is not equal to B
                 <         A<B     True if A is less than B
                 >         A>B     True if A is greater than B
                 <=        A<=B    True if A is less than or equal to B
                 >=        A>=B    True if A is greater than or equal to B






                                          7






          2.7 OPERATOR PRECEDENCE:

          Overall  operator precedence is shown below.  The operator at the
          top of the list has the highest priority in any expression, while
          the operator at the bottom has the lowest priority.

                  ()      Expression enclosed in parenthesis
                 NOT      Unary minus and NOT (one's complement)
                 */       Multiplication, division, and Mod (remainder)
                 +-       Addition and subtraction
                 =        Relational operators
                 <>
                 <
                 >
                 <=
                 >=
                .AND.     All logical operators have the same precedence
                .OR.
                .EOR.


          2.8 OPERATING MODES:

          BASIC11 has two operating modes,  the RUN mode and the  immediate
          Mode.   In the Run mode program lines that have previuos been en-
          tered are executed starting with the smallest line number and con-
          tinues until a STOP or END satement is executed, an error occurs,
          or a control C is typed on the terminal.

          In the immediate Mode, any legal BASIC11 statement or command may
          be typed in without a  line  number  and  a  statement  will  im-
          mediately be executed.  BASIC11 may be used in this mode to debug
          programs by examining variables, memory locations, or I/O ports.

          2.9 REMARKS:

          It is a good idea to place remarks throughout  your  programs  so
          that  some  one else can understand the operation of your program
          if it ever becomes necessary to change it.  It can even help  you
          if  you haven't worked with the program in a while.  Even through
          the REM statement is not executable it may be referenced by other
          program statements ( for example, by a GOTO or GOSUB statement).











                                          8






          3.0 COMMANDS:

          Commands are instructions to BASIC11 that  allow  it  to  perform
          "housekeeping" tasks at the users request.  None of the following
          commands may appear in a BASIC11 program.

          NAME     EXAMPLE/EXPLANATION

          CLEAR    CLEAR
                   The clear command is used to set all variables to zero
                   and to reset the GOSUB, WHILE, and FOR - NEXT stacks.
                   A clear is automatically performed when a RUN command
                   is enterd.

          CONT     CONT
                   The CONT command is used to restart a BASIC11 program
                   either after it has been stopped by either a STOP
                   statement or a control-C was typed at the terminal.
                   The program can't be restarted if an error occured in
                   the program or if the program is modified.

          LIST     LIST                    Lists the entire program
                   LIST [line#]            Lists one line
                   LIST [line#]-[line#]    Lists from the first line number
                                           through the second line number
                   The LIST command can be used to display selected lines
                   of the program on the terminal. As can be seen from the
                   above examples, all, part, or a single line of the
                   program may be listed.

          LLIST    LLIST
                   LLIST [LINE#]
                   LLIST [LINE#]-[LINE#]
                   The LLIST works in the same manner as the LIST command,
                   except that the program lines are sent to the system
                   printer instead of the terminal.

          NEW      NEW
                   The NEW command is used to clear out both the BASIC
                   program buffer and the variable storage space. It
                   prepares BASIC11 to accept a "NEW" program.

          RUN      RUN
                   The RUN command is used to begin execution of the
                   program that is currently in memory.

          ESAVE    ESAVE
                   The ESAVE command is used to save the program that is
                   currently in RAM to the program storage EEPROM that
                   resides in the system.



                                          9






          ELOAD     ELOAD

                    The ELOAD commmand is used to transfer aprogram to RAM
                    that has previuosly been saved using the ESAVE command

          AUTOEE    AUTOEE

                    The AUTOEE command is used to set a flag that resides
                    in the program storage EEPROM that will allow the
                    BASIC11 program to execute from a powerup or reset
                    condition. Note that the BASIC11 program is executed
                    out of the program storage EEPROM and is not copied
                    into RAM. This allows the entire system RAM to be used
                    for variable storage.

          NOAUTO    NOAUTO

                    This command resets the auto start flag set by the
                    AUTOST command and disables the automatic execution of
                    a BASIC program stored in the program storage EEPROM.

          FREE      FREE

                    The FREE command may be used to display the amount of
                    RAM memory that is currently available for BASIC11
                    program statements and variables.


          4.0 STATEMENTS:

          All of the following statements  are  used  in  the  creation  of
          BASIC11  programs.  The statements are arranged in logical groups
          to make similar functions easy to find.  Each statement is accom-
          panied by one or more program lines showing it's proper usage and
          an explannation of how the statement works if necessary.

          4.1 ASSIGNMENT:

          DATA      <line number>DATA<number>[,<number>,<number>...]
                    10 DATA 500,-10,200,99,$CD03
                    20 DATA $FE, 1000, -300

                    The DATA statement is used to specify data that will be
                    assigned to variables with a READ statement. That data
                    is read from left to right and always begin with the
                    first data statement in the program. When the program
                    has read all the data in asingle DATA statement,
                    BASIC11 will search the program for the next DATA
                    statement starting at the line following the just
                    exhausted DATA line. This is done because all data
                    statements in a program are considered logicallly to
                    be one long DATA statement.

                                         10






          LET       <line number>LET<variable>=<expression>
                    10 LET X=5
                    20 LET Y=25*(Y/3)
                    30 LET AX(3)=AX(5)*10
                    40 CD=DE+23
                    50 XZ=-55

                    The LET statement is the most often used way to assign
                    a value to a variable. Notice in the line numbers 40
                    and 50 above do not contain the keyword LET. This is
                    what is known as an implied LET and is a feature of
                    BASIC11 to help cut down typing time when entering a
                    program since this is one of the most often used
                    statements. One final note. As stated earlier,
                    assignment statements and arithmetic/logic statements
                    may contain no imbedded spaces. This mean that there
                    may be no spaces between the variable and equals, the
                    equals and the start of the expression, and no spaces
                    whithin the expression.

          READ      <line number>READ<variable>[,<variable>,variable>,...]
                    READ A,B,C

                    The READ statement is used in conjunction with the DATA
                    statement to assign values to variables. The first time
                    the READ staement is executed, it will assign the first
                    item in the first DATA statement to the first variable
                    in its variable list. If additional variables are
                    present  in its variable list, each one will
                    sequentially be assigned the next item in the DATA
                    statement. Care must be taken when a program is written
                    so that BASIC11 does not try to read the last item in
                    the last DATA statement. If this happens, Error # 38
                    will be issued.

          RESTORE   <line number>RESTORE

                    330 RESTORE

                    The RESTORE statement is used to reset BASIC11's
                    internal "pointer to the next item" in a DATA
                    statement that appears in the program.











                                         11






          EEP()     <line number>EEP(<expression>)=<expression>
                    25 EEP(30)=$55
                    30 EEP(X+1)=A/B

                    The EEP() statement is actually a special form of the
                    implied LET. EEP() is actually a subscripted variable
                    that allows the BASIC program to directly write to the
                    MC68hc11's on chip EEPROM. All the timing and control
                    information necessary to write to the EEPROM is taken
                    care of by BASIC11. This feature makes it very
                    convinient to save all kind of calibration data that
                    must be retained in the event of a power failure.
                    Currently the subscript of the EEP() statement is
                    limited to 255. CAUTION: Since the number of write /
                    erase cycles of the EEPROM is limited, be very care-
                    ful that the EEP() statement doesn't get executed
                    repeatedly for the same location by having it reside
                    within a loop.

          PORTA
          PORTB
          PORTC
          PORTD  <line number>PORTx=<expression>
                    75 PORTA=$A5
                    85 PORTC=X+(E-K)

                    The PORTx statement is also a special form of the
                    implied LET statement. It allows BASIC!! to directly
                    assign an 8-bit value to one of the MC68HC11's I/O
                    ports. Note that for a logic value to actually appear
                    on one of the port pins, that particular pin must have
                    been programmed as an output by using the POKE() state-
                    ment to write a one to that particular port's Data
                    Direction Register (DDR). If a value of greater than
                    255 ($FF) is written to a port, Error # 46 will be
                    issued.

          TIME      <line number> TIME=<expression>
                    65 TIME=0
                    15 TIME=SC/60

                    The TIME statement, like the EEP() and PORT statement,
                    is a special form of the implied LET statement that
                    allows the BASIC program to assign a value to the
                    system variable TIME which is used as BASIC11'S
                    "Real Time Clock". BASIC11 uses the output compare
                    one (OC1) register to generate a periodic interupt
                    which then divided down by software so that the
                    variable TIME is increamented once per second.
                    Since the variable is a 16 bit number, elapsed time
                    can be kept trackof for 65535 seconds (approximately
                    18 hours) without any software overhead.

                                         12






          RTIME     <line number> RTIME

                    10 RTIME

                    When assigning a value to the TIME system variable
                    (see page 12 of the BASIC11 manual), BASIC11 will
                    update the value of the TIME variable asynchronuosly
                    in relation to interupts generated by output compare
                    one (OC1). The RTIME statement will reset the entire
                    system time keeping function. The RTIME statement may
                    be used to synchronize the system time keeping function
                    to some external event.
                    Note: To maintain accuracy of the system time keeping
                    function, the RTIME statement should NOT be used within
                    an ONTIME interupt routine.

          PACC      <line number>PACC=<expression>

                    85 PACC=25
                    95 PACC=-5.AND.$00FF

                    Like the TIME, EEP(), and PORT statements, PACC
                    statement is a special form of the implied LET
                    statement that allows programmer to directly alter
                    the value of the MC68HC11's Pulse Accumulator.
                    Since the Pulse Accumulator is only an 8-bit
                    register, the must be inthe range
                    0<=expression<=255.


          4.2 CONTROL TRANSFER:

          GOSUB     <line number>GOSUB<line number>
                    100 GOSUB 1000

                    The GOSUB statement is used to transfer control of the
                    program to the subroutine whose line number follows the
                    GOSUB statement. The last statement of any subroutine
                    should be a RETURN statement which will return control
                    back to the statement following the GOSUB.

          RETURN    <line number>RETURN
                    1100 RETURN
                    As mentioned above the RETURN statement should be the
                    last executed statement ina subroutine and will return
                    program execution to the statement following the GOSUB.

          GOTO      <line number>GOTO<line number>
                    50 GOTO 10
                    The GOTO statement is used just to transfer control of
                    program execution to the line number following the GOTO
                    statement.

                                         13






          ON GOSUB  <line number>ON<expression>GOSUB<line number>[,<line#>]
                    200 ON X+1 GOSUB 10,90,300, 550

                    The ON GOSUB statement provides a facility to allow
                    BASIC11 to decide which of a number of subroutines to
                    execute based on the value of an expression. When the
                    expression is evaluated, the resulting number is used
                    to pick one of the line numbers following the GOSUB it
                    should be execute. In the above example if X were
                    equal to 0, the expression would evaluate to 1 and the
                    subroutine at line 10 would be executed. If X equal to
                    1, then the subroutine at line 90 would be executed 
                    and so on. If the expression is evalutes to 0, 
                    a negative  number or a number that is greater 
                    than the number of lines litsed after the GOSUB,
                    Error # 32 will be issued.

          ON GOTO   <line number>ON GOTO<line nmuber>[,<line number>,...]
                    500 ON X GOTO 100, 200, 300, 400, 500

                    The ON GOTO statement works in basically the same
                    manner as the ON GOSUB except that control is
                    transferred directly to the line number that is
                    selected from the list following the GOTO. NO return
                    address is saved and hence control cannot be returned
                    to the statement following the ON GOTO statement.


          4.3 CONDITIONAL TESTS:

          IF THEN   <line number>IF<expression>THEN<line number>

                    55 IF A=1 THEN 200
                    70 IF A=1.AND.B=1 THEN 500

                    The IF THEN statement is used to transfer control of
                    the program to another statement based on the results
                    of the evaluation of the expression. If the expression
                    is true (evaluates to any non-zero value) then control
                    is transferred to the statement at the line number
                    following THEN. If the expression evaluates as false
                    (equal to zero) then the next sequential statement in
                    the program will be executed. Notice in the second
                    example that multiple conditions may easily be tested
                    in a single IF statement by use of the logical
                    operators.









                                         14






          IF THEN
            ELSE    <line number>IF<expression>THEN<line#>ELSE<line#>

                    75 IF PORTA=$FE THEN 200 ELSE 300

                    This form of the IF THEN statement is a slight
                    variation in that if the expression is evaluated as
                    false control of the program is transferred to the
                    line number following the ELSE clause.

                    NOTE: In the above examples  a space follows the
                    expression in the IF statement. This IS REQUIRED so
                    that BASIC11 will know where the expression ends.
                    Failure to follow the expression with a space will
                    result in an Error being reported (most likely Error
                    # 6).


          4.4 INPUT/OUTPUT:

          INPUT     <line number>INPUT["string constant",]<variable>
                                             [,<variable>,...<variable>]

                    45 INPUT "Enter three numbers",A,B,C
                    55 INPUT XE,ZE,PI

                    The input statement is one of the ways that a value
                    may be assigned to a variable. When the INPUT statement
                    is executed, the prompt string, if present, will be
                    printed on the terminal followed by a question mark and
                    will wait for the user to enter the requested data. If
                    the user enters less data than is requested , BASIC11
                    will respond by printing a question mark on the next
                    line and will wait for the next piece of data to be
                    entered. This will continue until all requested data
                    has been entered by the user. If more data is entered
                    by the user than was requested by the INPUT statement,
                    the excess will be ignored.

                    Note that if the user responds to an INPUT statement
                    with a control-C, program execution will be halted and
                    BASIC11 will return to the command mode. Noye that the
                    program cannot be restarted by the use of the CONT
                    command.









                                         15






          PRINT     <line number>PRINT[variable,expression,"string
                                                               constant"]

               10 PRINT "The value of X is "; X
               20 PRINT X,X*X,X/Z+3
               30 PRINT X, Y, Z
               35 PRINT A, B, C;
               65 PRINT

               The PRINT statement may be optionally followed by any
               combination of variables, expressions, or string constants
               each separated by either a coma or a semicolon. The
               significance of separating the items in a PRINT statement
               by either a coma or a semicolon is explained below.

               BASIC11 devides each output line into "fields" of eight
               characters. When the arguments following a PRINT statement
               are separated by comas, BASIC11 will print each item begin-
               ning at the next field in the line. In line 30 in the above
               example, BASIC11 would print the value of variable X begin-
               ning in column 0, the value of variable Y would be printed
               starting in column 8 and the value of variable Z would be
               printed starting in column 16.

               Separating variables with semicolons effectively disables
               this "fielding" feature by printing variables and constants
               next to one another. There will still be a space or two
               between successive numerical expressions that are printed
               because each number that is printed with one trailing space.
               Also if a number is not negative a space will be printed in
               front of the number in place of the minus sign.

               Notice in line number 35 above that a semicolon (it could
               have been a comma) follows the last variable. This has the
               effect of suppressing the normal carriage return/line feed
               sequence that would normally be issued after printing the
               last expression.

               As mentioned in the first paragraph, the argument list that
               follows the PRINT statement is optional as is illustrated in
               the example of line 60 above. This form of the print
               statement has the effect of printing only a blank line.

          ?    <line number> ? [variable,expression,"string constant"]

               The question mark can be entered instead of the keyword
               "PRINT" to save typing time when entering a program or
               executing a line in the immediate mode. When entered in a
               program line the question mark is replaced by the same token
               as the keyword PRINT. Because of this, when the program line
               is listed the keyword PRINT will appear instead of the
               question mark.

                                         16






          INPUT#    <line#>INPUT#<expression,>["string constant",]
                                      <variable>[,<variable>,...<variable>]

               15 INPUT #5,AX
               20 INPUT #0,AX,DF,EG
               25 INPUT #DE-1,LO

               This form of the INPUT statement works in the same manner as
               the standard INPUT statement except that the data is
               obtained from a hardware devive other than the control
               console or terminal. The expresson that follows the "#" is
               evaluated and is then used to choose one of 8 different
               hardware devices, numbered 0 through 7, from which to get
               the input data. Device number 0 and 1 are currently used by
               BASIC11 for the control console and the system printer
               respectively. All other device numbers are available to the
               user for inputting data form special devices. Note however
               that the user must provide the proper "drivers" for each
               device. For a detailed explaination of how to use alternate
               devices for input, see Appendix A. If <expression> is
               negative or greater than 7 error number 48 will be issued.

          PRINT#    <line number>PRINT#<expression,>[<expression>...
                                                             <expresson>]
               25 PRINT #1,"This is a test"
               35 PRINT #0,AX,FG,R

               This form of the PRINT statement works in the same manner as
               the standard PRINT statement except that data is sent to an
               alternate hardware device. The same rules that apply to the
               INPUT # statement also apply to the PRINT # statement. Again
               for a detailed explaination of how to use alternate devices
               for ouput, see Appendix A.

          INBYTE    <line number>INBYTE<variable>
               10 INBYTE DC
               20 INBYTE #3, AX(Z)
               30 INBYTE #1,CV
               The INBYTE statement is another way that a value may be
               assigned to a variable. The INBYTE statement is similar
               to the input statement except that instead of expecting an
               ASCII formatted number from the specified input device, it
               assigns the value of an ASCII byte to the variable that
               follows it. If the statement in line 10 were executed and
               the character "Y" were typed at the terminal, the variable
               DC would contain the decimal value 89  which is the
               numerical value of the ASCII character "Y". The INBYTE
               statement is very useful for obtaining data from input
               devices other than the control terminal. The example in line
               number 30 above would retrieve a byte of data from the
               HC11's Serial Communications Interface (SCI) and would
               assign that value to the variable CV.

                                         17






          4.5 LOOPING CONSTRUCTS:

          FOR  <line number>FOR<variable>=<expression>TO<expresson>
                                                        [STEP<expresson>]
               85 FOR X=1 TO 1000
               90 FOR X=A TO B+C STEP 10
               95 FOR X=100 TO 0 STEP -1
               The FOR NEXT statemanets are what is known as a
               deterministic looping construct because the number of times
               the loop will be executed is determined at the start of the
               loop when the FOR statement is executed. When a FOR state-
               ment is excuted all instructions between it and the matching
               NEXT will repeatedly execute until one of two condition is
               met. Each pass through the loop the STEP value is added to
               the value of the control variable. If the STEP value is
               positive, the loop will be executed again if the control
               variable is less than or equal to the value of the expres-
               sion following the TO. Note that if no STEP value is sup-
               plied (it's optional) that a value of one (+1) is assumed.
               Also note that all of the expression in the FOR statements
               are evaluated only once at the start of the loop. This
               mean that the terminating value and the step value may not
               be changed in the body of the loop, however; since the con-
               trol variable is the same as any other variable, its value
               may be changed within the body of the loop. This would
               allow for exciting the loop before it normally would. Again
               note that the test of the control variable against the ter-
               minating value is actually performed when the NEXT statement
               is executed, so the code between FOR and NEXT will be
               executed at least once.

               FOR - NEXT statements may be nested but they must each use
               their own separate control variable. Currently the maximum
               number of nested FOR - NEXT loops is 8. Loops may be excited
               early by use of GOTO's however this is not good programming
               practice and is not recommended.

               NOTE: IN the above examples a space follows each of the ex-
               pression in the FOR statement. This IS REQUIRED so that
               BASIC11 will know where the expression ends. Failure to
               follow each expression with a space will result in an error
               being reported (most likely error #6).

          NEXT <line number>NEXT<variable>
               100 NEXT X
               The NEXT statement is used in programs to complete a FOR
               loop. The variable specified in the NEXT statement must be
               the same as the control in the matching FOR. If it is not,
               Error # 36 will be issued and program execution will stop.
               As mentioned above, the test to see whether the loop should
               be terminated or not is actually performed when the NEXT
               statement is executed.

                                         18






          WHILE <line number>WHILE<expression>

               500 WHILE X<=1000

               The WHILE - ENDWH statements are considered tobe a non-
               deterministic type of looping construct because the number
               of times the loop will execute is not determined at the
               start of the loop. In fact since the expression following
               the WHILE statement is evaluated at the start of the loop,
               the loop may never be executed if the expression is false
               (evaluates to zero) upon entry of the loop. There is one
               important point that needs to be made about the WHILE
               looping construct. The statements within the loop must
               contain a statement that changes the value of the test
               expression following WHILE so that the expression even-
               tually becomes false otherwise the loop will never ter-
               minate and the statements bounded by WHILE and ENDWH will
               execute forever!

               The WHILE statement may be used as part of a multiple
               statement line, however; in order to provide improved
               program readability and to show the structure of the
               program this practice is discouraged.

               WHILE - ENDWH loop may be nested up to 8 levels deep.
               WHILE loops may be excited early by use of GOTO's
               however this is not good programming practice and is not
               recommended.

          ENDWH     <line number>ENDWH

               600 ENDWH

               The ENDWH statement is used only in conjunction with a
               matching WHILE statement to enclose a group of lines
               within a loop. The effect of the ENDWH statement is to
               evaluate the expression following WHILE to determine
               whether the loop should be executed again. Note that
               the ENDWH statement may be part of a multi-statement line
               however, it must be the first statement on the line.













                                         19






          4.6 PROGRAM TERMINATION:

          STOP <line number>STOP

               1000 STOP

               The STOP statement is essentially a software break
               (control-C) instruction. When the STOP statement is
               executed, program execution is temporarily suspended
               and the message:

               STOPPED AT LINE # <line number>

               is printed on the terminal. In the above example
               <line number> would be 1000. If no alterations are
               made to the program after it has been suspended,
               execution may be restarted with the CONT command. The first
               statement executed will be the one immediately following
               the STOP statement.

          END  <line number> END

               300 END

               The END statement is used to terminate program execution.
               It does not have to be the last statement and may appear
               anywhere in the program. In fact an end statement need
               not appear any where in the program. If BASIC11 tries to
               execute past the end of the program, an END statement
               will automatically be executed. Unlike the STOP statement
               after an END statement has been executed the program
               may not be restarted via the CONT command.

          4.7 REAL TIME EVENT STATEMENTS:

          In  any control environment,  events usually occur asynchronously
          with resprct to main program execution. To cope with this kind of
          environment the MC68HC11 was designed with an extensive interrupt
          structure to support all of its on chip subsystems. The following
          statements  all  provide  control  of  interrupt  driven   events
          directly form BASIC11.

          ONTIME    <line #>ONTIME <expression>,<line #>

               25 ONTIME 120,500
               35 ONTIME HR+1,200
               95 ONTIME 0,500






                                         20






               In  many control situations it is necessary to take periodic
          measurements or record certain events at  fixed  time  intervals.
          THe  ONTIME  statement frees the main program from having to con-
          tinously check the value of the system variable TIME. in order to
          determine when to take a measurement or record an event.  The ON-
          TIME  statement allows program control to be transferred directly
          to an interrupt handling routine beginning at <line number>  when
          the  value  of <expression> matches the value of the system vari-
          able TIME.  THe value of <expression> may evaluate to  any  legal
          integer,  however;  if  <expression> evaluates to zero it has the
          effect of disabling the ONTIME function.

               One of two methods may be used to generate  periodic  inter-
          rupts using the ONTIME statement. THe first method involves zero-
          ing  the  system  variable TIME in the interrupt handling routine
          with the statement TIME=0.  This method may be used if  continous
          time  keeping  is not  required by the system.  The second method
          involves executing the ONTIME statement in the interrupt routine,
          adding the desired time interval  (in  seconds)  to  the  current
          value  of the system variable TIME.  This second method should be
          used if continous time keeping is required by the system. The fol-
          lowing examples should clarify things.

               First method:
                    10 TIME=0
                    20 ONTIME 10,100
                    .
                    .
                    .
                    100 TIME=0
                    .
                    .
                    150 RETI
               The above example will produce a timer  interrupt  every  10
          seconds.

               Second method:
                    10 TIME =0
                    20 ONTIME 20,500
                    .
                    .
                    .
                    500 ONTIME TIME+20,50
                    .
                    .
                    550 RETI
               The  above  example  will produce a timer interrupt every 20
          seconds.





                                         21






          ONIRQ     <line #> ONIRQ <expresson>,<line #>

               10 ONIRQ 1,355
               25 ONIRQ MD,225

               The ONIRQ statement allows BASIC11 to directly handle inter-
          rupts  that  are  generated  by  an  active  transition  on   the
          MC68HC11's IRQ pin.  The <expression> following the ONIRQ keyword
          is used to select the mode of the statement.  If  the  expression
          evaluates to any non-zero integer, the servicing of the IRQ inter-
          rupt  by BASIC11 is enabled.  If the expression evalutes to zero,
          IRQ interrupts are effectively disabled.  The <line #>  following
          the expression may be any legal BASIC11 line number.

          ONPACC    <line #> ONPACC<expression>,<expression>,<line #>

               105 ONPACC 1,0,1000
               255 ONPACC A,B,3000

               The  ONPACC statement allows the programmer to handle events
          associated with the MC68HC11's Pulse Accumulaotr on an  interrupt
          basis.  The first expression following the ONPACC keyword is used
          to set the operating mode of the pulse accumulator.  The  expres-
          sion  must  evaluate to a number from 0 through 4.  The operating
          modes of the pulse accumulator are discribed in the table below.

               MODE      ACTION ON CLOCK
                0        Disables the Pulse Accumulator
                1        Falling Edge on PA7 Increments the Counter
                2        Rising Edge on PA7 INcrements the Counter
                3        A "0" on PA7 Inhibits E/64 from Incrementing
                         Counter
                4        A "1" on PA7 Inhibits E/64 from Incrementing
                         Counter

               The second expression is used  to  determine  which  of  two
          events  will cause an interrupt to be gennerated by the pulse ac-
          cumulator.  If the expression evalutes to zero then an  interrupt
          will  be generated each time an active edge is detected on PA7 as
          described in the table above. If it evaluates to 1, the pulse ac-
          cumulator will generate an interrupt only when it overflows  from
          $FF to $00. The <line #> tell BASIC11 where the interrupt routine
          begins when a Pulse Accumulator interrupt occurs.

               For  more  information  on  the Pulse Accumulator subsystem,
          please refer to the MC68HC11's data sheet.







                                         22






          RETI <line #> RETI

               485 RETI

               All BASIC11 interrupt service routines must  end  with  this
          statement.  failure to an interrupt routine with RETI will result
          in all successive interrupts being masked!  This will effectively
          stop the system TIME function.

          SLEEP     <line #> SLEEP

               700 SLEEP

               The  SLEEP  statement allows the MC68HC11 to be put into the
          'Stop Mode' which is its lowest power consumption  mode.  In  the
          'Stop Mode',  all clocks,  including the internal oscillator, are
          stop and all internal processing is  halted.  Recovery  from  the
          SLEEP  statement  may be accomplished by either a processor RESET
          or an XIRQ interrupt.  When an XIRQ interrupt  is  used,  BASIC11
          will  continue  execution  with the next BASIC program statement.
          When a hardware RESET is used to exit the sleep mode,  the action
          taken by BASIC11 will depend on a couple of factors. If the 'Auto
          start'  flag  has  been  set  with the AUTOST command,  the BASIC
          program stored in external EEPROM/EPROM  will  automatically  ex-
          ecuted.  If the 'Auto Start' flag has not been set,  BASIC11 will
          return to the command mode.

          4.8 MISCELLANEOUS STATEMENTS:

          DIM  <line #> DIM <subscripted variable>[,subscripted variable..]

               10 DIM AX(100),DX(9),LK(1000)
               20 DIM Z(A+5),D(X)
               30 DIM X(0)

               The DIM statement,  which was discussed briefly  in  section
          2.3 (Variables), is used to allocate storage for subscripted vari-
          ables  when a program is run.  As can be seen from the example in
          line 20 above,  the expression in parenthesis does not have to be
          a  constant.  This  is because array storage is dynamically allo-
          cated at runtime.  This feature is especially nice in control ap-
          plications where memory is usually at a premium because large ar-
          rays  don't  have  to  be dimensioned in advance to fit the worst
          case.  All subscripted variables must appear in a  DIM  statement
          before they may be used in an expression. Failure to do this will
          result   in  Error  #  24  being  issued  when  the  variable  is
          referenced.

               The storage required by subscripted integer variable is:
               2*(<expression>+1)+2 bytes



                                         23






               Remember that all subscripts start at zero.  In the  example
          in line 10 above,  the variable AX(100) would actually create 101
          integer variables, AX(0) through AX(100). Although it may be seem
          strange the example in line 30  is  legal.  This  will  create  a
          single integer subscripted variable x(0).

          POKE <line #> POKE(<expression>,<expression>)

               45 POKE($ED00,$5A)
               55 POKE(AD,X*5)

               The  POKE  statement  allows the BASIC11 program to directly
          modify RAM memory or I/O locations.  The first expression  within
          the  parenthesis  is  the  address at which the second expression
          will be stored. The first expression may be evaluate to any legal
          integer number.  However the second expression  must  be  in  the
          range  0<=expression<= 255 since a byte location is being written
          to. If the second expression is outside the above range,  Error #
          48 will be issued. Care should be taken when using this statement
          so that part of the BASIC11 program or its data are not overwrit-
          ten.

          PEEK(X)
               The  PEEK  function performs the opposite action of the POKE
          function. It allows BASIC11 directly retrieve the contents of any
          memory or I/O location in the MC68HC11 memory map.  The  argument
          X, Since it is an address, is taken to be an unsigned number so X
          may  be  take on any integer value.  A single byte is returned by
          the function so it value will be >=0 and <=255.

          REM  <line #> REM [any text]

               10 REM This is a remark statement

          The REM statement is used to insert comments about the  operation
          or  structure of a program.  Any text following the REM statement
          is ignored,  so if it appears in a multiple  statement  line,  it
          should be the last statement on the line. If control is passed to
          the REM statement by a GOTO,  GOSUB, ect., control is just passed
          to the line following the REM statement.

          TRON  <line #> TRON

               20 TRON

               The TRON statement is used to turn the trace  mode  on.  The
          trace mode,  when tirned on,  will print line numbers in brackets
          as each line is executed. This can be used as an aid in debugging
          programs.




                                         24






          TROFF  <line #> TROFF

                 100 TROFF

                 The TROFF statement is used to turn the trace mode off.

          5.0 BUILT IN FUNCTIONS:

               BASIC11 has a number of built in functions that are used  to
          perform  common operations on numerical quantities,  perform spe-
          cial calculations,  call  user  written  assembly  language  sub-
          routines, and access some of the special hardware features of the
          MC68HC11.

          5.1 MATHEMATICAL FUNCTIONS:

          ABS(X)    The ABS function will return the ABSolute value of the
                    expression in parenthesis. The function will always
                    return a positive number as its result.

          FDIV(X,Y) The FDIV function is used to perform an unsigned
                    fractional devide using the MC68HC11's FDIV instruc-
                    tion. This function allows BASIC11 to resolve
                    fractional part of the remainder of an integer devide
                    without using floating point math. The result is a
                    binary weighted decimal number. Some examples may
                    clarify what the function does.

               3/4=.75 decimal
               3/4=$C000 binary weighted decimal

               2/4=.50 decimal
               2/4=$8000 binary weighted decimal

               1/4=.25 decimal
               1/4=$4000 binary weighted decimal

               .9999...=$FFFF

               For  the  function to execute properly X must be less than Y
          and Y may not be equal to zero.  If either condition exists Error
          #44 will be issued and program execution will terminate.











                                         25






          RND(X)    The RND function will return a pseudo random number
                    between 0 and 32767 inclusive. The value of the
                    argument X has the following effect on the function:

               For X<0 a new series of random numbers will be started
                    by reading the current value of the timer/counter and
                    using it as the new seed value.
               For X=0 a new random number will be returned each time
                    the function is called.
               For X>0 the last random number that was generated is
                    returned.

                    Note that the function only generates pseudo random
                    numbers and that a particular series will repeat
                    every 65536 calls of the function.
          SGN(X)    The SGN function will return a +1 If the argument is
                    positive, 0 if the argument is zero, and a -1 if the
                    argument is negative.

          5.2 PRINT FUNCTIONS:

          CHR$(X)   The CHR$ function will return a single character string
                    whole ASCII value is the argument X. This function is
                    very useful for sending non-printable ASCII characters
                    to an output device. The value of the argument X must
                    be in the range of 0<=X<=255 or Error # 43 will be
                    issued. This function may only be used in the PRINT
                    statement.

          HEX(X)    The HEX function is used to convert a binary number to
                    a four digit hexadecimal string. This function is very
                    when printing the contents of memory locations of I/O
                    ports. This function may only beused in the print
                    statement.

          HEX2(X)   The HEX2 function perform a similar operation to the
                    HEX function except that it is used to convert a number
                    in the rang 0<=X<=255 to a two digit hexadecimal
                    string. If a number outside the specified range is
                    passed as an argument to the HEX2 function, Error # 50
                    will be reported.

          TAB(X)    The TAB function will move the cursor to column X on
                    the output device. If the output device is already
                    passed column X then no action is performed. The
                    argument to the TAB function must be in the range of
                    0<=X<=255 or Error # 42 will be issued. This function
                    may only be used in the PRINT statement.





                                         26






          5.3 HARDWARE RELATED FUNCTIONS:

          ADC(X)    The ADC function allows a program to directly access
                    the MC68HC11's on board 8-bit A-to-D converter. Any
                    one of the 8 channels may be read by calling the func-
                    tion with the proper argument. If the argument is not
                    in the proper range (betwwen 0 and 7) Error # 45 will
                    be issued. The A-to-D converter is operated in a
                    single channel mode and is converted four times. These
                    4 conversions are then averaged by BASIC11 and the
                    result is then returned. Since the A-to-D conversion
                    time is fast (16us at 2.0MHz) this tends to help
                    average out  any noise in the reading.

          CALL(X)   Even though BASIC11 is extremely fast for an
                    interpreted BASIC, there are still some things that
                    may need to be to control that it can't keep up with.
                    The CALL function allows machine language subroutines
                    to be called directly from BASIC11. The CALL function
                    must appear in an expression since it will return a
                    16-bit numbers as a result of the function call. Some
                    examples follow:

                    10 F=CALL($EAF0)
                    20 Z=CALL(AX*2)
                    30 PRINT CALL($100)

                    The users machine language program must only preserve
                    the Y-index register, the stack pointer, and the cur-
                    rent state of the stack. All other registers may be
                    destroyed. The user subroutine is entered via a JSR
                    (Jump to SubRoutine) instruction, Therefore it must end
                    with the execution of an RTS (Return from SubRoutine)
                    instruction. Generally the users subroutine should have
                    about 100 bytes of stack space available. If more than
                    this is needed, the subroutine will have to allocate
                    its own stack storage space.

          EEP(X)    As mentioned in section 4.1 the EEP statement allows a
                    BASIC11 program to directly write information to the
                    MC68HC11's on chip EEPROM when the EEP statement
                    appears to the left of the equals as a basic
                    "statement". When EEP appears on the right side of the
                    equals it will act like a function and will return the
                    value currently stored in the EEP array location
                    described by the argument X. Again, the argument to
                    the function is actually the subscript of the EEP array
                    so it may not be negative and must not be greater than
                    the maximum value of 255.




                                         27






          PORTA
          PORTB
          PORTC
          PORTD
          PORTE     The PORTx functions are different from the other func-
                    tions in that they do not reqiure an argument. Essen-
                    tially these funtions act as special variables that
                    allow  direct reading of the MC68HC11's I/O ports
                    from BASIC.

                    PORTC and PORTD are general purpose I/O ports and as
                    such may have each pin of the port programmed as
                    either an input or an output. Each ports Data Direc-
                    tion Register (DDR) is used to specify the primary
                    direction of data on the I/O pin. If the corresponding
                    port pins DDR bit is set to a 1, the port pin will be
                    configured as an output. If the DDR bit is clear to a
                    0 the port pin will be configured as input and will
                    become high impedance. When a bit which is configured
                    for output is read, the value returned is the value at
                    the input to the pin driver. If a write is executed to
                    a pin that is configured as an input, the value will be
                    stored in an internal latch so that if the pin is later
                    configured as an output, the latched value will then
                    appear on the output.

                    PORTA, PORTB, and PORTE are all fixed direction Ports
                    with the exception of bit-7 of PORTA. When PORTB is
                    being used for general purpose output, it is configured
                    for output only and reads return the actual level
                    sensed at the input of the pin drivers. When PORTA is
                    being used for general purpose I/O, bit 0, 1, and 2 are
                    configured as inputs and write to these bits have no
                    effect or meaning. Bit 3, 4, 5, and 6 are configured
                    for output only and reads return the actual level
                    sensed at the input of the pin drivers. Bit 7 of PORTA
                    can be configured as either an input or an output via
                    the DDRA7 bit in the PORTA control register (PACTL).
                    PORTE contains the 8 inputs to the A-to-D converter,
                    however they may also be used as digital inputs. Write
                    to the PORTE address have no meaning or effect.

                    For a more complete discussion of the function of the
                    I/O subsystems contained in the MC68HC11, it is
                    suggested that the part data sheet be consulted.

          TIME      Like the PORTx functions, the TIME function requires
                    no arguments and is used to retrieve the current value
                    of the system time.

          RTIME     The RTIME function requires no arguments, it is used to
                    reset the entire system time keeping function.

                                         28






          PACC      When the keyword PACC appears to the right of the
                    equals sign it allows the program to retrieve the
                    current value of the Pulse Accumulator.
                    Effectively PACC is a function that requires no
                    arguments.

          POKE <line #> POKE(<expression>,<expression>)

               45 POKE($ED00,$5A)
               55 POKE(AD,X*5)

               The  POKE  statement  allows the BASIC11 program to directly
          modify RAM memory or I/O locations.  The first expression  within
          the  parenthesis  is  the  address at which the second expression
          will be stored. The first expression may be evaluate to any legal
          integer number.  However the second expression  must  be  in  the
          range  0<=expression<= 255 since a byte location is being written
          to. If the second expression is outside the above range,  Error #
          48 will be issued. Care should be taken when using this statement
          so that part of the BASIC11 program or its data are not overwrit-
          ten.

          PEEK(X)
               The  PEEK  function performs the opposite action of the POKE
          function. It allows BASIC11 directly retrieve the contents of any
          memory or I/O location in the MC68HC11 memory map.  The  argument
          X, Since it is an address, is taken to be an unsigned number so X
          may  be  take on any integer value.  A single byte is returned by
          the function so it value will be >=0 and <=255.

          6.0 ERROR REPORTING:

          BASIC11 has an extensive error reporting structure  that  reports
          two basic types of errors. The first category is command line er-
          rors. If a mistake is made by either typing an illegal command or
          a syntax error is detected either in the program line or a state-
          ment that is to be executed in the direct mode, BASIC11 will
          print  the  contents  of  the input buffer.  On the next line as-
          terisks and arrow will be printed showing the  approximate  loca-
          tion of the error within the line.  Finally,  a number is printed
          telling the operator what is wrong with the line.  In the example
          shown below programmer input is underlined.

                    #10 FOR X=1 100 STEP 2
                    ----------------------

                     10 FOR X=1 100 STEP 2
                     ********^^^
                    ERROR #17
                    READY

                    #

                                         29






          Looking up error #17 in the error table we find that we have inad-
          vertently left out the "TO" in the FOR statement. By retyping the
          line  with  "TO"  between  the  1 and 100 BASIC11 will accept the
          line.

          When the programmer mistypes a command, Error #3 (Invalid Expres-
          sion) will generally be issued. An example follows:

                    #LOST (what the programmer meant to type was LIST)
                    -----

                     LOST
                     *^^^
                    ERROR #3
                    READY

                    #
          THe reason error #3 is issued is that BASIC11 first searches  its
          command table to see if the programmer has typed a command. If no
          match is found,  BASIC11 then searches its statement table to try
          to match the input buffer with one of the keywords.  If no  match
          is  found,  BASIC11 assumes that the statement is an implied LET.
          In the above example the first two letters,  "LO",  would be  as-
          sumed to be a variable name, and the rules say that in an implied
          (or declared) LET the assignment variable must be immediately fol-
          lowed by an equals ('=').

          The  second  category of errors is runtime errors.  These errors,
          which are context dependent,  occur while the program is running.
          All runtime errors are considered to be fatal in BASIC11 and will
          immediately  terminate  program  execution.  A  message  will  be
          printed on the terminal indiv=cating what error  occured  and  in
          which  line  it  occuredd.  Even though BASIC11 does not list the
          source line for runtime errors,  the  error  number  is  specific
          enough that the problem can easily be identified.

                    A list of error numbers and their meanings follows.




          ERROR#    MEANING

            1       Line number<0 or >32767
            2       Syntax Error
            3       Invalid Expression
            4       Unbalanced Parenthesis
            5       Data Type Mismatch





                                         30






            6       Illegal Operator
            7       Illegal Variable
            8       Illegal Token
            9       Out of Memory
            10      Integer Overflow
            11      Invalid Hex Digit
            12      Hex Number Overflow
            13      Missing Quote
            14      Missing Open or Closing Parenthesis
            15      Syntax Error in "ON" Statement
            16      Missing "THEN" in an "IF" Statement
            17      Missing "TO" in a "FOR" Statement
            18      Line NUmber Zero(0) Not Allowed
            19      Illegal Data Type
            20      Expression Too Complex
            21      Missing Comma
            22      Missing Comma or Semicolon
            23      Math Stack Overflow
            24      Undimensioned Array
            25      Subscripted Out of Range
            26      Divide by 0
            27      Line # not found
            28      Too Many Nested "GOSUB's" (maximum is 8)
            29      "RETURN" without "GOSUB"
            30      Too Many active "WHILE's" (maximum is 8)
            31      "ENDWH" without "WHILE"
            32      "ON" argument is negative, zero, or too large
            33      Non-Subcriptable Variable Found in "DIM" Statement
            34      Variable has Already been DIMensioned
            35      Too many active "FOR-NEXT" loops (maximum is 8)
            36      Mismatch "FOR-NEXT" loop
            37      Can't Continue
            38      Out of Data in "READ" or "RESTORE" Statement
            39      Negative Subscript not allowed
            40      "EEP()" Subscript Negative or > 255
            41      Function only allowed in "PRINT" Statement
            42      Argument <0 or >255 in "TAB()" function
            43      Argument <0 or >255 in "CHR$()" function
            44      Overflow or divide by zero in "FDIV()" function
            45      Invalid Channel Number in "ADC()" function
            46      Tried to Assign a Value of <0 or >255 to a Port
            47      Illegal PORT
            48      Illegal Device Number
            49      Uninitialized I/O Vector
            50      Argument <0 or >255 in "HEX2()" function
            51      Statement not allowed in immediate mode
            52      RETI executed when not in an interrupt routine
            53      Tried to assign a value of <0 or >255 to PACC
            54      Interrupt or Count mode error in ONPACC
            55      Program storage EEPROM is too small



                                         31






                                        APPENDIX  A

          This appendix contains information specific to BASIC11's implemen-
          tation  for  the  Motorola  MC68HC11  evaluation  board  (Part  #
          M68HC11EVB ).

          PROGRAM STORAGE EEPROM:

          Note: The  following  modification  only  needs  to  be  made  to
          Rev.'A'EVB's  For Rev.'B' and beyond,  the program storage EEPROM
          may be placed in socket U4.  For the ESAVE and ELOAD commands  to
          work properly, a fabricated jumper must be placed on J3.

          The  M68HC11EVB  was  designed to be an extremely low cost way of
          evaluating the capabilities of the MC68HC11  microcomputer  hence
          it  has  no  memory  expansion  capabilities.  To be able to save
          BASIC11 programs either while working on them or for stand  alone
          execution in a control environment,  some additional non-volatile
          memory must be added. This memory is added in the form of an 8kx8
          EEPROM that is piggybacked on to the 8k x 8 RAM (U4).  The EEPROM
          that  is used must have latched address,  data,  control signals,
          automatic erase before write capabilities,  and  have  self  time
          write cycles.  Several parts that meet these requirements are the
          XICOR X2864A-25, Samsung KM2864A, EXEL XL2864A-25.

          To add the 8K x 8 EEPROM it is neccessary  to  parallel  all  ad-
          dress,  data, and control lines of the part except pin # 20 (chip
          enable), pin # 22 (output enable), pin # 1 (RDY/BUSY). Do this by
          placing the EEPROM on top of the 8K x 8 RAM  (U4)  and  carefully
          soldering  all  the  leads,  except  pin 20,  pin 22,  and pin 1,
          together.  Carefully bend pin # 20,  # 22,  #1 of the EEPROM away
          from the corresponding pins of the RAM I.C.,  U4.  Pin # 1 may be
          cut off since it will not be used.

          To meet the write cycle timing requirements of the 2864  EEPROMS,
          the output enable must be negated (logic 1) during writes. To ac-
          complish this, an inverted R/W signal is routed to pin #22 of the
          EEPROM.  On the bottom of the board, cut the trace connecting pin
          #11 and pin #13 of I.C.  U14 (MC74HC14).  Using a piece of  small
          gauge  wire,  connect pin #11 of U14 (MC74HC14) to pin # 10 of U6
          (MC14066B). Once again using a piece of small gauge wire, connect
          pin #10 of U14 to pin #22 of the EEPROM.

          Next using a piece of wire wrap or other small gauge  wire,  con-
          nect  pin # 20 of the EEPROM to pin # 59 of the MCU I/O port con-
          nector,  P1.  Again,  using a piece of wire wrap or  other  small
          gauge  wire,  connect  pin #60 of connecttor P1 to pin #12 of the
          74HC138 (U5). This connects the chip enable pin of the EEPROM to
          the address decoder and places it in the memory map from  address
          $6000 thru $7FFF. As a final step, solder a 10k ohm pull-up resis-
          tor between pin #12 and #16 of the 74HC138 (U5).


                                         32






          Finish  the  installation  by placing a fabricated jumper between
          pin #59 and 60 of the port connector P1.

          The fabricated jumper installed in the previous step is  used  so
          that the EEPROM may be disabled during powerup.  This will effec-
          tively disable the automatic execution of a program stored in  it
          if the AUTOST command was entered prior to the last power down.

          SYSTEM PRINTER:

           BASIC11  contains device drivers that allows the connection of a
          serial printer to the HOST port of the  M68HC11EVB.    Since  the
          HOST  port on the HC11EVB does not support any hardware handshak-
          ing, the printer must be able to support X-On/X-Off software hand-
          shaking.  The characters used for X-On/X-Off flow control are cur-
          rently set to $13 for X-OFF and $11 for X-ON.   If these  charac-
          ters need to be changed to accommodate other printers or devices,
          there  are two variables located on page zero that may be changed
          by POKEing the desired values into them.   The X-ON  variable  is
          located at $0043 and the X-OFF variable is located at $0044.  The
          default  configuration  for the printer port is 9600 BAUD,  eight
          data bits, one start bit,  and one stop bit.   This may easily be
          changed by poking the proper value into the BAUD control register
          located  at  $102B.    For  further information on the MC68HC11's
          Serial Communications Interface (SCI),  please refer to the parts
          data sheet.

          Besides being used to get hard copy listings of programs with the
          LLIST  command,  the system printer may be accessed from within a
          program by using the "PRINT#<expression>" form of the PRINT state-
          ment with the value of <expression> evaluating  to  1.    So  the
          program line 10 PRINT #1, "HELLO THERE WORLD", would print "HELLO
          THERE  WORLD" on the system printer.   Even though it is not pos-
          sible to "INPUT" anything from the system printer, the input vec-
          tor for device #1 has  been  setup  to  allow  characters  to  be
          received via the RxD line of the target system.

          One  final  note  about using the SCI port of the HC11 for serial
          Input and Output.  The HC11EVB hardware was designed so that both
          the TxD and RxD lines of the SCI could be disconnected  from  the
          HOST  computer I/O connector.   The TxD line is disconnected from
          the HOST port by simply removing the  fabricated jumper, J4.  The
          RxD line is alternately connected to either the target system or
          HOST port by  means  of  an  MC74HC4066  digital  switch  and  an
          MC74HC74  flip flop.  The switching of the receiver line from the
          target system to the HOST I/O port is accomplished by  writing  a
          logic  one  in  bit  0  to  any address in the range #A000-$BFFF.
          Likewise,  writing a logic zero in bit 0 to any  address  in  the
          same rang results in the target system being connected to the RxD
          pin of the HC11.



                                         33






          BASIC11 initializes the hardware so that the SCI RxD line is con-
          nected to the HOST I/O port.  Connection to the target system may
          be accomplished by executing the statement POKE($A000,1).

          ALTERNATE DEVICE I/O:

          BASIC11  supports a form of device independent I/O in the  PRINT,
          INPUT,   and  INBYTE  statements  by  using  the  "#<expression>"
          modifier after each keyword.  The expression is evaluated and  is
          used  as  an index into a pair of vector tables located in page 0
          RAM.  Each table consists of 8 entries  of  two  byte  addresses,
          therefore  <expression>  must  evaluate  to  be in the range of 0
          through 7. The two tables, "INTABLE" AND "OUTABLE",  arre located
          at $00A4 and $00B4 respectively. Currently device #0 is set up to
          be  the  control  console I/O routines and device #1 is set up to
          send data to a system printer connected to  the  HOST  I/O  port.
          Device  numbers 2 through 7 are available for use by the program-
          mer.

          As mentioned above, device #0 is used for the control console and
          is curruntly set up to use the MC6850 ACIA for system I/O.  If it
          is  desired to use other hardware for system I/o the user may re-
          place the current vextors in INTABLE and  OUTABLE.  If  control-C
          break in capability is to be maintained for the new hardware, two
          additional vectors must be modified.

          The CONSTAT (CONsole STATus) vector located at $009E should point
          to a routine that checks the control console hardware to see if a
          character has been typed.  If a character has been received,  the
          routine should return a NOT EQUAL condition (Z condition code bit
          cleared).  This routine MAY NOT modify any registers  except  the
          condition code register. The CONINNE (CONsole INput No Echo) vec-
          tor located at $00A1 should point to a routine that gets a charac-
          ter  from  the  console hareware but does not echo it back to the
          hardware.  Note that these vectors are 3 byte  vectors  with  the
          first byte containing a JMP instruction ($7E). The address of the
          user routines needs to be put in the second and third bytes.

          By  using  the  CONSTAT  vector to point to a routine that always
          returns an equal condition, (Z bit in the condition code register
          set) the control-C break-in capability  can  effectively  be  dis
          abled.

          INTERRUPT VECTOR TABLE:

          All  twenty of the interrupt vectors for the different subsystems
          on the MC68HC11 are located in the memory map at  location  $FFD4
          through $FFFF.  To provide for more flexibility in using the sub-
          systems in an interrupt driven mode,  the  ROM  hardware  vectors
          "point" to a second "JUMP" vector table located in RAM on page 0.
          The  table,  as shown below,  may be altered by the programmer to
          point to special interrupt handlers for a particular application.

                                         34






          The PACCIE,  PACCOVF,  TOC1,  and IRQI vectors are initialized by
          BASIC11  to  point  to its own interrupt routines for the various
          real time control functions provided by BASIC11. The ILLOP,  COP,
          and  CMF vectors are initialized to jump to the start of BASIC11.
          All the rest of the vectors point to an RTI instruction.


          *
          *
                    ORG  $009E
          *
          CONSTAT   RMB  3         GET CONTROL CONSOLE STATUS (FOR BREAK
                                                                 ROUTINE).
          INCONNE   RMB  3         GET BYTE DIRECTLY FROM CONTROL CONSOLE,
                                                                  NO ECHO.
          *
          *
                    ORG  $00A4
          *
          INTABLE   RMB  16        RESERVE SPACE FOR 8 DIFFERENT INPUT
                                                                ROUTINES.
          OUTABLE   RMB  16        RESERVE SPACE FOR 8 DIFFERENT OUTPUT
                                                                ROUTINES.
          *
          *
          *
          *
                    ORG  $00C4     START OF RAM INTERRUPT VECTORS.
          *
          RAMVECTS  EQU  *
          SCISS     RMB  3         SCI SERIAL SYSTEM
          SPITC     RMB  3         SPI TRANSFER COMPLETE
          PACCIE    RMB  3         PULSE ACCUMULATOR INPUT EDGE
          PACCOVF   RMB  3         PULSE ACCUMULATOR OVERFLOW
          TIMEROVE  RMB  3         TIMER OVERFLOW
          TOC5      RMB  3         TIMER OUTPUT COMPARE 5
          TOC4      RMB  3         TIMER OUTPUT COMPARE 4
          TOC3      RMB  3         TIMER OUTPUT COMPARE 3
          TOC2      RMB  3         TIMER OUTPUT COMPARE 2
          TOC1      RMB  3         TIMER OUTPUT COMPARE 1
          TIC3      RMB  3         TIMER INPUT COMPARE 3
          TIC2      RMB  3         TIMER INPUT COMPARE 2
          TIC1      RMB  3         TIMER INPUT COMPARE 1
          REALTIMI  RMB  3         REAL TIME INTERRUPT
          IRQI      RMB  3         IRQ INTERRUPT
          XIRQ      RMB  3         XIRQ INTERRUPT
          SWII      RMB  3         SOFTWARE INTERRUPT
          ILLOP     RMB  3         ILLEGAL OPCODE TRAP
          COP       RMB  3         WATCH DOG TIMER FAIL
          CMF       RMB  3         CLOCK MONITOR FAIL
          *
          *

                                         35

