I notice an interesting property of data variables declared in the .DATA section. For example, when you use BYTE swapping i.e. BYTE PSTR VariableName + #bytes
, you could actually go belong the memory addresses of that a variable, which in this example is VariableName.
varOne DB 'testing 1 2 3'
varTwo DW 'September 2002'
mov ax, WORD PTR DB + 12
In the last line above, the code will make a copy of "3" and "S." ASM is interesting because when you declare variables in .DATA, variables get memory locations right after one another. I am most familiar with C++. In C++, you have no idea where memory gets allocated.
Is it valid that in ASM memory gets allocated continuously, or is it random?