Re: Compiler or interpreter? (Anton Ertl)
Tue, 15 Jun 2010 13:05:56 GMT

          From comp.compilers

Related articles
Compiler or interpreter? (glen herrmannsfeldt) (2010-06-13)
Re: Compiler or interpreter? (2010-06-15)
Re: Compiler or interpreter? (glen herrmannsfeldt) (2010-06-16)
Re: Compiler or interpreter? (glen herrmannsfeldt) (2010-06-17)
Re: Compiler or interpreter? (BGB / cr88192) (2010-06-18)
Re: Compiler or interpreter? (Paul Biggar) (2010-06-18)
Re: Compiler or interpreter? (Al Kossow) (2010-06-18)
Re: Compiler or interpreter? (glen herrmannsfeldt) (2010-06-18)
[3 later articles]
| List of all articles for this month |

From: (Anton Ertl)
Newsgroups: comp.compilers
Date: Tue, 15 Jun 2010 13:05:56 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
References: 10-06-032
Keywords: interpreter, design
Posted-Date: 17 Jun 2010 13:15:35 EDT

glen herrmannsfeldt <> writes:
>More specific to the above mentioned discussion, is that many of
>the early DEC systems used threaded code. Does threaded code
>count as compiler or interpreter?

As our esteemed moderator writes, this is a false dichotomy. A
compiler translates the source code to something else, and an
interpreter executes either source code (rarely) or (more frequently)
intermediate code. So any programming language implementation that
uses an intermediate code (e.g., threaded code) interpreter contains
both a compiler or an interpreter.

What you are probably thinking of when you write "true compiler" is a
native code compiler, which generates machine code for a real machine
(possibly indirectly through an assembler, linker, and loader).

The line I draw between interpreted intermediate code and native code
is this: If the CPU executes the code directly, it is native code,
otherwise it is interpreted code. Two tests for the difference are:

* If the program counter of the CPU points to the code during
execution, it is native code.

* If CPUs with memory protection require execute permission, not just
    read permission, to execute the code, it is native code.

In particular, "subroutine-threaded code", which consists mainly of a
sequence of native calls to routines of the run-time system, where
each routine returns to the caller, is a form of native code.

In contrast, direct-threaded code, where the program consists of a
sequence of addresses of run-time routines, and each run-time routine
ends by dispatching to the run-time routine specified by the next
address, is an interpreted intermediate code (although not necessarily
slower than subroutine-threaded code).

- anton
M. Anton Ertl

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.