home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / f / forthmac / !Forthmacs / lib / checkrel < prev    next >
Encoding:
Text File  |  1997-02-10  |  1.5 KB  |  52 lines

  1. \ This program can help you find relocation problems in your applications.
  2. \ It should be loaded before you load your application.  It will display
  3. \ a warning message if your application does something that might result
  4. \ in a relocation problem.  After you have fixed the relocation problems,
  5. \ you can load your application without first loading this program.
  6.  
  7. warning @
  8. warning off
  9.  
  10. only forth also hidden also definitions
  11.  
  12. : dictionary-adr?    ( adr -- flag )
  13.     origin here 2 cells+ between  ;
  14. : .word-name        ( adr -- )
  15.     dup  last token@  name>  u>=
  16.     if    drop  last token@ .id    exit then
  17.     dup  origin  u<
  18.     if    drop ." <unknown> "    exit then
  19.     begin    dup probably-cfa? 0=
  20.     while    #align -
  21.     repeat .name ;
  22. : .loc            ( adr -- )
  23.     base @ >r  hex
  24.     dup . ." [ " .word-name ." ]"
  25.     r> base ! ;
  26. : ?relocation-problem    ( data adr -- data adr )
  27.     over dictionary-adr?  over dictionary-adr?  and
  28.     if    ." Possible relocation problem: " cr
  29.         ."    Storing "  over .loc  ."  at " dup .loc  cr
  30.         ."    "  where
  31.     then ;
  32. : ?-relocation-problem    ( adr -- adr )
  33.     dup dictionary-adr? 0=
  34.     if    ." Possible relocation problem: " cr
  35.         ." Relocatable reference adr used with non-dictionary address" cr
  36.         ."  at " dup .loc  cr
  37.         ."    "  where
  38.     then ;
  39.  
  40. forth definitions
  41.  
  42. : !        ( data adr -- )    ?relocation-problem !   ;
  43. : unaligned-!    ( data adr -- )    ?relocation-problem unaligned-!   ;
  44. : ,        ( data -- )    here ?relocation-problem  drop ,  ;
  45.  
  46. assembler definitions
  47.  
  48. : adr        ( reg adr -- )    ?-relocation-problem  adr   ;
  49.  
  50. only forth also definitions
  51. warning !
  52.