4

I just started learning ASM, I have C experience 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.

Frédéric Hamidi
  • 258,201
  • 41
  • 486
  • 479
adad
  • 41
  • 1
  • 2
  • 2
    The language is called "assembly" and the piece of system software that turns it into an executable is called an "assembler". – Sparafusile Jul 26 '11 at 18:25

2 Answers2

1

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
0

Just use the reserve data directive and reserve 12 tbytes:

array:          rt 12
Jens Björnhager
  • 5,632
  • 3
  • 27
  • 47