home *** CD-ROM | disk | FTP | other *** search
/ Archive Magazine CD 1995 / Archive Magazine CD 1995.iso / discs / prog_disc / volume_4 / issue_07 / assembler / asmdebug / readme < prev   
Encoding:
Text File  |  1991-03-16  |  2.8 KB  |  52 lines

  1.  
  2.         BASIC Function for Assembler Debug Facility 
  3.         ===========================================
  4.                                               (directory AsmDebug)
  5.  
  6. When writing and testing any program it is very useful to be able to follow
  7. the execution path through the program.  This facility is provided in BASIC
  8. by the TRACE facility, which will display the statement number being
  9. executed.  It is also easy in BASIC to insert extra PRINT statements so that
  10. the flow can be seen, and variables displayed.
  11.  
  12. These problems exist also when writing assembler programs, with the added
  13. difficulty that assembler programs can easily loop or overwrite unintended
  14. bits of storage, often locking up the computer completely with no clues
  15. where it is.  In assembler there is no TRACE facility, and although SWI
  16. calls can be inserted to display characters or strings, the insertion can
  17. cause the program to change its behaviour due to register corruption.
  18. Breakpoints can be inserted using *BreakSet, but these are limited, and slow
  19. the program down.
  20.  
  21. My solution to this was to write a BASIC function which generates assembler
  22. code to enable trace entries to be easily inserted at any point in an
  23. assembler program.  All that is needed is to insert FNdebug("message of your
  24. choice") : this will generate code to print the message from the parameter
  25. to identify the location, then provide a full register list, plus the flag
  26. values, and then return to the program under test, with all registers and
  27. flags unchanged.  The debug functions can be left in the source, and turned
  28. on and off for any assembly simply by setting debug to TRUE or FALSE.  The
  29. code will run in User mode, and also in Supervisor mode.
  30.  
  31. There is obviously some storage overhead when running with debug, which is
  32. about 300 bytes for code which included only once, and 13 bytes plus the
  33. length of the message for each  FNdebug included in the program.  It also
  34. slows the code down, but you normally need to slow it down much further with
  35. CTRL+SHIFT to read the debug information!
  36.  
  37. The debug function is fully documented, and it needs only 2 variables set
  38. before it can be used: opt should be set to the assembler OPT value, and
  39. debug should be set to TRUE to generate debug code, or FALSE to omit it.
  40. Note that there must also be included in the program FNdebug("Debug_Init")
  41. :this will generate the common code if debug is TRUE.  It should be placed
  42. after the end of the executable code.  After assembly CALL showregs can be
  43. used to obtain a register list at any time from BASIC.
  44.  
  45. The sample program DemoDebug includes the function as a LIBRARY, then
  46. assembles a short routine either with or without the debug facility, then
  47. CALLs the routine.  Run the program first to see what the assembler program
  48. does (don't get too exited!) then change line 40 to debug = TRUE and RUN the
  49. program again to see the debug function in action.
  50.  
  51.  
  52. Martin Avison