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/istore.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/istore.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 ; ( n addr -- ) Memory
61 ; R( -- )
62 ; writes a cell in flash
63 VE_ISTORE:
64 .db $02, &quot;i!&quot;,0
65 .dw VE_HEAD
66 .set VE_HEAD = VE_ISTORE
67 XT_ISTORE:
68 .dw DO_COLON
69 PFA_ISTORE:
70 .dw XT_INTOFF
71 .dw XT_TO_R
72 .dw XT_OVER
73 .dw XT_OVER
74 .dw XT_SPMBUF
75  
76 .dw XT_DUP
77 .dw XT_SPMPAGELOAD
78  
79 ; an erase cycle is only necessary
80 ; when changing a bit from 0 to 1
81 .dw XT_OVER
82 .dw XT_OVER
83 .dw XT_IFETCH
84 .dw XT_INVERT
85 .dw XT_AND
86 .dw XT_DOCONDBRANCH
87 .dw PFA_ISTORE_WRITE
88 .dw XT_DUP
89 .dw XT_SPMERASE
90 PFA_ISTORE_WRITE:
91 .dw XT_DUP
92 .dw XT_SPMWRITE
93 .dw XT_SPMRWW
94 .dw XT_DROP
95 .dw XT_DROP
96 .dw XT_R_FROM
97 .dw XT_INTRESTORE
98 .dw XT_EXIT
99  
100  
101 ; ( addr -- )
102 ; R( -- )
103 ; load the flash page of cell addr into write buffer, omitting addr itself
104 ;VE_SPMPAGELOAD:
105 ; .db 11, &quot;spmpageload&quot;
106 ; .dw VE_HEAD
107 ; .set VE_HEAD = VE_INTSPMPAGELOAD
108 XT_SPMPAGELOAD:
109 .dw DO_COLON
110 PFA_SPMPAGELOAD:
111 .dw XT_DUP
112 .dw XT_TO_R
113 .dw XT_DOLITERAL
114 .dw PAGEMASK
115 .dw XT_AND
116 .dw XT_DOLITERAL
117 .dw PAGESIZE
118 .dw XT_SWAP
119 PFA_SPMPAGELOAD1:
120 .dw XT_OVER
121 .dw XT_GREATERZERO
122 .dw XT_DOCONDBRANCH
123 .dw PFA_SPMPAGELOADDONE
124 .dw XT_R_FROM
125 .dw XT_DUP
126 .dw XT_TO_R
127 .dw XT_OVER
128 .dw XT_NOTEQUAL
129 .dw XT_DOCONDBRANCH
130 .dw PFA_SPMPAGELOAD3
131 .dw XT_DUP
132 .dw XT_IFETCH
133 .dw XT_OVER
134 .dw XT_SPMBUF
135 PFA_SPMPAGELOAD3: ;( size addr -- )
136 .dw XT_1PLUS
137 .dw XT_SWAP
138 .dw XT_1MINUS
139 .dw XT_SWAP
140 .dw XT_DOBRANCH
141 .dw PFA_SPMPAGELOAD1
142 PFA_SPMPAGELOADDONE:
143 .dw XT_DROP
144 .dw XT_DROP
145 .dw XT_R_FROM
146 .dw XT_DROP
147 .dw XT_EXIT
148  
149 ; ( spmcsr x addr -- )
150 ; R( -- )
151 ; execute spm instruction
152 ;VE_DOSPM:
153 ; .db $03, &quot;(spm)&quot;
154 ; .dw VE_HEAD
155 ; .set VE_HEAD = VE_DOSPM
156 XT_DOSPM:
157 .dw PFA_DOSPM
158 PFA_DOSPM:
159 ; wait for pending spm instruction
160 PFA_DOSPM1:
161 in temp1, SPMCR
162 andi temp1, (1&lt;&lt;SPMEN)
163 brne PFA_DOSPM1
164  
165 PFA_DOSPM2:
166 sbic EECR, EEWE
167 rjmp PFA_DOSPM2
168  
169 ; address
170 movw zl, tosl
171 lsl zl
172 rol zh
173 ; value
174 ld r0, Y+
175 ld r1, Y+
176 ; command
177 ld temp0, Y+
178 ld temp1, Y+
179 ; spm timed sequence
180 out SPMCR, temp0
181 spm
182 loadtos
183 rjmp DO_NEXT
184  
185 ; ( x addr -- )
186 ; R( -- )
187 ; execute spm buf instruction
188 ;VE_SPMBUF:
189 ; .db $06, &quot;spmbuf&quot;,0
190 ; .dw VE_HEAD
191 ; .set VE_HEAD = VE_SPMBUF
192 XT_SPMBUF:
193 .dw DO_COLON
194 PFA_SPMBUF:
195 .dw XT_TO_R
196 .dw XT_TO_R
197 .dw XT_DOLITERAL
198 .dw (1&lt;&lt;SPMEN)
199 .dw XT_R_FROM
200 .dw XT_R_FROM
201 .dw XT_DOSPM
202 .dw XT_EXIT
203  
204 ; ( addr -- )
205 ; R( -- )
206 ; execute spm erase instruction
207 ;VE_SPMERASE:
208 ; .db $08, &quot;spmerase&quot;,0
209 ; .dw VE_HEAD
210 ; .set VE_HEAD = VE_SPMERASE
211 XT_SPMERASE:
212 .dw DO_COLON
213 PFA_SPMERASE:
214 .dw XT_DOLITERAL
215 .dw PAGEMASK
216 .dw XT_AND
217 .dw XT_TO_R
218 .dw XT_DOLITERAL
219 .dw (1&lt;&lt;PGERS|1&lt;&lt;SPMEN)
220 .dw XT_ZERO
221 .dw XT_R_FROM
222 .dw XT_DOSPM
223 .dw XT_EXIT
224  
225 ; ( spmcsr x addr -- )
226 ; R( -- )
227 ; execute spm write instruction
228 ;VE_SPMWRITE:
229 ; .db $08, &quot;spmwrite&quot;,0
230 ; .dw VE_HEAD
231 ; .set VE_HEAD = VE_WPMWRITE
232 XT_SPMWRITE:
233 .dw DO_COLON
234 PFA_SPMWRITE:
235 .dw XT_DOLITERAL
236 .dw PAGEMASK
237 .dw XT_AND
238 .dw XT_TO_R
239 .dw XT_DOLITERAL
240 .dw (1&lt;&lt;PGWRT|1&lt;&lt;SPMEN)
241 .dw XT_ZERO
242 .dw XT_R_FROM
243 .dw XT_DOSPM
244 .dw XT_EXIT
245  
246 ; ( -- )
247 ; R( -- )
248 ; re-enables rww section execute spm rww instruction
249 ;VE_SPMRWW:
250 ; .db $05, &quot;spmrww&quot;
251 ; .dw VE_HEAD
252 ; .set VE_HEAD = VE_SPMRWW
253 XT_SPMRWW:
254 .dw DO_COLON
255 PFA_SPMRWW:
256 .dw XT_DOLITERAL
257 .dw (1&lt;&lt;RWWSRE|1&lt;&lt;SPMEN)
258 .dw XT_ZERO
259 .dw XT_ZERO
260 .dw XT_DOSPM
261 .dw XT_EXIT
262  
263 </pre>
264  
265 <p>
266 <input type=button onClick="history.back()" value="Back">
267 <input type=button onClick="history.forward()" value="Forward">
268 <a href="../WordList.en.html">Jump to Vocabulary</a>
269 </p>
270  
271 </div>
272  
273 <!-- AUTOINCLUDE START "Page/Footer.en.ihtml" DO NOT REMOVE -->
274 <!-- ============== FOOTER ============== -->
275 <div class="Footer">
276 <script type="text/javascript">
277 <!--
278 SetRelativePath("../../../../");
279 DrawFooter();
280 // -->
281 </script>
282 <noscript>
283 <p><b> JavaScript is required for including of the footer </b></p>
284 </noscript>
285 </div>
286 <!-- AUTOINCLUDE END -->
287  
288 </body>
289 </html>