views:

183

answers:

2

Hi, I'm working in x86 assembly in 16bits. I have three files that need to share 'variables between them' - basically, the data segment. When I compile them, as in the following:

ml file1.asm,file2.asm,file3.asm io.lib

They cannot access each other's variables How do I share a data segment, and thus variables between the files? Thank you!

+3  A: 

This looks relevent: The PUBLIC, EXTERN, and EXTRN Directives and The EXTERNDEF Directive.

ChrisW
+3  A: 

Just about like in C, you create a header (usually given the extension ".inc") that contains external declarations for what's contained in another file, as in:

;file def_data.asm:
.586P
.model flat, c

.data
     myword dd ?

end 

; file def_data.inc:
externdef myword:dword

; file use_data.asm:
.586P
.model flat, c

include def_data.inc

.code
myproc proc
    mov eax, myword
myproc endp
    end
Jerry Coffin
thank you. how would I go about doing such a thing for a proc?
yuval
Sorry -- I didn't notice this until you asked it as a separate question. Hopefully that answer helped...
Jerry Coffin
thank you very much!
yuval