In assembly(x86 NASM), it is perfectly okay to do this
a dd 17h
a2 dd a
with these 2 lines of code in the data segment I declare a doubleword a, to which I assign the value 17h. Then I declare another doubleword and I give this doubleword the value of the address of a. This works and I understand what's going on.
But when I try to do this:
a dd 17h
a2 dd [a]
I get a syntax error! And I don't really know why. I expected this piece of code to define a doubleword a with the value 17h (this is the same as in the previous example) and then define a doubleword a2 that takes the value of a, so 17h. But as I said, this doesn't seem to work. I am confused why this wouldn't work. From what I know, we can address memory as long as we follow the address offset formula which is in the form of [base + index * scale + constant]. In my case, the address of a a is constant so that will be the constant from the formula, and the base and scale will be zero. At least this is how I thought about it. But clearly, it doesn't work.