Tuesday, November 13, 2018

SIN() in please! (MC-10 ROM changes)

The new MC-10 ROM has been sitting untouched and incomplete for far too long, so I worked on it a few hours.

A small list of some of the changes that were made.
  1. Miscellaneous fixes such as only adding a colon in front of the ELSE statement during tokenization if the character before it isn't already a colon.  It would add one no matter what before.  The colon is required for the ELSE to work.
  2. A redundant floating point register load was eliminated.
  3. The variable that saves the current line number was changed to the current line pointer.  This was the easiest way to implement the feature, and it only took about an hour.  All that needed changed was the code that sets or reads the variable, and code that needs the current line number.  This will only be faster once I store both, but it was the quickest way to get it working since it didn't require significant stack code changes.  The code that prints the line number on BREAK, now prints the address of the line, but the fix shouldn't be difficult once I have time to work on it.  A side benefit of this change was the elimination of some unnecessary code and it's close to working in 8K again.
  4. The most significant change, is the SIN() function now uses multiply to perform division by 2*Pi using the reciprocal (invert and multiply).  So it multiplies by 1/(2*Pi).  The code works well enough to perform some initial tests, which show this offers a significant speedup.  This also speeds up COS() since that is calculated with SIN(n+(Pi/2)), and TAN() which is calculated with  SIN(n) / COS(n).  The code does not work for all cases though, so there's some work to be done yet, but it works well enough I could make the video below.

This is the previous video showing the speed of the new ROM vs the factory ROM:


This is the ROM with the SIN() code change:

No comments:

Post a Comment