在汇编中编写循环和数组

时间:2011-04-08 19:58:16

标签: assembly

我正在尝试在asm中学习数组和循环。任何人都可以转换这些或帮助吗?

for (int a = 0; a < amount; a++)
    templetter =  originalletter[a];    
Enletters [i] = templetter;

1 个答案:

答案 0 :(得分:0)

在最低级别,循环(假设它没有被优化掉)通常如下所示:

LoopStart:
Set loopVariable = 0
  Do loopy-stuff
Compare loopVariable with maxValue
If loopVariable < maxValue, goto LoopStart

在C-class中学习时,以下两个表达式是相同的

myArray[i]
*(myArray + i)

第二个语句正是编译器将如何转换数组访问:

Add i to myArray (the memory address of the first array-element)
The result is the memory address of the i-th element

请注意,您需要将i乘以数组元素的大小,例如。具有2 struct s的int将为2字大