It is usual rutine when we inform user about some errors and we detect them checking the return from some func if it's FALSE or INVALID_HANDLE_VALUE something like: invoke SomeFunc, bla, bla, bla .IF eax==FALSE ;or .IF eax==INVALID_HANDLE_VALUE invoke MessageBox, 0,addr Text, addr Capt,MB_OK ... ;some additional code to hanle errors .ELSE ... .ENDIF the following code consist cuple of macros which can help to generate code that a little bit faster and shorter than usual and save some typing. .586 .model flat,stdcall option casemap:none include C:\masm32\include\windows.inc include C:\masm32\include\user32.inc include C:\masm32\include\kernel32.inc includelib C:\masm32\lib\kernel32.lib includelib C:\masm32\lib\user32.lib ErrZ macro text LOCAL name LOCAL lbl jmp lbl name db text,0 lbl: push eax push eax push offset name push eax call MessageBox endm ErrInvH macro text LOCAL name LOCAL lbl jmp lbl name db text,0 lbl: not eax push eax push eax push offset name push eax call MessageBox endm .code start: xor eax,eax .IF eax == NULL ErrZ 'Somtehing wrong' .ENDIF mov eax,INVALID_HANDLE_VALUE .IF eax == INVALID_HANDLE_VALUE ErrInvH 'Invalid handle value' .ENDIF call ExitProcess end start ;Version of the macros for somebody who prefers to keep data in .data section: ErrZ macro text LOCAL name .data name db text,0 .code push eax push eax push offset name push eax call MessageBox endm ErrInvH macro text LOCAL name .data name db text,0 .code not eax push eax push eax push offset name push eax call MessageBox endm Q: Is there any way to use a multiline string as a parameter to macro?
just a couple of notes bout your macro, i have a simaler macro, it does basicly the same thing, except for a couple of differences, also multiline is easy... first of all, with your optimization tricks i have noticed you using, because of caching systems in pentium processers, data in the code segemnt, is much slowwwer thatn normal...even intel does not recomend storing data in the code section, or if it has to be, at the very end, so someting like this: LOCAL lbl jmp lbl name BYTE text,0 lbl: is bad. There is a very much better and easyier way to delcare small items of data as such: .data? name BYTE text,0 .code The only restriction is the macro can only be used in the code section. And for multiline, just ErrZ "Line1",13,10,"Line2",13,10,"Line3" also, if you add a pushad/popad pair, your macro can be used anywhere for more than just notifying of an error condition, without the chance of corrupting registers
Thanks for your reply. 1. I had tried to use ErrZ "Line1",13,10,"Line2" before posted my Q: here :) But it had not worked. MASM cutted text after first comma. And there always just "Line1" So I still dont know how to make multiline text:) 2. I agree on your comments regarding slowing performance by putting data in code section. That's why I included at the end of 1st message versions which put text in data section. Some piple like speed while others - size. So I offered choise :)