Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Copy a Value - x86 NASM Assembly

I am trying to figure out how to copy a value I am holding in a register for use immediately, and for use later in the program. I will be looping through code, and this value will need to be copied to another register for pushing it onto the stack, and then removal, copying, and repeating.

I know that the mov instruction moves a value into another register, but does the register from which the value is moved from able to retain the value?

For example:

mov eax, ebx

This would move ebx's value into eax, but would ebx still hold a value?

Any instruction that could help me do this is greatly appreciated.

like image 700
nmagerko Avatar asked Nov 05 '11 01:11

nmagerko


1 Answers

would ebx still hold a value?

Yes -- mov is really a copy, so the source retains its original value.

like image 178
Daniel Lubarov Avatar answered Oct 29 '22 13:10

Daniel Lubarov