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
精彩评论