3 Gordon Drive, P.O.Box 1347 Rockland, Maine 04841 U.S.A.
Find Tools for Your Chip


 

© 2004 Avocet Systems, Inc.
Call Us Today at 207-596-7766 ("Picton Press")
Avocet Systems, Inc. : The Complete Solution for Embedded Systems Development Tools
Hints
Debugging with DDE

Abstract
The DDE link in Windows gives you a powerful way to exert control over your debugging session. Here's how.

No emulator can be all things to all people. There are so many different requirements that tool vendors are forced to cater to the needs of the many, sometimes unfortunately neglecting the needs of the few.

With Windows and DDE (Dynamic Data Exchange) this problem disappears. Would you like some sort of special feature - say, generate a 3-D graph of the value of a variable in memory versus time? It's easy to create a program that communicates over a DDE link with the debugger. Softaid's Source Level Debugger for Windows (SLDW) supports DDE to let you create your own customized applications.

However, everyone knows how hard it is to write Windows apps... right? In fact, everyone is wrong. Microsoft's Visual Basic is so easy that, quite literally, we had a simple working Windows application running only an hour after opening the box. Visual Basic is not appropriate for large programs because it is somewhat slow, but it gives you a very fast way to build DDE-aware applications that can control an emulator. HyperApp

To illustrate this, Softaid provides an application written in Visual Basic on the SLDW distribution disks. We include the source code so you can use it as a model. HyperApp is a moderate-size program that displays the values of the I/O ports in certain high-integration processors (the Z180, 80188/186, and others).

For example, the 80188 includes over a dozen ports dedicated just to interrupt control. Though the emulator itself lets you issue I/O commands to view and change these ports, it's a little awkward to remember the addresses and bit positions of this information. HyperApp solves this problem. It's a separate application that displays everything you need to know about each port and bit. It communicates via the DDE link to SLDW to get the state of each port, and, if you change a bit setting, to transmit the new port value back to the emulator. DDE Made Easy

Visual Basic (VB) is the glue that makes DDE communication easy. Softaid's SLDW, which is written in C, has a rather complex and large module needed to handle DDE via the Windows SDK calls. By contrast, VB masks the details behind a few simple commands.

VB is a true object-oriented language (in Basic! Who would have imagined!). Every important action is associated with an object - in VB lingo, a control. Each button on a screen is a control; every box, frame, and other screen element is a control as well. So, you must define an object responsible for handling the DDE communications. In HyperApp we call this txtLink, and give it attributes that make the control invisible to the user. It's existence is for DDE only.

Softaid defined a DDE API for SLDW that includes a small set of commands you can invoke over the DDE. The commands are:

MEMBS address
MEMWS address
IOWS address
IOBS address
ASSIGN address, value

MEMBS, IOWS, IOBS all let you read or set one memory or I/O (MEM Vs IO) word or byte (W Vs B).

ASSIGN immediately sets an address to the value supplied. It uses the DDE Execute method. ASSIGN is not used in the HyperApp program.

When SLDW receives any of these DDE commands it runs the address parameter through its symbol processor. The result - you can specify case-sensitive symbolic names from your program as addresses!

To set any VB application up as a DDE "client" (i.e., an application requesting data), issue the following statements, all in this case tied to the txtLink control:

txtLink.LinkTopic="SLDW|SLDWAPI"
txtLink.LinkMode=3
txtLink.LinkItem="BREAKADVISE"

These statements tell VB that the application will communicate with SLDW. LinkMode 3 means that whenever SLDW encounters a breakpoint (BREAKADVISE) it will cause the txtLink control to go to the LinkNotify routine. LinkNotify is a standard routine (called "Event" in VB parlance) for any object. Thus, if the emulator hits a breakpoint LinkNotify in the VB application will be automatically invoked via these commands.

To read data from SLDW issue one of the commands listed above over the DDE. For example, to read a byte from address 00, use the following commands.

txtLink.LinkItem="IOBS 00"
txtLink.LinkRequest

Immediately after the LinkRequest the object (txtLink) will get the data in string form in its Text property. Retrieve the value into sValue$ via:

sValue$=txtLink.Text

Sending data is just as easy. Put the string to send to SLDW in the object's Text property. This example sends 11 to port 00:

txtLink.LinkItem="IOBS 00"
txtLink.Text="11"
txtLink.LinkPoke

Conclusion

HyperApp uses these simple DDE commands to extract and change any of the CPU's internal I/O ports. There's no reason you couldn't extend this to include information about your own I/O -- external to the CPU -- since all of the port and bit definitions are in an ASCII file read by HyperApp on powerup.

HyperApp is included with each of Softaid's emulators. We supply it with the complete Visual Basic source code.

Copyright 1994, Softaid, Inc.