开发者

Initializing array in assembler

I just started learning ASM, I have C experien开发者_开发技巧ce but I guess it doesn't matter. Anyway how can I initialize a 12 elements array of DT to 0s, and how not to initialize it?

I use FASM.


Since arrays are just a contiguous chunk of memory with elements one after the other, you can do something like this in NASM (not sure if FASM supports the times directive, but you could try):

my_array:
    times 12 dt 0.0

That is expanded out when your source is assembled to:

my_array:
    dt 0.0
    dt 0.0
    dt 0.0
    dt 0.0
    dt 0.0
    dt 0.0
    dt 0.0
    dt 0.0
    dt 0.0
    dt 0.0
    dt 0.0
    dt 0.0


Just use the reserve data directive and reserve 12 tbytes:

array:          rt 12
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜