In: Computer Science
Please write in x86 Assembly language on Visual Studio. IRVINE32
Write a program to copy one array of size 24 to another array of size 24 using string instructions. Write 3 versions of this code. One code must copy byte at a time. One code must copy word at a time and one code must copy double word at a time. Cut and paste the array in memory to show your code is working.
For the following solution, I have assumed that the data is stored as in SRC which is the source , array DEST which is the destination array.
1) For the first version, where we need to copy one byte at a time, we use lodsb command whidch loads the memory byte addressed in the destination register, relative to the ES segment register, into the AL register.
CODE:
Lea si, SRC
lea di, DESI
Mov cx,24
X1:lodsb
Stosb
Loop x1
2) For the first version, where we need to copy one byte at a time, we use lodsw command which loads the memory word addressed in the destination register, relative to the ES segment register, into the AX register.
CODE:
Lea si,SRC
Lea di,DEST
Mov cx ,12
X1:lodsw
Stosw
Loopx1
3) For the first version, where we need to copy one byte at a time, we use lodsl which loads the memory double-word addressed in the destination register, relative to the ES segment register, into the EAX register.
CODE:
Lea si,SRC
Lea di, DEST
Mox cx,6
X1:lodsl
Stosl
Loopx1