Rev Author Line No. Line
4985 kaklik 1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5 <title> words/find.asm </title>
6 <meta name="keywords" content="amforth programming language Forth ATmega ATMEL">
7 <meta name="description" content="amforth - laguage Forth for ATMEL ATmega">
8 <!-- AUTOINCLUDE START "Page/Head.en.ihtml" DO NOT REMOVE -->
9 <link rel="StyleSheet" href="../../../../Web/CSS/MLAB.css" type="text/css" title="MLAB Basic Style">
10 <link rel="StyleSheet" href="../../../../Web/CSS/MLAB_Print.css" type="text/css" media="print">
11 <link rel="shortcut icon" type="image/x-icon" href="../../../../Web/PIC/MLAB.ico">
12 <script type="text/javascript" src="../../../../Web/JS/MLAB_Menu.js"></script>
13 <!-- AUTOINCLUDE END -->
14 </head>
15  
16 <body lang="en">
17  
18 <!-- AUTOINCLUDE START "Page/Header.en.ihtml" DO NOT REMOVE -->
19 <!-- ============== HEADER ============== -->
20 <div class="Header">
21 <script type="text/javascript">
22 <!--
23 SetRelativePath("../../../../");
24 DrawHeader();
25 // -->
26 </script>
27 <noscript>
28 <p><b> JavaScript is required for including of the header </b></p>
29 </noscript>
30 </div>
31 <!-- AUTOINCLUDE END -->
32  
33 <!-- AUTOINCLUDE START "Page/Menu.en.ihtml" DO NOT REMOVE -->
34 <!-- ============== MENU ============== -->
35 <div class="Menu">
36 <script type="text/javascript">
37 <!--
38 SetRelativePath("../../../../");
39 DrawMenu();
40 // -->
41 </script>
42 <noscript>
43 <p><b> JavaScript is required for including of the menu </b><p>
44 </noscript>
45 </div>
46 <!-- AUTOINCLUDE END -->
47  
48 <!-- ============== TEXT ============== -->
49 <div class="Text">
50  
51 <h1> words/find.asm </h1>
52  
53 <p>
54 <input type=button onClick="history.back()" value="Back">
55 <input type=button onClick="history.forward()" value="Forward">
56 <a href="../WordList.en.html">Jump to Vocabulary</a>
57 </p>
58  
59 <pre>
60 ; ( addr -- -- [ addr 0 ] | [ xt [-1|1]] ) Tools
61 ; R( -- )
62 ; search dictionary
63 VE_FIND:
64 .db $04, &quot;find&quot;, 0
65 .dw VE_HEAD
66 .set VE_HEAD = VE_FIND
67 XT_FIND:
68 .dw DO_COLON
69 PFA_FIND:
70 .dw XT_DUP
71 .dw XT_TO_R
72 .dw XT_HEAD
73 .dw XT_EFETCH
74 PFA_FIND1:
75 ; ( addr )
76 .dw XT_DUP
77 .dw XT_NOTEQUALZERO
78 .dw XT_DOCONDBRANCH
79 .dw PFA_FIND2
80 .dw XT_ICOMPARE
81 ; (addr-ram addr-flash -- addr-flash' 0|1
82 .dw XT_QDUP
83 .dw XT_NOTEQUALZERO
84 .dw XT_DOCONDBRANCH
85 .dw PFA_FIND3
86 ; we found the word
87 .dw XT_SWAP
88 .dw XT_1PLUS ; make XT
89 .dw XT_SWAP
90 .dw XT_R_FROM
91 .dw XT_DROP
92  
93 .dw XT_EXIT
94  
95 PFA_FIND3:
96 .dw XT_R_FROM
97 .dw XT_DUP
98 .dw XT_TO_R
99 .dw XT_SWAP
100 .dw XT_IFETCH
101 .dw XT_DOBRANCH
102 .dw PFA_FIND1
103  
104 PFA_FIND2:
105 .dw XT_DROP
106 .dw XT_DROP
107 .dw XT_R_FROM
108 .dw XT_ZERO
109 .dw XT_EXIT
110  
111 ; private headerless routine
112 ; compares counted string in RAM with counted string in flash
113 ;
114 ; ( addr -- -- [ addr 0 ] | [ xt [-1|1]] )
115 ; R( -- )
116 ; search dictionary
117 ;VE_ICOMPARE:
118 ; .db $04, &quot;icompare&quot;
119 ; .dw VE_HEAD
120 ; .set VE_HEAD = VE_ICOMPARE
121 XT_ICOMPARE:
122 .dw DO_COLON
123 PFA_ICOMPARE:
124 ; ( addr-ram addr-flash -- 0| +/-1
125 .dw XT_DUP
126 .dw XT_IFETCH
127 .dw XT_DUP
128 .dw XT_DOLITERAL
129 .dw $0080
130 .dw XT_AND
131 .dw XT_TO_R ; send immediate flag to r-stack
132 .dw XT_ZERO
133 .dw XT_TO_R
134 .dw XT_DOLITERAL
135 .dw $001f
136 .dw XT_AND
137 .dw XT_2SLASH
138 .dw XT_1PLUS
139 .dw XT_TO_R
140 PFA_ICOMPARE1:
141 .dw XT_OVER
142 .dw XT_OVER
143 .dw XT_IFETCH
144 .dw XT_DOLITERAL
145 .dw $ff7f
146 .dw XT_AND
147 .dw XT_SWAP
148 .dw XT_FETCH
149 .dw XT_EQUAL
150 .dw XT_DOCONDBRANCH
151 .dw PFA_ICOMPARE3
152 ; increment pointers, 1 CELL for FLASH, 2 bytes for RAM
153 .dw XT_1PLUS
154 .dw XT_SWAP
155 .dw XT_1PLUS
156 .dw XT_1PLUS
157 .dw XT_SWAP
158 ; decrement cell counter, leave loop for zero
159 .dw XT_R_FROM
160 .dw XT_1MINUS
161 .dw XT_DUP
162 .dw XT_TO_R
163 .dw XT_EQUALZERO
164 .dw XT_DOCONDBRANCH
165 .dw PFA_ICOMPARE2
166 ; we found matching strings
167 .dw XT_R_FROM
168 .dw XT_R_FROM
169 .dw XT_DROP
170 .dw XT_DOLITERAL
171 .dw 1
172 .dw XT_TO_R
173 .dw XT_TO_R
174 .dw XT_DOBRANCH
175 .dw PFA_ICOMPARE3
176 PFA_ICOMPARE2:
177 .dw XT_DOBRANCH
178 .dw PFA_ICOMPARE1
179  
180 PFA_ICOMPARE3:
181 .dw XT_SWAP
182 .dw XT_DROP
183 .dw XT_R_FROM
184 .dw XT_PLUS
185 .dw XT_R_FROM
186 .dw XT_R_FROM
187 .dw XT_EQUALZERO
188 .dw XT_DOCONDBRANCH
189 .dw PFA_ICOMPARE4
190 .dw XT_NEGATE
191 PFA_ICOMPARE4:
192 .dw XT_EXIT
193 </pre>
194  
195 <p>
196 <input type=button onClick="history.back()" value="Back">
197 <input type=button onClick="history.forward()" value="Forward">
198 <a href="../WordList.en.html">Jump to Vocabulary</a>
199 </p>
200  
201 </div>
202  
203 <!-- AUTOINCLUDE START "Page/Footer.en.ihtml" DO NOT REMOVE -->
204 <!-- ============== FOOTER ============== -->
205 <div class="Footer">
206 <script type="text/javascript">
207 <!--
208 SetRelativePath("../../../../");
209 DrawFooter();
210 // -->
211 </script>
212 <noscript>
213 <p><b> JavaScript is required for including of the footer </b></p>
214 </noscript>
215 </div>
216 <!-- AUTOINCLUDE END -->
217  
218 </body>
219 </html>