Reputation: 26713
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!
Upvotes: 3
Views: 1940
Reputation: 56123
This looks relevent: The PUBLIC, EXTERN, and EXTRN Directives and The EXTERNDEF Directive.
Upvotes: 5
Reputation: 490408
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
Upvotes: 5