为什么一条指令在汇编中不能包含两个内存引用? [英] Why can't one instruction include two memory references in assembly?

查看:199
本文介绍了为什么一条指令在汇编中不能包含两个内存引用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是汇编语言的初学者.我了解到以下指令无效,因为它不能同时将源和目标都作为内存引用.我想知道原因.

I'm a beginner in assembly language. I have learned that the below instruction is invalid because it cannot have both source and destination be memory references. I want to know the reason.

movl (%eax) (%ebx)  

推荐答案

指令集要求设计位模式以对指令进行编码.每个可能的指令都可能具有位模式,但是处理器构造起来并不实用.因此,处理器设计人员限制了指令的种类(因此常常限制了样式),以使处理器的构造更加容易.

Instruction sets require that bit patterns be designed to encode the instructions. One could have bit patterns for every conceivable instruction, but then the processor would not be practical to construct. So processor designers limit the variety (and consequently often the style) of instructions to make processor construction easier.

处理器设计中的一个共同主题是指令在 one 寄存器和 one 存储器位置上进行操作.两个操作数表示此样式可以完成将存储器加载到寄存器,将寄存器存储到存储器以及各种常见的二进制操作,例如将存储器添加到寄存器,将寄存器比较到存储器等.该主题在实践中非常有效,几乎不需要用于在多个内存位置上运行的指令,其规律性使CPU的中央"处理部分更易于实现.您提到的运动"指令符合此主题,因此,只有一个内存操作数.

A common theme in processor design is that instructions operate on one register and one memory location. Two operands means this style can do load memory to register, store register to memory, and a variety of common binary operations such as add memory to register, compare register to memory, etc. This theme works so well in practice that there is little need for instructions that work on multiple memory locations, and its regularity makes the "central" processing part of the CPU easier to implement. The "movl" instruction you mention fits this theme, thus, only one memory operand.

真正的答案是拥有这样一条指令的回报并不能证明工程的合理性.

So the real answer is that the payoff for having such an instruction doesn't justify the engineering.

大多数处理器设计已经存在20多年了,现在晶体管相对便宜.结果,几乎所有这些机器的指令集都变得更加复杂,通常包括引用多个内存操作数的 some 指令.但是这些说明是例外,不是规则.

Most processor designs have now been around for 20+ years, and now transistors are relatively cheap. As a consequence, the instruction sets for virtually all these machines has gotten more complex, often including some instructions that refer to multiple memory operands. But these instructions are the exception, not the rule.

这篇关于为什么一条指令在汇编中不能包含两个内存引用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆