Hi, all~

I have problem with conditonal assemble below code.
I met "unmatched block nesting : if-else" message....

Can anyone help me ?

As you see, i'd like assemble two way...

-----------------------------------------------------
ml /c /coff /DLL /D TEST_DLL test.asm
link /DLL /SUBSYSTEM:WINDOWS test.obj
-----------------------------------------------------
ml /c /coff test.asm
link /SUBSYSTEM:WINDOWS test.obj
-----------------------------------------------------

thanks~...



.386
.model flat, stdcall
option casemap :none ; case sensitive

include c:\masm32\include\windows.inc

; #########################################################################
.code

IFDEF TEST_DLL ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
LibMain proc hInstDLL:DWORD, reason:DWORD, unused:DWORD

.if reason == DLL_PROCESS_ATTACH
mov eax, 1
ret
.elseif reason == DLL_PROCESS_DETACH
.elseif reason == DLL_THREAD_ATTACH
.elseif reason == DLL_THREAD_DETACH
.endif

ret

LibMain Endp

End LibMain
ELSE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

start:
mov eax, 0
end start

ENDIF


Posted on 2003-06-26 22:55:13 by muzidowa

Hi, all~

I have problem with conditonal assemble below code.
I met "unmatched block nesting : if-else" message....

Can anyone help me ?

As you see, i'd like assemble two way...

-----------------------------------------------------
ml /c /coff /DLL /D TEST_DLL test.asm
link /DLL /SUBSYSTEM:WINDOWS test.obj
-----------------------------------------------------
ml /c /coff test.asm
link /SUBSYSTEM:WINDOWS test.obj
-----------------------------------------------------

thanks~...

/code
.386
.model flat, stdcall
option casemap :none ; case sensitive

include c:\masm32\include\windows.inc

; #########################################################################
.code

IFDEF TEST_DLL ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
LibMain proc hInstDLL:DWORD, reason:DWORD, unused:DWORD

.if reason == DLL_PROCESS_ATTACH
mov eax, 1
ret
.elseif reason == DLL_PROCESS_DETACH
.elseif reason == DLL_THREAD_ATTACH
.elseif reason == DLL_THREAD_DETACH
.endif

ret

LibMain Endp

End LibMain
ELSE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

start:
mov eax, 0
end start

ENDIF


/code



Maby becouse u forgot to type " LibMain: "
Posted on 2003-06-27 03:04:30 by AceEmbler
u mean like this?




LibMain:

LibMain proc xxxx

LibMain endp

end LibMain



This won't work....
Posted on 2003-06-27 03:29:47 by muzidowa
MASM may not be seeing the ENDIF statement because it's after the end statement...

:)
Posted on 2003-06-27 10:10:31 by S/390
S/390 is right -- anything can be put after an END statement and MASM ignores it.
Posted on 2003-06-27 10:26:51 by bitRAKE
So one solution may be something like this:

IF ....

StartLabel equ LibMain

ELSE

StartLabel equ Start

ENDIF

end StartLabel
Posted on 2003-06-28 15:12:20 by tenkey
Thanks all, and tenkey...

I solved it...



.386
.model flat, stdcall
option casemap :none ; case sensitive

include c:\masm32\include\windows.inc
include c:\masm32\include\user32.inc
include c:\masm32\include\kernel32.inc

includelib c:\masm32\lib\user32.lib
includelib c:\masm32\lib\kernel32.lib

; #########################################################################
szText MACRO Name, Text:VARARG
LOCAL lbl
jmp lbl
Name db Text,0
lbl:
ENDM

.code

IFDEF TEST_DLL
StartLabel equ LibMain
ELSE
StartLabel equ start
StartLabel:
ENDIF

IFDEF TEST_DLL
LibMain proc hInstDLL:DWORD, reason:DWORD, unused:DWORD

.if reason == DLL_PROCESS_ATTACH
mov eax, 1
ret
.elseif reason == DLL_PROCESS_DETACH
.elseif reason == DLL_THREAD_ATTACH
.elseif reason == DLL_THREAD_DETACH
.endif

ret
LibMain Endp

ELSE

mov eax, 0

ENDIF

TestProc proc
szText szTestProcMsg, "From dll msg!"
szText szTitle, "hi~~"
invoke MessageBox,NULL,ADDR szTestProcMsg,addr szTitle,MB_OK
ret
TestProc endp

end StartLabel

[/code/
Posted on 2003-06-29 22:04:57 by muzidowa