DELETED user/crc/debug.rx Index: user/crc/debug.rx =================================================================== --- user/crc/debug.rx +++ user/crc/debug.rx @@ -1,93 +0,0 @@ -( Copyright [c] 2010, Charles Childers ) -( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) - -global with console - -{{ - ( Helpers to make the code easier to read ~~~~~~~~~~~~~~~~~ ) - : case: ( nn- ) ` over ` =if ` space ; immediate - : ;case ( nn-n ) ` nip ` ;then ; immediate - - ( Resolve addresses to headers ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) - : header? ( a-af ) dup xt->d ; - : xt->name ( a-$ ) xt->d d->name ; - : .name ( a- ) xt->name type space ; - : resolve ( n- ) header? if .name ;then red ." emit space ; - : (resolve) ( n- ) header? if red dup . yellow '( emit space .name ') emit space ;then red . ; - - : instr? ( n-f ) - 0 case: ." nop" 0 ;case - 1 case: ." lit" -1 ;case - 2 case: ." dup" 0 ;case - 3 case: ." drop" 0 ;case - 4 case: ." swap" 0 ;case - 5 case: ." push" 0 ;case - 6 case: ." pop" 0 ;case - 7 case: ." call" -1 ;case - 8 case: ." jump" -1 ;case - 9 case: ." ;" 0 ;case - 10 case: ." >jump" -1 ;case - 11 case: ." >" 0 ;case - 25 case: ." 0;" 0 ;case - 26 case: ." 1+" 0 ;case - 27 case: ." 1-" 0 ;case - 28 case: ." in" 0 ;case - 29 case: ." out" 0 ;case - 30 case: ." wait" 0 ;case - space resolve 0 ; - - : end? ( a-a || a- ) - ( First, see if we have a ; followed by a header ~~~~~~~~~~ ) - dup 1- @+ 9 =if @ 30 >if pop 2drop ;then ;then drop - ( Otherwise, look for two nop's in a row ~~~~~~~~~~~~~~~~~~ ) - dup @+ 0 =if @+ 0 =if pop 2drop else drop ;then drop ;then - ( Neither? Discard the address ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) - drop ; - : row ( a-a ) cyan dup . @+ instr? if @+ space (resolve) then cr ; - : decompile ( a- ) repeat row end? again ; - - ( Interactive browsing of memory ~~~~~~~~~~~~~~~~~~~~~~~~~~ ) - variable x - : rows ( -n ) @fh 1- ; - : handle - key - 'i case: x -- drop ;then - 'k case: x ++ drop ;then - 'j case: rows -x drop ;then - 'l case: rows +x drop ;then - 'z case: rdrop drop ;then - drop ; - : browse ( - ) - repeat - clear - @x rows for row next drop - handle - again ; ----reveal--- - : see ( "- ) - ' 0; cr decompile normal ; - : nav ( a- ) !x browse normal ; -}} - -global - - -1 2 3 4 5 -see cr -see words -see cr -see type -see ++