-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtools.frt
More file actions
61 lines (44 loc) · 1.77 KB
/
Copy pathtools.frt
File metadata and controls
61 lines (44 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
( $Id: tools.frt,v 1.6 2025/10/25 17:12:51 albert Exp $ )
( Copyright{2000}: Albert van der Horst, HCC FIG Holland by GNU Public License)
( Uses Richard Stallmans convention. Uppercased word are parameters. )
\ Tools are those auxiliary thingies that are not appropriate elsewhere.
\ ------------------------------------------------------------------------
WANT HEX:
WANT RESTORED
WANT UNUSED
WANT $-PREFIX
'% HIDDEN
\ Print N in hex with comma separator and leaving out groups of zeroes.
: (H.-) 0 <# BEGIN # # # # 2DUP OR WHILE &, HOLD REPEAT #> ;
: H.- (H.-) TYPE ;
: |W| $FFFF AND ;
: |L| $FFFF,FFFF AND ;
\ Sign extend a 32 bit value into a cell.
: L>C DUP $8000,0000 AND 0= 0= $FFFF,FFFF INVERT AND OR ;
: .^ .S R@ @ >NFA @ $@ TYPE ;
: \D POSTPONE \ ; IMMEDIATE
\ : \D ;
\ Make QSORT safe by allowing an empty range.
\ Not tested and maybe not necessary.
\ : QSORT-SAFE 2>R 2DUP < IF 2R> QSORT ELSE 2DROP RDROP RDROP THEN ;
\ Make the output disappear till the end of the calling word.
: 2DROP' 2DROP ; \ Need a high level word here.
: SHUTUP '2DROP' >DFA @ 'TYPE >DFA ! CO 'TYPE RESTORED ;
\ Make ADDRESS return some label NAME, static memory so use immediately.
: INVENT-NAME "L" PAD $! (H.-) PAD $+! PAD $@ ;
\ For ADDRESS and NAME: "that name WAS invented".
: INVENTED-NAME? 10 <> IF 2DROP 0 ELSE SWAP INVENT-NAME CORA 0= THEN ;
\D HEX ." EXPECT: L0000,0042 " 42 INVENT-NAME TYPE .S CR
\D HEX ." EXPECT: 0 " 42 "L0000,0043" INVENTED-NAME? . .S CR
\D HEX ." EXPECT: -1 " 42 "L0000,0042" INVENTED-NAME? . .S CR
\D DECIMAL
\ Missing.
\ I1 I2 : F
: >= < 0= ;
\ I1 I2 : F
: <= > 0= ;
\ If FLAG is not zero, output STRING on the error channel and exit
\ with an error code of 2.
: ?ABORT ROT IF ETYPE 2 EXIT-CODE ! BYE ELSE 2DROP THEN ;
WANT $=
WANT ."$"