是什么让 x = 2 机器独立于 MOV X , 2?
What makes x = 2 machine independent vs MOV X , 2?
来自编译器构建 (Louden):
Assembly language is extremely dependent on the particular machine for which it was written, so code written for one computer must be completely rewritten for another machine. Clearly, the next major step in programming technology was to write the operations of a program in a concise form more nearly resembling mathematical notation or natural language, in a way that was independent of any one particular machine and yet capable of itself being translated by a program into executable code. For example, the assembly code MOV X, 2
can be written in a concise, machine-independent form as x = 2
我不明白——我想我没有理解他的意思。如果现代编程语言使用 MOV X, 2
而不是 x = 2
,这将如何降低它们的机器独立性?编译器仍然必须将任一语句转换为等效的机器代码,不是吗?
示例 MOV X, 2
假设 MOV 是硬连线的 CPU 指令。它将 2 加载到寄存器 X 中。
你是对的,解析器可以将 MOV X, 2
翻译成任何其他语言。事实上,汇编程序确实将其解析并翻译成机器语言,这只是0和1.
的流
另一方面,x=2
不像机器指令。它是高级语言中的典型语法。
来自编译器构建 (Louden):
Assembly language is extremely dependent on the particular machine for which it was written, so code written for one computer must be completely rewritten for another machine. Clearly, the next major step in programming technology was to write the operations of a program in a concise form more nearly resembling mathematical notation or natural language, in a way that was independent of any one particular machine and yet capable of itself being translated by a program into executable code. For example, the assembly code
MOV X, 2
can be written in a concise, machine-independent form asx = 2
我不明白——我想我没有理解他的意思。如果现代编程语言使用 MOV X, 2
而不是 x = 2
,这将如何降低它们的机器独立性?编译器仍然必须将任一语句转换为等效的机器代码,不是吗?
示例 MOV X, 2
假设 MOV 是硬连线的 CPU 指令。它将 2 加载到寄存器 X 中。
你是对的,解析器可以将 MOV X, 2
翻译成任何其他语言。事实上,汇编程序确实将其解析并翻译成机器语言,这只是0和1.
x=2
不像机器指令。它是高级语言中的典型语法。