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.

1
  • 2
    The language is called "assembly" and the piece of system software that turns it into an executable is called an "assembler". Commented Jul 26, 2011 at 18:25

2 Answers 2

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
Sign up to request clarification or add additional context in comments.

3 Comments

I tried that and I get invalid operand when I do it with times syntax.
Oh, yeah it supports times directive but i don't know why I can't use it with dt variable x_x
You can't initialize tbytes to integers, only to floats: times 12 dt 0.0
0

Just use the reserve data directive and reserve 12 tbytes:

array:          rt 12

8 Comments

well then I would have to reserve 10x12 bytes right? dt is 10 bytes.
And then can I normally reffer to that bytes like that :mov eax, [array+10](second element)?
Yes, but as you are working with tbytes perhaps you meant something like fld tbyte [array+10]?
Why is that? I just started learnign some things are still blur to me.
eax is 32 bits, you can only fit four bytes there. tbytes are mostly used for 80-bit full-precision floating-point numbers.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.