Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Double literals, M*/ #434

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Conversation

burnsauce
Copy link
Contributor

This patch does 2 things:

  1. Implement M*/
  2. Implement double literals with a trailing period

Discussion of this feature at #433

M*/ is required to achieve the double literal because base conversion must use doubles as input to multiplication, and this is the only forth operator to do this. Internally it's a 32*32=64 bit multiplier with a 48/16=32 bit divider.

There is no performance impact to the math.asm changes: ud/mod's changes come out in the wash when integrated with ut/mod, an unlisted function that accepts a triple (48-bit) dividend and a 16-bit divisor. It is effectively the exact same routine as before, as the cascading divison required a leading 0 to divide the top word anyways.

READ_NUMBER is slower, owing to the 32-bit multiplication, but now able to return a double.

The code is obviously larger.

This commit updates the changelog and has cleared include test.

@jkotlinski
Copy link
Owner

Hi!
Just wanted to say, sorry I haven't had the time to review yet!
It's been a busy start of the year, and I haven't had much spare time or brain cycles.
I will get to it when I can give it the attention it deserves.

@burnsauce
Copy link
Contributor Author

Hi! Just wanted to say, sorry I haven't had the time to review yet! It's been a busy start of the year, and I haven't had much spare time or brain cycles. I will get to it when I can give it the attention it deserves.

No problem. I update the related issue with my new doubt about use of doubles for fixed point maths. The single-precision divisor of M*/ seems to be a severely limiting factor.

As fixed-point was going to be my primary use of doubles, I now doubt the utility of this patch.

I'll keep thinking about it and update this patch to my latest, but there's no imperative to merge this.

@jkotlinski
Copy link
Owner

OK, I will keep it open for further pondering.

@jkotlinski
Copy link
Owner

Did you think further about this topic? I have been undecided, if I think this functionality would be a valuable addition or not.

To get some bearings, I did a quick investigation on how other C64 Forths do. It seems double literals are near-universally supported, while M*/ is less common, but implemented by some high-quality Forths (e.g. Blazin` Forth).

Personally I do not care so much about either, as I prefer to do any serious number crunching on the PC, and then lift the results to C64.
But I think it would be fair to argue that double literals is something one could expect from a 16-bit Forth.
As such, I am open for this idea, if anyone wants it added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants