home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / forth / compiler / fpc / source / dbgfix.seq < prev    next >
Text File  |  1989-09-21  |  2KB  |  56 lines

  1. \ DBGFIX.SEQ    make INLINE NEXT kernel debugable.      by Tom Zimmer
  2.  
  3. comment:
  4.  
  5.   This handy little utility allows me to build the F-PC kernel with INLINE
  6. NEXT, for performance, and at will convert the kernel back to JMP NEXT for
  7. use when DEBUGging. It is a one way street however so once the conversion
  8. is made, the system stays debugable until you restart F-PC.  The word
  9. DEBUGABLE is called by the debugger, to switch the kernel to a debugable
  10. form, just as you start the debug process. On an XT class machine this may
  11. take as much as a second, but is only done once the first time you use the
  12. debugger.
  13.  
  14.   This utility works by patching each occurance of the unique sequence
  15. "26 AD FF E0" to JMP NEXT.
  16.  
  17. comment;
  18.  
  19. only forth also hidden definitions also
  20.  
  21. variable dbgbl                  \ is Forth curently debugable?
  22.  
  23. : findinline    ( a1 --- a2 f1 )
  24.                 dup up @ >
  25.                 if      false exit
  26.                 then
  27.         begin   1+ up @ over - 0MAX $26 scan dup
  28.                 if      drop dup 1+ @ $FFAD = over 3 + c@ $E0 = and ?dup
  29.                 else    true
  30.                 then
  31.         until   ;
  32.  
  33. code fixinline  ( a1 --- a1 )           \ a1 is the address of an inline next.
  34.                 pop bx          push bx
  35.                 mov 0 [bx], # $E9
  36.                 mov ax, # >next
  37.                 sub ax, bx
  38.                 sub ax, # 3
  39.                 mov 1 [bx], ax
  40.                 next            end-code
  41.  
  42. only forth also definitions hidden also
  43.  
  44. : debugable     ( --- )
  45.                 false =: restnext           \ We DO NOT want next restored
  46.                 dbgbl @ 0=
  47.                 if      >next               \ find and replace each occurance
  48.                         begin   findinline  \ of NEXT found with JMP NEXT
  49.                         while   fixinline
  50.                         repeat  drop
  51.                         dbgbl on
  52.                 then    ;
  53.  
  54. only forth also definitions
  55.  
  56.