1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3 ;; based on AberSoft FIG-Forth v1.1A
4 ;; restored & partially rewritten by Ketmar
5 ;; distribution terms: GNU GPL v3
6 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
9 ;; excuse me my English, i'm not a native speaker
10 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11 ;; the code has to be optimized!!!
12 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
15 USE_SMALL_MULDIV EQU 0
17 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
26 ;; bit 5: SMUDGE flag (=1: word definition isn't finished)
27 ;; bit 6: IMMEDIATE flag (=1: true)
29 ;; the last byte of the name always has bit 7 set
31 ;; for CODE words: cfa points to the body
32 ;; for FORTH words: cfa points to "_doforth"
33 ;; for CONST words: cfa points to "_doconst"
34 ;; for VAR words: cfa points to "_dovar"
35 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
37 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
40 ;; BC: address interpreter insrtuction pointer
42 ;; IY: used by ROM, do not change
43 ;; all other regs are free
46 ;; data stack: machine stask (PUSH/POP)
47 ;; exec stack: address with f_curRP (last item)
48 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
52 ;; start address: #6000
55 jp run_0 ;; DO NOT CHANGE THIS TO JR!
63 ; save byte at #C000 for 48K
74 out (c),a ;; now #C000 should be the screen page #5
75 ld (#C000),a ;; trash it
77 out (c),a ;; and go back (just in case) %-)
79 or a ;; now check if we really trashed the scrren
100 ;;;;;;;;;;;;;;; VARIABLES
105 f_curRP: defw #D7AE ;; ???
107 ;; address of the first "user" variable (def: run_cold-64)
108 f_userBASE: defw #D7B0
114 defw #D600 ;; S0: starting SP. SP grows to addr #0000
115 defw #D7AE ;; R0: starting RP. RP grows to addr #0000
119 defw latest_byte ;; FENCE
120 defw latest_byte ;; DP
121 defw forth_voc_link ;; VOC-LINK
122 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
124 ;;; address interpreter
145 ;;; end of address interpreter
148 $FORTH_CONST (.NEXT) i_next
149 $FORTH_CONST (.PUSHHL) i_pushhl
150 $FORTH_CONST (.PUSHDEHL) i_pushde
151 $FORTH_CONST (@CUR-RP) f_curRP
152 $FORTH_CONST (@CUR-BASE) f_userBASE
153 $FORTH_CONST (LAST-7FFD) f_cur7FFD
165 $FORTH_END_CODE_WORD LIT
167 $FORTH_CODE_WORD EXECUTE
172 $FORTH_END_CODE_WORD EXECUTE
174 $FORTH_CODE_WORD BRANCH FBRANCH
187 $FORTH_END_CODE_WORD BRANCH
189 $FORTH_CODE_WORD 0BRANCH FBRANCH
199 $FORTH_END_CODE_WORD 0BRANCH
201 $FORTH_CODE_WORD TBRANCH FBRANCH
208 $FORTH_END_CODE_WORD TBRANCH
210 $FORTH_CODE_WORD (LOOP) FBRANCH
247 $FORTH_END_CODE_WORD (LOOP)
249 $FORTH_CODE_WORD (+LOOP) FBRANCH
253 $FORTH_END_CODE_WORD (+LOOP)
255 $FORTH_CODE_WORD (DO)
273 $FORTH_END_CODE_WORD (DO)
283 $FORTH_END_CODE_WORD I
295 $FORTH_END_CODE_WORD I'
309 $FORTH_END_CODE_WORD J
311 $FORTH_CODE_WORD DIGIT
332 $FORTH_END_CODE_WORD DIGIT
334 $FORTH_CODE_WORD (FIND)
336 ;; ( addr l addr2 -- pfa b tf ok)
337 ;; ( addr l addr2 -- ff bad)
385 $FORTH_END_CODE_WORD (FIND)
387 $FORTH_CODE_WORD ENCLOSE
389 ;; ( addr delimeter -- addr w_start_ofs w_end_ofs next_scan_ofs )
390 pop de ;; E=delimeter
399 ;; here: E=word len; A=delim; HL=addr
408 push de ;; store # of delimiters before the word
410 ld d,a ;; D=delimiter
411 ;; check for "end of buffer" (#0)
416 ;; oops... no more blondies on the island
419 push de ;; store full length
422 push de ;; store position of the next char to scan
425 ;; here: E=word len; D=delim; HL=addr
427 ;; now collect the word itself
432 jr z,enclose2 ;; word ends?
433 ;; no, check "end of buffer"
438 ;; oops... no more blondies on the island
440 push de ;; store full length
441 push de ;; store position of the next char to scan (???)
446 push de ;; store full length
448 push de ;; store position of the next char to scan
450 $FORTH_END_CODE_WORD ENCLOSE
452 ;; check if BREAK is pressed
453 $FORTH_CODE_WORD ?BREAK
457 call #1F54 ;; uses only A
462 $FORTH_END_CODE_WORD ?BREAK
464 $FORTH_CODE_WORD PAGE-CMOVE
466 ;; CMOVE with page swapping
467 ;; ( from to len destpage -- )
468 ;; addr must be >= #C000
471 ;;AND #07 ; we can have much more memory
472 ; get other args and save BC
477 ex (sp),hl ; save BC and get src
493 $FORTH_END_CODE_WORD PAGE-CMOVE
495 $FORTH_CODE_WORD CMOVE
497 ;; ( from to len -- )
510 $FORTH_END_CODE_WORD CMOVE
512 $FORTH_CODE_WORD FILL
532 $FORTH_END_CODE_WORD FILL
535 include "fastmuldiv_small.zas"
537 include "fastmuldiv.zas"
540 $FORTH_CODE_WORD 256U*
547 $FORTH_END_CODE_WORD 256U*
549 $FORTH_CODE_WORD 256U/
556 $FORTH_END_CODE_WORD 256U/
566 $FORTH_END_CODE_WORD 2U/
576 $FORTH_END_CODE_WORD 2U*
578 $FORTH_CODE_WORD 2UMOD
587 $FORTH_END_CODE_WORD 2UMOD
589 $FORTH_CODE_WORD 256UMOD
595 $FORTH_END_CODE_WORD 256UMOD
609 $FORTH_END_CODE_WORD AND
612 $FORTH_CODE_WORD LAND
614 ;; ( n0 n1 -- 0 or 1 )
626 $FORTH_END_CODE_WORD LAND
640 $FORTH_END_CODE_WORD OR
645 ;; ( n0 n1 -- 0 or 1 )
658 $FORTH_END_CODE_WORD LOR
661 $FORTH_CODE_WORD NOTNOT
670 $FORTH_END_CODE_WORD NOTNOT
684 $FORTH_END_CODE_WORD XOR
693 $FORTH_END_CODE_WORD SP@
703 $FORTH_END_CODE_WORD sp!
711 $FORTH_END_CODE_WORD RP@
720 $FORTH_END_CODE_WORD RP!
722 ;; end of "colon" word
733 $FORTH_END_CODE_WORD ;S
735 ;; DO/LOOP will stop on the next iteration
736 $FORTH_CODE_WORD LEAVE
748 $FORTH_END_CODE_WORD LEAVE
750 ;; move value from paremeter stack to execution stack
763 $FORTH_END_CODE_WORD >R
765 ;; move value from execution stack to paremeter stack
776 $FORTH_END_CODE_WORD R>
778 ;; copy value from execution stack to paremeter stack
788 $FORTH_END_CODE_WORD R@
790 $FORTH_CODE_WORD RDROP
797 $FORTH_END_CODE_WORD RDROP
811 $FORTH_END_CODE_WORD 0=
817 $FORTH_END_CODE_WORD NOT
830 $FORTH_END_CODE_WORD 0<
851 $FORTH_END_CODE_WORD <
856 2DUP XOR 0< 0BRANCH uless0
857 DROP 0< 0= BRANCH uless1
901 $FORTH_END_CODE_WORD <>
911 $FORTH_END_CODE_WORD !=
930 $FORTH_END_CODE_WORD 1+
938 $FORTH_END_CODE_WORD 2+
948 $FORTH_END_CODE_WORD 4+
955 $FORTH_END_CODE_WORD 1-
963 $FORTH_END_CODE_WORD 2-
973 $FORTH_END_CODE_WORD 4-
982 $FORTH_END_CODE_WORD +
992 $FORTH_END_CODE_WORD -
1013 $FORTH_END_CODE_WORD D+
1016 ;; TODO: error on -32768?
1017 $FORTH_CODE_WORD NEGATE
1025 $FORTH_END_CODE_WORD NEGATE
1028 ;; TODO: error on MAXLONGINT?
1029 $FORTH_CODE_WORD DNEGATE
1048 $FORTH_END_CODE_WORD DNEGATE
1050 $FORTH_CODE_WORD DROP
1056 $FORTH_END_CODE_WORD DROP
1058 $FORTH_CODE_WORD 2DROP
1063 $FORTH_END_CODE_WORD 2DROP
1065 $FORTH_CODE_WORD OVER
1067 ;; ( n0 n1 -- n0 n1 n0 )
1072 $FORTH_END_CODE_WORD OVER
1076 ;; ( d0 d1 -- d0 d1 d0 )
1077 ;; k8: rewrite on asm?
1078 2SWAP 2DUP >R >R 2SWAP R> R> ;S
1079 $FORTH_END_WORD 2OVER
1081 $FORTH_CODE_WORD SWAP
1083 ;; ( n0 n1 -- n1 n0 )
1087 $FORTH_END_CODE_WORD SWAP
1091 ;; ( d0 d1 -- d1 d0 )
1092 ;; k8: rewrite on asm?
1094 $FORTH_END_WORD 2SWAP
1096 $FORTH_CODE_WORD DUP
1102 $FORTH_END_CODE_WORD DUP
1104 $FORTH_CODE_WORD -DUP
1106 ;; ( n -- n n ) if n is not 0
1107 ;; ( n -- n ) if n is 0
1114 $FORTH_END_CODE_WORD -DUP
1116 $FORTH_CODE_WORD 2DUP
1124 $FORTH_END_CODE_WORD 2DUP
1126 $FORTH_CODE_WORD ROT
1128 ;; ( n0 n1 n2 -- n1 n2 n0 )
1133 $FORTH_END_CODE_WORD ROT
1148 $FORTH_END_CODE_WORD +!
1150 $FORTH_CODE_WORD TOGGLE
1159 $FORTH_END_CODE_WORD TOGGLE
1178 $FORTH_END_CODE_WORD 2@
1187 $FORTH_END_CODE_WORD C@
1198 $FORTH_END_CODE_WORD @
1214 $FORTH_END_CODE_WORD 2!
1223 $FORTH_END_CODE_WORD C!
1234 $FORTH_END_CODE_WORD !
1236 $FORTH_CODE_WORD 0C!
1242 $FORTH_END_CODE_WORD 0C!
1252 $FORTH_END_CODE_WORD 0!
1254 $FORTH_CODE_WORD 1C!
1260 $FORTH_END_CODE_WORD 1C!
1270 $FORTH_END_CODE_WORD 1!
1273 $FORTH_CODE_WORD FORTH-WORD?
1290 $FORTH_END_CODE_WORD FORTH-WORD?
1295 ?EXEC !CSP CURRENT @ CONTEXT ! CREATE ]
1317 $FORTH_WORD CONSTANT
1321 $FORTH_END_WORD CONSTANT
1332 $FORTH_WORD VARIABLE
1335 $FORTH_END_WORD VARIABLE
1340 $FORTH_WORD 2CONSTANT
1342 CREATE SMUDGE HERE 2! 4 ALLOT
1344 $FORTH_END_WORD 2CONSTANT
1361 $FORTH_WORD 2VARIABLE
1365 $FORTH_END_WORD 2VARIABLE
1375 $FORTH_END_WORD USER
1386 ;;;;;;;;;;;;;; some speedup constants
1394 $FORTH_CONST c/l #40
1398 $FORTH_END_WORD +ORIGIN
1400 ;; these ones will be inited by COLD with the predefined values
1404 $FORTH_USER WIDTH #0C
1405 $FORTH_USER WARNING #0E
1406 $FORTH_USER FENCE #10
1408 $FORTH_USER VOC-LINK #14
1409 ;; these ones will not be inited by COLD
1412 $FORTH_USER READ-ONLY #1A
1414 ;; OFFSET is the offset for BLOCK operation
1415 ;; i.e. actual block number will be n+OFFSET
1416 $FORTH_USER OFFSET #1E
1417 $FORTH_USER CONTEXT #20
1418 $FORTH_USER CURRENT #22
1419 $FORTH_USER STATE #24
1420 $FORTH_USER BASE #26
1426 ;; new var for TLOAD
1427 $FORTH_USER TLOAD-Y #32
1428 $FORTH_USER SHOW-HIDDEN #34
1431 ;; 6x8 printing driver
1436 $FORTH_CODE_WORD BYE
1439 ;;;; return to BASIC?
1447 $FORTH_END_CODE_WORD BYE
1449 $FORTH_CODE_WORD 128K?
1455 $FORTH_END_CODE_WORD 128K?
1457 $FORTH_CODE_WORD 48K?
1461 jr z,cw_is_128k_done
1464 $FORTH_END_CODE_WORD 48K?
1466 $FORTH_WORD .CREDITZ
1468 (.") ~\n48K/128K dsFORTH v0.0.1\n~
1469 (.") ~original version: \x7F Abersoft, 1983\n~
1470 (.") ~modifications by Ketmar//Invisible Vector\n~
1471 ;; (.") ~distribution terms: GNU GPL\n~
1473 $FORTH_END_WORD .CREDITZ
1479 $FORTH_END_WORD HERE
1484 SP@ LIT 32 - DP @ U< 0BRANCH allot0 (.") ~ALLOT: out of memory!~ CR ABORT ;; "
1488 $FORTH_END_WORD ALLOT
1501 $FORTH_WORD TRAVERSE
1505 OVER + LIT 127 OVER C@ <
1508 $FORTH_END_WORD TRAVERSE
1514 $FORTH_END_WORD LATEST
1528 LIT 5 - LIT -1 TRAVERSE ;S
1533 1 TRAVERSE LIT 5 + ;S
1540 $FORTH_END_WORD !CSP
1545 SWAP 0BRANCH qerror0
1546 ERROR BRANCH qerror1
1551 $FORTH_END_WORD ?ERROR
1555 STATE @ 0= LIT 17 ?ERROR ;S
1556 $FORTH_END_WORD ?COMP
1560 STATE @ LIT 18 ?ERROR ;S
1561 $FORTH_END_WORD ?EXEC
1566 $FORTH_END_WORD ?PAIRS
1570 SP@ CSP @ - LIT 20 ?ERROR ;S
1571 $FORTH_END_WORD ?CSP
1573 $FORTH_WORD ?LOADING
1575 BLK @ 0= LIT 22 ?ERROR ;S
1576 $FORTH_END_WORD ?LOADING
1580 ?COMP R> DUP 2+ >R @ , ;S
1581 $FORTH_END_WORD COMPILE
1595 LATEST LIT #20 TOGGLE ;S
1596 $FORTH_END_WORD SMUDGE
1606 $FORTH_END_WORD DECIMAL
1610 R> LATEST PFA CFA ! ;S
1611 $FORTH_END_WORD (;CODE)
1613 $FORTH_WORD ;CODE IMM
1615 ?CSP COMPILE (;CODE)
1617 $FORTH_END_WORD ;CODE
1622 $FORTH_END_WORD <BUILDS
1628 $FORTH_END_WORD DOES>
1648 $FORTH_END_WORD COUNT
1650 $FORTH_WORD -TRAILING
1654 OVER OVER + 1- C@ BL - 0BRANCH ntrailing1
1655 LEAVE BRANCH ntrailing2
1661 $FORTH_END_WORD -TRAILING
1664 $FORTH_WORD ." IMM ;;"
1666 LIT 34 STATE @ 0BRANCH dotq0
1668 WORD C@ 1+ ALLOT BRANCH dotq1
1675 $FORTH_CODE_WORD (")
1686 $FORTH_END_CODE_WORD (") ;;"
1688 $FORTH_WORD " IMM ;; "
1691 ;; compile string into the current definition
1692 ;; or place it at PAD (depends of current STATE)
1693 LIT 34 STATE @ 0BRANCH dots0
1695 WORD C@ 1+ ALLOT BRANCH dots1
1700 $FORTH_END_WORD " ;;"
1702 include "editstr.zas"
1707 1- (EDITSTR-MAXLEN) ! (EDITSTR-ADDR) !
1708 (EDITSTR-LEN) 0! (EDITSTR-cp) 0!
1710 $FORTH_END_WORD EXPECT
1714 TIB @ LIT 80 EXPECT IN 0! ;S
1715 $FORTH_END_WORD QUERY
1717 ;; ~ will be changed to char with code 0 by ZASM
1718 ;; this word will be called by INTERPRET
1719 ;; when it meets the end of line marker (0x00)
1720 ;; zwb: break INTERPRET
1721 ;; zw2: continue INTERPRETING
1722 $FORTH_WORD ~ IMM ;; #0
1724 TLOAD-Y @ 0BRANCH zwx
1725 FREADLN 0BRANCH zwx1 ;; no more lines
1726 DROP TIB ! IN 0! BRANCH zw2
1728 TLOAD-Y 0! LIT f_userDEF 4+ @ DUP 0! TIB ! IN 0!
1733 1 BLK +! IN 0! BLK @ b/SCR 1- AND 0= 0BRANCH zw0
1748 $FORTH_END_WORD ERASE
1754 $FORTH_END_WORD BLANKS
1760 LIT -1 HLD +! HLD @ C! ;S
1761 $FORTH_END_WORD HOLD
1770 ;; read next word from the input stream
1771 ;; place it at HERE as the counted string
1774 ;; ( delimeter -- here )
1775 BLK @ 0BRANCH word0 ;; not LOADing?
1776 BLK @ BLOCK BRANCH word1 ;; else -- load block and get its address
1781 ;; ENCLOSE: ( addr delimeter -- addr w_start_ofs w_end_ofs next_scan_ofs )
1784 IN +! ;; ( addr w_start_ofs w_end_ofs )
1785 OVER - ;; ( addr w_start_ofs w_len )
1786 DUP >R HERE C! ;; length stored; ( addr w_start_ofs | w_len )
1789 $FORTH_END_WORD WORD
1791 $FORTH_WORD (NUMBER)
1794 1+ DUP >R C@ BASE @ DIGIT 0BRANCH xnumber2
1795 SWAP BASE @ U* DROP ROT BASE @ U* D+ DPL @ 1+ 0BRANCH xnumber1
1801 $FORTH_END_WORD (NUMBER)
1805 0 0 ROT DUP 1+ C@ LIT 45 = DUP >R + LIT -1
1807 DPL ! (NUMBER) DUP C@ BL - 0BRANCH number1
1808 DUP C@ LIT 46 - 0 ?ERROR 0
1811 DROP R> 0BRANCH number2
1815 $FORTH_END_WORD NUMBER
1817 ;; read next word from the input stream
1818 ;; search it in the dictionary
1821 ;; ( -- pfa b tf ok)
1823 BL WORD CONTEXT @ @ (FIND)
1824 DUP 0= 0BRANCH nfind0
1825 DROP HERE LATEST (FIND)
1828 $FORTH_END_WORD -FIND
1834 $FORTH_END_WORD (ABORT)
1840 WARNING @ 0< 0BRANCH error0
1843 HERE COUNT TYPE (.") ~? ~ MESSAGE ;; "
1844 sp! BLK @ -DUP 0BRANCH error1
1847 LIT f_userDEF 4+ @ TIB !
1849 $FORTH_END_WORD ERROR
1854 PAD LIT 32 LIT 95 FILL
1855 DUP PFA LFA OVER - PAD SWAP CMOVE
1856 PAD COUNT LIT 31 AND 2DUP + 1- DUP @ LIT #FF7F AND SWAP !
1862 -FIND 0BRANCH create0
1863 DROP NFA ID. 4 MESSAGE SPACE
1865 HERE DUP C@ WIDTH @ MIN 1+ ALLOT DUP
1866 LIT #A0 TOGGLE HERE 1- LIT #80 TOGGLE
1867 LATEST , CURRENT @ ! HERE 2+ , ;S
1868 $FORTH_END_WORD CREATE
1870 $FORTH_WORD [COMPILE] IMM
1872 -FIND 0= 0 ?ERROR DROP CFA , ;S
1873 $FORTH_END_WORD [COMPILE]
1875 $FORTH_WORD LITERAL IMM
1877 STATE @ 0BRANCH literal0
1881 $FORTH_END_WORD LITERAL
1883 $FORTH_WORD DLITERAL IMM
1885 STATE @ 0BRANCH dliteral0
1886 SWAP LITERAL LITERAL
1889 $FORTH_END_WORD DLITERAL
1893 SP@ S0 @ SWAP U< 1 ?ERROR SP@ HERE LIT 128 + U< LIT 7 ?ERROR ;S
1894 $FORTH_END_WORD ?STACK
1896 $FORTH_WORD INTERPRET
1899 -FIND 0BRANCH interpret3
1900 STATE @ < 0BRANCH interpret1
1901 CFA , BRANCH interpret2
1905 ?STACK BRANCH interpret6
1907 HERE NUMBER DPL @ 1+ 0BRANCH interpret4
1908 DLITERAL BRANCH interpret5
1915 $FORTH_END_WORD INTERPRET
1917 $FORTH_WORD IMMEDIATE
1919 LATEST LIT #40 TOGGLE ;S
1920 $FORTH_END_WORD IMMEDIATE
1922 $FORTH_WORD DEFINITIONS
1924 CONTEXT @ CURRENT ! ;S
1925 $FORTH_END_WORD DEFINITIONS
1932 ;;FIXME: NOT PROPERLY TESTED!
1935 BLK @ 0BRANCH cmt_eol_tib
1936 BLK @ BLOCK BRANCH cmt_eol_main ;; else -- load block and get its address
1941 IN @ + ;; ( staddr curaddr )
1946 DUP 0BRANCH cmt_eol_done
1948 DUP LIT 13 = TBRANCH cmt_eol_done
1949 DUP LIT 10 = TBRANCH cmt_eol_done
1955 ;;DEBUG: SPACE DUP U. CR
1965 RP! CR QUERY INTERPRET STATE @ 0= 0BRANCH quit1
1969 $FORTH_END_WORD QUIT
1974 sp! DECIMAL ?STACK .CREDITZ
1976 FORTH DEFINITIONS QUIT
1977 $FORTH_END_WORD ABORT
1982 ;; 8 1 16384 TR-SREAD
1985 $FORTH_END_WORD WARM
1990 FIRST BUF-USE ! FIRST BUF-PREV ! DR0
1991 ;; the first USER is at f_userBASE+6
1992 LIT f_userDEF LIT f_userBASE @ LIT 6 + LIT 16 CMOVE
1994 LIT f_userBASE @ LIT #1A + 0! ;; READ-ONLY
1995 LIT f_userBASE @ LIT #34 + 0! ;; SHOW-HIDDEN
1996 LIT latest_word LIT forth_voc_latest !
1997 LIT f_cur7FFD C@ LIT #7FFD OUTP
1999 $FORTH_END_WORD COLD
2002 ;; convert normal singed number to double
2003 $FORTH_CODE_WORD S->D
2014 $FORTH_END_CODE_WORD S->D
2040 $FORTH_END_WORD DABS
2062 2DUP U> 0BRANCH umin0
2067 $FORTH_END_WORD UMIN
2071 2DUP U< 0BRANCH umax0
2076 $FORTH_END_WORD UMAX
2081 2DUP XOR >R ABS SWAP ABS U* R> D+- ;S
2086 OVER >R >R DABS R@ ABS U/MOD R> R@ XOR +- SWAP R> +- SWAP ;S
2097 $FORTH_END_WORD /MOD
2112 $FORTH_END_WORD */MOD
2121 >R 0 R@ U/MOD R> SWAP >R U/MOD R> ;S
2122 $FORTH_END_WORD M/MOD
2125 ;; show warning message
2129 ;; show warning text?
2130 WARNING @ 0BRANCH message1
2131 ;; message #0 is "word?" show no warning text
2132 -DUP 0BRANCH message0
2133 ;; show message line
2134 4 OFFSET @ b/SCR / - .LINE SPACE
2141 $FORTH_END_WORD MESSAGE
2146 -FIND 0= 0 ?ERROR DROP LITERAL ;S
2152 $FORTH_END_WORD BACK
2154 $FORTH_WORD BEGIN IMM
2157 $FORTH_END_WORD BEGIN
2159 $FORTH_WORD ENDIF IMM
2161 ?COMP 2 ?PAIRS HERE OVER - SWAP ! ;S
2162 $FORTH_END_WORD ENDIF
2164 $FORTH_WORD THEN IMM
2167 $FORTH_END_WORD THEN
2175 $FORTH_WORD LOOP IMM
2177 3 ?PAIRS COMPILE (LOOP)
2179 $FORTH_END_WORD LOOP
2181 $FORTH_WORD +LOOP IMM
2183 3 ?PAIRS COMPILE (+LOOP)
2185 $FORTH_END_WORD +LOOP
2187 $FORTH_WORD UNTIL IMM
2189 1 ?PAIRS COMPILE 0BRANCH
2191 $FORTH_END_WORD UNTIL
2198 $FORTH_WORD AGAIN IMM
2200 1 ?PAIRS COMPILE BRANCH
2202 $FORTH_END_WORD AGAIN
2204 $FORTH_WORD REPEAT IMM
2206 >R >R AGAIN R> R> 2- ENDIF ;S
2207 $FORTH_END_WORD REPEAT
2215 $FORTH_WORD IFNOT IMM
2219 $FORTH_END_WORD IFNOT
2221 $FORTH_WORD ELSE IMM
2223 2 ?PAIRS COMPILE BRANCH
2224 HERE 0 , SWAP 2 ENDIF 2 ;S
2225 $FORTH_END_WORD ELSE
2227 $FORTH_WORD WHILE IMM
2230 $FORTH_END_WORD WHILE
2239 DROP DROP HLD @ PAD OVER - ;S
2244 ROT 0< 0BRANCH sign0
2248 $FORTH_END_WORD SIGN
2252 BASE @ M/MOD ROT LIT 9 OVER < 0BRANCH sharp0
2261 # OVER OVER OR 0= 0BRANCH ns0
2267 >R SWAP OVER DABS <# #S SIGN #> R> OVER - SPACES TYPE ;S
2295 $FORTH_WORD KEY-WAIT-CR-SPACE
2298 key_wait_cr_space_loop:
2300 DUP LIT 13 = SWAP LIT 32 = OR
2301 0BRANCH key_wait_cr_space_loop
2303 $FORTH_END_WORD KEY-WAIT-CR-SPACE
2305 $FORTH_WORD KEY-SCROLL-MSG-WAIT
2308 (.") "\r<press ENTER...>" ;;"
2310 EMITCR CONWIDTH 1- SPACES EMITCR
2312 $FORTH_END_WORD KEY-SCROLL-MSG-WAIT
2315 $FORTH_VAR (SCROLL-CRCOUNT) 0
2316 $FORTH_VAR (SCROLL-CRMAX) 20
2318 $FORTH_WORD (SCROLL-CR-RESET)
2321 (SCROLL-CRCOUNT) 0! ;S
2322 $FORTH_END_WORD (SCROLL-CR-RESET)
2324 $FORTH_WORD (SCROLL-CR)
2328 (SCROLL-CRCOUNT) @ 1+
2329 DUP (SCROLL-CRMAX) @ >= 0BRANCH words_cr_nowait
2335 $FORTH_END_WORD (SCROLL-CR)
2344 SHOW-HIDDEN @ 0= 0BRANCH vlist0_1
2345 ;; check if hidden word
2346 DUP 1+ C@ LIT 40 - 0BRANCH vlist4
2349 DUP C@ LIT 31 AND R@ SWAP - DUP 0< 0BRANCH vlist1
2350 (SCROLL-CR) DROP DUP C@ LIT 31 AND CONWIDTH SWAP -
2356 COUNT LIT 31 AND -DUP 0BRANCH vlistT9
2359 DUP C@ LIT 127 AND XEMIT 1+
2364 R@ 0= 0BRANCH vlist2
2365 (SCROLL-CR) RDROP CONWIDTH BRANCH vlist3
2372 PFA LFA @ DUP 0= ?BREAK OR
2375 $FORTH_END_WORD WORDS
2380 DECIMAL CR DUP SCR ! (.") ~SCR #~ . ;; "
2383 CR I 3 .R SPACE I SCR @ .LINE ?BREAK 0BRANCH list1
2388 $FORTH_END_WORD LIST
2390 ;; read next word from the input stream
2391 ;; place it at PAD as the counted string
2396 WORD PAD c/l 1+ CMOVE ;S
2397 $FORTH_END_WORD TEXT
2401 DUP LIT #FFF0 AND LIT 23 ?ERROR SCR @ (LINE) DROP ;S
2402 $FORTH_END_WORD LINE
2407 $FORTH_END_WORD SIZE
2412 $FORTH_END_WORD FREE
2416 CURRENT @ CONTEXT @ - LIT 24 ?ERROR
2417 ' DUP FENCE @ U< LIT 21 ?ERROR
2418 DUP NFA DP ! LFA @ CURRENT @ ! ;S
2419 $FORTH_END_WORD FORGET
2429 $FORTH_END_WORD EXIT
2431 $FORTH_WORD CASE IMM
2433 ?COMP CSP @ !CSP 4 ;S
2434 $FORTH_END_WORD CASE
2438 4 ?PAIRS COMPILE OVER
2441 HERE 0 , COMPILE DROP
2445 $FORTH_WORD ENDOF IMM
2447 LIT 5 ?PAIRS COMPILE BRANCH
2448 HERE 0 , SWAP 2 ENDIF 4 ;S
2449 $FORTH_END_WORD ENDOF
2451 $FORTH_WORD OTHERWISE IMM
2453 ;; part of CASE: OTHERWISE ( val ) ... ENDOF
2458 $FORTH_END_WORD OTHERWISE
2460 $FORTH_WORD ENDCASE IMM
2472 $FORTH_END_WORD ENDCASE
2476 $FORTH_DOES FORTH voc_does IMM
2480 defw latest_word ;; prev voc latest
2482 defw 0 ;; prev voc-link
2484 $FORTH_WORD VOCABULARY
2486 <BUILDS LIT #A081 , CURRENT @ CFA , HERE VOC-LINK @ , VOC-LINK ! DOES>
2489 $FORTH_END_WORD VOCABULARY
2498 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2499 ;; buffers, blocks, etc...
2500 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2502 include "blocks.zas"
2503 include "textfile.zas"
2504 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2505 ;; end of buffers, blocks, etc...
2506 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2511 ;;;;;;;;;;;;;;;;;;;; INSERT YOUR WORDS BELOW ;;;;;;;;;;;;;;;;;;;;
2514 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2516 ;;!!!!!! THIS LABEL SHOULD BE JUST BEFORE THE LAST DEFINED WORD
2518 ;;!!!!!! DO NOT REMOVE THIS WORD! THE SYSTEM USES IT
2521 $FORTH_END_WORD NOOP
2523 latest_byte: defw 666