Does anyone know how to implement the C assert function in asm?
Posted on 2002-05-20 08:50:19 by yoursguideline
interesting question, so I did a small research:

ASSERT is defined as:
#define _ASSERT(__expr)							    \

if( !(__expr) ) { \
_CrtDbgReport( _CRT_ASSERT, __FILE__, __LINE__, \
The CrtDbgReport function does this:
_CrtDbgReport can send the debug report to three different destinations: a debug report file, a debug monitor (the Visual Studio debugger), or a debug message window. Two configuration functions, _CrtSetReportMode and _CrtSetReportFile, are used to specify the destination or destinations for each report type. These functions allow the reporting destination or destinations for each report type to be separately controlled. For example, it is possible to specify that a reportType of _CRT_WARN only be sent to the debug monitor, while a reportType of _CRT_ASSERT be sent to a debug message window and a user-defined report file.
the function is pesent in the clib library and will probably be not useful from asm.
Posted on 2002-05-21 04:01:00 by beaster
Dont wast your time hacking thu this, instead wait shortly for VKim to finish his next debug update. Trust me, it will be worth the wait ;)

Posted on 2002-05-21 04:16:27 by NaN
VKim's debugging window rocks! Really makes dbshow obsolete.

NaN what's he adding into it now?
Posted on 2002-05-21 08:13:29 by AmkG
He never gave me the freedoms to say so ;)

So i wont. I will only say that there is an assert-like macro being developed. And a handfull of other powerful command tools to really help development.

Sorry, guess you'll have to wait. I believe he plans on releasing it with hutch's next masm package, but he may release it beforehand as well.. I really dont know his full intentions, or how close to finish he feels his updates are, so i cant give you anything more than this.

All i can say, is its worth the wait ;)

Posted on 2002-05-21 14:08:41 by NaN
Hi all!
I am preparing the new version of the debugging tool. There are some new features and macros:
- A very serious bug has been fixed. In the current version if you close the window while minimized then the registry values are trashed and the window doesn't display next time DBGWIN is executed. Now if the window cannot appear on the screen by its registry settings then it appears by force.
- NaN has fixed a bug in PrintHex macro.
- PrintDouble macro has been added.
- The current version cannot be used simultaneously in different files of a project. The new version doesn't have this very inconvenient feature.
- In the new version the window has two additional buttons ?"Save file" & "Open file". So you can save debugging information in a separate file.
- ASSERT macro has been added. :)
- NaN has added some very useful macros.
- All macros use conditional compilation. There is a switch DBGWIN_DEBUG_ON. If it has value 0 then any debugging information will be removed from your program. So you can get release version of your program by switching off DBGWIN_DEBUG_ON.
- There is a switch DBGWIN_EXTRA_INFO for adding some extra debugging information. If it has value 1 then macro will print a file name and number of line.
I know that Steve Hutchesson is going to release a service pack for MASM32. I hope the new version will be included.
Now I am waiting for any suggestions and ideas. My e-mail is
Posted on 2002-05-22 05:42:33 by vkim
Hi vkim,

I use both Ewayne's AsmEdit and ketil0's RadASM.

In AsmEdit I added the DbgDump Macro by Thomas Bleeker, but I haven't had the time to adapt it into your debug routine in RadASM (it needs to be passed 2 parameters instead of one). I find it very useful at times and was wondering if you
were going to include something similar in your new Debug program?

Keep up the great work!
Posted on 2002-05-22 08:02:56 by gscundiff

I am sure that many people already like your debug system so with a new one, it will also be popular. I am currently writing a new toy for MASM32 to do dialogs quickly in much the same way as the Prostart wizard and there is already a number of library modules to add to MASM32, Ernie Murphy's new image loading module being just one of them.

When I get it all together I intend to release a service pack with all of the new stuff but there is now a large demand on the bandwidth to do this so I wil have to be careful to get it right.

Regards and thanks for doing the extra research and development work.
Posted on 2002-05-22 10:19:16 by hutch--
I've got an array of error strings of equal length. When I call a function it returns a code which I use to calculate the index into the array. at the mo. I'm using the following to print the error string


I've decided to see what the hype was about vKims degug macros
And I must say they're very impressive.

It can't however do

PrintStringByAddr szErrors[eax]

I'd have a go at modifying the macro but I'm afraid my macro skills are all but non-existent... anybody have any ideas how to achieve this?

without explicitly adding the address of szErrors to eax?
Posted on 2002-05-22 11:55:39 by MArtial_Code
MArtial_Code, create a list of error code pointers:
MySillyErrorCodes \

dd cTXT("Not enough coffee")
dd cTXT("Low on sugar")
dd cTXT("Boss is near")
dd cTXT("Deadline too close")
...then just use:
; when eax is the error number
invoke DebugPrint, MySillyErrorCodes
Posted on 2002-05-22 12:05:28 by bitRAKE
Cheers BitRake. I did think of using Pointers but I didn't wan't to creat another array.

As it turns out creating another array would be more memory efficient.
Posted on 2002-05-22 13:44:02 by MArtial_Code
Look at this example of using PrintStringByAddr macro:

.model flat, stdcall
option casemap: none

include \masm32\include\
include \masm32\include\
include \masm32\include\
include \masm32\include\

includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib
includelib \masm32\lib\debug.lib

szErr1 byte "First error", 0
szErr2 byte "Second error", 0
szErr3 byte "Third error", 0
pErrors dword 3 dup(0)

mov pErrors[0], offset szErr1
mov pErrors[4], offset szErr2
mov pErrors[8], offset szErr3
xor eax, eax
.while eax <= 2
PrintStringByAddr pErrors[eax*4]
inc eax
end main

I hope it will help you. :)
Posted on 2002-05-22 21:41:29 by vkim
Cheers vkim. From now on I'll definitely be using those macros...

Any thing wrong with this code? It works but just checking if there's any pitfalls which I should look out for:

szFT_OK db 'FT_OK',0

pszFTErrors dd offset szFT_OK
dd offset szFT_INV_HAN
dd offset szFT_DEV_NOT_FOU
dd offset szFT_DEV_NOT_OPE
dd offset szFT_IO_ERR
dd offset szFT_INS_RES
dd offset szFT_INV_PAR
Posted on 2002-05-23 10:00:19 by MArtial_Code