How do I make a variable accessable by other modules?
main.asm
module1.asm
main.asm
.data?
example dd ?
module1.asm
.code
mov example,100
try this http://www.asmcommunity.net/board/index.php?topic=15097.0
It depends on the order you include files. Look at one of my templates.
But, whenever I try to assemble the modules, it spits back that 'example' is undefined when assembling Module2.asm.
I tried using "PUBLIC example" before declaring example in Module1.asm, but with no luck. Here's an example of what I tried.
Module1.asm
Module2.asm
Module1.inc
I tried using "PUBLIC example" before declaring example in Module1.asm, but with no luck. Here's an example of what I tried.
Module1.asm
.586
model flat, stdcall
option casemap :none
include Module1.inc
.data
example db "I'm public!",0
.code
entry:
invoke Module2
invoke ExitProcess,0
END entry
Module2.asm
.586
.model flat, stdcall ; 32 bit memory model
option casemap :none ; case sensitive
include windows.inc
include user32.inc
inlcudelib user32.lib
.code
Module2 proc
invoke MessageBox,NULL,addr example,NULL,MB_OK
ret
Module2 endp
end
Module1.inc
include windows.inc
include kernel32.inc
includelib kernel32.lib
Module2 PROTO
Try this:
...proc for function prototypes, EXTERDEF for external data :)
.586
.model flat, stdcall ; 32 bit memory model
option casemap :none ; case sensitive
include windows.inc
include user32.inc
includelib user32.lib
EXTERNDEF example:byte
.code
Module2 proc
invoke MessageBox,NULL,addr example,NULL,MB_OK
ret
Module2 endp
end
...proc for function prototypes, EXTERDEF for external data :)
Thanks!!?
That was all good, but when I defined "EXTERNDEF example:BYTE" in Module2.asm and tried to assemble the modules, it spit out "unresolved external symbol _example".?
So in Module1.asm I defined "PUBLIC example" as well, and it worked perfectly.
Here's the working code.
Module1.asm
Module2.asm
Module1.inc
That was all good, but when I defined "EXTERNDEF example:BYTE" in Module2.asm and tried to assemble the modules, it spit out "unresolved external symbol _example".?
So in Module1.asm I defined "PUBLIC example" as well, and it worked perfectly.
Here's the working code.
Module1.asm
.586
model flat, stdcall
option casemap :none
include Module1.inc
.data
PUBLIC example
example db "I'm public!",0
.code
entry:
? ?invoke Module2
? ?invoke ExitProcess,0
END entry
Module2.asm
.586
.model flat, stdcall? ; 32 bit memory model
option casemap :none? ; case sensitive
include windows.inc
include user32.inc
inlcudelib user32.lib
EXTERNDEF example:BYTE
.code
Module2 proc
invoke MessageBox,NULL,addr example,NULL,MB_OK
ret
Module2 endp
end
Module1.inc
include windows.inc
include kernel32.inc
includelib kernel32.lib
Module2 PROTO