先决条件–语言处理器:汇编器,编译器和解释器
编译器:
编译器主要用于将源代码从高级编程语言转换为机器级语言以创建可执行程序的程序。编译器会将整个程序视为一个完整的代码,然后进行翻译。编译器的主要工作是检查各种限制,范围,错误等。在编译器可以成功执行代码之前,必须从源代码中删除错误。编译语言的示例是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. |