News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Missing error messages

Started by jj2007, February 24, 2024, 07:55:52 PM

Previous topic - Next topic

jj2007

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

HSE

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.
Equations in Assembly: SmplMath

_japheth

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.
Dummheit, gepaart mit Dreistigkeit - eine furchtbare Macht.

jj2007

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.

johnsa

Silly suggestion.. don't forget .CODE ? :)

jj2007

Yes, a "warning: you are executing code in the data section - did you forget .CODE?" would be perfect :thumbsup: