51
51
\ 2015-05-31: Fix: `editor` is immediate! It needed a
52
52
\ `[compile]`. Improvement: the bounds of zones can be marked
53
53
\ with "unlabeled".
54
+ \
55
+ \ 2015-06-02: Fix: the loop in `do-colon-zone` didn't
56
+ \ processed the last word of the definition.
54
57
55
58
\ -----------------------------------------------------------
56
59
@@ -196,18 +199,6 @@ vocabulary print-voc immediate print-voc definitions hex
196
199
\ Start a new pfa zone. Used after a string or a literal.
197
200
: new-pfa-zone ( pfa+n -- ) zone-first ! 1 pfa-zone# +! ;
198
201
199
- ( Special zones )
200
-
201
- \ The word compiled after `COMPILE` does not need a specific
202
- \ zone, because the pfa is marked as "pointers zone". Only
203
- \ the current address must be updated, to prevent the
204
- \ compiled cfa to be checked as part of the executable
205
- \ definition.
206
-
207
- : do-compile-zone ( pfa+n -- pfa+n+2 ) 2+ ;
208
- \ pfa+n = Address of `COMPILE` in the current pfa.
209
- \ pfa+n+2 = Address after the data word minus 2.
210
-
211
202
\ Do a specific zone for a compiled literal. It will be a
212
203
\ "wordata zone" with a unique address-based name.
213
204
@@ -220,6 +211,27 @@ vocabulary print-voc immediate print-voc definitions hex
220
211
\ pfa+n+2 = Address of the byte after the literal minus 2.
221
212
dup end-pfa-zone (do-literal-zone) dup 2+ new-pfa-zone ;
222
213
214
+ ( Special zones )
215
+
216
+ \ Flag: Was the last word of the definition a branch?
217
+ 0 variable final-branch?
218
+
219
+ : do-branch-zone ( pfa+n -- pfa+n+2 )
220
+ \ pfa+n = Address of the cf that precedes the compiled
221
+ \ literal.
222
+ \ pfa+n+2 = Address of the byte after the literal minus 2.
223
+ final-branch? on do-literal-zone ;
224
+
225
+ \ The word compiled after `COMPILE` does not need a specific
226
+ \ zone, because the pfa is marked as "pointers zone". Only
227
+ \ the current address must be updated, to prevent the
228
+ \ compiled cfa to be checked as part of the executable
229
+ \ definition.
230
+
231
+ : do-compile-zone ( pfa+n -- pfa+n+2 ) 2+ ;
232
+ \ pfa+n = Address of `COMPILE` in the current pfa.
233
+ \ pfa+n+2 = Address after the data word minus 2.
234
+
223
235
\ Do a specific zone for a compiled string. It will be a a
224
236
\ "bytedata zone" (z80dasm does not provide text zones) with
225
237
\ a unique address-based name.
@@ -252,16 +264,15 @@ vocabulary print-voc immediate print-voc definitions hex
252
264
\ The words that manage every individual case must
253
265
\ return the received address updated, pointing to the byte
254
266
\ after the data minus 2.
255
- dup @
267
+ final-branch? off dup @
256
268
case
257
- [ ' compile cfa ] literal of do-compile-zone endof
258
- [ ' lit cfa ] literal of do-literal-zone endof
259
- [ ' branch cfa ] literal of do-literal-zone endof
260
- [ ' 0branch cfa ] literal of do-literal-zone endof
261
- [ ' (loop) cfa ] literal of do-literal-zone endof
262
- [ ' (+loop) cfa ] literal of do-literal-zone endof
263
- [ ' (.") cfa ] literal of do-string-zone endof
264
- [ ' slit cfa ] literal of do-string-zone endof
269
+ [ ' compile cfa ] literal of do-compile-zone endof
270
+ [ ' lit cfa ] literal of do-literal-zone endof
271
+ [ ' branch cfa ] literal of do-branch-zone endof
272
+ [ ' 0branch cfa ] literal of do-branch-zone endof
273
+ [ ' (loop) cfa ] literal of do-branch-zone endof
274
+ [ ' (+loop) cfa ] literal of do-branch-zone endof
275
+ [ ' (.") cfa ] literal of do-string-zone endof
265
276
endcase ;
266
277
267
278
( Checks )
@@ -330,9 +341,17 @@ false variable semicolon-code?
330
341
331
342
: do-colon-zone ( pfa --- )
332
343
\ Print a colon definition.
333
- dup begin dup colon-end? 0=
334
- while do-special-zones 2+
335
- repeat 1+ zone-last ! pfa-label$ pointers-zone
344
+ \ XXX OLD -- buggy
345
+ \ dup begin dup colon-end? 0=
346
+ \ while do-special-zones 2+
347
+ \ repeat 1+ zone-last ! pfa-label$ pointers-zone
348
+ dup begin dup colon-end? >r
349
+ do-special-zones 2+ r> until 2-
350
+ \ If the word was not finished by a branch,
351
+ \ create the end of the pointers zone.
352
+ final-branch? @ 0=
353
+ if 1+ zone-last ! pfa-label$ pointers-zone
354
+ else drop then
336
355
\ If the word was finished by `;code`, define a code zone
337
356
\ for z80dasm.
338
357
semicolon-code? @
@@ -414,7 +433,7 @@ false variable semicolon-code?
414
433
cr ." ; This file was automatically created by "
415
434
program-name cr
416
435
." ; This file is part of Abersoft Forth disassembled" cr
417
- ." ; By Marcos Cruz (programandala.net), 2015-05 " cr
436
+ ." ; By Marcos Cruz (programandala.net), 2015" cr
418
437
." ; http://programandala.net/en.program.abersoft_forth.html"
419
438
cr cr ;
420
439
0 commit comments