在x86汇编中声明数组 [英] Declaring Arrays In x86 Assembly
问题描述
我正在学习Assembly,我需要做很多事情。我已经看过如何声明数组,并且遇到了这个问题。
I am learning Assembly and I need to make a large array. I have looked around at how to declare arrays and I have come across this.
array db 10 dup(?)
其中声明了10个未初始化字节的数组。我尝试过并尝试对其进行汇编,并得到错误:操作数1之后应加逗号。我意识到x86不支持?,因此我将其设置为常量并得到了相同的错误。我最后做了这个。
Where an array of 10 uninitialized bytes is declared. I tried this and tried to assemble it and get "error: comma expected after operand 1". I realized that the '?' is not supported in x86 so I made it a constant and got the same error. I ended up doing this.
array db 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
这有效!但是问题是,我需要大数组(〜100-400个整数),并且它们的值不会总是已知的。我可以写出400 0,但我认为必须有一种更简单的方法。那么,有没有更好的方法来声明大数组呢?
This worked! But the problem is, I need large arrays (~100-400 integers) and their values will not always be known. I could write out 400 0's but I figured there must be an easier way. So is there a better way to declare large arrays?
我正在基于AT& T语法的基于Intel的Macbook Pro上使用x86_64 Assembly。
I am using x86_64 Assembly on an Intel-Based Macbook Pro with AT&T syntax.
推荐答案
您尝试使用 TIMES指令
。使用此代码声明一个
Did you try TIMES directive
.Use this code for declaring an array of a given size.
array TIMES 8 DB 0
这将创建大小为8的数组
This will create an array of size 8
请参阅此链接以获取更多信息。
Refer to this link for more.
这篇关于在x86汇编中声明数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!