Assembly 汇编程序-数组故障

Assembly 汇编程序-数组故障,assembly,integer,cpu-registers,dword,Assembly,Integer,Cpu Registers,Dword,我对负责将一个数组复制到其他整数数组的汇编程序中的代码有一些问题 这就是我在c++中创建数组的方式: int *myArray=new int[myFunctions::getCounter()]; int *newArray; int *newArray = new int[counter+1]; // I have some information in [0] 这就是我如何声明汇编函数的 extern int copy(myArray[], int *newArray, int how

我对负责将一个数组复制到其他整数数组的汇编程序中的代码有一些问题

这就是我在c++中创建数组的方式:

int *myArray=new int[myFunctions::getCounter()];
int *newArray;
int *newArray = new int[counter+1]; // I have some information in [0]
这就是我如何声明汇编函数的

extern int  copy(myArray[], int *newArray, int howManyElements, int howManyProcesses, int indexOfProcess);
关于流程:这是项目的一部分。循环中的过程是这样工作的:

在这个例子中,我们在数组中有3个进程和10个元素

第一个进程复制到新数组元素中:[1][4][7][10] 第2[2][5][8]3[3][6][9]

C++中的P>:

for (int i=indexOfProcess; i<=howManyElements; i+=howManyProcess){

        newArray[i]  = myArray[i];

    }

我想你至少有两个问题。第一,你不是整数大小的缩放。您必须将指针的数量增加4倍。另一个问题是您试图使用eax for循环计数器,但同时您也将其用作副本的临时计数器,因此您会覆盖计数器

mov ecx, indexOfProcess          
mov ebx, myArray       
mov edx, newArray   
mov adressOfTab, edx

lea ebx, [ebx+ecx*4]       ; scale by 4 for int size
lea edx, [edx+ecx*4]       ; scale by 4 for int size

loop:
mov eax, [ebx]
mov [edx], eax
mov eax, ahowManyProcesses ; the increment in items
lea ebx, [ebx+eax*4]       ; scale by 4 for int size
lea edx, [edx+eax*4]       ; scale by 4 for int size
add ecx, eax               ; do not scale, it is a counter

cmp ecx, ahowManyElements 
jbe loop
附言:你应该学会使用调试器,这样你就可以修正自己的错误