5

Moving data in assembly language:

MOV B, A

If I move content from internal register A to register B, what happens to content of register A? Is it deleted? Stays unchanged?

Lucenzo97
  • 293

2 Answers2

2

The MOV command will leave the contents of register A alone. From some x86 documentation (emphasis added):

The mov instruction copies the data item referred to by its second operand (i.e. register contents, memory contents, or a constant value) into the location referred to by its first operand (i.e. a register or memory).

http://www.cs.virginia.edu/~evans/cs216/guides/x86.html

There are many other assembly languages, but you can count on most modern languages working the same way.

riwalk
  • 7,690
1

The answer depends heavily on the CPU and assembly language you're targeting:

The source is left unchanged for a move.

Out of curiosity, and nostalgy, a couple of older CPUs used other covnetions as well:

  • the good old PDP11 (ok there is little risk that you'll target this nowadays) had the move in the other direction: MOV source, target
  • the still old family of Motorala 68K had a MOVE source, target
  • the PowerPC had no MOV, but uses several variants of loads and stores, the first using targe, source, and the second source, target. It also had several variants of move but called differently keepng from the naming convention only the first letter.
Christophe
  • 81,699