ATP Assembly Mini-Debugger v1.11 by Alexander Toresson
-----------------------------------------------------

New in v1.11:
-------------

The windows version works now, without modification!
I've now upgraded the asm.e included to Mic's latest.

New in v1.1:
------------

Now with support for windows!
The cleanup routine were undocumented!

General info
------------

Why I wrote this? Well, it's a story about some completely correct asm code
and buggy euphoria testing code :B
It uses a modified version of Mic's modified version of Pete's asm.e. 
I've enabled instructions of type 'ret 4'.
This has the side-effect that there may be troubles with 'ret' instructions
without any arguments. Just change them to 'ret 0'.

Features
--------

* Lets you watch over all of the standard registers (EAX, EBX, ECX, EDX,
ESI, EDI, EBP, ESP, EIP and EFL). Also shows each flag individually.
* Lets you step through your asm code.
* Lets you turn on and off the tracing whenever you want.
* Both DOS and Windows gui.

Using it
--------

To use, first include AsmDebug.e. It will automatically include either the
windows or dos version, depending on what your program runs under.
If you want to compile your program combined with this debugger, which I
doubt anyone will want, you'll have to include either AsmDebugDOS.e or
AsmDebugWin.ew.
There's one global function, debug_asm(sequence asmcode).
It will create a version of the asm code combined with the debugger.
You may have to change your conditional and unconditional jumps into
near ones, instead of short ones, which are the default.
That is because these routines add two instructions between and around all
of your commands. That brings us to the second point. A line of your code
is considered a command. That means that you'll have to add a \n between your
commands to make this debugger trace them all.
When it works, just call it like normal, whether you call it with call()
or with c_proc().

Note for DOS: You shouldn't have more than around 75 characters on each line.
              This program is not made for that, and the lines will wrap.

Note for Windows: To use the windows version of the debugger with a program that
                  never calls WinMain(), you have to options on how to make it
                  work:

                  1. Create a window which contains a button, where the button
                     starts your program. This will enable you to use WinMain().

                  2. Make vWinMainState in win32lib.ew global and add: 

                       vWinMainState = kStarted

                     after each time openWindow() has been called in asmdebugwin.ew.
                     
                     Setting vWinMainState to kStarted in openWindow() itself doesn't work.
      
Turning it on and off
---------------------

There is one asm procedure which is made for your asm code to call. It will
turn tracing on and off. You use it like this:

mov ebx, 1
call near @@dbg_setstate    ;This will turn on tracing.

mov ebx, 0
call near @@dbg_setstate    ;This will turn off tracing.

You will have to push ebx if you want to preserve the
contents of it.

Note: All labels and procedures in the debugger are prepended with '@@dbg_'.
      That makes it very unlikely that identifier clashes arise.

Cleaning Up
-----------

To clean up the allocated memory that the DOS debugger uses, call asm_cleanup().
To clean up after the Windows debugger, first call asm_end(), let the debugger
respond to it, and then call asm_cleanup(). This is achieved by putting
asm_end() in the w32Close window event procedure of your program, and
asm_cleanup() in the w32Destroy window event procedure.
That should be done when the program is about to quit.
Note that if the debugger is invoked after you've called asm_cleanup(),
it will crash.

Credits
-------

Thanks to the win32lib team for win32lib 0.60.6! At last there are no resource
leaks! My fonts aren't messed up anymore! Yahoo!
Thanks to Tommy Carlier for the layoutpanels and eucontrols. Makes the layouting
very easy.

Disclaimer:
Use at your own risk. The author is not liable for anything this program may cause.

License:
Free to distribute, but with all files unchanged. You can use any part of my code
in your own program, but only of you give me credit where credit is due. If you
just have debugged your asm code with this program, you don't have to give me a credit,
but it would be nice ;). For commercial use, please contact me.      
Alexander Toresson

8/10 2004 21:53 (20:53 GMT)
alexander.toresson@gmail.com (preferred, for fast reply - I can use the internet at school for replying)
alexander.toresson@tele2.se (neutral)
toressonodakra@swipnet.se (spam-attacked)
atodakra@hotmail.com (slow, micro$oft, only to be used in case of emergency)
You can also contact me through the euphoria messageboard.
No homepage atm. I'll probably get a domain together with a friend some time into the future.
I'm on #euphoria sometimes, reach me at 17-21 GMT weekdays. My nick's Eulex.