[A83] Re: Compiled BASIC ?


[Prev][Next][Index][Thread]

[A83] Re: Compiled BASIC ?




On Thu, 16 Aug 2001, TypeR unknown wrote:

> I was just wondering, since the TI-OS converts every BASIC program to
> assembly in real-time, isn't it then possible to "pre-compile" a BASIC
> program to assembly and then sending that to the calc?
>
> This would mean that you can get the speed of a ASM program with the
> simplicity of a BASIC program, right?
>
> It probably sounds too good to be true or else it would already have
> happened, but I'm still wondering =)

There actually have been some efforts to "pre-compile" basic programs, but
none of the programs I have seen that claim to do this are even close to
being complete (though I may not have looked at every one ever released).

The first problem with this idea is that the calculator does not really
convert to assembly in real time at all, but rather only "interprets" it
in real time; that is, it analyzes each command to see what it does and
then runs the necessary pre-existing routines to perform each part of it.
I am sure there are others on this list much more qualified to give
details of the calculator's interpreter in particular, but this is the
general idea of an interpreter.

Of course, a compiler could be made that does these interpretation steps
in advance and actually outputs an assembly program.  No really complex
techniques are even needed to do this, though unless you're a really
skilled programmer you shouldn't expect to finish it the same day you
start.

More importantly, though, basic isn't slower just because it is
interpreted.  Among other things, basic programs use floating point
numbers, even though they are often not needed, which wastes time (even
when floating point is needed, the BCD format used by TI makes it less
efficient thn it could be).  They also have variables in the VAT which
have to be searched for.  Of course, a good compiler could mostly overcome
these problems, but that would take even more time to make.

Problems would still remain.  Simply outputting assembly code isn't the
same as outputting good assembly code, as you can see by looking at some
of the C compilers for the calculators which write code several times
larger than slower than what any decent assembly programmer could easily
do.  The problem would be even worse for TI-basic, since basic programs
are designed even more differently from assembly than a C program is.





Follow-Ups: References: