[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: List of Integer BASIC keyword tokens, anyone?



In article <32139783.34E0@post.its.mcw.edu> Ron Kneusel
<rkneusel@post.its.mcw.edu> writes:
>The Applesoft list of keyword tokens is easy to find.  But does anyone have
>the list for Integer BASIC?

Yes.  It's not nearly as straightforward as the Applesoft token list--in many
cases the same keyword has several different tokens, depending on the context
in which the keyword appears.  For example, PRINT is $61 when followed by
a string expression, $62 when followed by a numeric expression, and $63 when
it appears alone.

     Token  Keyword
     -----  -------
      $00           (not used?  lists as "HIMEM:")
      $01           (end of line)
      $02   _       (used internally to mark the end of a keyboard command line)
      $03   :       (end of statement)
      $04   LOAD
      $05   SAVE
      $06   CON
      $07   RUN     (without line number?)
      $08   RUN     (with line number?)
      $09   DEL
      $0A   ,       (between DEL line numbers)
      $0B   NEW
      $0C   CLR
      $0D   AUTO
      $0E   ,       (between AUTO line numbers)
      $0F   MAN
      $10   HIMEM:
      $11   LOMEM:
      $12   +       (addition)
      $13   -       (subtraction)
      $14   *
      $15   /
      $16   =       (numeric comparison)
      $17   #       (numeric comparison)
      $18   >=      (numeric comparison)
      $19   >       (numeric comparison)
      $1A   <=      (numeric comparison)
      $1B   <>      (numeric comparison)
      $1C   <       (numeric comparison)
      $1D   AND
      $1E   OR
      $1F   MOD
      $20   ^
      $21           (not used?  lists as "+")
      $22   (       (begin string subscript in DIM statement)
      $23   ,       (separates subscripts in substring references)
      $24   THEN    (followed by line number)
      $25   THEN    (followed by statement)
      $26   ,       (in INPUT statement; string var follows)
      $27   ,       (in INPUT statement; numeric var follows)
      $28   "       (begin string literal)
      $29   "       (end string literal)
      $2A   (       (begin substring reference with two subscripts)
      $2B           (not used?  lists as "!")
      $2C           (not used?  lists as "!")
      $2D   (       (begin numeric array subscript)
      $2E   PEEK
      $2F   RND
      $30   SGN
      $31   ABS
      $32   PDL
      $33           (not used?  lists as "RNDX")
      $34   (       (begin numeric array subscript in DIM statement)
      $35   +       ("positive" operator--leaves sign unchanged)
      $36   -       (negation operator)
      $37   NOT
      $38   (       (open parenthesis in expression)
      $39   =       (string comparison)
      $3A   #       (string comparison)
      $3B   LEN(
      $3C   ASC(
      $3D   SCRN(
      $3E   ,       (between args of SCRN)
      $3F   (       (open parenthesis after PEEK, RND, SGN, ABS, PDL)
      $40   $       (string var suffix)
      $41           (not used?  lists as "$")
      $42   (       (begin substring reference with one subscript)
      $43   ,       (separate vars in DIM statement; string follows)
      $44   ,       (separate vars in DIM statement; numeric follows)
      $45   ;       (PRINT separator; string expression follows)
      $46   ;       (PRINT separator; numeric expression follows)
      $47   ;       (PRINT separator; nothing follows)
      $48   ,       (PRINT separator; string expression follows)
      $49   ,       (PRINT separator; numeric expression follows)
      $4A   ,       (PRINT separator; nothing follows)
      $4B   TEXT
      $4C   GR
      $4D   CALL
      $4E   DIM     (string follows)
      $4F   DIM     (numeric follows)
      $50   TAB
      $51   END
      $52   INPUT   (string var follows)
      $53   INPUT   (string literal follows)
      $54   INPUT   (numeric var follows)
      $55   FOR
      $56   =       (in FOR statement)
      $57   TO
      $58   STEP
      $59   NEXT
      $5A   ,       (between vars in NEXT statement)
      $5B   RETURN
      $5C   GOSUB
      $5D   REM
      $5E   LET
      $5F   GOTO
      $60   IF
      $61   PRINT   (string expression follows)
      $62   PRINT   (numeric expression follows)
      $63   PRINT   (nothing follows)
      $64   POKE
      $65   ,       (between POKE values)
      $66   COLOR=
      $67   PLOT
      $68   ,       (between PLOT coordinates)
      $69   HLIN
      $6A   ,       (between HLIN coordinates)
      $6B   AT      (in HLIN statement)
      $6C   VLIN
      $6D   ,       (between VLIN coordinates)
      $6E   AT      (in VLIN statement)
      $6F   VTAB
      $70   =       (string assignment)
      $71   =       (numeric assignment)
      $72   )       (close parenthesis; end subscript)
      $73           (not used?  lists as ")")
      $74   LIST    (followed by line numbers)
      $75   ,       (between LIST line numbers)
      $76   LIST    (not followed by line numbers)
      $77   POP
      $78   NODSP   (followed by string var)
      $79   NODSP   (followed by numeric var)
      $7A   NOTRACE
      $7B   DSP     (followed by string var)
      $7C   DSP     (followed by numeric var)
      $7D   TRACE
      $7E   PR#
      $7F   IN#

A tokenized number is three bytes long.  The first byte is the ASCII code
for the number's first digit (with the high bit set), and the next two bytes
are the binary value of the number (low byte first).  Negative numbers are
encoded as the negation operator ($36), followed by a tokenized positive
number.

The above list was derived from this program:

     >HIMEM:32767
     >10 REM
     >20 ADRS= PEEK (202)+256* PEEK (203)+3
     >30 FOR TKN=0 TO 127: POKE ADRS,TKN: IF TKN<10 THEN PRINT " ";:IF
         TKN<100 THEN PRINT " ";
     >40 PRINT TKN;: LIST 10
     >50 NEXT TKN: POKE ADRS, 93: END

Note that the initial HIMEM:32767 is essential--without it, the calculation
in line 20 overflows the range of an integer variable, and the program
crashes.

After running this program, I did a lot of experimenting to figure out
which duplicate tokens go with which contexts.

	     - Neil Parker
-- 
Neil Parker, nparker@{cie-2,cie}.uoregon.edu, http://cie-2.uoregon.edu/~nparker

     "I was going to be a neo-deconstructivist but Mom wouldn't let me."
                                     -- Calvin and Hobbes, 7/13/1995