dsforth: added `[CHAR]`
[urasm.git] / dsforth / main_hldef.zas
blob6630ea411bcd8514f5ad6afda1e7b493ab599493
1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2 ;; high-level definition words
3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5 $FORTH_WORD : IMM
6 ;; AberSoft
7 ;; ( -- )
8   ?EXEC !CSP CURRENT @ CONTEXT ! CREATE ]
9   (;CODE)
10 $FORTH_END_WORD :
11 _doforth:
12   ld    hl,(f_curRP)
13   dec   hl
14   ld    (hl),b
15   dec   hl
16   ld    (hl),c
17   ld    (f_curRP),hl
18   inc   de
19   ld    c,e
20   ld    b,d
21 _doforth_dbg:
22   jp    i_next
24 $FORTH_WORD ; IMM
25 ;; AberSoft
26 ;; ( -- )
27   ?CSP COMPILE ;S
28   SMUDGE [ ;S
29 $FORTH_END_WORD ;
31 $FORTH_WORD CONSTANT
32 ;; AberSoft
33 ;; ( n -- )
34   CREATE SMUDGE ,
35   (;CODE)
36 $FORTH_END_WORD CONSTANT
37 _doconst:
38   inc   de
39   ex    de,hl
40   ld    e,(hl)
41   inc   hl
42   ld    d,(hl)
43 doxvarx:
44   push  de
45   jp    i_next
47 $FORTH_WORD VARIABLE
48 ;; AberSoft
49 ;; ( n -- )
50   CONSTANT (;CODE)
51 $FORTH_END_WORD VARIABLE
52 _dovar:
53   inc   de
54   jr    doxvarx
56 $FORTH_WORD 2CONSTANT
57 ;; AberSoft
58 ;; ( lo hi -- )
59   CREATE SMUDGE HERE 2! 4 ALLOT
60   (;CODE)
61 $FORTH_END_WORD 2CONSTANT
62 _do2const:
63   inc   de
64   ex    de,hl
65   inc   hl
66   inc   hl
67   ld    e,(hl)
68   inc   hl
69   ld    d,(hl)
70   push  de
71   dec   hl
72   dec   hl
73   ld    d,(hl)
74   dec   hl
75   ld    e,(hl)
76   jr    doxvarx
78 $FORTH_WORD 2VARIABLE
79 ;; AberSoft
80 ;; ( lo hi -- )
81   2CONSTANT
82   (;CODE)
83 $FORTH_END_WORD 2VARIABLE
84 _do2var:
85   jr    _dovar
86 ;;  INC  DE
87 ;;  PUSH DE
88 ;;  JP   i_next
90 $FORTH_WORD USER
91 ;; AberSoft
92 ;; ( n -- )
93   CONSTANT (;CODE)
94 $FORTH_END_WORD USER
95 _douser:
96   inc   de
97   ex    de,hl
98   ld    e,(hl)
99   ld    d,0
100   push  ix
101   pop   hl
102   add   hl,de
103   jp    i_pushhl
106 $FORTH_WORD (;CODE)
107 ;; AberSoft
108 ;; ( -- )
109   R> LATEST PFA CFA ! ;S
110 $FORTH_END_WORD (;CODE)
112 $FORTH_WORD ;CODE IMM
113 ;; AberSoft
114 ;; ( -- )
115   ?CSP COMPILE (;CODE)
116   [ SMUDGE ;S
117 $FORTH_END_WORD ;CODE
119 $FORTH_WORD <BUILDS
120 ;; AberSoft
121 ;; ( -- )
122   0 CONSTANT ;S
123 $FORTH_END_WORD <BUILDS
125 $FORTH_WORD DOES>
126 ;; AberSoft
127 ;; ( -- )
128   R> LATEST PFA !
129   (;CODE)
130 $FORTH_END_WORD DOES>
131 _dodoes:
132   ld   hl,(f_curRP)
133   dec  hl
134   ld   (hl),b
135   dec  hl
136   ld   (hl),c
137   ld   (f_curRP),hl
138   inc  de
139   ex   de,hl
140   ld   c,(hl)
141   inc  hl
142   ld   b,(hl)
143   inc  hl
144   jp   i_pushhl
147 $FORTH_WORD CREATE
148 ;; AberSoft
149 ;; ( -- )
150   -FIND 0BRANCH create0
151   DROP NFA ID. 4 MESSAGE SPACE
152 create0:
153   HERE DUP C@ WIDTH @ MIN 1+ ALLOT DUP
154   LIT #A0 TOGGLE HERE 1- LIT #80 TOGGLE
155   LATEST , CURRENT @ ! HERE 2+ , ;S
156 $FORTH_END_WORD CREATE