A
A
Aleviy2021-11-06 00:16:46
Computers
Aleviy, 2021-11-06 00:16:46

Multilevel computer organization. Is the written code interpreted/translated until it reaches machine code?

Read Tanenbaum "Computer Architecture". It is written that the computer consists of "levels".

The invention of a whole series of languages, each more human-friendly
than the last, may continue until we arrive at
a language that suits us. Each such language uses its predecessor
as a basis, so we can think of the computer as a series of layers,
shown in Fig. 1.1. The language at the very bottom of the hierarchical
structure is the most primitive, and the language at the top is the most
complex.


So, I can't understand one thing. Let's say I'm writing code in a top-level language. Will it be translated to a lower level each time until it reaches the lowest level and, accordingly, the language of the lowest level. After all, it was written in the book that a computer executes a command only in machine code, which is the language of the lowest level.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Aetae, 2021-11-06
@Aetae

Well kakbe languages ​​are divided into interpreted and compiled.
The latter are immediately compiled into (almost) machine code and stored in this form. There "transmission" is minimal.
The first in its most primitive form, yes - it is "broadcast" every time to the very bottom. But the modern interpreters of most of these languages ​​are rather fat monsters that "prepare" a lot of things and use a lot of brain-bending tricks to speed up.
Well, if we talk about "chains of languages" - of course, there is (almost) no such thing.
A maximum of one intermediate level is added for cross-platform, e.g. in the same Java.

H
hint000, 2021-11-06
@hint000

When I was a student, we had a course on "translation methods". As a practical part, a subset of a high-level language (C or Pascal) was taken and translated into assembly language.
"Combat" translators may also use assembly language as the only intermediate language, or they may not use anything intermediate.
Also quoting from Wikipedia:

Interpreted languages ​​that use bytecode include Perl, PHP (such as Zend Engine), Ruby (since version 1.9), Python, Erlang, and many others.
Common platforms using bytecode[9]:
Java bytecode (stack virtual machine) executed by various Java virtual machines[10][11]. The platform was created by Sun for the Java language, but has been used for other languages ​​as well; there are dozens of high performance JVM implementations using JIT compilers.
There are options for translating Java into register machine bytecode, for example, in the Dalvik virtual machine (with JIT compilation) or when AOT compilation in ART
The Microsoft .NET platform uses the Intermediate Language (CIL, MSIL)[8] bytecode stack, which is executed by the Common Language Runtime (CLR), created by Microsoft for C# and several other languages.
The JavaScript scripting language is executed by various high-performance "engines", mostly built into web browsers, often with JIT optimization capabilities. Many interpreters are built using bytecode, but Javascript programs are distributed as source codes.
The ActionScript scripting language is translated into stack bytecode, distributed as swf and pdf files, and executed by virtual machines in Adobe Flash and Adobe Acrobat.
The Clipper compiler creates an executable file that includes the bytecode translated from the program's source code and a virtual machine that executes this bytecode.
Java programs are usually compiled into class files containing Java bytecode. These generic files are transferred to various target machines.
Early implementations of Visual Basic (before version 6) used high-level Microsoft p-code[9]
High-level p-codes and byte codes were used in DBMS, some implementations of BASIC and Pascal.
In Sun Microsystems' Open Firmware standard, the bytecode represents Forth operators.
from here: https://ru.wikipedia.org/wiki/Bytecode
As you can see, one intermediate level is not that rare. But more than one is not practical.
Here we are not talking about microprogram translation inside the processor, this is not available to mere mortals.

G
Griboks, 2021-11-06
@Griboks

It depends on the specific implementation of a particular language on a particular device. The code can either be translated into another code at any level of the language (including machine code or microcode), or immediately executed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question