Re: BASIC > ASM


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

Re: BASIC > ASM



Tom Lake wrote:
>
> >Everything that actually runs on the computer is machine language.  Basic
> is
> >running in machine language.  Machine language instructions have a 1 to 1
> >correspondance with ASM.  They're essentially the same thing.
> >
> >So the program that translates Basic to ASM is the basic interpretter.

False.

> 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.

A compiler will translate the program in machine language once, you're
right. But the interpreter translate the basic into a semi-compiled stated
(ready to be interpreted) where each language word are replace by a token
(i.e. 'ClrHome' is 7 letters but 1 token). This is done once when you start
the program for the first time after the last edition (check the size of
the program before and after the first start). The semi-compiled state
avoids to parse the program each time. Then the steps are:

1) write or edit the basic program
2) run it
   2.1) interpreter translate it to token (different from asm)
   2.2) interpreter read the list of tokens and execute the corresponding
machine language functions in the ROM.
3) run it again
   3.1) same as 2.2

Why the basic is so slow (despite it has a low consumption 68000 at 10Mhz
!):
1) takes some time to read a token and then call the corresponding ROM
entry point. interpreting the semi-compiled program is not so easy that
just reading tokens one after the other. Some tokens will need parameters,
etc...

2) the basic works only with dynamic size integers (implies very slow
loops). almost all basic operations call a complex machine language
function. That's why an empty 'For' loop counts up to 6000 in 1 minute
instead of 10000000 for a machine language loop !

3) all variables are pointers and operation on them use indirection (slower
than register access), but the advantage is you don't need to specify their
type.

4) most of the basic function are not oriented on fast numerical
application but on slow formal application (main difference between a
calculator='slow but powerful' and a computer='fast but stupid').

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
******************************************************************


Follow-Ups: References: