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

Re: Integer Basic Tokenization



In article <vwrs6.20654$PH.1741328@e3500-chi1.usenetserver.com>,
Matthew Russotto <russotto@wanda.pond.com> wrote:
 
> In article <98sef0$5tq$1@merope.saaf.se>, Paul Schlyter <pausch@saaf.se> wrote:
> 
>> Correct: Integer Basic eocnides all integer constants as 16-bit
>> binaries, prefixed with a byte B0-B9.  Interpretation gets quicker if
>> integer constants need not be converted from ASCII each and every
>> time they are encountered in the code.
> 
> Which is why in Applesoft, it was significantly faster to use
> variables instead of constants.
 
Another thing which added to the slowness of Applesoft Basic was
that it really was a floating-point only Basic in many respects.
E.g. the statement:
 
    10  A% = 2
 
would parse the "2" as a floating-point number, and then convert it
to an integer before storing it in A% !!!!
 
Applesoft (as well as several other related versions, such as PET
Basic and Commodore 64 Basic) was really Microsoft's 6502 version of
its Basic interpreter version 2.  Microsoft never upgraded the 6502
Basic interpreters any further, but the 8080 versions got released in
new versions up to version 5.(something).  In version 5 of MBASIC,
all numeric constants were stored in binary format - integer as well
as floating-point constants, and the latter could appear in
single-precision as well as double-presicion verisons.  MBASIC ver 5
also did a quite interesting thing with the GOTO <linenumber>
statement: at first when entered, <linenumber> was stored just as the
line number, in binary format of course.  The first time this GOTO
executed, the program was scanned for the target line; when found,
the GOTO token was changed to another GOTO token, and <linenumber>
was changed to a binary offset from the beginning of the program.
Thus, on subsequent executions, the target line didn't need to be
searched.  However the LIST command had to be intelligent enough to
convert a "GOTO2 <offset>" statement to a "GOTO <linenumber>"
statement.  And any change to the program would force a scan of the
entire program, converting all <offset>'s back to <linenumber>'s.
GOSUB <linenumber> and RESUME <linenumber> were treated in a similar
way.
 
-- 
----------------------------------------------------------------
Paul Schlyter,  Swedish Amateur Astronomer's Society (SAAF)
Grev Turegatan 40,  S-114 38 Stockholm,  SWEDEN
e-mail:  pausch at saaf dot se   or    paul.schlyter at ausys dot se
WWW:     http://hotel04.ausys.se/pausch    http://welcome.to/pausch