[Slackers] Slang v1.4 released
Magnus Lind
magli143 at gmail.com
Mon Jul 3 12:38:33 CDT 2006
Steve Judd wrote:
>> Finally, how about that big endian stored int type (16 bit signed, for
>> BASIC interoperability)? Would it be much work? Is it something that I
>> can do myself by modifying slangdef/userdef or is the type stuff
>> embedded deeper in the language core?
>
> To do this, you'd need to modify slangdef. First, a new type would need
> to be added, e.g. "basint". That's easy.
like this?
----------------
type basint
len 2
fixed
signed
----------------
This means that the slang core would see this type exactly like an int,
right?
>
> The hard part is that you'd need to rewrite all of the operators, if you
> were going to use these in an expression. Remember that any expression
> has ARGL, ARGR, and DEST: "ARGL + ARGR -> DEST". So you'd have to be able
> to handle all combinations (e.g. int + basint -> basint).
> Probably the easiest way would be to first convert this basint type to a
> regular int, then operate, then convert to the dest type. But at that
> point I'd ask myself, why not just perform conversion at the point of
> calling basic functions?
Ah, you mean that I could extend the operators to take basints into
consideration by transforming them into normal ints, then operate and
then transform back.
>
> So yup, big-endian ints could be added, but it would be quite a lot of
> work, and I believe it would be far simpler (and generate better code) to
> simply add type conversion to the call to the basic routine (before or
> after the call, as needed).
I agree, doing the conversion deeper in the code generator will be more
complex and obscure.
However, equal code generation quality compared to ints is possible. But
then big endian ints would have to be supported by the internal type
system of the slang core. Possibly by a type declaration endian modifier
like 'fixedbig' or something similar. And this seems to be a far from
trivial task :)
>
> The 6502 really likes little-endian; the big-endian basic int is just a
> byproduct of the floating-point storage format. After all, BASIC itself
> doesn't even operate on those ints -- it either convers them to floats
> (for arithmetic) or converts them to little-endian (for pointers).
Yes, I know, the only time when integers are preferable to floats are
when using arrays since they take less space.
> Did you have a specific application in mind, btw?
Well, not really, I did imagine some basic extension that modifies
integer arrays. It would have been a little quicker than manual endian
conversion since I thought that using a basint type wouldn't need ANY
conversion at all. Now I know better :)
Ok, just one for the road..
I seem to have found another bug. The following code will loop forever.
------------------------------------
ubyte i
for i=0:255
endfor
------------------------------------
However, its very easy to work around by using another flow control
construct.
/Regards
Magnus Lind
More information about the Slackers
mailing list