aboutsummaryrefslogtreecommitdiffstats
path: root/forth/tools.fth
blob: 8992d483f2c02cbdf689a0abe57198a90cd98ea9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
: .s       depth dup 0 ?do dup i - pick . loop drop ;
: ?        @ . ;
: dump     hex 0 do i cells over + @ s>d <# # # # # bl hold #> type loop
           drop decimal ;

: words    _latest @ begin
           dup @ dup 31 &
           2 pick cell+ \ lt l len ws
           2 pick 6 >> 1023 < if \ lt l len ws
           rot 6 >> else \ lt len ws adv
           >r cell+ rot drop r> @ then
           -rot swap type space \ lt adv
           over _begin <> while - repeat 2drop ;

( xt -- caddr u )
: _nameof  _latest @ begin \ xt lt
           2dup < while \ xt lt
           dup @ \ xt lt l
           dup 6 >> 1023 < if \ xt lt l
           6 >> - else
           drop dup cell+ @ - then \ xt lt
           repeat nip \ lt
           dup @ swap cell+ over 31 & \ l lt len
           rot 6 >> 1023 = if swap cell+ swap then ; \ lt len