Chr$ MACRO args:VARARG
Local NewString
.DATA
NewString db args, 0
.CODE
EXITM <offset NewString>
ENDM
WinMain proc ....
...
invoke CreateWindowEx, 0, wc.lpszClassName, Chr$("Hello World"), ...
ret
WinMain endp
Looks harmless, right?
Error A2142: Unmatched block nesting: WinMain
I wasted a lot of time chasing this bug; in the end, it turned out that one word was missing before WinMain proc...: .code
So when Chr$() is being used, there is a switch from .data to .code :rolleyes:
IMHO a PROC in the .DATA section should trigger a "wrong section" error.
Original post (https://masm32.com/board/index.php?msg=127381)
JWAsm and UAsm have problems with errors, mostly with error location. Nidud solved that, but he change so much things that made his assembler Masm incompatible.
Quote from: jj2007 on February 24, 2024, 07:55:52 PMIMHO a PROC in the .DATA section should trigger a "wrong section" error.
This would introduce a severe incompatibility. The following code - no problems for masm/jwasm/uasm - would be rejected:
.386
.MODEL flat
externdef final_dest:near
.data
assume cs:_DATA
test1 proc
mov eax,1
mov ebx,2
ret
test1 endp
end_of_test1:
.code
mov esi, offset test1
mov ecx, end_of_test1 - test1
mov edi, offset final_dest
rep movsb
END
An assembler must be able to handle code as data.
Quote from: _japheth on February 27, 2024, 02:23:32 AMa severe incompatibility
Ok, make it a warning then; anything that gives a hint what "unmatched block nesting" could really mean will be considered helpful.
Silly suggestion.. don't forget .CODE ? :)
Yes, a "warning: you are executing code in the data section - did you forget .CODE?" would be perfect :thumbsup: