Jump to content

Lee Stewart

+AtariAge Subscriber
  • Posts

    5,846
  • Joined

  • Last visited

4 Followers

About Lee Stewart

Profile Information

  • Gender
    Male
  • Location
    Silver Run, Maryland

Recent Profile Visitors

21,093 profile views

Lee Stewart's Achievements

Quadrunner

Quadrunner (9/9)

4.9k

Reputation

  1. Thank you. Well, you might be disappointed. It may well be good enough for things TI-99/4A, but LCGs are, generally, not considered good PRNGs, anymore. Here is a comment made by the authors (W. H. Press, S. A. Teukolsky, W. T. Vetterling, B. P. Flannery) of Numerical Recipes: The Art of Scientific Computing, 3rd Edition, 2007, in Chapter 7, “Random Numbers”: With hindsight, it seems clear that the whole field of random number generation was mesmerized, for far too long, by the simple recurrence equation Ij+1 = aIj + c (mod m) (7.1.1) You can read the entire chapter (or book, for that matter) at the Numerical Recipes website. The above-referenced chapter as well as Chapter 3, “Random Numbers” in D. E. Knuth’s The Art of Computer Programming, Volume 2: Seminumerical Algorithms, 3rd Edition, 1998, are very good, comprehensive discussions and references on the subject. There are, certainly, tests for assessing the quality of PRNGs, but, again, my primary mission in this thread is to explain the XB PRNG. ...lee
  2. The principal reason for this thread is to explain what XB’s PRNG is and how it is calculated—mainly, because there seems to have been a lot of misunderstanding over the years about it. I (we) will certainly be comparing it to other PRNGs, but it is not the primary purpose. ...lee
  3. More or less—I have in mind to make some sort of comparison with TI Basic’s PRNG, which is discussed here, and TI Forth and fbForth’s PRNGs. As to the Geneve ABasic’s PRNG, it is virtually identical to XB, with GPL code converted to ALC. I understand per @InsaneMultitasker that Myarc Basic II was the source for Abasic, in which case the PRNG is certainly the same. I would need that source code to be sure. That is, currently, the extent of my comparison plans. ...lee
  4. It is my intention, here, to explain the details of the pseudorandom number generator (PRNG) in TI Extended Basic (XB). Over the next few days, I will expand this first post to include my analysis to date in an effort to make it as nearly complete as I am able. I will also make any updates relevant to further insights from the ensuing discussion: XB’s PRNG is a linear congruential generator (LCG) with the following recurrence equation: xnew = (ax + c) mod m (1) where x = current seed, which is initialized at power-up to 335212624223 a = 14389820420821 c = 21132486540519 m = 1014 xnew = pseudorandom number (PRN) sought and the new seed for the next go-round. The above converts the above PRNG to the following equation: xnew = (14389820420821x + 21132486540519) mod 1014 (2) To preserve precision for the radix-100, floating point calculations, all of the above numbers were split into a least-significant half (LSH), with subscript 1, and a most-significant half (MSH), with subscript 2, such that x = 107x2 + x1 (3) a = 107a2 + a1 (4) c = 107c2 + c1 (5) which converts (1) to xnew = ((107a2 + a1)(107x2 + x1) + 107c2 + c1) mod 1014 xnew = (1014a2x2 + 107a2x1 + 107a1x2 + a1x1 +107c2 + c1) mod 1014 (6) At the very least, the first term drops out because 1014a2x2 mod 1014 = 0 simplifying (6) to xnew = (107a2x1 + 107a1x2 + a1x1 +107c2 + c1) mod 1014 (7) ...lee
  5. Here are all seven volumes—no calendars: YesterdaysNews.zip ...lee
  6. So sorry to hear this. My condolences to you and your family. ...lee
  7. Nearly finished with updating FBLOCKS. I need to burn an EPROM with the latest beta so I can test my revised Compact Flash utilities. Actually, the only one I had to modify was CFPMOUNT , which is the word that writes the mounted DSK volume to the compact flash so that the mount persists past power-down. The change was necessitated by the new DSRLNK described a few posts back and here. ...lee
  8. It does save 4 bytes where the jump calculation is performed in ENDIF and BACK , and obviates the need for BACK , which saves 18 bytes for a total savings in the resident dictionary of 26 bytes. It also saves 2 trips through the inner interpreter in compiling LOOP +LOOP UNTIL AGAIN because “ , ” replaces BACK (defined as “ HERE - , ”), but time savings while compiling are not usually that important. ...lee
  9. Maybe we should get Fred ( @F.G. Kaal ) to weigh in. I believe he had significant input to later versions of the DSR---maybe even wrote it? ...lee
  10. One of my TODOs is to possibly change BRANCH and 0BRANCH to use absolute addresses (per @Willsy’s TurboForth) instead of an offset (per figFORTH/TI Forth/fbForth), but I really do not see the advantage except, possibly, at compile time, which does not seem that important. The difference at execution time is MOV *IP,IP <---IP is a register versus A *IP,IP <---IP is a register which take exactly the same amount of time, as far as I can tell. So, unless someone (@Willsy? @Tursi? @matthew180? @jedimatt42? @apersson850? @TheBF? ??) can show me a significant difference in execution time, I am inclined to leave sleeping dogs lie—the mod would be significant! ...lee
  11. I added a routine to check for the ISR hook and, if not there, to call the fbForth ERROR word with the proper error message number to print “ISR?” after the usual “ERROR ?” and abort. While adding the new message, I took the opportunity to shorten many of the messages. Now, even after adding the ISR checking routine to bank#0 and the code to call it to 3 words in the same bank, there are 256 bytes free! I should add that the free-space increase is due not only to message size reduction but also to some other changes such as the redefinition of .S and shortening of a handful of words to use newly added words. There is still a little work before release. Here is the current state of the TODO list: fbForth300_TODO.txt ...lee
  12. Regarding booting up fbForth with its ISR disabled, I will have PLAY , STREAM , SAY check for a cleared ISR hook (>83C4) and, upon seeing it cleared, exit the routine immediately. Do you think I should include a message such as, “ISR not active!” or just fail quietly? ...lee
  13. Of course, there can be many reasons for choosing one operation over another. Regarding getting the MSB to the LSB, the point of using “SRL Rn,8” over “SWPB Rn” is usually to zero the MSB in the same instruction—saving instructions can outweigh speed. If you want to duplicate SWPB with a shift, “SRC Rn,8” will do nicely. Furthermore, if you want to test the result, the shift is the only way—SWPB does not affect the status register. Regarding zeroing a register, CLR is, indeed, the clear (groan) winner—unless, for some reason, you need a comparison. Both XOR and LI affect the status register, whereas, CLR does not. LI also takes an additional 2 bytes over the other two, when dealing only with registers. ...lee
  14. With your GPLLNK routine modified to use a writable workspace and storage locations (see @Gary from OPA post above), there are several Scratchpad RAM locations and one ROM location you can store XMLRTN for the return from GPL: >8300, >830E, >831C, >831E in Scratchpad RAM and >603E in ROM. The GROM0 addresses of the corresponding GPL XML instructions to place in the DATA directive at GXMLAD are >0376, >0EDA, >1675, >00E5, and >0131. Some of them have more than one GROM0 location, but I listed the first I found. ...lee
  15. With a couple of changes (“ CELL - ” to “ 2- ” and “ ? ” to “ @ U. ”), the following code is, indeed, shorter—16 bytes less!: : .S ( -- ) CR ." | " S0 @ BEGIN 2- SP@ OVER < WHILE DUP @ U. REPEAT DROP ; ...lee
×
×
  • Create New...