| ||
Now, it is time describe debugging programs written using high-level languages. If the debug information was saved in the executable module at compile time, Turbo Debugger will be able to work with high-level language. Consider, for example, a simple console program demonstrating the bubble sort algorithm. The program is presented in Listing 23.1.
#include <windows.h> #include <stdio.h> void sort(DWORD a[], DWORD ); void main() { DWORD a [10]; DWORD j, p, k, r; randomize () ; for(j=0; j<10; j++) a[j]=random(10); // Sorting { for(k=9; k>l; k--) { r=0; for(j=0; j<k; j++) { if(a[j]>a[j+l]){p=a[j+l]; a[j+l]=a[j]; a[j]=p; r=l; }; } if (r==0) break; } for(j=0; j<10; j++) printf("%lu\n", a[j]); ExitProcess(0); }
Fig. 23.5 shows the Turbo Debugger window with the program from Listing 23.1 loaded. In the lower part of the main window, the Watches window resides. This window traces the values of elements of the array a [ ] . If you switch to the CPU window, you'll see how the bubble sort algorithm implemented in C language is converted into Assembly code.
| ||