module1.asm =>
.686
.model flat, stdcall
option scoped
option casemap :none
.data
string db "Order in Chaos",0
align 4
.code
myproc proc
mov edx,7
mov eax,3
ret
myproc endp
start:
main proc
call myproc
ret
main endp
end start
-------------------------------------------------
module2.asm =>
.686
.model flat, stdcall
option scoped
option casemap :none
INCLUDE modinc.inc
.data
align 4
.code
start:
main proc
call myproc
ret
main endp
end start
--------------------------
modinc.inc =>
externdef myproc : proc
--------------------------
ml /c module1.asm
ml /c module2.asm
link module1.obj module2.obj /out:test.exe
module1.obj : warning LNK4033: converting object format from OMF to COFF
module2.obj : warning LNK4033: converting object format from OMF to COFF
module2.obj : error LNK2005: _main@0 already defined in module1.obj
LINK : fatal error LNK1561: entry point must be defined
:sad:
What's going on???
.686
.model flat, stdcall
option scoped
option casemap :none
.data
string db "Order in Chaos",0
align 4
.code
myproc proc
mov edx,7
mov eax,3
ret
myproc endp
start:
main proc
call myproc
ret
main endp
end start
-------------------------------------------------
module2.asm =>
.686
.model flat, stdcall
option scoped
option casemap :none
INCLUDE modinc.inc
.data
align 4
.code
start:
main proc
call myproc
ret
main endp
end start
--------------------------
modinc.inc =>
externdef myproc : proc
--------------------------
ml /c module1.asm
ml /c module2.asm
link module1.obj module2.obj /out:test.exe
module1.obj : warning LNK4033: converting object format from OMF to COFF
module2.obj : warning LNK4033: converting object format from OMF to COFF
module2.obj : error LNK2005: _main@0 already defined in module1.obj
LINK : fatal error LNK1561: entry point must be defined
:sad:
What's going on???
What's going on???
it says: you have two "main"-s AND you have two entrypoints!
module1.asm =>
.686
.model flat, stdcall
option casemap :none
externdef main : proc
.data
string db "Order in Chaos",0
align 4
.code
myproc proc
mov edx,7
mov eax,3
ret
myproc endp
start:
call main
ret
end start
-------------------------------------------------
module2.asm =>
.686
.model flat, stdcall
option casemap :none
INCLUDE modinc.inc
.code
main proc
call myproc
ret
main endp
end
--------------------------
modinc.inc =>
externdef myproc : proc
What's going on???
it says: you have two "main"-s AND you have two entrypoints!
And if i remove one of the main:s i will get main missing when assemble?
And if i remove one of the main:s i will get main missing when assemble?
1. Make one module your main module, ie the starting point of your exe
this defines your entrypoint, have this in the main module
start: ;; the label can be anything
end start
2. In other modules just put procedures or data
.686
.model flat, stdcall
option casemap :none
.code
;; function definitons go here
end;; <- nothing else here
3. Add a header file (.inc) to the main module, which defins all external procedures and or data
4. Make sure the names are different in each module even for unexported functions ( unless you use proc private)
5. If you are going to link a C runtime library, remove the entrypoint labels and write the appropriate entry functions (_main or _WinMain@16)
start: ;; the label can be anything
end start
2. In other modules just put procedures or data
Thank you, now it works - lovely.
But can you check if i missed anything?
var1 & var2 are not in myinc.inc but it works anyway strange.
---------------------------------------------------
module1.asm
---------------------------------------------------
.686
.model flat, stdcall
option scoped
option casemap :none
include myinc.inc
externdef var1:dword,var2:dword,proc1:near
.data
align 4
.code
start:
mov eax,2
mov edx,5
mov var1,eax
mov var2,edx
call proc1
ret
end start
---------------------------------------------------
module2.asm
---------------------------------------------------
.686
.model flat, stdcall
option scoped
option casemap :none
public var1,var2,proc1
.data
var1 dd ?
var2 dd ?
align 4
.code
proc1 proc
mov eax,var1
add eax,var2
ret
proc1 endp
end
---------------------------------------------------
myinc.inc
---------------------------------------------------
proc1 PROTO
var1 & var2 are not in myinc.inc but it works anyway strange.
external definitions don't have to be in an .inc file, it's just convenient that way for multiple inclusion
yeh looks ok :thumbsup: