P
P
PrayHero2021-04-26 03:33:00
assembler
PrayHero, 2021-04-26 03:33:00

Marketing moves around assembly language?

Why do books on high-level languages ​​accuse assembly language of being unportable? After all, experienced programmers fit into the 8086 instruction set. Like C programs, Assembler programs need to be recompiled for each new platform. Is not it so? Why then are assembler programs not portable? Explain, please, intelligibly.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
G
galaxy, 2021-04-26
@PrayHero

After all, experienced programmers fit into the 8086 instruction set
No. For 30 years, no one has been trying to meet 8086. On the contrary, if they undertake to write in assembler, then often with the aim of using some iron-dependent things.
Like C programs, assembler programs need to be recompiled for each new platform. Is not it so?
What do you mean by "new platform"?
Other OS? - yes, you need to rebuild and change it often, because the API of different operating systems is different. At the same time, C often allows the source code of the program not to be touched, because standard library functions, POSIX APIs provide a platform-independent interface. But in the asm program, the corresponding code will have to be rewritten.
New OS version? - there are some nuances here, but a statically compiled program usually works fine for many generations of the OS (you don’t download a new version, for example, of a game for each version of Windows? Take diablo 2 out - how it worked under Win 98 is just as great the binary will start in Win 10).
New processor? These are generally pathologically backwards compatible. Code written or compiled purely for a 30-year-old 386 will run on i9 (as long as it's compatible with the points above).
Returning to the original question, you don't seem to understand or care that there are more than just x86 processors. Initially, high-level PLs were developed precisely with the aim of abstracting the program code from a specific hardware. In the 60-80s there was no single and even one common iron platform, what would you order, for example, to rewrite the standard Unix utilities from beginning to end in a new (I emphasize, NEW, different) assembler?
Even now, when x86 seems to be around, there is Itanium (well, ok, it was in the recent past), ARM (in the form of several architecture versions and a huge number of iron incarnations), SPARC and PowerISA are glimmering somewhere. Finally, microcontrollers (hello arduino).
In short: high-level PLs (not only C) are allowed to abstract (up to certain limits) from hardware and from the OS and not change the source code of programs when ported to another platform, limited to a mechanical recompilation procedure.

I
Ivan Shumov, 2021-04-26
@inoise

You can immediately see a person who has neither read Tanenbaum, nor even opened Wikipedia. Assembler is not a language, it is a translator of instructions into machine code. Assemblers exactly the same number of hardware architectures. Instructions for one processor will not be in another processor and they are not interchangeable. This is the lowest level where there are no abstractions (I'm exaggerating a little, but in relation to other languages ​​this is true)

S
Saboteur, 2021-04-26
@saboteur_kiev

Because the C program can be simply rebuilt.
And rewrite the program in assembler.

C
CityCat4, 2021-04-26
@CityCat4

Why then are assembler programs not portable?

Because a program written in Assembler for IBM/360 will never work on IBM PC :) despite the fact that initially they were made by one company :)
In 1990 - 1995 I did a lot of programming on IBM/360, on PL/1 and assembler (and there was no other there), wrote gigantic programs, had hundreds of macros in stock.
After I switched to i8086 - most of this knowledge went to the trash, only a general understanding of how the processor works :)
Assembler is the lowest of the available development levels, only misson-critical sections are written on it now, because it is really machine-dependent - on another family of processors, even the same architecture may no longer work, on another architecture it will not work for sure.

V
VitalyChaikin, 2021-04-26
@VitalyChaikin

If it is intelligible, then this is the difference between a high-level language and a low-level one;
High-level -> Compiler to low-level language on a given architecture -> executable code
Low-level language on a given architecture -> executable code
It is easy to see that Assembler (aka Low-level language on a given architecture) already includes a given architecture, and therefore cannot be ported to another architecture;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question