Appendix C.2 - The ZX81 for those that understand BASIC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The BASICNumbers are stored to an accuracy of 9 or 10 digits. The largest number you can get is about 1038, & the smallest (positive) number is about 4 * 10-39.A number is stored in the ZX81 in floating point binary with one exponent byte e (1 e 255), & four mantissa bytes m (½ m 1). This represents the number m * 2e-128. Since ½ m 1, the most significant bit of the mantissa m is always 1. Therefore in actual fact we can replace it with a bit to show the sign - 0 for positive numbers, 1 for negative. Zero has a special representation in which all 5 bytes are 0. Numeric variables have names of arbitrary length, starting with a letter and continuing with letters and digits. All these are significant, so that for instance LONGNAME & LONGNAMETOO are distinct names. Spaces are ignored. Control variables for FOR-NEXT loops have names a single letter long. Numeric arrays have names a single letter long, which may be the same as the name of a simple variable. They may have arbitrarily many dimensions of arbitrary size. Subscripts start at 1. Strings are completely flexible in length. The name of a string consists of a single letter followed by $. String arrays can have arbitrarily many dimensions of arbitrary size. The name is a single letter followed by $ and may not be the same as the name of a string. All the strings in a given array have the same fixed length, which is specified as an extra, final dimension in the DIM statement. Subscripts start at 1. Slicing: Substrings of strings may be specified using slicers. A slicer can be (i) empty or (ii) numerical expression or (iii) optional numerical expression TO optional numerical expression & is used in expressing a substring either by (a) string expression (slicer) or by (b) string array variable (subscript,...,subscript, slicer) which means the same as string array variable (subscript,...,subscript)(slicer) In (a), suppose the string expression has the value s$. If the slicer is empty, then the result is s$ considered as a substring of itself. If the slicer is a numerical expression with value m, then the result is the mth character of s$ (a substring of length 1). If the slicer has the form (iii), then suppose the first numerical expression has the value m (the default value is 1), & the second, n (the default value is the length of s$). If 1 m n the length of s$ then the result is the substring of s$ starting with the mth character & ending with the nth. If 0 n m then the result is the empty string. Otherwise, error 3 results. Slicing is performed before functions or operations are evaluated, unless brackets dictate otherwise. Substrings can be assigned to (see LET). The argument of a function does not need brackets if it is a constant or a (possibly subscripted or sliced) variable.
The following are binary operations:
Functions & operations have the following priorities:
|