3 * fig-FORTH FOR 6809, converted by unintelligent conversion from 6800 source.
4 * ASSEMBLY SOURCE LISTING
8 * WITH COMPILER SECURITY
9 * AND VARIABLE LENGTH NAMES
11 * This public domain publication is provided
12 * through the courtesy of:
18 * P.O. Box 8231 - San Jose, CA 95155 - (408) 277-0668
19 * Further distribution must include this notice.
21 NAM Copyright:FORTH Interest Group
24 * === FORTH-6800 06-06-79 21:OO
27 * This listing is in the PUBLIC DOMAIN and
28 * may be freely copied or published with the
29 * restriction that a credit line is printed
30 * with the material, crediting the
31 * authors and the FORTH INTEREST GROUP.
37 * === The Forth Interest Group
39 * === San Carlos, CA 94070
41 * === Unbounded Computing
42 * === 1134-K Aster Ave.
43 * === Sunnyvale, CA 94086
45 * This version was developed on an AMI EVK 300 PROTO
46 * system using an ACIA for the I/O. All terminal 1/0
47 * is done in three subroutines:
48 * PEMIT ( word # 182 )
52 * The FORTH words for disc related I/O follow the model
53 * of the FORTH Interest Group, but have not been
54 * tested using a real disc.
56 * Addresses in this implementation reflect the fact that,
57 * on the development system, it was convenient to
58 * write-protect memory at hex 1000, and leave the first
59 * 4K bytes write-enabled. As a consequence, code from
60 * location $1000 to lable ZZZZ could be put in ROM.
61 * Minor deviations from the model were made in the
62 * initialization and words ?STACK and FORGET
63 * in order to do this.
68 NBLK EQU 4 # of disc buffer blocks for virtual memory
69 MEMEND EQU 132*NBLK+$3000 end of ram
70 * each block is 132 bytes in size,
71 * holding 128 characters
73 MEMTOP EQU $3FFF absolute end of all ram
74 ACIAC EQU $FBCE the ACIA control address and
75 ACIAD EQU ACIAC+1 data address for PROTO
77 * MEMORY MAP for this 16K system:
78 * ( positioned so that systems with 4k byte write-
79 * protected segments can write protect FORTH )
81 * addr. contents pointer init by
82 * **** ******************************* ******* ******
84 * substitute for disc mass memory
87 * 4 buffer sectors of VIRTUAL MEMORY
89 * >>>>>> memory from here up must be RAM <<<<<<
92 * 6k of romable "FORTH" <== IP ABORT
94 * the VIRTUAL FORTH MACHINE
96 * 1004 <<< WARM START ENTRY >>>
97 * 1000 <<< COLD START ENTRY >>>
99 * >>>>>> memory from here down must be RAM <<<<<<
100 * FFE RETURN STACK base <== RP RINIT
104 * holds up to 132 characters
105 * and is scanned upward by IN
108 * F2F DATA STACK <== SP SP0,SINIT
109 * | grows downward from F2F
113 * I DICTIONARY grows upward
115 * 183 end of ram-dictionary. <== DP DPINIT
118 * 150 "FORTH" ( a word ) <=, <== CONTEXT
120 * 148 start of ram-dictionary.
122 * 100 user #l table of variables <= UP DPINIT
123 * F0 registers & pointers for the virtual machine
124 * scratch area used by various words
125 * E0 lowest address used by FORTH
131 * CONVENTIONS USED IN THIS PROGRAM ARE AS FOLLOWS :
133 * IP points to the current instruction ( pre-increment mode )
134 * RP points to second free byte (first free word) in return stack
135 * SP (hardware SP) points to first free byte in data stack
137 * when A ANDB hold one 16 bit FORTH data word,
138 * A contains the high byte, B, the low byte.
147 N RMB 10 used as scratch by (FIND),ENCLOSE,CMOVE,EMIT,KEY,
148 * SP@,SWAP,DOES>,COLD
151 * These locations are used by the TRACE routine :
153 TRLIM RMB 1 the count for tracing without user intervention
154 TRACEM RMB 1 non-zero = trace mode
155 BRKPT RMB 2 the breakpoint address at which
156 * the program will go into trace mode
157 VECT RMB 2 vector to machine code
158 * (only needed if the TRACE routine is resident)
161 * Registers used by the FORTH virtual machine:
165 W RMB 2 the instruction register points to 6800 code
166 IP RMB 2 the instruction pointer points to pointer to 6800 code
167 RP RMB 2 the return stack pointer
168 UP RMB 2 the pointer to base of current user's 'USER' table
169 * ( altered during multi-tasking )
172 * This system is shown with one user, but additional users
173 * may be added by allocating additional user tables:
174 * UORIG2 RMB 64 data table for user #2
177 * Some of this stuff gets initialized during
178 * COLD start and WARM start:
179 * [ names correspond to FORTH words of similar (no X) name ]
182 UORIG RMB 6 3 reserved variables
183 XSPZER RMB 2 initial top of data stack for this user
184 XRZERO RMB 2 initial top of return stack
185 XTIB RMB 2 start of terminal input buffer
186 XWIDTH RMB 2 name field width
187 XWARN RMB 2 warning message mode (0 = no disc)
188 XFENCE RMB 2 fence for FORGET
189 XDP RMB 2 dictionary pointer
190 XVOCL RMB 2 vocabulary linking
191 XBLK RMB 2 disc block being accessed
192 XIN RMB 2 scan pointer into the block
193 XOUT RMB 2 cursor position
194 XSCR RMB 2 disc screen being accessed ( O=terminal )
195 XOFSET RMB 2 disc sector offset for multi-disc
196 XCONT RMB 2 last word in primary search vocabulary
197 XCURR RMB 2 last word in extensible vocabulary
198 XSTATE RMB 2 flag for 'interpret' or 'compile' modes
199 XBASE RMB 2 number base for I/O numeric conversion
200 XDPL RMB 2 decimal point place
202 XCSP RMB 2 current stack position, for compile checks
205 XDELAY RMB 2 carriage return delay count
206 XCOLUM RMB 2 carriage width
207 IOSTAT RMB 2 last acia status from write/read
218 * end of user table, start of common system variables
227 * These things, up through the lable 'REND', are overwritten
228 * at time of cold load and should have the same contents
235 FORTH FDB DODOES,DOVOC,$81A0,TASK-7
238 FCC "(C) Forth Interest Group, 1979"
246 REND EQU * ( first empty location in dictionary )
249 * The FORTH program ( address $1000 to $27FF ) is written
250 * so that it can be in a ROM, or write-protected if desired
253 * ######>> screen 3 <<
255 ***************************
256 ** C O L D E N T R Y **
257 ***************************
260 ***************************
261 ** W A R M E N T R Y **
262 ***************************
264 JMP WENT warm-start code, keeps current dictionary intact
267 ******* startup parmeters **************************
269 FDB $6800,0000 cpu & revision
270 FDB 0 topmost word in FORTH vocabulary
271 BACKSP FDB $7F backspace character for editing
272 UPINIT FDB UORIG initial user area
273 SINIT FDB ORIG-$D0 initial top of data stack
274 RINIT FDB ORIG-2 initial top of return stack
275 FDB ORIG-$D0 terminal input buffer
276 FDB 31 initial name field width
277 FDB 0 initial warning mode (0 = no disc)
278 FENCIN FDB REND initial fence
279 DPINIT FDB REND cold start value for DP
281 COLINT FDB 132 initial terminal carriage width
282 DELINT FDB 4 initial carriage return delay
283 ****************************************************
287 * ######>> screen 13 <<
288 PULABX PULS A 24 cycles until 'NEXT'
290 STABX STA 0,X 16 cycles until 'NEXT'
293 GETX LDA 0,X 18 cycles until 'NEXT'
295 PUSHBA PSHS B 8 cycles until 'NEXT'
301 * "NEXT" takes 38 cycles if TRACE is removed,
303 * and 95 cycles if NOT tracing.
305 * = = = = = = = t h e v i r t u a l m a c h i n e = = = = =
308 LEAX 1,X pre-increment mode
311 NEXT2 LDX 0,X get W which points to CFA of word to be done
313 LDX 0,X get VECT which points to executable code
315 * The next instruction could be patched to JMP TRACE =
316 * if a TRACE routine is available: =
320 * JMP TRACE ( an alternate for the above )
322 * = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
329 FCC 'LI' ; 'LIT' : NOTE: this is different from LITERAL
331 FDB 0 link of zero to terminate dictionary scan
341 * ######>> screen 14 <<
343 CLITER FDB *+2 (this is an invisible word, with no header)
353 FCC 'EXECUT' ; 'EXECUTE'
358 LDX 0,X get code field address (CFA)
363 * ######>> screen 15 <<
366 FCC 'BRANC' ; 'BRANCH'
369 BRAN FDB ZBYES Go steal code in ZBRANCH
373 FCC '0BRANC' ; '0BRANCH'
379 * ABA is only used here.
380 * Could immediately convert PULs to LDD ,S++ ;
381 * with no need for trailing BCS to look for overflow
382 * because we are only testing for non-zero, but,
383 * converting as if by unintelligent macro:
386 * End of unintelligent ABA conversion.
389 ZBYES LDX IP Note: code is shared with BRANCH, (+LOOP), (LOOP)
397 ZBNO LDX IP no branch. This code is shared with (+LOOP), (LOOP).
398 LEAX 1,X jump over branch delta
403 * ######>> screen 16 <<
406 FCC '(LOOP' ; '(LOOP)'
411 LDB #1 get set to increment counter by 1
412 BRA XPLOP2 go steal other guy's code!
416 FCC '(+LOOP' ; '(+LOOP)'
419 XPLOOP FDB *+2 Note: +LOOP has an un-signed loop counter
423 BPL XPLOF forward looping
429 BRA XPLONO fall through
433 ADDB 3,X add it to counter
435 STB 3,X store new counter value
444 XPLONO LEAX 1,X done, don't branch back
449 BRA ZBNO use ZBRAN to skip over unused delta
451 * ######>> screen 17 <<
457 XDO FDB *+2 This is the RUNTIME DO, not the COMPILING DO
484 * ######>> screen 18 <<
490 DIGIT FDB *+2 NOTE: legal input range is 0-9, A-Z
494 BMI DIGIT2 IF LESS THAN '0', ILLEGAL
496 BMI DIGIT0 IF '9' OR LESS
498 BMI DIGIT2 if less than 'A'
500 BPL DIGIT2 if greater than 'Z'
501 SUBA #7 translate 'A' thru 'F'
503 BPL DIGIT2 if not less than the base
506 DIGIT1 STB 1,X store the flag
510 LEAS 1,S pop bottom number
512 STB 0,X make sure both bytes are 00
515 * ######>> screen 19 <<
517 * The word format in the dictionary is:
519 * char-count + $80 lowest address
524 * link high byte \___point to previous word
526 * CFA high byte \___pnt to 6800 code
535 FCC '(FIND' ; '(FIND)'
541 PD EQU N ptr to dict word being checked
544 PCT EQU N+6 ; PC in 6800 source
547 PFIND0 PULS A loop to get arguments
554 PFIND1 LDB 0,X get count dict count
560 LDA 0,X get count from arg
564 CMPA ,S+ compare lengths
574 TSTB is dict entry neg. ?
580 PFIND3 LDX 0,X get new link
581 BNE PFIND1 continue if link not=0
588 PFIND8 PSHS B ; sim CBA
592 PFIND9 LDB 0,X scan forward to end of this name
599 FOUND LDA PD compute CFA
618 * ######>> screen 20 <<
621 FCC 'ENCLOS' ; 'ENCLOSE'
625 * FC means offset (bytes) to First Character of next word
626 * EW " " to End of Word
627 * NC " " to Next Character to start next enclose at
630 PULS B now, get the low byte, for an 8-bit delimiter
634 * wait for a non-delimiter or a NUL
638 CMPA ,S+ CHECK FOR DELIM
643 * found first character. Push FC
644 ENCL3 LDA N found first char.
648 * wait for a delimiter or a NUL
652 CMPA ,S+ ckech for delim.
662 * advance and push NC
665 * found NUL before non-delimiter, therefore there is no word
666 ENCL6 LDB N found NUL
671 * found NUL following the word instead of SPACE
680 * ######>> screen 21 <<
681 * The next 4 words call system dependant I/O routines
682 * which are listed after word "-->" ( lable: "arrow" )
714 FCC '?TERMINA' ; '?TERMINAL'
720 JMP PUSHBA stack the flag
731 * ######>> screen 22 <<
734 FCC 'CMOV' ; 'CMOVE' : source, destination, count
737 CMOVE FDB *+2 takes ( 43+47*count cycles )
741 STA 0,X move parameters to scratch area
763 * ######>> screen 23 <<
775 * The following is a subroutine which
776 * multiplies top 2 words on stack,
777 * leaving 32-bit result: high order word in A,B
778 * low order word in 2nd word of stack.
780 USTARS LDA #16 bits/word counter
785 USTAR2 ROR 5,X shift multiplier
795 USTAR4 LEAS 1,S dump counter
798 * ######>> screen 24 <<
833 JMP SWAP+4 reverse quotient & remainder
835 * ######>> screen 25 <<
875 * ######>> screen 26 <<
895 * Potential problem area? No. ******
896 TFR X,S watch it ! X and S are not equal -- on 6800.
897 * But they are on 6809, and that's what we want here.
905 LDX RINIT initialize from rom constant
919 LDX 0,X get address we have just finished.
920 JMP NEXT+2 increment the return address & do next word
922 * ######>> screen 27 <<
976 * ######>> screen 28 <<
999 LDA #$80 check the sign bit
1008 * ######>> screen 29 <<
1044 FCC 'MINU' ; 'MINUS'
1058 FCC 'DMINU' ; 'DMINUS'
1075 * ######>> screen 30 <<
1127 * ######>> screen 31 <<
1138 PULS A get stack data
1140 ADDB 1,X add & store low byte
1142 ADCA 0,X add & store hi byte
1148 FCC 'TOGGL' ; 'TOGGLE'
1151 TOGGLE FDB DOCOL,OVER,CAT,XOR,SWAP,CSTORE
1154 * ######>> screen 32 <<
1207 * ######>> screen 33 <<
1212 COLON FDB DOCOL,QEXEC,SCSP,CURENT,AT,CONTXT,STORE
1216 * Here is the IP pusher for allowing
1217 * nested words in the virtual machine:
1218 * ( ;S is the equivalent un-nester )
1220 DOCOL LDX RP make room in the stack
1226 STA 2,X Store address of the high level word
1227 STB 3,X that we are starting to execute
1228 LDX W Get first sub-word of that definition
1229 JMP NEXT+2 and execute it
1232 FCB $C1 ; imnediate code
1235 SEMI FDB DOCOL,QCSP,COMPIL,SEMIS,SMUDGE,LBRAK
1238 * ######>> screen 34 <<
1241 FCC 'CONSTAN' ; 'CONSTANT'
1244 CON FDB DOCOL,CREATE,SMUDGE,COMMA,PSCODE
1247 LDB 3,X A & B now contain the constant
1252 FCC 'VARIABL' ; 'VARIABLE'
1255 VAR FDB DOCOL,CON,PSCODE
1259 ADCA #0 A,B now contain the address of the variable
1267 USER FDB DOCOL,CON,PSCODE
1268 DOUSER LDX W get offset into user's table
1271 ADDB UP+1 add to users base address
1273 JMP PUSHBA push address of user's variable
1275 * ######>> screen 35 <<
1309 BL FDB DOCON ascii blank
1314 FCC 'FIRS' ; 'FIRST'
1318 FDB MEMEND-528 (132 * NBLK)
1322 FCC 'LIMI' ; 'LIMIT' : ( the end of memory +1 )
1330 FCC 'B/BU' ; 'B/BUF' : (bytes/buffer)
1338 FCC 'B/SC' ; 'B/SCR' : (blocks/screen)
1343 * blocks/screen = 1024 / "B/BUF" = 8
1347 FCC '+ORIGI' ; '+ORIGIN'
1350 PORIG FDB DOCOL,LIT,ORIG,PLUS
1353 * ######>> screen 36 <<
1380 FCC 'WIDT' ; 'WIDTH'
1388 FCC 'WARNIN' ; 'WARNING'
1396 FCC 'FENC' ; 'FENCE'
1404 FCC 'D' ; 'DP' : points to first free byte at end of dictionary
1407 DICPT FDB DOUSER ; DP in 6800 source
1412 FCC 'VOC-LIN' ; 'VOC-LINK'
1428 FCC 'I' ; 'IN' : scan pointer for input line buffer
1449 * ######>> screen 37 <<
1453 FCC 'OFFSE' ; 'OFFSET'
1461 FCC 'CONTEX' ; 'CONTEXT' : points to pointer to vocab to search first
1469 FCC 'CURREN' ; 'CURRENT' : points to ptr. to vocab being extended
1477 FCC 'STAT' ; 'STATE' : 1 if compiling, 0 if not
1485 FCC 'BAS' ; 'BASE' : number base for all input & output
1531 * ======>> 82.5 <<== SPECIAL
1533 FCC 'COLUMN' ; 'COLUMNS' : line width of terminal
1539 * ######>> screen 38 <<
1545 ONEP FDB DOCOL,ONE,PLUS
1553 TWOP FDB DOCOL,TWO,PLUS
1561 HERE FDB DOCOL,DICPT,AT
1566 FCC 'ALLO' ; 'ALLOT'
1569 ALLOT FDB DOCOL,DICPT,PSTORE
1576 COMMA FDB DOCOL,HERE,STORE,TWO,ALLOT
1584 CCOMM FDB DOCOL,HERE,CSTORE,ONE,ALLOT
1591 SUB FDB DOCOL,MINUS,PLUS
1598 EQUAL FDB DOCOL,SUB,ZEQU
1626 GREAT FDB DOCOL,SWAP,LESS
1634 ROT FDB DOCOL,TOR,SWAP,FROMR,SWAP
1639 FCC 'SPAC' ; 'SPACE'
1642 SPACE FDB DOCOL,BL,EMIT
1650 MIN FDB DOCOL,OVER,OVER,GREAT,ZBRAN
1661 MAX FDB DOCOL,OVER,OVER,LESS,ZBRAN
1672 DDUP FDB DOCOL,DUP,ZBRAN
1677 * ######>> screen 39 <<
1680 FCC 'TRAVERS' ; 'TRAVERSE'
1684 TRAV2 FDB OVER,PLUS,CLITER
1686 FDB OVER,CAT,LESS,ZBRAN
1693 FCC 'LATES' ; 'LATEST'
1696 LATEST FDB DOCOL,CURENT,AT,AT
1704 LFA FDB DOCOL,CLITER
1714 CFA FDB DOCOL,TWO,SUB
1722 NFA FDB DOCOL,CLITER
1724 FDB SUB,ONE,MINUS,TRAV
1732 PFA FDB DOCOL,ONE,TRAV,CLITER
1737 * ######>> screen 40 <<
1743 SCSP FDB DOCOL,SPAT,CSP,STORE
1748 FCC '?ERRO' ; '?ERROR'
1751 QERR FDB DOCOL,SWAP,ZBRAN
1760 FCC '?COM' ; '?COMP'
1763 QCOMP FDB DOCOL,STATE,AT,ZEQU,CLITER
1770 FCC '?EXE' ; '?EXEC'
1773 QEXEC FDB DOCOL,STATE,AT,CLITER
1780 FCC '?PAIR' ; '?PAIRS'
1783 QPAIRS FDB DOCOL,SUB,CLITER
1793 QCSP FDB DOCOL,SPAT,CSP,AT,SUB,CLITER
1800 FCC '?LOADIN' ; '?LOADING'
1803 QLOAD FDB DOCOL,BLK,AT,ZEQU,CLITER
1808 * ######>> screen 41 <<
1811 FCC 'COMPIL' ; 'COMPILE'
1814 COMPIL FDB DOCOL,QCOMP,FROMR,TWOP,DUP,TOR,AT,COMMA
1821 LBRAK FDB DOCOL,ZERO,STATE,STORE
1828 RBRAK FDB DOCOL,CLITER
1835 FCC 'SMUDG' ; 'SMUDGE'
1838 SMUDGE FDB DOCOL,LATEST,CLITER
1856 FCC 'DECIMA' ; 'DECIMAL'
1861 FCB 10 note: hex "A"
1865 * ######>> screen 42 <<
1868 FCC '(;CODE' ; '(;CODE)'
1871 PSCODE FDB DOCOL,FROMR,TWOP,LATEST,PFA,CFA,STORE
1876 FCC ';COD' ; ';CODE'
1879 SEMIC FDB DOCOL,QCSP,COMPIL,PSCODE,SMUDGE,LBRAK,QSTACK
1881 * note: "QSTACK" will be replaced by "ASSEMBLER" later
1883 * ######>> screen 43 <<
1886 FCC '<BUILD' ; '<BUILDS'
1889 BUILDS FDB DOCOL,ZERO,CON
1894 FCC 'DOES' ; 'DOES>'
1897 DOES FDB DOCOL,FROMR,TWOP,LATEST,PFA,STORE
1901 LDX RP make room on return stack
1905 STA 2,X push return address
1907 LDX W get addr of pointer to run-time code
1910 STX N stash it in scratch area
1913 CLRA get address of parameter
1917 PSHS B and push it on data stack
1921 * ######>> screen 44 <<
1924 FCC 'COUN' ; 'COUNT'
1927 COUNT FDB DOCOL,DUP,ONEP,SWAP,CAT
1935 TYPE FDB DOCOL,DDUP,ZBRAN
1937 FDB OVER,PLUS,SWAP,XDO
1938 TYPE2 FDB I,CAT,EMIT,XLOOP
1947 FCC '-TRAILIN' ; '-TRAILING'
1950 DTRAIL FDB DOCOL,DUP,ZERO,XDO
1951 DTRAL2 FDB OVER,OVER,PLUS,ONE,SUB,CAT,BL
1966 PDOTQ FDB DOCOL,R,TWOP,COUNT,DUP,ONEP
1967 FDB FROMR,PLUS,TOR,TYPE
1980 FDB COMPIL,PDOTQ,WORD
1981 FDB HERE,CAT,ONEP,ALLOT,BRAN
1983 DOTQ1 FDB WORD,HERE,COUNT,TYPE
1986 * ######>> screen 45 <<
1987 * ======>> 126 <<== MACHINE DEPENDENT
1989 FCC '?STAC' ; '?STACK'
1992 QSTACK FDB DOCOL,CLITER
1994 FDB PORIG,AT,TWO,SUB,SPAT,LESS,ONE
1996 * prints 'empty stack'
1999 * Here, we compare with a value at least 128
2000 * higher than dict. ptr. (DP)
2007 * prints 'full stack'
2011 * ======>> 127 << this word's function
2012 * is done by ?STACK in this version
2017 *QFREE FDB DOCOL,SPAT,HERE,CLITER
2019 * FDB PLUS,LESS,TWO,QERR,SEMIS
2021 * ######>> screen 46 <<
2024 FCC 'EXPEC' ; 'EXPECT'
2027 EXPECT FDB DOCOL,OVER,PLUS,OVER,XDO
2028 EXPEC2 FDB KEY,DUP,CLITER
2030 FDB PORIG,AT,EQUAL,ZBRAN
2033 FCB 8 ( backspace character to emit )
2034 FDB OVER,I,EQUAL,DUP,FROMR,TWO,SUB,PLUS
2037 EXPEC3 FDB DUP,CLITER
2038 FCB $D ( carriage return )
2041 FDB LEAVE,DROP,BL,ZERO,BRAN
2044 EXPEC5 FDB I,CSTORE,ZERO,I,ONEP,STORE
2045 EXPEC6 FDB EMIT,XLOOP
2052 FCC 'QUER' ; 'QUERY'
2055 QUERY FDB DOCOL,TIB,AT,COLUMS
2056 FDB AT,EXPECT,ZERO,IN,STORE
2060 FCB $C1 immediate < carriage return >
2063 NULL FDB DOCOL,BLK,AT,ZBRAN
2066 FDB ZERO,IN,STORE,BLK,AT,BSCR,MOD
2068 * check for end of screen
2071 FDB QEXEC,FROMR,DROP
2074 NULL2 FDB FROMR,DROP
2077 * ######>> screen 47 <<
2083 FILL FDB DOCOL,SWAP,TOR,OVER,CSTORE,DUP,ONEP
2084 FDB FROMR,ONE,SUB,CMOVE
2089 FCC 'ERAS' ; 'ERASE'
2092 ERASE FDB DOCOL,ZERO,FILL
2097 FCC 'BLANK' ; 'BLANKS'
2100 BLANKS FDB DOCOL,BL,FILL
2108 HOLD FDB DOCOL,LIT,$FFFF,HLD,PSTORE,HLD,AT,CSTORE
2116 PAD FDB DOCOL,HERE,CLITER
2121 * ######>> screen 48 <<
2127 WORD FDB DOCOL,BLK,AT,ZBRAN
2129 FDB BLK,AT,BLOCK,BRAN
2132 WORD3 FDB IN,AT,PLUS,SWAP,ENCLOS,HERE,CLITER
2134 FDB BLANKS,IN,PSTORE,OVER,SUB,TOR,R,HERE
2135 FDB CSTORE,PLUS,HERE,ONEP,FROMR,CMOVE
2138 * ######>> screen 49 <<
2141 FCC '(NUMBER' ; '(NUMBER)'
2145 PNUMB2 FDB ONEP,DUP,TOR,CAT,BASE,AT,DIGIT,ZBRAN
2147 FDB SWAP,BASE,AT,USTAR,DROP,ROT,BASE
2148 FDB AT,USTAR,DPLUS,DPL,AT,ONEP,ZBRAN
2151 PNUMB3 FDB FROMR,BRAN
2158 FCC 'NUMBE' ; 'NUMBER'
2161 NUMB FDB DOCOL,ZERO,ZERO,ROT,DUP,ONEP,CAT,CLITER
2163 FDB EQUAL,DUP,TOR,PLUS,LIT,$FFFF
2164 NUMB1 FDB DPL,STORE,PNUMB,DUP,CAT,BL,SUB
2169 FDB SUB,ZERO,QERR,ZERO,BRAN
2171 NUMB2 FDB DROP,FROMR,ZBRAN
2178 FCC '-FIN' ; '-FIND'
2181 DFIND FDB DOCOL,BL,WORD,HERE,CONTXT,AT,AT
2182 FDB PFIND,DUP,ZEQU,ZBRAN
2184 FDB DROP,HERE,LATEST,PFIND
2187 * ######>> screen 50 <<
2190 FCC '(ABORT' ; '(ABORT)'
2193 PABORT FDB DOCOL,ABORT
2198 FCC 'ERRO' ; 'ERROR'
2201 ERROR FDB DOCOL,WARN,AT,ZLESS
2203 * note: WARNING is -1 to abort, 0 to print error #
2204 * and 1 to print error message from disc
2207 ERROR2 FDB HERE,COUNT,TYPE,PDOTQ
2210 FDB MESS,SPSTOR,IN,AT,BLK,AT,QUIT
2218 IDDOT FDB DOCOL,PAD,CLITER
2221 FCB $5F ( underline )
2222 FDB FILL,DUP,PFA,LFA,OVER,SUB,PAD
2223 FDB SWAP,CMOVE,PAD,COUNT,CLITER
2228 * ######>> screen 51 <<
2231 FCC 'CREAT' ; 'CREATE'
2234 CREATE FDB DOCOL,DFIND,ZBRAN
2240 FDB NFA,IDDOT,CLITER
2243 CREAT2 FDB HERE,DUP,CAT,WIDTH,AT,MIN
2244 FDB ONEP,ALLOT,DUP,CLITER
2246 FDB TOGGLE,HERE,ONE,SUB,CLITER
2248 FDB TOGGLE,LATEST,COMMA,CURENT,AT,STORE
2252 * ######>> screen 52 <<
2255 FCC '[COMPILE' ; '[COMPILE]'
2258 BCOMP FDB DOCOL,DFIND,ZEQU,ZERO,QERR,DROP,CFA,COMMA
2263 FCC 'LITERA' ; 'LITERAL'
2266 LITER FDB DOCOL,STATE,AT,ZBRAN
2268 FDB COMPIL,LIT,COMMA
2273 FCC 'DLITERA' ; 'DLITERAL'
2276 DLITER FDB DOCOL,STATE,AT,ZBRAN
2278 FDB SWAP,LITER,LITER
2281 * ######>> screen 53 <<
2284 FCC 'INTERPRE' ; 'INTERPRET'
2288 INTER2 FDB DFIND,ZBRAN
2298 INTER5 FDB HERE,NUMB,DPL,AT,ONEP,ZBRAN
2302 INTER6 FDB DROP,LITER
2303 INTER7 FDB QSTACK,BRAN
2305 * FDB SEMIS never executed
2308 * ######>> screen 54 <<
2311 FCC 'IMMEDIAT' ; 'IMMEDIATE'
2314 IMMED FDB DOCOL,LATEST,CLITER
2321 FCC 'VOCABULAR' ; 'VOCABULARY'
2324 VOCAB FDB DOCOL,BUILDS,LIT,$81A0,COMMA,CURENT,AT,CFA
2325 FDB COMMA,HERE,VOCLIN,AT,COMMA,VOCLIN,STORE,DOES
2326 DOVOC FDB TWOP,CONTXT,STORE
2331 * Note: FORTH does not go here in the rom-able dictionary,
2332 * since FORTH is a type of variable.
2337 FCC 'DEFINITION' ; 'DEFINITIONS'
2340 DEFIN FDB DOCOL,CONTXT,AT,CURENT,STORE
2347 PAREN FDB DOCOL,CLITER
2352 * ######>> screen 55 <<
2358 QUIT FDB DOCOL,ZERO,BLK,STORE
2361 * Here is the outer interpretter
2362 * which gets a line of input, does it, prints " OK"
2364 QUIT2 FDB RPSTOR,CR,QUERY,INTERP,STATE,AT,ZEQU
2372 * FDB SEMIS ( never executed )
2376 FCC 'ABOR' ; 'ABORT'
2379 ABORT FDB DOCOL,SPSTOR,DEC,QSTACK,DRZERO,CR,PDOTQ
2384 * FDB SEMIS never executed
2387 * ######>> screen 56 <<
2388 * bootstrap code... moves rom contents to ram :
2395 * CENT LDS #REND-1 top of destination on 6800
2396 CENT LDS #REND top of destination on 6809
2397 LDX #ERAM top of stuff to move
2400 PSHS A move TASK & FORTH to ram
2404 * LDS #XFENCE-1 put stack at a safe place for now -- 6800
2405 * But only matters if we're interrupted.
2406 LDS #XFENCE put stack at a safe place for now -- 6809
2419 * WENT LDS #XFENCE-1 top of destination -- 6800
2420 WENT LDS #XFENCE top of destination -- 6809
2421 LDX #FENCIN top of stuff to move
2428 * Don't get faked out.
2429 * This is just a safe place for the stack if we're interrupted.
2430 * ABORT sends us through RP! and then SP!
2431 * And SP! loads S through X, which is just fine for the 6809, too.
2434 STX UP init user ram pointer
2437 NOP Here is a place to jump to special user
2438 NOP initializations such as I/0 interrups
2441 * For systems with TRACE:
2443 STX TRLIM clear trace mode
2445 STX BRKPT clear breakpoint address
2446 JMP RPSTOR+2 start the virtual machine running !
2448 * Here is the stuff that gets copied to ram :
2451 RAM FDB $3000,$3000,0,0
2455 FCC 'FORT' ; 'FORTH'
2458 RFORTH FDB DODOES,DOVOC,$81A0,TASK-7
2460 FCC "(C) Forth Interest Group, 1979"
2465 RTASK FDB DOCOL,SEMIS
2466 ERAM FCC "David Lion"
2469 * ######>> screen 57 <<
2475 STOD FDB DOCOL,DUP,ZLESS,MINUS
2495 SLMOD FDB DOCOL,TOR,STOD,FROMR,USLASH
2502 SLASH FDB DOCOL,SLMOD,SWAP,DROP
2510 MOD FDB DOCOL,SLMOD,DROP
2515 FCC '*/MO' ; '*/MOD'
2518 SSMOD FDB DOCOL,TOR,USTAR,FROMR,USLASH
2526 SSLASH FDB DOCOL,SSMOD,SWAP,DROP
2531 FCC 'M/MO' ; 'M/MOD'
2534 MSMOD FDB DOCOL,TOR,ZERO,R,USLASH
2535 FDB FROMR,SWAP,TOR,USLASH,FROMR
2543 ABS FDB DOCOL,DUP,ZLESS,ZBRAN
2553 DABS FDB DOCOL,DUP,ZLESS,ZBRAN
2558 * ######>> screen 58 <<
2579 PBUF FDB DOCOL,CLITER
2581 FDB PLUS,DUP,LIMIT,EQUAL,ZBRAN
2584 PBUF2 FDB DUP,PREV,AT,SUB
2589 FCC 'UPDAT' ; 'UPDATE'
2592 UPDATE FDB DOCOL,PREV,AT,AT,LIT,$8000,OR,PREV,AT,STORE
2597 FCC 'EMPTY-BUFFER' ; 'EMPTY-BUFFERS'
2600 MTBUF FDB DOCOL,FIRST,LIMIT,OVER,SUB,ERASE
2608 DRZERO FDB DOCOL,ZERO,OFSET,STORE
2611 * ======>> 174 <<== system dependant word
2616 DRONE FDB DOCOL,LIT,$07D0,OFSET,STORE
2619 * ######>> screen 59 <<
2622 FCC 'BUFFE' ; 'BUFFER'
2625 BUFFER FDB DOCOL,USE,AT,DUP,TOR
2626 BUFFR2 FDB PBUF,ZBRAN
2628 FDB USE,STORE,R,AT,ZLESS
2631 FDB R,TWOP,R,AT,LIT,$7FFF,AND,ZERO,RW
2632 BUFFR3 FDB R,STORE,R,PREV,STORE,FROMR,TWOP
2635 * ######>> screen 60 <<
2638 FCC 'BLOC' ; 'BLOCK'
2641 BLOCK FDB DOCOL,OFSET,AT,PLUS,TOR
2642 FDB PREV,AT,DUP,AT,R,SUB,DUP,PLUS,ZBRAN
2644 BLOCK3 FDB PBUF,ZEQU,ZBRAN
2646 FDB DROP,R,BUFFER,DUP,R,ONE,RW,TWO,SUB
2647 BLOCK4 FDB DUP,AT,R,SUB,DUP,PLUS,ZEQU,ZBRAN
2650 BLOCK5 FDB FROMR,DROP,TWOP
2653 * ######>> screen 61 <<
2656 FCC '(LINE' ; '(LINE)'
2659 PLINE FDB DOCOL,TOR,CLITER
2661 FDB BBUF,SSMOD,FROMR,BSCR,STAR,PLUS,BLOCK,PLUS,CLITER
2667 FCC '.LIN' ; '.LINE'
2670 DLINE FDB DOCOL,PLINE,DTRAIL,TYPE
2675 FCC 'MESSAG' ; 'MESSAGE'
2678 MESS FDB DOCOL,WARN,AT,ZBRAN
2684 FDB OFSET,AT,BSCR,SLASH,SUB,DLINE,BRAN
2688 FCC 'err # ' ; 'err # '
2694 FCC 'LOA' ; 'LOAD' : input:scr #
2697 LOAD FDB DOCOL,BLK,AT,TOR,IN,AT,TOR,ZERO,IN,STORE
2698 FDB BSCR,STAR,BLK,STORE
2699 FDB INTERP,FROMR,IN,STORE,FROMR,BLK,STORE
2707 ARROW FDB DOCOL,QLOAD,ZERO,IN,STORE,BSCR
2708 FDB BLK,AT,OVER,MOD,SUB,BLK,PSTORE
2713 * ######>> screen 63 <<
2714 * The next 4 subroutines are machine dependent, and are
2715 * called by words 13 through 16 in the dictionary.
2717 * ======>> 182 << code for EMIT
2721 BITB #2 check ready bit
2722 BEQ PEMIT+4 if not ready for more data
2728 RTS only A register may change
2729 * PEMIT JMP $E1D1 for MIKBUG
2730 * PEMIT FCB $3F,$11,$39 for PROTO
2731 * PEMIT JMP $D286 for Smoke Signal DOS
2733 * ======>> 183 << code for KEY
2738 BCC PKEY+4 no incoming data yet
2740 ANDA #$7F strip parity bit
2742 STB IOSTAT+1-UORIG,X
2746 * PKEY JMP $E1AC for MIKBUG
2747 * PKEY FCB $3F,$14,$39 for PROTO
2748 * PKEY JMP $D289 for Smoke Signal DOS
2750 * ######>> screen 64 <<
2751 * ======>> 184 << code for ?TERMINAL
2752 PQTER LDA ACIAC Test for 'break' condition
2753 ANDA #$11 mask framing error bit and
2756 LDA ACIAD clear input buffer
2763 * ======>> 185 << code for CR
2764 PRTCR LDA #$D carriage return ; PCR in 6800 source
2770 LDB XDELAY+1-UORIG,X
2772 BMI PQTER2 return if minus
2774 BSR PEMIT print RUBOUTs to delay.....
2781 * ######>> screen 66 <<
2784 FCC '?DIS' ; '?DISC'
2790 * ######>> screen 67 <<
2793 FCC 'BLOCK-WRIT' ; 'BLOCK-WRITE'
2799 * ######>> screen 68 <<
2802 FCC 'BLOCK-REA' ; 'BLOCK-READ'
2808 *The next 3 words are written to create a substitute for disc
2809 * mass memory,located between $3210 & $3FFF in ram.
2816 FDB MEMEND a system dependent equate at front
2824 FDB MEMTOP ( $3FFF in this version )
2826 * ######>> screen 69 <<
2832 RW FDB DOCOL,TOR,BBUF,STAR,LO,PLUS,DUP,HI,GREAT,ZBRAN
2836 FCC ' Range ?' ; ' Range ?'
2844 * ######>> screen 72 <<
2849 TICK FDB DOCOL,DFIND,ZEQU,ZERO,QERR,DROP,LITER
2854 FCC 'FORGE' ; 'FORGET'
2857 FORGET FDB DOCOL,CURENT,AT,CONTXT,AT,SUB,CLITER
2859 FDB QERR,TICK,DUP,FENCE,AT,LESS,CLITER
2861 FDB QERR,DUP,ZERO,PORIG,GREAT,CLITER
2863 FDB QERR,DUP,NFA,DICPT,STORE,LFA,AT,CONTXT,AT,STORE
2866 * ######>> screen 73 <<
2872 BACK FDB DOCOL,HERE,SUB,COMMA
2877 FCC 'BEGI' ; 'BEGIN'
2880 BEGIN FDB DOCOL,QCOMP,HERE,ONE
2885 FCC 'ENDI' ; 'ENDIF'
2888 ENDIF FDB DOCOL,QCOMP,TWO,QPAIRS,HERE
2889 FDB OVER,SUB,SWAP,STORE
2897 THEN FDB DOCOL,ENDIF
2905 DO FDB DOCOL,COMPIL,XDO,HERE,THREE
2913 LOOP FDB DOCOL,THREE,QPAIRS,COMPIL,XLOOP,BACK
2918 FCC '+LOO' ; '+LOOP'
2921 PLOOP FDB DOCOL,THREE,QPAIRS,COMPIL,XPLOOP,BACK
2926 FCC 'UNTI' ; 'UNTIL' : ( same as END )
2929 UNTIL FDB DOCOL,ONE,QPAIRS,COMPIL,ZBRAN,BACK
2932 * ######>> screen 74 <<
2943 FCC 'AGAI' ; 'AGAIN'
2946 AGAIN FDB DOCOL,ONE,QPAIRS,COMPIL,BRAN,BACK
2951 FCC 'REPEA' ; 'REPEAT'
2954 REPEAT FDB DOCOL,TOR,TOR,AGAIN,FROMR,FROMR
2963 IF FDB DOCOL,COMPIL,ZBRAN,HERE,ZERO,COMMA,TWO
2971 ELSE FDB DOCOL,TWO,QPAIRS,COMPIL,BRAN,HERE
2972 FDB ZERO,COMMA,SWAP,TWO,ENDIF,TWO
2977 FCC 'WHIL' ; 'WHILE'
2980 WHILE FDB DOCOL,IF,TWOP
2983 * ######>> screen 75 <<
2986 FCC 'SPACE' ; 'SPACES'
2989 SPACES FDB DOCOL,ZERO,MAX,DDUP,ZBRAN
2992 SPACE2 FDB SPACE,XLOOP
3001 BDIGS FDB DOCOL,PAD,HLD,STORE
3009 EDIGS FDB DOCOL,DROP,DROP,HLD,AT,PAD,OVER,SUB
3017 SIGN FDB DOCOL,ROT,ZLESS,ZBRAN
3028 DIG FDB DOCOL,BASE,AT,MSMOD,ROT,CLITER
3046 DIGS2 FDB DIG,OVER,OVER,OR,ZEQU,ZBRAN
3050 * ######>> screen 76 <<
3056 DOTR FDB DOCOL,TOR,STOD,FROMR,DDOTR
3064 DDOTR FDB DOCOL,TOR,SWAP,OVER,DABS,BDIGS,DIGS,SIGN
3065 FDB EDIGS,FROMR,OVER,SUB,SPACES,TYPE
3073 DDOT FDB DOCOL,ZERO,DDOTR,SPACE
3080 DOT FDB DOCOL,STOD,DDOT
3087 QUEST FDB DOCOL,AT,DOT
3090 * ######>> screen 77 <<
3096 LIST FDB DOCOL,DEC,CR,DUP,SCR,STORE,PDOTQ
3102 LIST2 FDB CR,I,THREE
3103 FDB DOTR,SPACE,I,SCR,AT,DLINE,XLOOP
3110 FCC 'INDE' ; 'INDEX'
3113 INDEX FDB DOCOL,CR,ONEP,SWAP,XDO
3114 INDEX2 FDB CR,I,THREE
3115 FDB DOTR,SPACE,ZERO,I,DLINE
3125 FCC 'TRIA' ; 'TRIAD'
3128 TRIAD FDB DOCOL,THREE,SLASH,THREE,STAR
3129 FDB THREE,OVER,PLUS,SWAP,XDO
3131 FDB LIST,QTERM,ZBRAN
3141 * ######>> screen 78 <<
3144 FCC 'VLIS' ; 'VLIST'
3147 VLIST FDB DOCOL,CLITER
3149 FDB OUT,STORE,CONTXT,AT,AT
3150 VLIST1 FDB OUT,AT,COLUMS,AT,CLITER
3154 FDB CR,ZERO,OUT,STORE
3155 VLIST2 FDB DUP,IDDOT,SPACE,SPACE,PFA,LFA,AT
3156 FDB DUP,ZEQU,QTERM,OR,ZBRAN
3166 NOOP FDB NEXT a useful no-op
3167 ZZZZ FDB 0,0,0,0,0,0,0,0 end of rom program