Skip to content

Commit dbd47ca

Browse files
Update from development backup 201506020137
1 parent 6db2284 commit dbd47ca

10 files changed

+213
-58
lines changed

Makefile

+10-3
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ abersoftforth2z80dasmblocks: abersoftforth2z80dasmblocks_compiling.tap
205205

206206
abersoftforth2z80dasmblocks_compiling.tap: \
207207
abersoftforth2z80dasmblocks.tap \
208-
afera_for_disassembling.tap
208+
afera_for_disassembling.tap \
209+
patch_question_stack.tap
209210
cat \
210211
abersoft_forth.original.tap \
211212
lib/loader.tap \
@@ -216,6 +217,7 @@ abersoftforth2z80dasmblocks_compiling.tap: \
216217
lib/recurse.tap \
217218
lib/decode.tap \
218219
lib/lowersys.tap \
220+
patch_question_stack.tap \
219221
lib/bank.tap \
220222
lib/16kramdisks.tap \
221223
lib/upperc.tap \
@@ -236,7 +238,9 @@ abersoftforth2z80dasmblocks_compiling.tap: \
236238

237239
abersoftforth2nfa4vim: abersoftforth2nfa4vim_compiling.tap
238240

239-
abersoftforth2nfa4vim_compiling.tap: abersoftforth2nfa4vim.tap
241+
abersoftforth2nfa4vim_compiling.tap: \
242+
abersoftforth2nfa4vim.tap \
243+
patch_question_stack.tap
240244
cat \
241245
abersoft_forth.original.tap \
242246
lib/loader.tap \
@@ -247,6 +251,7 @@ abersoftforth2nfa4vim_compiling.tap: abersoftforth2nfa4vim.tap
247251
lib/recurse.tap \
248252
lib/decode.tap \
249253
lib/lowersys.tap \
254+
patch_question_stack.tap \
250255
lib/bank.tap \
251256
lib/48kq.tap \
252257
lib/16kramdisks.tap \
@@ -271,7 +276,8 @@ abersoftforth2branches: abersoftforth2branches_compiling.tap
271276

272277
abersoftforth2branches_compiling.tap: \
273278
abersoftforth2branches.tap \
274-
afera_for_disassembling.tap
279+
afera_for_disassembling.tap \
280+
patch_question_stack.tap
275281
cat \
276282
abersoft_forth.original.tap \
277283
lib/loader.tap \
@@ -282,6 +288,7 @@ abersoftforth2branches_compiling.tap: \
282288
lib/recurse.tap \
283289
lib/decode.tap \
284290
lib/lowersys.tap \
291+
patch_question_stack.tap \
285292
lib/bank.tap \
286293
lib/48kq.tap \
287294
lib/16kramdisks.tap \

TO-DO.adoc

+9-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,12 @@ Document `cold_start`, `COLD`, `warm_start` and `WARM`.
1212

1313
Make the automatic blocks unlabeled?
1414

15-
Tidy the strings.
15+
.2015-06-02:
16+
17+
Unpatch `r/w`, at least its branch, before creating the branches.
18+
19+
Document l706dh.
20+
21+
Document `mon`.
22+
23+
Document 0xCBE0.

_notes_about_integer_division.adoc

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
= Abersoft Forth integer division
2+
:author: Marcos Cruz (programandala.net)
3+
:revdate: 2015-06-02
4+
5+
|===
6+
7+
| Calculation | Abersoft Forth | SpecForth | 40/80 Forth | WL | Spectrum Forth-83 | Gforth
8+
9+
| 10 7 /mod . . | 1 3 | | | | |
10+
| -10 7 /mod . . | -1 -3 | | | | |
11+
| 10 -7 /mod . . | -1 -3 | | | | |
12+
| -10 -7 /mod . . | 1 -3 | | | | |
13+
14+
| -64 128 mod | -64 | 64 | -64 |-64 | 64 | 64
15+
| | | | | | |
16+
| | | | | | |
17+
| | | | | | |
18+
| | | | | | |
19+
| | | | | | |
20+
| | | | | | |
21+
| | | | | | |
22+
| | | | | | |
23+
24+
|===

abersoftforth2branches.fsb

+16-9
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,13 @@
3939
\
4040
\ 2015-05-31: Fix: `editor` is immediate! It needed a
4141
\ `[compile]`.
42-
42+
\
43+
\ 2015-06-01: Fix: the loop in `print-colon` didn't processed
44+
\ the last word of the definition.
45+
\
4346
\ -----------------------------------------------------------
4447

45-
forth
48+
forth
4649

4750
\ <------------------------------>
4851
128k? dup ?\ ." ERROR: this program needs a" cr
@@ -162,9 +165,9 @@ vocabulary print-voc immediate print-voc definitions hex
162165
' addr ! true
163166
addr @ [ ' ;s cfa ] literal = ?exit
164167
addr @ [ ' (;code) cfa ] literal = ?exit
165-
addr 6E04 = ?exit \ end of COLD
168+
addr 6E08 = ?exit \ end of COLD (original, not patched)
166169
addr 6DAE = ?exit \ end of WARM
167-
addr 6D6A = ?exit \ end of ABORT
170+
addr 6D91 = ?exit \ end of ABORT (original, not patched)
168171
addr 6C99 = ?exit \ end of INTERPRET
169172
addr 6B2A = ?exit \ end of ERROR
170173
addr 6D4C = ?exit \ end of QUIT
@@ -187,9 +190,13 @@ vocabulary print-voc immediate print-voc definitions hex
187190

188191
: print-colon ( pfa --- )
189192
\ Print branches of a colon definition.
190-
dup current-pfa ! begin dup colon-end? 0=
191-
while (print-colon) 2+
192-
repeat drop ;
193+
\ XXX OLD -- buggy
194+
\ dup current-pfa ! begin dup colon-end? 0=
195+
\ while (print-colon) 2+
196+
\ repeat drop ;
197+
\ XXX NEW
198+
dup current-pfa !
199+
begin dup colon-end? >r (print-colon) 2+ r> until drop ;
193200

194201
( print-pfa )
195202

@@ -223,7 +230,7 @@ vocabulary print-voc immediate print-voc definitions hex
223230
." program with the provided" cr
224231
." boot shell file for Fuse, copy" cr
225232
." the printout of your emulator" cr
226-
." to the file "
233+
." to the file "
227234
mode @ if cr ." <z80dasm_symbols.branches.z80s>."
228235
else ." <tidy_branches.vim>." then cr
229236
." Then close the emulator and use" cr
@@ -235,7 +242,7 @@ vocabulary print-voc immediate print-voc definitions hex
235242
: file-header ( -- )
236243
~ ." This file was automatically created by " program-name
237244
~ ." This file is part of Abersoft Forth disassembled"
238-
~ ." By Marcos Cruz (programandala.net), 2015-05"
245+
~ ." By Marcos Cruz (programandala.net), 2015"
239246
~ ." http://programandala.net/en.program.abersoft_forth.html"
240247
cr cr ;
241248

abersoftforth2nfa4vim.fsb

+1-1
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ char " constant quote
251251
: file-header ( -- )
252252
" ." This file was automatically created by " program-name
253253
" ." This file is part of Abersoft Forth disassembled"
254-
" ." By Marcos Cruz (programandala.net), 2015-05"
254+
" ." By Marcos Cruz (programandala.net), 2015"
255255
" ." http://programandala.net/en.program.abersoft_forth.html"
256256
cr cr ;
257257

abersoftforth2z80dasmblocks.fsb

+44-25
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@
5151
\ 2015-05-31: Fix: `editor` is immediate! It needed a
5252
\ `[compile]`. Improvement: the bounds of zones can be marked
5353
\ with "unlabeled".
54+
\
55+
\ 2015-06-02: Fix: the loop in `do-colon-zone` didn't
56+
\ processed the last word of the definition.
5457

5558
\ -----------------------------------------------------------
5659

@@ -196,18 +199,6 @@ vocabulary print-voc immediate print-voc definitions hex
196199
\ Start a new pfa zone. Used after a string or a literal.
197200
: new-pfa-zone ( pfa+n -- ) zone-first ! 1 pfa-zone# +! ;
198201

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-
211202
\ Do a specific zone for a compiled literal. It will be a
212203
\ "wordata zone" with a unique address-based name.
213204

@@ -220,6 +211,27 @@ vocabulary print-voc immediate print-voc definitions hex
220211
\ pfa+n+2 = Address of the byte after the literal minus 2.
221212
dup end-pfa-zone (do-literal-zone) dup 2+ new-pfa-zone ;
222213

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+
223235
\ Do a specific zone for a compiled string. It will be a a
224236
\ "bytedata zone" (z80dasm does not provide text zones) with
225237
\ a unique address-based name.
@@ -252,16 +264,15 @@ vocabulary print-voc immediate print-voc definitions hex
252264
\ The words that manage every individual case must
253265
\ return the received address updated, pointing to the byte
254266
\ after the data minus 2.
255-
dup @
267+
final-branch? off dup @
256268
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
265276
endcase ;
266277

267278
( Checks )
@@ -330,9 +341,17 @@ false variable semicolon-code?
330341

331342
: do-colon-zone ( pfa --- )
332343
\ 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
336355
\ If the word was finished by `;code`, define a code zone
337356
\ for z80dasm.
338357
semicolon-code? @
@@ -414,7 +433,7 @@ false variable semicolon-code?
414433
cr ." ; This file was automatically created by "
415434
program-name cr
416435
." ; 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
418437
." ; http://programandala.net/en.program.abersoft_forth.html"
419438
cr cr ;
420439

afera_for_disassembling.fsb

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
\ -----------------------------------------------------------
1111
\ Description
1212

13-
\ This is a modifed version of <afera.fsb>, the main file of
13+
\ This is a modified version of <afera.fsb>, the main file of
1414
\ the Afera library.
1515
\
1616
\ It does the same than the original one except some

patch_question_stack.fsb

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
.( Patch ?STACK )
2+
3+
\ patch_question_stack.fsb
4+
5+
\ Copyright (C) 2015 Marcos Cruz (programandala.net)
6+
7+
\ This file is part of
8+
\ Abersoft Forth disassembled
9+
\ <http://programandala.net/
10+
\ en.program.abersoft_forth_disassembled.html>.
11+
12+
\ -----------------------------------------------------------
13+
\ Description
14+
15+
\ This file modifies the patch of `?stacks` created by the
16+
\ Afera module <lowersys.fsb>, in order to make the patched
17+
\ `?stacks' have the same size than its original version.
18+
19+
\ -----------------------------------------------------------
20+
\ History
21+
22+
\ 2015-06-01.
23+
24+
HERE
25+
26+
' NOOP CFA , ' NOOP CFA , ' ;S CFA ,
27+
28+
DUP \ Origin: start of the compiled patch.
29+
' ?STACK 28 + \ Destination.
30+
OVER HERE SWAP - CMOVE \ Do it.
31+
DP ! \ Free the space of the compiled patch.
32+
33+
\ vim: filetype=abersoftforthafera
34+

0 commit comments

Comments
 (0)