The MASM Forum

64 bit assembler => UASM Assembler Development => Topic started by: jj2007 on February 24, 2024, 07:55:52 PM

Title: Missing error messages
Post by: jj2007 on February 24, 2024, 07:55:52 PM
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)
Title: Re: Missing error messages
Post by: HSE on February 24, 2024, 09:21:06 PM
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.
Title: Re: Missing error messages
Post by: _japheth on February 27, 2024, 02:23:32 AM
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.
Title: Re: Missing error messages
Post by: jj2007 on February 27, 2024, 04:06:28 AM
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.
Title: Re: Missing error messages
Post by: johnsa on March 21, 2024, 02:22:44 AM
Silly suggestion.. don't forget .CODE ? :)
Title: Re: Missing error messages
Post by: jj2007 on March 21, 2024, 03:23:31 AM
Yes, a "warning: you are executing code in the data section - did you forget .CODE?" would be perfect :thumbsup: