VolksForth

decom-tools
Login

SQLITE_NOTICE(539): recovered 3 pages from /var/www/fossil/volksforth.fossil-journal

Forth decompiler tools

\ tools for decompiling,      clv12oct87 

( interactive use

Onlyforth Tools also definitions

| : ?:  ?cr dup 4 u.r ." :"  ;
| : @?  dup @ 6 u.r ;
| : c?  dup c@ 3 .r ;
| : bl  $24 col - 0 max spaces ;

: s  ( adr - adr+)
 ( print literal string)
 ?:  space c? 4 spaces dup count type
 dup c@ + 1+ bl  ;  ( count + re)

: n  ( adr - adr+2)
 ( print name of next word by its cfa)
 ?: @? 2 spaces
 dup @ >name .name 2+ bl ;

: k  ( adr - adr+2)
 ( print literal value)
 ?: @? 2+ bl ;

( tools for decompiling, interactive )

: d  ( adr n - adr+n) ( dump n bytes)
 2dup swap ?: 3 spaces  swap 0
 DO  c? 1+ LOOP
 4 spaces -rot type bl ;

: c  ( adr - adr+1)
 ( print byte as unsigned value)
 1 d ;

: b  ( adr - adr+2)
 ( print branch target location )
 ?: @? dup @ over + 6 u.r 2+ bl ;

( used for : )
( Name String Literal Dump Clit Branch ) 
( -    -      -       -    -    -      ) 

( debugging utilities      bp 19 02 85 ) 

: unravel   \  unravel perform (abort"   
 rdrop rdrop rdrop
 cr ." trace dump is "  cr
 BEGIN  rp@   r0 @ -
 WHILE   r>  dup  8 u.r  space
         2- @  >name .name  cr
 REPEAT (error ;

' unravel errorhandler !