问题描述
为什么我们不能将数据直接从一个存储位置移动到另一个存储位置.
如果我问一个愚蠢的问题,请原谅我,但我认为这是真实的情况,至少对于我遇到的情况而言(8085,8086 n 80386)
我并不是真正在寻找一种解决方案来移动数据(例如,使用movs n all),但实际上是导致这种异常的原因.
大多数CPU品种不允许内存到内存的移动.通常,CPU一次只能访问一个存储位置,这意味着在移动值时需要一个临时位置来存储值(通常是通用寄存器).如果您考虑一下,直接从一个内存位置移动到另一个内存位置将要求CPU能够同时访问RAM中的两个不同位置-这意味着至少两个完整的内存控制器,即使那样,它们也会发挥作用"好",足以访问相同的RAM将会非常糟糕.芯片设计人员可能已经能够采取一些技巧,以允许从一个RAM芯片直接复制到另一个RAM芯片,但这将是一种非常特殊的应用程序功能,只会增加成本和复杂度来解决一个非常罕见的问题. >
至少从CPU的角度来看,您也许可以使用某些特殊的DMA硬件使程序看起来像在没有临时存储的情况下移动内存一样.
Why can't we move data directly from a memory location into another memory location.
Pardon me if I am asking a dumb question, but I think this is a true situation, at least for the ones I've encountered (8085,8086 n 80386)
I am not really looking for a solution for moving the data (like for eg, using movs n all), but actually the reason for this anomaly.
Most CPU varieties don't allow memory-to-memory moves. Normally the CPU can access only one memory location at at time, which means you need a temporary spot to store the value when moving it (a general purpose register, usually). If you think about it, moving directly from one memory location to another would require that the CPU be able to access two different spots in RAM simultaneously - that means two full memory controllers at least, and even then, the chances they'd "play nice" enough to access the same RAM would be pretty bad. The chip designers might have been able to pull some tricks to allow direct copies from one RAM chip to another, but that would be a pretty special-application kind of feature that would just add cost and complexity to solve a very uncommon problem.
You might be able to use some special DMA hardware to make it look to your program like memory is being moved without that temporary storage, at least from the perspective of your CPU.
这篇关于在微控制器中将数据从内存移动到内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!