php - 机器码和操作码有什么区别?

标签 php assembly opcode machine-code vm-implementation

这个问题主要与 PHP 有关,因为恕我直言,操作码主要在 PHP 上下文中提及。根据这个description ,下面是一个php代码到opcode的转换过程:

php 文本 -> 扫描/解析 -> 结果 = 标记 -> 编译 > 结果 = 操作码

这里有几个问题:

1)操作码只是机器码的一部分吗,机器码是由操作码组成的吗? 2)在Wamp服务器的上下文中思考,PHP模块负责什么?该模块只是将 PHP 代码转换为 token 的 PHP 解释器,还是将 token 编译为在硬件(处理器)上执行的操作码的编译器?

最佳答案

The question is mostly related to PHP because IMHO opcode is mostly mentioned in PHP context.

事实上,Java 因其字节码/操作码而更受欢迎

1) Is opcode just a portion of machine code, does machine code consist of opcodes?

是的,但是这个操作码是机器相关的。 Java 或 PHP 字节码的有趣之处在于它与机器无关,并在特定于平台的虚拟机中运行。

2) Thinking in the context of Wamp server, what PHP module is responsible for?

没有模块,它是核心的一部分。

Lexer => Tokenizer => Compiler

Is that module just PHP interpreter who transforms PHP code into tokens or is it also a compiler who compiles tokens into opcode that is executed on the hardware (processor)?

不完全是。生成的字节码与机器无关(名为“Zend-opcode”),不能直接在硬件上运行。最后一步是将此字节码转换为机器相关的操作码。

关于php - 机器码和操作码有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11028702/

相关文章:

php - 在自定义 Symfony 命令中使用 Doctrine?

assembly - intVal3 TBYTE 1234 -- 汇编器没有注意到无效的 TBYTE 变量声明

C++/ASM : Passing by value uses xmm0, 但通过引用它使用 rdi

assembly - 为什么即使包含 JUMPDEST 也无法跳转到指令?

assembly - PowerPC 操作码表?

c++ - 理解CHIP8仿真器中的一段代码

php - mysqli_fetch_assoc()需要参数/调用成员函数bind_param()错误。如何获取并修复实际的mysql错误?

php - 仅当php中没有 "%"登录时如何显示表单元素

php - 如何使事件永久保留在全日历中

assembly - INT 16h/AH=0h 不等待引导加载程序中的按键