Differences From Artifact [8fe0ba28ee1541c2]:
File autopsy.rx part of check-in [b1f910be0c] - autopsy: add help text, '1' to jump to address directly by charleschilders on 2010-11-14 15:04:14. [annotate] [view]
To Artifact [7458de0f1cfb56e4]:
File autopsy.rx part of check-in [82c2a445c5] - update autopsy for latest image; use new style EOW recognition by charleschilders on 2011-01-17 23:24:55. [annotate] [view]
@@ -12,18 +12,18 @@
{{
( Helpers to make the code easier to read ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ )
: case
[ over = ] dip swap
- [ do swap space puts nip -1 ] [ drop 0 ] choose 0; pop 2drop ;
+ [ do swap space puts nip -1 ] [ drop 0 ] if 0; pop 2drop ;
( Resolve addresses to headers ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ )
: header? ( a-af ) dup xt->d ;
: .name ( a- ) xt->d d->name puts space ;
: .call ( n- ) "call " puts color.literal putn space ;
- : opcode ( n- ) header? if color.name .name ;then .call ;
- : (name) ( a- ) color.header '( emit space .name ') emit space ;
+ : opcode ( n- ) header? [ color.name .name ] &.call if ;
+ : (name) ( a- ) color.header '( putc space .name ') putc space ;
: resolve ( n- )
- color.literal header? [ dup putn space (name) ] [ putn space ] choose ;
+ color.literal header? [ dup putn space (name) ] [ putn space ] if ;
: instr? ( n-f )
0 [ "nop" 0 ] case 1 [ "lit" -1 ] case
2 [ "dup" 0 ] case 3 [ "drop" 0 ] case
@@ -49,15 +49,13 @@
( - if so, is it followed by a header? )
( - are there two seqeuntial nop instructions? )
( If either condition is true, we assume the function is at an end. )
( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ )
- : end? ( a-a || a- )
- dup 1- @+ 9 =if @ 30 >if pop 2drop ;then ;then drop
- dup @+ 0 =if @+ 0 =if pop 2drop else drop ;then drop ;then drop ;
-
+ : end? ( a-af || a-af )
+ dup 1- @+ swap @ [ 9 = ] bi@ and not ;
: row ( a-a )
- color.normal dup putn space @+ instr? if @+ space resolve then cr ;
- : decompile ( a- ) repeat row end? again ;
+ color.normal dup putn space @+ instr? [ @+ space resolve ] ifTrue cr ;
+ : decompile ( a- ) [ row end? ] while drop ;
( Interactive browsing of memory ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ )
: help ( - )
clear
@@ -77,26 +75,26 @@
"+---+----------------------------------+\n" puts
"| 1 | Jump to address |\n" puts
"+---+----------------------------------+\n" puts
"\nPress any key to return to autospy.\n" puts
- key drop ;
+ getc drop ;
2 elements x more?
: getAddress ( "- )
clear "Address to jump to: " puts getToken toNumber !x ;
- : rows @fh 2 - ;
- : cols @fw 1 - ;
+ : rows @ch 2 - ;
+ : cols @cw 1 - ;
: handle
- color.ui cols [ '- emit ] times cr
- key
+ color.ui cols [ '- putc ] times cr
+ getc
'i over = [ 1 -x ] ifTrue
'k over = [ 1 +x ] ifTrue
'j over = [ rows -x ] ifTrue
'l over = [ rows +x ] ifTrue
'? over = [ help ] ifTrue
'1 over = [ getAddress ] ifTrue
- 'z over = [ more? off ] ifTrue
+ 'z over = [ more? off ] ifTrue
drop ;
: browse ( - ) [ clear @x rows &row times drop handle @more? ] while ;
---reveal---
: see ( "- ) ' 0; cr decompile color.default ;