[A83] Re: Compiled BASIC ?


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

[A83] Re: Compiled BASIC ?




As you might have seen, I was one of the few wanna-be's who tried to make
such a precompiler/converter. Altough it seems fairly easy to create such a
program, many problems arise when thinking about structure in the BASIC
programs. If you take very optimized BASIC code, it's hard to compile it
into anything like the original.

Second problem you get is detecting when the program wants to write to the
graphscreen or the homescreen - this is causing much trouble because you
simply can't know all the time.

Thirdly, variables are a problem. In my unfinished demo, you could see that
the prog detects string and lists, but *you* must enter a maximal byte size
for these things. I also made al variables like A, B etc... integers with
one byte precision (0x00 to 0xFF). Also my program is able to extract all
string resources (you know what I mean - all strings used in the program)
and let you edit them (UPPERCASE BASIC to lowercase ASM).

If anyone would try to make another attempt for a compiler/converter, I
might be able to provide some support, but hey - I'm not going to try it
again because I'm done with TI-BASIC and have many other things to do right
now ;)

And if you're starting such a converter/compiler, keep in mind the following
code in TI-BASIC :) (for the sake of the example, I haven't optimized this).

:Menu("START",S,"LOAD",L,"QUIT",Q)
:Lbl S
:prgmSTARTME
:Stop
:Lbl L
:prgmLOADVARS
:13/->/L1(Y)
:L1(X)/->/A[23,4]
:ClrHome
:ClrDraw
:Disp "LOADED"
:Lbl Q

That's it. Have fun with that.

Yours sincerely,
Frank Schoep



----- Original Message -----
From: "Patrick Davidson" <pad@OCF.Berkeley.EDU>
To: <assembly-83@lists.ticalc.org>
Sent: Thursday, August 16, 2001 7:21 PM
Subject: [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: