Chapter 9 Assembly Languages

字数 286阅读 20

Characteristics Of A High-level Programming Language

  • One-to-many translation
    Each statement in a high-level language corresponds to multiple machine instructions.

  • Hardware independence

  • Application orientation

  • General-purpose

  • Powerful abstractions

Characteristics Of A Low-level Programming Language

  • One-to-one translation
  • Hardware dependence
  • Systems programming orientation
  • Special-purpose
  • Few abstractions

Assembly languages

It is important to understand that the phrase assembly language differs from phrases such as Java language or C language because assembly does not refer to a single language.

Programming paradigm

Experienced programmers understand that consistency and clarity are usually more important than clever tricks or optimizations. Thus, experienced programmers develop idioms: patterns that they use consistently.

Assembler

Although both a compiler and an assembler translate a source program into equivalent binary code, a compiler has more freedom to choose which values are kept in registers, the instructions used to implement each statement, and the allocation of variables to memory. An assembler merely provides a one-to-one translation of each statement in the source program to the equivalent binary form.

Conceptually, an assembler makes two passes over the source program: one to assign addresses and one to generate code.

Paste_Image.png

Question
Both a compiler and an assembler translate a source program into equivalent binary code.
However, according to the Figure 4.6, the compiler translates the source code into assembly code. What is going on here?

Macros

A macro expansion facility preprocesses an assembly language source program to produce another source program in which each macro invocation is replaced by the text of the macro. Because a macro processor uses textual substitution, incorrect arguments are not detected by the macro processor; errors are only detected by the assembler after the macro processor completes.

推荐阅读更多精彩内容