Making reference to a data segment that is in another file

Sorry guys... I can't find another group that matches my needs
but anyway...

How do I make reference to a data segment that is in another file?
for examples:

In file A,

_DATASEG segment para public use16
        data_123  db 0

In file B,

mov ax, _DATASEG
mov ds, ax

Can I do this?
extrn _DATASEG:far in both files or there is another method?!

Best Regards,
Jacky Luk
Who is Participating?
arun_taConnect With a Mentor Commented:
declare _DATASEG as public in file A.
In file B use extrn.
whlukAuthor Commented:
Edited text of question
If that doesn't work.  (I'm not sure what assembler you are using)  You can declare the segment in the second file and place no data in it.    Like

_DATASEG segment para public use16

Then the 2nd file will know about it as well.  This is allowed (in MASM at least) you can declare segments multiple times with or without data, the linker will find all the segments definitions and collect them together into one segment
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.