Initializing an array in assembler

I just started to learn ASM, I have C experience, but I think it doesn’t matter. Anyway, how can I initialize an array of 12 DT elements to 0s and how not to initialize it?

I am using FASM.

+4
source share
2 answers

Since arrays are just a continuous block of memory with elements one after another, you can do something similar in NASM (you are not sure if FASM supports the times directive, but you can try):

 my_array: times 12 dt 0.0 

This expands when your source is compiled into:

 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 
0
source

Just use the backup directive and reserve 12 terabytes:

 array: rt 12 
0
source

All Articles