Re: BASIC > ASM


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

Re: BASIC > ASM



Tom Lake wrote:
>
> >> True but the Basic interpreter has to interpret each line as it's
> executed.
> >> If you have a loop that's executed 5000 times, the interpreter has to do
> >> 5000 translations of each line in the loop.  A compiler translates the
> >> program once and from then on, you run the machine language directly
> rather
> >> than having it interpreted each time you run it.
> >
> >False.
> >
>
> Not false at all.  A true interpreter works the way I described.  Even if it
> tokenizes the program only once, it still has to interpret (NOT parse!) each
> line of code once for each time in the loop.

I agree, but that's not what you said... 'Good' interpreters translate the
code only once and not

> the interpreter has to do 5000 translations of each line in the loop

as you said. But of course, once translated, the intepreter still has to
'execute' token for each loop exactly as the processor does for a compiled
program. The difference comes from the king of words to execute: tokens or
machine language words. Of course the first case takes more time but this
not the main reason of the bad speed of the TI Basic.

Our misfit comes maybe from the word "translation". I used the word "parse"
because this is the first step of the translation (and the only one if you
don't have the optimization step). Interpretation comes later, when
executed.

To be more precise, we can split the steps as follow:

1) Parse the program
   1) Lexical analysis
   2) Syntactic analysis
   3) Semantic analysis (of the program!)
   4) translate to useful meta representation
2) Optimize the program (easier on meta representation than tokens !)
3) Write the tokens or machine code to file

4) Execute the program (compiler)
   1) execute each machine code
4) Interprete the program (interpreter)
   1) Check semantic (of variables !)
   2) Call internals associated with tokens (may include 4.1)

Step 1) to 3) are "translation" and done once.
Step 4) is done for each loop whatever it is compiled or interpreted

Hope this help :-)

--
[ Deniau Laurent -- Data Analysis and Signal Processing ]
[ CERN -- The European Laboratory for Particle Physics  ]
[ Laurent.Deniau@cern.ch - http://home.cern.ch/~ldeniau ]
[   -- One becomes old when dreams become regrets --    ]

******************************************************************
* To UNSUBSCRIBE, send an email TO: listserv@lists.ppp.ti.com
* with a message (not the subject) that reads SIGNOFF CALC-TI
*
* Archives at http://peach.ease.lsoft.com/archives/calc-ti.html
******************************************************************


References: