CoreForth-0

common/utils.ft.md


: dump          >r dup cr hex. space begin
                r@ while
                  dup c@ h.2 space 1+
                  r> 1- dup $10 mod 0= over and if cr over hex. space then >r
                repeat rdrop drop ;

: dumph         >r dup cr hex. space begin
                r@ while
                  dup h@ h.4 space 2+
                  r> 1- dup $8 mod 0= over and if cr over hex. space then >r
                repeat rdrop drop ;

: dumpw         >r dup cr hex. space begin
                r@ while
                  dup @ hex. space cell+
                  r> 1- dup $4 mod 0= over and if cr over hex. space then >r
                repeat rdrop drop ;

: b.8'          base @ swap binary
                <# # # # # [char] ' hold # # # # #> type base ! ;
: b.16'         base @ swap dup 8 rshift b.8' [char] ' emit b.8' base ! ;

: delay         begin ?dup while 1- repeat ;

: list          latest begin @ ?dup while
                  dup link> hex. space dup link>name count type cr
                repeat ;

: .s            depth 0= if exit then
                dup u.
                sp@ begin dup s0 cell- < while dup @ u. cell+ repeat drop ;
: .r            rp@ begin dup r0 < while dup @ u. cell+ repeat drop ;