why does the following code compile perfectly?
Data Segment
Var1 Dw (any 4 digit hex value)
Var2 Dw Var1
Data Ends
what does the line "Var2 Dw Var1" even mean? I thought that only an immediate value can go after the type defining .
why does the following code compile perfectly?
Data Segment
Var1 Dw (any 4 digit hex value)
Var2 Dw Var1
Data Ends
what does the line "Var2 Dw Var1" even mean? I thought that only an immediate value can go after the type defining .
When you declare a variable like this:
then you're basically saying:
In your specific example,
Var1
is the first variable in the data segment, so the declaration ofVar2
is equivalent to:If, later on, you add more variables before
Var1
, in effect movingVar1
further into the segment, the value ofVar2
will adjust correspondingly.The typical usage of this is to get the start of array-like constructs by getting the address (offset in this context) of the start of the array.