[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Two friendly questions to Apple II users...
Fabrice Frances <frances@ensica.fr> wrote:
> ...from an Oric user 8-)
>
> I'm trying to trace back the origins of the Microsoft Basic we use on
> Oric computers, and I wonder if it comes from the Apple world, could
> someone mail me answers ? (I don't read this newsgroup usually)
>
> 1) I quite remember the floating point variables were 4 bytes in Apple's
> Basic (an accuracy of about 6 and half decimals), am I wrong ? or were
> there two Basics, one from Apple and one from Microsoft ? And the one
> from Microsoft used 5 bytes floating point values (about 9 and half
> decimals) ?
Floating point values are 5 bytes in Applesoft BASIC. The only other
widespread BASIC interpreter for the Apple II was Integer BASIC, which
was written in machine code by Steve Wozniak for the Apple 1, then
ported to the Apple II. It does not support floating point.
Applesoft floating point variables have about 9 decimal digits of
precision, with an exponent range of E+/-37.
As far as I know, Applesoft BASIC was mostly written by Microsoft, with
some Apple code added for graphics support (mostly taken from Integer
BASIC). I think the underlying implementation was a general 6502
version of Microsoft BASIC, which may have ended up on other 6502-based
platforms (I don't know what CPU the Oric uses).
> 2) Also, can anyone clearly affirm the Microsoft Basic for the Apple II
> didn't really use integers ? I mean, there *are* integer variables
> (suffixed with a % char), but every computation is done with floating
> point computations, so integer variables are converted to and back
> from floating point. Is it the case ? (please note I would like sound
> answers, not "it seems to me that..." 8-)
Yes. There are a few pure integer calculations: line numbers and some
machine-level stuff are parsed as integers (expressions are not
allowed), but everything else is evaluated using floating point and
converted back to integer afterwards (if necessary).
> 3) Easier: names of variable aren't limited in length but only the first
> two characters are significative... right or wrong ?
Correct. The data structure used to hold a variable only stores the
first two characters (bit 7 of each character is used to encode the
variable type). Variable names must therefore be unique in the first
two letters. Another limitation is that reserved words must not appear
within variable names, because the parser will tokenise them.
Variables of different types may use the same name, e.g. AB$, AB, AB%,
AB(n), AB$(n), AB%(n).0
> 4) More technical: is there a microsoft signature in the code,
> consisting of the ascii characters !FTOSORCIM (Microsoft! backwards),
> but hidden as two floating point values after the floating point
> constants
> used for a polynomial (the one for computing TAN I think), that is to
> say,
> bits 6 and/or 7 of some bytes are inversed. One way to easily verify
> this:
> mask each byte with a $3F value, then add $40, and search FTOSORCIM...
Well, there are ten unused bytes immediately after the lookup table
which is used to calculate SIN (TAN is done by calculating SIN and COS
then dividing). In order the bytes are:
A6 D3 C1 C8 D4 C8 D5 C4 CE CA
Exclusive-OR each byte with 87, and you get:
21 54 46 4F 53 4F 52 43 49 4D
Converting to ASCII:
!TFOSORCIM
:-)
The XOR was an educated guess, from looking at the first byte! I have
no idea why 87 was picked as the mask.
--
David Empson
dempson@actrix.gen.nz
Snail mail: P.O. Box 27-103, Wellington, New Zealand