I started working with Assembler & C++ about 1/2 months ago, needless to say, I've learned both rapidly! My first program is a chess game written in both languages! I have started with the AI already, the board layout and ability to move pieces is complete!

Anyway, one of the QUICK and EASY 'debug' things I miss about VB is, if I want to see the value at anytime in code of an integer, I just write one line:

MsgBox IntegerVariable

and the VB compiler compiles it 4 me, converting the integer to a string for the MessageBox. In C++ you generally use _itoa or _utoa or one of those functions, then call the MessageBox function to display the string! Note that when I need this functionality, it's just so I can quickly see a value at runtime, then I remove the line immediately! It's quick and easy and the fastest way to see/check a value at runtime.

So, doing the same thing in Assembler was NOT as easy! I could call one of the C++ functions but decided to write my own (primarily because I want to know how it's done)! There are 2 functions I wrote, based partially on the _utoa function in C++, primitive speed tests suggested that my functions are 15% faster than their C++ counterparts. The first one is MsgDD, used like this:

invoke MsgDD, eax

will display the unsigned decimal value of eax. The other is MsgHex:

invoke MsgHex, eax

will display the Hex representation of eax.

Both functions work only with 32bit values and 'should' preserve ALL registers, so you can place it almose ANYWHERE in code!
Don't forget to add the function PROTOtypes before using invoke!
Anyone wanting a more detailed explanation of how it works, don't hesitate 2 ask!
I will write one for representing signed values later
Any advice on code optimization or reliability will be welcome as I'm obviously still learning!

I hope this helps someone and improves debug speed as much as it has for me ...
Posted on 2002-08-21 08:43:08 by SubEvil
Sorry, the attachment of my code dissapeared!
Posted on 2002-08-21 08:46:29 by SubEvil
If u did a preview post, it will clear out your attachment field.

Some where in here is a bunch of atoi like functions .. you might want to check those out and see what other ppl has done for optimization.

But I will check this out ... very handy.

Posted on 2002-08-21 09:26:57 by gorshing

Check out vKims Debug Macros in your masm32 folder.
It does exactly what you want and more without having to click OK on each and every MessageBox.
Posted on 2002-08-21 10:47:09 by JimmyClif