Rnd
From Maze
(Difference between revisions)
| Line 4: | Line 4: | ||
| − | The random function (RND) as used in the commodore 64 program | + | =The random function (RND) as used in the commodore 64 program 10 print chr$(79+int(rnd(0)*2));:goto 10= |
| − | 10 print chr$(79+int(rnd(0)*2));:goto 10 | ||
C64-specific: | C64-specific: | ||
| Line 24: | Line 23: | ||
| + | =C64 floating-point= | ||
| + | |||
| + | The native number format of Commodore BASIC, like that of its parent MS BASIC, was floating point. Most of the contemporary BASIC implementations used one byte for the characteristic (exponent) and three bytes for the mantissa. This led to problems in business applications since the accuracy of a floating point number using a three-byte mantissa is only about 6.5 decimal digits, and round-off error is common. '''Commodore, however, used MS BASIC's four-byte mantissa, which made their BASIC much more adapted for business than most other BASICs of the era'''. (reference: http://en.wikipedia.org/wiki/Commodore_BASIC) | ||
| − | Dartmouth BASIC | + | =Dartmouth BASIC= |
[http://dtss.dartmouth.edu/scans/BASIC/ Dartmouth BASIC code] | [http://dtss.dartmouth.edu/scans/BASIC/ Dartmouth BASIC code] | ||
| Line 58: | Line 60: | ||
| + | =C64 Rnd(0) Disassembly= | ||
| Line 63: | Line 66: | ||
perhaps we can depict this function somehow. | perhaps we can depict this function somehow. | ||
| − | C64 Rnd(0) Disassembly | + | * I would like to depict it, but I don't fully understand it yet. I can't quite find the portion where the floating-point mantissa is manipulated. I can see parts where it is shifted by one byte, but I can't see where it folds in the constants located at $E08D-$E094. Can anyone help? |
| + | |||
(most disassembly from http://www.ffd2.com/fridge/docs/c64-diss.html) | (most disassembly from http://www.ffd2.com/fridge/docs/c64-diss.html) | ||
