Can I make array of structures public, so that I can make function in other .asm file access it and modify it.
.data
NODE STRUCT
key dword ?
value dword ?
ends
THREE 10 DUP (0,0) NODE
And in the other .asm file to have a function that will access the array (THREE[0].KEY) and modify it.
I have tried but I reached a wall with the other function not knowing what NODE is. And I can't seem to find how to make NODE typedef STRUCT.
You can use the PUBLIC directive to make the symbol THREE accessible from other .ASM files. You also need to define THREE correctly:
.data
NODE STRUCT
key dword ?
value dword ?
NODE ENDS
PUBLIC THREE
THREE NODE 10 DUP ({0,0})
To access the symbol THREE you need to use the EXTERN directive:
NODE STRUCT
key dword ?
value dword ?
NODE ENDS
EXTERN THREE:NODE
.code
mov THREE[0].KEY, 1
Note that this requires repeating the NODE struct definition twice, once in each .ASM file. To avoid this you can move it to separate file and include it both .ASM files. For example you can put the following in file named node.inc
:
NODE STRUCT
key dword ?
value dword ?
NODE ENDS
and include it a modified version of my second example above like this:
INCLUDE node.inc
EXTERN THREE:NODE
.code
mov THREE[0].KEY, 1