“移动"“汇编语言"是复制还是移动? [英] "mov" of "assembly language" meant copy or move?

查看:81
本文介绍了“移动"“汇编语言"是复制还是移动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近看了std::mov的C++,想到了一个题目.

Recently, I read the C++ of std::mov, and I thought of a question as the title.

假设初始值如下:

int a= 1;
int b= 2;

我认为:

情况一,

移动后(a <- b):

a= 2 , b=  

b 为空,因为移动了

情况 2,

复制后(a <- b):

a=2  , b=2 

我知道 C++ 的 std::move 是情况 1

I know std::move of C++ is Situation 1

汇编语言mov(mov %b %a)是什么情况?

这是我的问题.

推荐答案

在我使用过的每个架构中,MOV 都会复制值,并保持源代码不变.这有一个非常简单的推理.组装是人们工作的基础层",需要是最小的组成部分.因此,每条指令都尽可能少地完成工作.这样一来,出现意外行为的可能性就会降低,并且可能有更精确的组合.

In every architecture I've worked with, a MOV copies the value, and leaves the source untouched. There's a very simple reasoning for this. Assembly is the "base-level" of what people work with, and needs to be the smallest constituent parts. Therefor, each instruction does as little as it needs to do to get the job done. That way, there's less of a chance of unintended behavior and there are more precise combinations possible.

这篇关于“移动"“汇编语言"是复制还是移动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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