tags:

views:

210

answers:

1

Hi, I have two files, in one I declare the variable SEED as such:

;file1.asm

.MODEL  SMALL,BASIC
.FARDATA RAND_DATA
SEED       DW      ?

.CODE
;Some code
END

And in the other I try to reference the variable

;file2.asm

.MODEL  SMALL,BASIC
EXTERNDEF SEED:WORD

FOO PROC  FAR PUBLIC USES DX,DS
    MOV     SEED,DX
FOO ENDP

END

When I try to compile both files using the code

ml file1.asm file2.asm io.lib

I get the following error:

error L2029: 'SEED' : unresolved external

What am I doing wrong?

Thank you!

+1  A: 

SEED in file1.asm should be made PUBLIC to be seen by other modules.

This is done by adding a line somewhere in file1.asm with

       PUBLIC SEED

Note that depending on the assembler you are you using this could require "global" instead.
Such scope statements can come +/- anywhere in the file, but there are several styles/conventions with regards to the location where this is done. The two main ones are:

  • Near the top of the file, all PUBLIC statements are grouped together
  • Just above each variable declaration per-se eg

Other conventions are typically variations on the above, for example all public data variables are scoped near the top the file, but the public declaration of procs is done just above each file where applicable.

mjv
how is that done?
yuval
#yuval: see how this is done in the amended response. Note, there are a few variations depending on the assembler in use, but in general, PUBLIC is the proper keyword for that purpose.
mjv
thank you very much!
yuval