【发布时间】:2019-09-13 13:18:13
【问题描述】:
Recently, I read the C++ of std::mov, and I thought of a question as the title.
Assume initial value following:
int a= 1;
int b= 2;
I think:
Situation 1,
after move (a <- b):
a= 2 , b=
b is null because moved
Situation 2,
after copy (a <- b):
a=2 , b=2
I know std::move of C++ isSituation 1
Which Situation is mov ( mov %b %a ) ofAssembly lang.?
This is my question.
【问题讨论】:
-
it does a copy...
-
Hi @Wagner Patriota: Thanks your reply. I know this question too stupid.... I am not familiar with assembly. So, answer isSituation 2?
-
@curlywei yes, a
movin assembly is a copy, not a move. And your C++ reference is not a very good one, becausestd::move()is just a typecast and does not actually move anything. Usingstd::move()in the assignment of POD types, likeint, is also a copy, not a move. -
there are countless different assembly languages, different processors different syntax per processor depending on the tools vendors, etc. but a move is a copy, in general the source is not destroyed, read the value in this register or memory location and write that value to this (other) register or memory location, which is a "copy" of something in english because the source is not destroyed. If there such a processor where the source is destroyed it is usually a different instruction or it is a special function of a peripheral/memory and not related to the instruction set.
-
Mostprocessor assembly languages have only one destination and one or more sources.