annotate README.txt @ 85:663d8e77b579

Implmement BCD floating point and update number parsing and printing Implements a BCD floating point system with 10 decimal digits of precistion and an exponent range of -63 to +63. Also include parsing integer and floating point values and printing them out.
author William Astle <lost@l-w.ca>
date Sun, 15 Oct 2023 22:15:36 -0600
parents fbb8f369ce76
children 1c1a0150fdda
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
1 This is the LWBasic project. Its goal is to create a replacement Basic for
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
2 the TRS80 Color Computer. This Basic will not be binary compatible with the
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
3 stock ROM. In particular, any various peeks, pokes, executes, and the like
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
4 intended to mess with the interpreter internals are unlikely to work, and,
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
5 in fact, may be completely detrimental.
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
6
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
7 There are two versions of LWBasic. One is for the Coco 1 and 2. The other
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
8 is for the Coco 3. The primary differences between the two are in the
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
9 startup code and features that rely on the existence of Coco 3 hardware. The
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
10 main differences for the Coco 3 version are:
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
11
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
12 * 32/40/64/80 column text modes with attributes
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
13 * 256/320/512/640 column bitmap graphics with up to 16 colours (256/320)
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
14 or 4 colours (512/640)
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
15 * palette register setting
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
16 * graphics and text screen located outside main program memory
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
17 * disk I/O buffers located outside main program memory
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
18 * separate heaps for strings, scalars, arrays, and program text not limited
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
19 to the 64K address space of the CPU
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
20 * ROM/RAM copy at startup and initialization of Coco 3 specific hardware;
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
21 defaulting to the 80 column text screen
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
22
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
23 Both versions can either be installed in ROM or loaded from disk or tape.
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
24 In the case of loading from disk or tape, the machine must have at least
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
25 64K of RAM. The loadable versions do not include certain initalization
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
26 routines that are only relevant to cold starting the hardware.
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
27
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
28 For the Coco 3 version, the ROM is a single 32K chunk intended to replace
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
29 the 32K internal ROM. For the Coco 1/2 version, there are three chunks: an
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
30 "Extended Color Basic" chunk (8K for the ECB socket), a "Color Basic" chunk
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
31 (8K for the CB socket), and "Disk Extended Color Basic", a 16K chunk
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
32 intended to be installed in a cartridge ROM, probably a disk controller. On
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
33 machines with a single 16K internal ROM, the "Extended Color Basic" and
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
34 "Color Basic" chunks should arranged with "Extended Color Basic" at the
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
35 lowest address and "Color Basic" immediately above.
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
36
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
37 An important note about the hardware interrupt vectors in the ROMs: the Coco
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
38 1/2 get the FFFx vectors from the top 16 bytes of the "Color Basic" chunk.
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
39 The Coco 3 gets the FFFx vectors from the top 16 bytes of the 32K internal
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
40 ROM.
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
41
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
42 Note that LWBasic does not look for the DK signature of a Disk Basic ROM
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
43 and, thus, will not autostart whatever Disk Basic you happen to have
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
44 installed. This is most relevant on a Coco 3 where the upper 16K of the
fbb8f369ce76 Initial project creation with README file
William Astle <lost@l-w.ca>
parents:
diff changeset
45 LWBasic ROM is internal instead of in a cartrige.
85
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
46
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
47
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
48 Numbers
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
49 =======
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
50
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
51 LWBasic has three numeric types: a 32 bit signed integer, stored as two's
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
52 complement, a decimal floating point type stored in packed BCD with
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
53 10 digits of precision and a base 10 exponent range of -63 to +63, and a
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
54 double precision decimal floating point type with 20 decimal digits of
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
55 precision and a base 10 exponent range from -2047 to +2047.
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
56
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
57 The BCD format using 48 bits is stored as follows:
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
58
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
59 Offset Size Content
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
60 0 1 Sign bit - 1 for negative
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
61 1 7 Decimal exponent with a bias of 64; 0 indicates a value of 0
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
62 8 40 10 BCD digits of the significand
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
63
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
64 *** Planned but not implememted
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
65 The BCD double format using 96 bits is stored as follows:
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
66
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
67 Offset Size Content
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
68 0 1 sign bit - 1 for negative
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
69 1 3 <reserved>
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
70 4 12 Decimal exponent with a bias of 2048; 0 indicates value of 0
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
71 16 80 20 BCD digits of the significand
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
72
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
73 It is worth noting the reason for using the BCD format instead of binary
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
74 floating point. Because interactions with the computer are typically in base
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
75 10, it makes sense to avoid the horrendous complications of attempting to
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
76 maximize the accuracy of converting binary floating point to decimal and
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
77 back again. While this is trivial for integers, it is non-trivial for
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
78 floating point where the variations in accuracy and the need for rounding is
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
79 unavoidable.
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
80
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
81 At the expense of some extra CPU cycles for doing the calculations, base 10
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
82 accuracy is preserved, at least to the precision limit of the data type.
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
83 This also allows pre-parsing numbers and being able to display them again
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
84 accurately when generating a program listing, even if extra nonsignificant
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
85 digits like trailing decimal zeroes are not reproduced.
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
86
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
87 It is, however, critical to note that despite the BCD representation, these
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
88 values are still floating point and have the inherent inaccuracies of all
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
89 limited precision data types. The simple difference is that it makes the
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
90 numbers in the computer behave exactly like scientific notiation with no
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 0
diff changeset
91 unexpected surprises.