drogon wrote:
Chromatix wrote:
It would be possible to make the multiplication result and dividend input used internally within a single expression into 32-bit quantities, without requiring syntax changes. Essentially this would involve recognising that the operand comes from the existing accumulator, and thus doesn't need to be moved and sign-extended. This isn't a common BASIC feature though.
BASICs have built-in functions - like RND(x) and so on, so creating a MULDIV (x,y,z) is just a matter of writing the code...
I don't think it's needed for a proof of concept 16bit Mandelbrot though, but I'll need to go through, my BCPL version to work out the maximum magnitude. It does a lot of x*x / 4096 in the inner loop, but I don't know just how big x gets...
Generally the loop termination threshold is set at mag(z) >= 2.0. Which means that you could have an iteration which gets to 1.999, does not terminate there, and proceeds to square again, resulting in a magnitude near 4.0. You could also then have the sum pushing in the same direction, for 6.0.
A division by 4096 implies a 12-bit fractional part, and thus that the intermediate result has 24 bits of fraction. You would need a 32-bit integer to hold that.
While BASICs usually do have internal functions, bootBasic does not, and I assume it would take at least a little bit of extra code to implement the syntax handling necessary for it. Additionally, things like CHR$() presuppose the existence of string-type variables. That's why I've gone for a VDU statement rather than PRINT CHR$(). It would probably be easier for me to just perform all intermediate calculations in a wider size than variables are stored, as that doesn't add any real complications.