先决条件 – 语言处理器:汇编器、编译器和解释器
编译器:
编译器主要用于将源代码从高级编程语言翻译成机器级语言以创建可执行程序的程序。编译器会将整个程序视为一个完整的代码,然后进行翻译。编译器的主要工作是检查各种限制、范围、错误等。在编译器成功执行代码之前,必须从源代码中删除错误。编译语言的例子是 C、C++、 Java、C# 等。
汇编器:
汇编器将汇编代码作为输入并将其转换为可重定位的机器代码。汇编程序检查每条指令的正确性并生成诊断消息,如果
编译器和汇编器的区别:
Compiler | Assembler |
---|---|
Compiler converts the source code written by the programmer to a machine level language. | Assembler converts the assembly code into the machine code. |
Compiler input source code. | Assembler input assembly language code. |
It converts the whole code into machine language at a time. | But the Assembler can’t do this at once. |
A Compiler is more intelligent than an Assembler. | But, an Assembler is less intelligent than a Compiler. |
The compilation phases are lexical analyzer, syntax analyzer, semantic analyzer, intermediate code generated, a code optimizer, code generator, and error handler | Assembler makes two phases over the given input, first phase and the second phase. |
The output of compiler is a mnemonic version of machine code. | The output of assembler is binary code. |
C, C++, Java, and C# are examples of compiled languages. | GAS, GNU is an example of an assembler. |