Fully synchronize sys/boot from FreeBSD-5.x, but add / to the module path
[dragonfly.git] / sys / boot / ficl / softwords / prefix.fr
1 \ ** 
2 \ ** Prefix words for ficl
3 \ ** submitted by Larry Hastings, larry@hastings.org
4 \ **
5 \ (jws) To make a prefix, simply create a new definition in the <prefixes> 
6 \ wordlist. start-prefixes and end-prefixes handle the bookkeeping
7 \
8 \ $FreeBSD: src/sys/boot/ficl/softwords/prefix.fr,v 1.2 2002/04/09 17:45:28 dcs Exp $
9 \ $DragonFly: src/sys/boot/ficl/softwords/prefix.fr,v 1.1 2003/11/10 06:08:34 dillon Exp $
10
11 variable save-current
12
13 : start-prefixes   get-current save-current ! <prefixes> set-current ;
14 : end-prefixes     save-current @ set-current ;
15 : show-prefixes    <prefixes> >search  words  search> drop ;
16
17 \ #if (FICL_EXTENDED_PREFIX)
18
19 start-prefixes
20
21 \ define " (double-quote) as an alias for s", and make it a prefix
22 : " postpone s" ; immediate
23
24
25 \ make .( a prefix (we just create an alias for it in the prefixes list)
26 : .(  .( ;
27
28
29 \ make \ a prefix, and add // (same thing) as a prefix too
30 \ (jws) "//" is precompiled to save aggravation with Perl
31 \ : // postpone \ ; immediate
32
33
34 \ ** add 0b, 0o, 0d, and 0x as prefixes 
35 \ ** these temporarily shift the base to 2, 8, 10, and 16 respectively
36 \ ** and consume the next number in the input stream, pushing/compiling
37 \ ** as normal
38
39 \ (jws) __tempbase is precompiled, as are 0x and 0d - see prefix.c
40 \
41 \ : __tempbase  { newbase | oldbase -- }
42 \   base @ to oldbase 
43 \   newbase base !
44 \   0 0 parse-word >number 2drop drop
45 \   oldbase base !
46 \   ;
47
48 : 0b  2 __tempbase ; immediate
49
50 : 0o  8 __tempbase ; immediate
51
52 \ : 0d 10 __tempbase ; immediate
53 \ "0d" add-prefix
54
55 \ : 0x 16 __tempbase ; immediate
56 \ "0x" add-prefix
57
58 end-prefixes
59
60 \ #endif