I have changed my mind a little bit after studying some Squeak sources.
Now I plan to implement LargeInteger primitives (20-39) _without_ changing the representation of LargeIntegers by extending the Interpreter arithmetic primitives using the CCodeGenerator. This avoids some problems dealing with different platforms.
In a later step changing the representation to bigger 'digits' (16,32,.. bits?) _could_ be interesting.
Perhaps 16 bits, but unlikely 32. How, for example, would you handle integer overflow when doing, say, the LargeInteger add? And how could you do the multiply without bit munging? Is it possible that a straight loop with carry would be much faster than all the masking and shifting necessary to do a carry written in C?
Well, since we're talking hackery here, Squeak's long Floats can probably help a lot. Yeh jes' load 'em into da mantissa an' press 'start' (hey, it's Friday night ;-).
That should work for the adding of the 32 bitters. How would you do a multiply?
Well, since we're talking hackery here, Squeak's long Floats can probably help a lot. Yeh jes' load 'em into da mantissa an' press 'start' (hey, it's Friday night ;-).
That should work for the adding of the 32 bitters. How would you do a multiply?
You don't use 32 bits (since Squeak's ints are only 30 bits + sign anyway. You make the choice of how many bits per int on how many the mult will handle. Probably around 25. There are some clever things you can do like adding a certain constant that forces everything to stay in alignment.
-D
squeak-dev@lists.squeakfoundation.org