Here is the files:

main.asm
mem.asm
variable.inc

variable.inc----------------------

HEAP STRUCT 4
Start dd ? <define some members
.
HEAP ENDS

Heap HEAP <> <define my Heap structure of type HEAP in

Mem.asm-------------------------

include variable.inc

mov eax, 1024
mov Heap.Start, eax <give this member some value


*******program continues to code in:
main.asm-------------------------

include variable.inc

.code

mov ebx, Heap.Start <mov the value into ebx

-------------------------------------

What do you think the value of ebx is?? 1024? Try 0.

This is a simplfication. Declaring my Heap structure in variables.inc
and including variables.inc into both asm file, gives me to copies of Heap. One copy for each object file. When the program moves to code in another asm file, the address of Heap moves to the address of Heap as defined by the other object file. Is there a way to prevent this dual-instantiation of Heap. Or a way to make sure Heap will occupy the same address in both obj files? Being able to declare variables in an include file would make it a lot easier for me to avoid using PUBLIC and EXTERN. I don't really like them.
Posted on 2002-01-16 13:35:54 by ThoughtCriminal
You could try putting the line AFTER the .CODE directive, I think what is happening is that the line,


include variable.inc

is not being included in the code section.

Regards,

hutch@movsd.com
Posted on 2002-01-16 18:37:24 by hutch--
Hutch, you wouldn't really want data in the code section, would
you now? The problem is the data structure defined twice.

CoffeeDrinker, you'll have to reorganize your code. If you want to
stick to the, in my opinion, kludgy include way of doing things,
put all your variables in one include, and include that first. Then
include the rest of the asm files.

Otherwise you'll have to fiddle around with public/private stuff.
Yes, this is more work, but (again, in my opinion) this is good as it
forces you to think a bit more about the layout/structure of your
code.
Posted on 2002-01-16 18:46:03 by f0dder
I tried including the rest of the asm files, but I guess I did it wrong.

Where is the correct place?

------------------------------------------
.686
.
.
.
include masm32.lib
include variables.inc
.
.
.
.
.data
********I dont think here would be good

.data?
********Or here

.code
********How about here?
include heap.asm

Start:

********?here?

main proc
********in the main body?
xor eax,eax

main endp

********Or here after main??

END

Thanks.

edit:
Otherwise you'll have to fiddle around with public/private stuff.
Yes, this is more work, but (again, in my opinion) this is good as it
forces you to think a bit more about the layout/structure of your
code.


I find PUBLIC and EXTERN to be kinda ugly. For quick and dirty, I have no problem with all my variable being global. Quick prototyping. Anything final , I agree, is better done with PUBLIC and EXTERN.
Posted on 2002-01-16 19:43:21 by ThoughtCriminal
Okay, include stuff... make the included files do ".data" and ".code"
and such. There's no problem with using these multiple times, the
linker will merge it all (well, in a single-file thing it's probably ml.exe
that merges it).

Include your variables.inc first (and make it do .data, .data?, .const
and such).
Posted on 2002-01-17 05:34:36 by f0dder
Yes I misread the listing but the problem is the same,

the lines,


mov eax, 1024
mov Heap.Start, eax <give this member some value

should be in the code section.

Regards,

hutch@movsd.com
Posted on 2002-01-18 05:24:13 by hutch--