简体   繁体   English

如何在x86程序集中增加数组?

[英]How to increment an array in x86 assembly?

How would you increment an array using x86 assembly within a for loop. 如何在for循环中使用x86程序集增加数组。 If the loop (made using c++) looked like: 如果循环(使用c ++制作)看起来像:

for (int i = 0; i < limit; i++)

A value from an array is put in a register then the altered value is placed in a separate array. 将数组中的值放入寄存器中,然后将更改的值放在单独的数组中。 How would I increment each array in x86 assembly (I know c++ is simpler but it is practice work), so that each time the loop iterates the value used and the value placed into the arrays is one higher than the previous time? 我如何在x86程序集中递增每个数组(我知道c ++更简单,但它是练习工作),所以每次循环迭代使用的值并且放入数组的值比前一次高一个? The details of what occur in the loop aside from the array manipulation are unimportant as I would like to know how this can be done in general, not a specific situation? 除了数组操作之外,在循环中发生的细节并不重要,因为我想知道如何在一般情况下完成这项工作,而不是特定情况?

The loop you write here would be: 你在这里写的循环是:

   xor eax, eax   ; clear loop variable
   mov ebx, limit
loop:
   cmp eax, ebx
   je done

   inc eax
   jmp loop

done:
 ...

I really don't understand what you mean by "increment an array". 我真的不明白你的意思是“增加一个数组”。

If you mean that you want to load some value from one array, manipulate the value and store the result in a target array, then you should consider this: 如果您想要从一个数组加载某个值,操作该值并将结果存储在目标数组中,那么您应该考虑这个:

Load the pointer for the source array in esi and the target pointer in edi. 在esi中加载源数组的指针,在edi中加载目标指针。

 mov esi, offset array1
 mov edi, offset array2
 mov ebx, counter

 loop:
 mov eax, [esi]
 do what you need
 move [edi], eax

 inc esi
 inc edi

 dec ebx
 jne loop

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM