码迷,mamicode.com
首页 > 其他好文 > 详细

为什么X86汇编中的mov指令不支持内存到内存的寻址?

时间:2014-05-25 14:50:06      阅读:248      评论:0      收藏:0      [点我收藏+]

标签:c   code   ext   a   int   com   

在X86汇编中,MOV [0012H], [0016H]这种指令是不允许的,至少得有一个操作数是寄存器。当然,这种问题在用高级语言的时候看不到,感觉好像基本上都是从内存到内存啊,为毛到了汇编就不行了???这个问题在stack overflow有个解释不错:

 

The answer involves a fuller understanding of RAM. Simply stated, RAM can only be in two states, read mode or write mode. If you wish to copy one byte in ram to another location, you must have a temporary storage area outside of RAM as you switch from read to write.

It is certainly possible for the architecture to have such a RAM to RAM instruction, but it would be a high level instruction that in microcode would translate to copying of data from RAM to a register then back to RAM. Alternatively, it could be possible to extend the RAM controller to have such a temporary registerjust for this copying of data, but it wouldnt provide much of a benefit for the added complexity of CPU/Hardware interaction.

 

CPU对内存,要么读,要么写,这样一来,这种设计就非常合理了。如果想让CPU像访问寄存器那样访问内存,那CPU的频率就要被内存拖垮了……

为什么X86汇编中的mov指令不支持内存到内存的寻址?,布布扣,bubuko.com

为什么X86汇编中的mov指令不支持内存到内存的寻址?

标签:c   code   ext   a   int   com   

原文地址:http://www.cnblogs.com/wangchengfeng/p/3750961.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!