News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

How to reference a variable in another asm file

Started by kohlyang, June 29, 2010, 04:03:05 AM

Previous topic - Next topic

kohlyang

hi, brothers, trouble you again:

in 1.asm, i declare a variable
.data
lpBuffer db "hello world", 0

and in 2.asm, how can I use that variable.



as i know if define a function 1.asm
f1 proc
  ret
f1 endp

we can use it in 2.asm like
f1 proto
then call f1, or invoke f1, but i don't know what about for variable.


in C language, i can do like in 1.c
char* lpBuffer

then in 2.c
extern char* lpBuffer


so can give me a way in asm, thanks ...  :bg

oex

if you just use

include \masm32\1.asm

You can use lpBuffer as if it's in the same file.... it (effectively) just replaces the include statement with the file contents

If you are refering to seperately build projects ie dlls someone elsemay be able to help you out
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

box

If you're asking how to make data in a library public you use something like:

.data
lpBuffer db "hello world", 0
public lpBuffer

and in the .inc file or 2.asm you would put something like:

extern lpBuffer:byte


Chapter 8 in the MASM programmers guide discusses this - I'm pretty inexperienced with MASM so maybe someone can elaborate

MichaelW

The attachment contains a simple example.
eschew obfuscation

kohlyang

Quote from: box on June 29, 2010, 04:36:36 AM
If you're asking how to make data in a library public you use something like:

.data
lpBuffer db "hello world", 0
public lpBuffer

and in the .inc file or 2.asm you would put something like:

extern lpBuffer:byte


Chapter 8 in the MASM programmers guide discusses this - I'm pretty inexperienced with MASM so maybe someone can elaborate



hi, box, thanks, this forum can always give me surprising result, after verify it can work,  :bg :thumbu

and for "Chapter 8 in the MASM programmers guide", do you mean "masm32.chm"? I should read more help documents ...

kohlyang

thanks for all of your enthusiastic reply, i should read more about these help documents first, then ask some high quality questions, not just basic ones.

jj2007

Quote from: kohlyang on June 29, 2010, 10:30:55 AM
and for "Chapter 8 in the MASM programmers guide", do you mean "masm32.chm"? I should read more help documents ...

See this thread.