• R/O
  • HTTP
  • SSH
  • HTTPS

bif-6809: コミット

ソースコード及び仕様書など
Source and documentation


コミットメタ情報

リビジョンc0de41c9360a9413bd91b06b4161555ddd540899 (tree)
日時2019-04-08 22:15:14
作者Joel Matthew Rees <joel.rees@gmai...>
コミッターJoel Matthew Rees

ログメッセージ

Baseline, with the license notices in README.TXT and BIFDOC.TXT.
Not yet tested in any real sense.

変更サマリ

差分

--- /dev/null
+++ b/BIFDOC.TXT
@@ -0,0 +1,2311 @@
1+
2+ BIF Documentation
3+ By Joel Matthew Rees
4+ 19 January 1992,
5+ 8 April 2019
6+
7+
8+ BIF documentation Copyright Joel Matthew Rees 1992, 2019
9+
10+
11+In the spirit of fig-FORTH, the author grants permission as follows:
12+=========
13+Permission to use, copy, modify, and/or distribute this software for
14+any purpose with or without fee is hereby granted, provided that the
15+accompanying copyright notices and this permission notice appear in
16+all copies.
17+
18+THE SOFTWARE IS PROVIDED “AS IS” AND ISC DISCLAIMS ALL WARRANTIES
19+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
20+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY
21+SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
22+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
23+AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
24+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
25+SOFTWARE.
26+=========
27+
28+If the copyright notices in this file and the README.TXT file are
29+retained, including that file and this with your distribution will
30+fulfill the copyright notice obligation.
31+
32+But you really should include both anyway, just to be kind to the
33+people who receive it.
34+
35+Note that:
36+
37+BIF is architecturally derived from fig-FORTH. fig-FORTH comes courtesy
38+of the FORTH INTEREST GROUP, PO Box 1105, San Carlos, CA 94070.
39+
40+This is not a commercial product; it was a student project, use it at
41+your own risk. No warranty whatsoever is made concerning it. (If, by
42+chance, anyone is interested in using BIF in a commercial product, I
43+would appreciate knowing about it in advance.) The author's intent is
44+only to make it available for experimentation, and it should be treated
45+as strictly experimental software. DO NOT ATTEMPT TO ACCESS ORDINARY
46+DISKS FORMATTED FOR USE BY OTHER OPERATING SYSTEMS WHILE BIF IS RUNNING!
47+
48+Contact as of January 2000:
49+ joel_rees@sannet.ne.jp
50+ http://www.page.sannet.ne.jp/joel_rees
51+ reiisi@nettaxi.com
52+ http://www.nettaxi.com/citizens/reiisi
53+
54+
55+*******************************************************************************
56+ General Information
57+
58+
59+BIF (BInary tree, fig-FORTH) is a dialect of FORTH for the Tandy Color
60+Computer. It is a direct-threaded version of the pre-FORTH-79 fORTH
61+interest group publication of FORTH (fig-FORTH), using a non-standard
62+binary tree dictionary structure. The direct-threading mechanism uses
63+the direct-page addressing mode of the 6809, and thus may not be easily
64+adaptable to FORTH-83. It also uses absolute addressing, and thus does
65+not comform to the requirements of OS-9. (I am working on an
66+indirect-threaded version of BIF for OS-9 in my spare time.)
67+
68+BIF.BIN is the executable object; after LOADMing it, EXEC the address
69+&H1300 (see below). BIFSOURC.ARC contains the archived (TC31) source
70+files; the assembler used is Disk EDTASM+. I used TSEdit to generate
71+the source files in EDTASM+ format:
72+
73+line-number SPACE [label] TAB mnemonic etc. LF
74+
75+Using a text editor to replace the macros with their expansions should
76+make it compatible with most other assemblers. An object which will run
77+under the EDTASM+ "stand-alone" debugger may be generated by changing
78+ORG $1200 in BIF.ASM to ORG $3F00.
79+
80+BIFSCREE.ARC contains the BIF/FORTH source for several utilities, the
81+assembler, and double integer definitions (TOOLS.G00) and a definition
82+pairing example (PAIRS.G28) useful for making paired lists. Using
83+TOOLS.G00 and PAIRS.G28 directly will require moving the two files to
84+their original granules, 0 and 28, on an ECB disk. Once they are moved,
85+protecting the BIF screens with ECB directory entries may be a good
86+idea. But resist the temptation to use a text editor on them. Messing
87+with the whitespace will move the source code out of alignment with the
88+physical FORTH/BIF screens, and thus cause the source code not to load.
89+
90+If you want to look at these two files with an editor, I suggest copying
91+them to a different disk and looking at the copies. Even my favorite
92+IBM PC editor, QEDIT, will insert a CR/LF at the end of every 512 bytes
93+on saving, which is not good. (I wonder how many letters from OS-9
94+users it would take to convince the folks at SEMWARE/Applied Systems
95+Technologies to make an OS-9 version of their editor?)
96+
97+For $5.00, to cover postage, time, and the cost of floppies, I will send
98+a copy of the BIF screens disk on a standard 5 1/4" (ECB formatted)
99+floppy. If you request the EDTASM+ compatible source code, I will send
100+that as well, on the same format disks. For $5.00 more, I will include
101+a photo-copy of the documentation (useful if you don't have a way to
102+print it).
103+
104+The documentation which follows is written in the standard FORTH
105+documentation style. It is not intended as a primer or study guide.
106+Brodie's Starting FORTH, Winfield's THE COMPLETE FORTH, or some other
107+text is suggested to those unfamiliar with FORTH. Much of the code and
108+examples should work as shown in the textbooks I recommend Leo Brodie's
109+work, because he points out most of the places the user will have to
110+refer to this documentation. Some of the descriptions are incomplete,
111+particularly where definitions are intended to be used inside other
112+definitions.
113+
114+The object contains a simple one-sector editor (for 32-column screens)
115+in the EDITOR vocabulary. It does not provide search and replace, but
116+it is sufficient, for the patient, to write code. My apologies for it.
117+I did not have a Color Computer 3 when I wrote the original code, and
118+haven't had the time to update it. Those with access to the fig-FORTH
119+Installation Manual should have no problem installing the editor shown
120+there.
121+
122+The assembler in the BIF screens is a full postfix assembler. The
123+double integer screens show a quick example of its use.
124+
125+
126+*******************************************************************************
127+ Getting BIF Running
128+
129+
130+Before you start, remember that BIF has the same post-fix grammar as
131+FORTH. Think Reverse Polish, as in HP calculators.
132+
133+Computer: Comments:
134+
135+ In Disk ECB, type:
136+LOADM "BIF.BIN" from whichever drive it is on, then remove all disks and
137+EXEC &H1300 BIF should tell you it is running with
138+6809 BIF V1.0
139+OK
140+ At this point, see if BIF is really running by typing
141+VLIST and hitting ENTER. You should see a listing of your
142+ main vocabulary (symbol table) which should run on for
143+ about 200 entries, and then the computer responds with
144+OK If this doesn't happen, you have a bad object file, get
145+ a new copy. Otherwise, you have BIF!
146+
147+ If you have my BIF screens disk, put it in drive 0.
148+ Then type
149+6 LOAD to load the utilities starting at screen 6. After the
150+ utilities are loaded, you can load the assembler by
151+ typing
152+DECIMAL 16 LOAD
153+
154+ If you don't have the BIF screens disk with the error
155+ messages, type
156+0 WARNING ! and BIF responds with
157+OK but now tells you error numbers instead of messages.
158+
159+Okay, a few examples:
160+
161+ 42 EMIT
162+
163+puts the ascii character 42 (asterisk if the current BASE is DECIMAL) on
164+the output device.
165+
166+ 5 6 * .
167+
168+prints the product of 5 and 6 (30, base ten) on the output device.
169+
170+ DECIMAL : CHARS 32 DO I . I EMIT CR LOOP ;
171+ HEX 45 CHARS
172+
173+will set up a BIF "word" called CHARS, which, being invoked on the second
174+line, will print the characters and hexadecimal ascii codes from SPACE
175+up to, but not including, DASH.
176+
177+The BIF screens disk should always be in drive 0 if you want real error
178+messages. If you want to look at the message text, the messages are at
179+the front of TOOLS.G00, after the directory screen and title screen.
180+Each message takes exactly 32 characters, including spaces and
181+non-printing characters. Numbering starts with 0. If you have some
182+other disk in drive 0 you will get funny and not exactly intelligent
183+error messages. I know it's weird, but I was following the fig-FORTH
184+model, which is designed for very limited memory.
185+
186+If you haven't been able to put the BIF screens disk together, you don't
187+really need it to play around with BIF, but do clear the WARNING
188+variable so BIF will know error messages are not available. Aside from
189+the error messages in drive 0, there is nothing special about screens
190+disks, except they do not have directory tracks. You should generally
191+not put them in your drives when running under BASIC (DECB), OS-9 or
192+some other system. By tradition, programmers use the first several
193+screens as a hand-typed directory. You can format fresh BIF disks with
194+either Disk Extended Color BASIC's DSKINI or OS-9's format. BIF ignores
195+the directory information both systems write, so you also generally
196+should not put a real DECB or OS-9 disk in while BIF is running.
197+
198+If you do format with OS-9, format single-sided (I used DECB's disk
199+interface routines so BIF can't do double sided) with as many tracks as
200+you want. To use the extra tracks, or a third or fourth drive, you will
201+need to modify the DRIVE-OFFSET array. Pick a standard disk
202+configuration and stick with it.
203+
204+An important word of warning. BIF, like FORTH, uses buffered I/O. Your
205+screens are not actually saved to disk until you cause the system to
206+need enough new buffers to write your editing back to the disk. To
207+force the system to save the buffers, give BIF the SAVE-BUFFERS command.
208+
209+
210+*******************************************************************************
211+ BIF's QUICK Editor
212+
213+
214+EDITOR gets you into the EDITOR vocabulary.
215+0 QLIST lets you look at the first sector of the directory.
216+4 B/SCR * QLIST lets you look at the first eight error messages.
217+DECIMAL makes sure your conversion base is base ten.
218+64 B/SCR * QUICK
219+ lets you edit the first sector of the pairing example.
220+ Use the cursor keys to move around; use the BREAK key to
221+ get out. If you modified something you don't want to
222+ change, type
223+EMPTY-BUFFERS and ENTER. If you want to make sure your changes are
224+ written to the disk, type
225+SAVE-BUFFERS and ENTER.
226+
227+The QUICK editor is in the EDITOR vocabulary. It is available at boot
228+up. You'll need to get into the EDITOR vocabulary, to access it. Pass
229+it a sector number, not a screen number. Multiplying by B/SCR (which
230+happens to be 4) will convert a screen number to a sector number. Add
231+1, 2, or 3 to the base sector number of a screen to get the sector
232+numbers for the second, third, and fourth sectors of that screen.
233+
234+The editor has no find/replace or block functions. Again I apologize
235+for the editor, but I found it surprisingly workable. Note that the
236+utility screens contain routines to move/copy sectors, so all is not
237+entirely mud. One more glitch. Lower case letters will show as VDG
238+codes until you run the cursor over them. What can I say?
239+
240+During editing, all arrow keys are cursor controls. Use SHIFT-LEFTARROW
241+for destructive backspace, SHIFT-DOWNARROW for `[' left bracket,
242+SHIFT-RIGHTARROW for `]' right bracket, SHIFT-UPARROW for `_' underscore
243+(back-arrow on CoCo2). SHIFT-CLEAR escapes the UP-ARROW to provide the
244+`^' caret. SHIFT-CLEAR also escapes itself to provide the backslash.
245+
246+Perhaps this is as good a place as any to mention a few points of
247+terminology. A block is a sector. Sectors are numbered sequentially
248+from 0. Sector numbering continues sequentially from drive n to drive
249+n+1, see DRIVE-OFFSET, but also see OFFSET. A SCREEN is a kilobyte
250+worth of blocks, in this case, four 256-byte sectors. SCREEN numbering
251+also begins with 0. (SCREENs are called SCREENs because a SCREEN can be
252+displayed on 16 lines of a 64-column CRT screen.) You will notice that
253+a CoCo 2 can't properly display and edit a whole SCREEN. Finally,
254+forward blocks are control constructs, not disk sectors.
255+
256+
257+*******************************************************************************
258+ The BIF Virtual Machine
259+
260+{ bifc_vm.h ---
261+fig 6809
262+UP [DP] pointer to the per-USER variable table (USER Pointer)
263+IP Y pointer to the next definition (Instruction Pointer)
264+RP S return/control stack pointer
265+SP U parameter/data stack pointer
266+W [S] pointer to executing definition's parameter field
267+}
268+ The BIF Virtual Machine
269+
270+fig 6809
271+{ bifc_vm.c bif.m bifdp.a
272+NEXT ( --- ) jmp [,y++] (macro in bif.m)
273+ Causes the next definition to execute.
274+
275+DOCOL ( *** IP ) jsr <XCOL (see bif.m, bifdp.a)
276+ Characteristic of a colon (:) definition. Begins execution of a
277+ high-level definition, i. e., nests the definition and begins
278+ processing icodes. Mechanically, it pushes the IP (Y register)
279+ and loads the Parameter Field Address of the definition which
280+ called it into the IP.
281+}
282+{ symbol.c bif.m bifdp.a
283+DOVAR ( --- vadr ) jsr <XVAR (bif.m, bifdp.a)
284+ Characteristic of a VARIABLE. A VARIABLE pushes its PFA address
285+ on the stack. The parameter field of a VARIABLE is the actual
286+ allocation of the variable, so that pushing its address allows
287+ its contents to be @ed (fetched). Ordinary arrays and strings
288+ that do not subscript themselves may be allocated by defining a
289+ variable and immediately ALLOTting the remaining space.
290+ VARIABLES are global to all users, and thus should have been
291+ hidden in resource monitors, but aren't.
292+
293+DOCON ( --- n ) jsr <XCON (bif.m, bifdp.a)
294+ Characteristic of a CONSTANT. A CONSTANT simply loads its value
295+ from its parameter field and pushes it on the stack.
296+
297+DOUSER ( --- vadr ) jsr <XUSER (bif.m, bifdp.a)
298+ Characteristic of a per-USER variable. USER variables are
299+ similiar to VARIABLEs, but are allocated (by hand!) in the
300+ per-user table. A USER variable's parameter field contains its
301+ offset in the per-user table.
302+
303+DOVOC ( --- ) jsr <XVOC (bif.m, bifdp.a)
304+ Characteristic of a VOCABULARY. A VOCABULARY stores a pointer
305+ to itself in the current interpretation ROOT per-USER variable.
306+ It contains a pointer to the definition at the root of its
307+ symbol table tree. This allows the symbol table routines to
308+ treat the root as a leaf node. This is also not standard FORTH!
309+
310+ ( --- PFA ) ( *** IP ) jsr <XDOES (routine in bifdp.a)
311+ Characteristic of a DOES> defined word. The characteristics of
312+ DOES> definitions are written in high-level icodes rather than
313+ machine level code. The first parameter word points to the
314+ high-level characteristic. This routine's job is to push the
315+ IP, load the high level characteristic pointer in IP, and leave
316+ the address following the characteristic pointer on the stack so
317+ the parameter field can be accessed.
318+
319+The following are not standard FORTH characteristics:
320+
321+DO1ARR ( index --- eadr ) jsr <X1ARR (bif.m, bifdp.a)
322+ Characteristic of a linear array. Linear arrays take the top
323+ word on the stack as an index to the array, and return the
324+ address of the element indexed. So this routine subtracts the
325+ base index of the array, limit checks the result, then
326+ multiplies by the size of the array elements. If the index is
327+ out of bounds, it returns a NULL pointer (0). At some point I
328+ intended to implement multi-dimensional arrays in a similar
329+ manner, but I haven't. It would be a quick and interesting
330+ project for anyone interested.
331+
332+DOUCON ( --- n ) jsr <XUCON (bif.m, bifdp.a)
333+ Characteristic of a USER variable treated as a CONSTANT, i. e.,
334+ fetches the value stored at the specified offset in the per-user
335+ table.
336+
337+ ( --- d ) jsr <XDCON (bifdp.a)
338+ Characteristic of a double integer constant; the parameter field
339+ contains two words instead of one, both of which get pushed.
340+}
341+{ unused
342+ADDTOP (MACRO in BIF.M) is not a characteristic; is used in several
343+ routines to add a value to the top of stack.
344+}
345+
346+One of the primary problems with extending BIF is that calls to the
347+built-in characteristics are not conform to ;CODE. Defining definitions
348+which use (;CODE) to establish the characteristics of the
349+sybmbols/definitions they define will hav a three-byte code field, where
350+the built-in compiling definitions -- VARIABLE, (1ARRAY, etc.,)
351+CONSTANT, USER, :, and VOCABULARY have two-byte code fields. One
352+specific example of the difficulties this can create is that
353+vocabularies with special properties built in BIF, rather than by hand,
354+can't be searched by BIF's symbol table search routine, -FIND. Of
355+course, XVOC could be moved to VOCABULARY, where it belongs, (and might
356+also be changed to a DOES> definition, but I don't think that's
357+necessary on the 6809).
358+
359+
360+*******************************************************************************
361+ The BIF Symbols/Definitions/Routines
362+
363+
364+I have added slightly to the FORTH documentation methods. I also show
365+the results on the return stack and in the input buffer, where
366+appropriate. The name on the left is the definition name, as it will be
367+found by ' (TICK) and the outer interpreter. To the right I indicate
368+precedence (P for higher Precedence than definition) and restrictions (C
369+for Compile-only). Below the name, I indicate the assembler source
370+label, where it is different from the name. The definitions on the
371+SCREENS disk also indicate screen and sector for the source.
372+
373+The parameters attempt to be mnemonic. It will help to remember that
374+there are no stack items smaller than 16 bits; character and byte
375+parameters will be integers with their high-bytes ignored. Double
376+integers are 32 bits. A further reminder, parameters are listed Pascal
377+order, first pushed first; thus, the right-most is at the top of stack,
378+or the lowest address. I specify a list of doubles pushed onto the
379+stack (used in the assembler) as dl. Finally, I will try to mean 16-bit
380+integer when I say word, but I may sometimes slip and mean (per FORTH
381+jargon) a definition/routine.
382+
383+Flags are slightly different than fig-FORTH -- true is set as -1, sensed
384+as non-zero. False is zero, of course.
385+
386+A number of routines (such as ENCLOSE) accept and return different
387+parameters than specified in fig-FORTH. I assume that those for whom
388+this fact may be of consequence will have copies of the standard and can
389+compare at their leisure.
390+
391+The definitions are not alphabetized, nor are they listed in order of
392+immediate interest, but they are organized by the source file they occur
393+in. The following file descriptions are generally accurate, but some
394+code is out of place.
395+
396+ BIF contains most of the virtual machine.
397+
398+ BIF.M contains the inner interpreter macro, some important
399+ symbol table offsets, and a few other general EQUates and
400+ macros.
401+
402+ BIFDP contains the rest of the virtual machine.
403+
404+ BIFU contains the allocation of the per-user system variables.
405+
406+ BIFST contains the boot up code and definitions.
407+
408+ BIF1 contains most of the calculator-style expression evaluator.
409+
410+ BIF2 is mostly constants and system variables, but contains the
411+ memory management primitives.
412+
413+ Most of BIF3 is code which interacts with system variables, for
414+ example, the words which set the conversion base to sixteen,
415+ ten, or eight.
416+
417+ BIF4 contains multiplication and division, and the disk
418+ interface primitives.
419+
420+ BIF5 is mostly output formatting.
421+
422+ BIF6 is mostly input formatting and terminal interface.
423+
424+ BIF7 contains most of the dictionary (interactive symbol table)
425+ machinery.
426+
427+Unless otherwise noted, all definitions are in the BIF vocabulary.
428+
429+There is much that is not sacred about FORTH and its dialects. For
430+many, the attraction of FORTH is the great abandon with which one may
431+play games with its inner workings. I have taken a number of liberties
432+and these routines still function. If you have an idea, back your disks
433+up and try it.
434+
435+
436+**** Definitions/Routines in BIF.ASM and BIFB.A:
437+{ vm_alu.c bif.asm
438+@ ( adr --- n )
439+FETCH Replace address on stack with the word at the address.
440+
441+
442+! ( n adr --- )
443+STORE Store second word on stack at address on top of stack.
444+
445+LIT ( --- n ) C
446+ Push the following word from the instruction stream as a
447+ literal, or immediate value.
448+
449+DLIT ( --- d ) C
450+ Push a double integer literal (see LIT).
451+}
452+
453+{ bifc_vm.c bif.asm
454+EXECUTE ( adr --- ) C
455+EXEC Jump to address on stack. Used by the "outer" interpreter to
456+ interactively invoke routines. (Not compile-only in fig.)
457+
458+0BRANCH ( f --- ) C
459+ZBR BRANCH if flag is zero.
460+
461+1BRANCH ( f --- ) C
462+TBR BRANCH if not zero. Not as useful as it might appear.
463+
464+BRANCH ( --- ) C
465+ Add the following word from the instruction stream to the
466+ instruction pointer (Y++). Causes a program branch.
467+}
468+
469+(LOOP) ( --- ) ( limit index *** limit index+1) C
470+XLOOP ( limit index *** )
471+ Counting loop primitive. The counter and limit are the top two
472+ words on the return stack. If the updated index/counter does
473+ not exceed the limit, a branch occurs. If it does, the branch
474+ does not occur, and the index and limit are dropped from the
475+ return stack.
476+
477+(+LOOP) ( n --- ) ( limit index *** limit index+n ) C
478+XPLOOP ( limit index *** )
479+ Loop with a variable increment. Terminates when the index
480+ crosses the boundary from one below the limit to the limit. A
481+ positive n will cause termination if the result index equals the
482+ limit. A negative n must cause the index to become less than
483+ the limit to cause loop termination.
484+
485+(DO) ( limit index --- ) ( *** limit index )
486+XDO Move the loop parameters to the return stack. Synonym for D>R.
487+
488+I ( --- index ) ( limit index *** limit index )
489+ Copy the loop index from the return stack. Synonym for R.
490+
491+J ( --- index2 ) ( index2 limit1 index1 *** index2 limit1 index1 )
492+ Copy the outer loop index from the return stack. As with (DO)
493+ and I, J may be useful outside looping contexts.
494+
495+DIGIT ( c base --- ff )
496+ ( c base --- n tf )
497+ Translate C in base, yielding a translation valid flag. If the
498+ translation is not valid in the specified base, only the false
499+ flag is returned.
500+
501+(FIND) ( name vocptr --- locptr f )
502+PFIND Search vocabulary for a symbol called name. Name is a pointer
503+ to a NUL terminated string of characters without count, vocptr
504+ is a pointer to a pointer to a definition (the length byte of a
505+ symbol table entry). Locptr is also a pointer to a pointer to a
506+ definition, such that, if the flag is false, a symbol with the
507+ name searched for may be inserted in proper order at that point.
508+ Vocptr and locptr may point to either the right or left entry of
509+ the order-parent entry in the symbol table, or to pointer to the
510+ root of a vocabulary. HIDDEN (smudged) definitions are
511+ lexically less than their name strings. Searches only the local
512+ vocabulary, from the order-parent node passed. Uses (REFIND).
513+
514+ vocptr is a pointer to the parameter field of a vocabulary
515+ header.
516+
517+ENCLOSE ( buffer c --- s length )
518+ENCLOS Scan buffer for a symbol delimited by c or ASCII NUL; return the
519+ length of the symbol scanned and the address of its first
520+ character. A length 0 and a pointer to a NUL means no symbol
521+ was scanned before NUL terminator was reached. (Buffer is the
522+ address of the buffer array to scan.)
523+
524+LITERAL ( n --- ) P
525+LITER ( n --- n ) if interpreting.
526+ Compile n as a literal, if compiling.
527+
528+DLITERAL ( d --- ) P
529+DLITER ( d --- d ) if interpreting.
530+ Compile d as a double literal, if compiling.
531+
532+EMIT ( c --- )
533+ Write c to the output device (screen or printer). Uses the ECB
534+ device number at address $6F, -2 is printer, 0 is screen.
535+
536+KEY ( --- c )
537+ ( --- BREAK )
538+ Wait for a key from the keyboard. If the key is BREAK, set the
539+ high byte (result $FF03).
540+
541+?TERMINAL ( --- f )
542+QTERM Scan keyboard, but do not wait. Return 0 if no key, BREAK
543+ ($ff03) if BREAK is pressed, or key currently pressed.
544+
545+CR ( --- )
546+ EMIT a Carriage Return (ASCII CR).
547+
548+(;CODE) ( --- ) ( IP *** ) C
549+XSCODE Compile the latest symbol as a reference to a ;CODE definition;
550+ overwrite the first three (3!) bytes of the code field of the
551+ symbol found by LATEST with a jump to the low-level
552+ characteristic code provided in the defining definition, and pop
553+ IP. The machine-level code which follows (;CODE) in the
554+ instruction stream is not executed by the defining symbol, but
555+ becomes the characteristic of the defined symbol. This is the
556+ usual way to generate the characteristics of VARIABLEs,
557+ CONSTANTs, etc., when FORTH compiles itself. BIF, however, was
558+ hand-optimized to take advantage of direct-page jumps. So its
559+ pre-compiled defining symbols with low-level characteristics
560+ look different from those compiled by BIF, having two bytes in
561+ their code fields instead of three.
562+
563+>PRT ( --- )
564+TOPRT Send output to printer via CoCo's ROM routines and the device
565+ number variable (see EMIT).
566+
567+>VID ( --- )
568+TOVID Send output to CRT, converse of >PRT.
569+
570+2* ( n --- n*2 )
571+LSHIFT Fast multiply by two.
572+
573+2/ ( n --- n/2 )
574+RSHIFT Fast divide by two.
575+
576+(REFIND) ( name vocptr --- name locptr f )
577+PREF Search vocabulary for the first symbol called name. (Will find
578+ HIDDEN/SMUDGEd definitions.) Name is a pointer to a string of
579+ characters without count, vocptr is a pointer to a pointer to a
580+ definition (the length byte of a symbol table entry). Locptr is
581+ also a pointer to a pointer to a definition, such that, if the
582+ pointer at the pointer is NULL, a symbol with the name searched
583+ for may be inserted in proper order at that point. Vocptr and
584+ locptr may be either the right or left entry of the order-parent
585+ entry in the symbol table, or a pointer to the root of a
586+ vocabulary. Flag f will indicate by offset whether the child or
587+ empty slot is a left link (LFTOFF), right link (RTOFF), or
588+ vocabulary (PFAOFF).
589+
590+ vocptr is a pointer to the parameter field of a vocabulary
591+ header.
592+
593+
594+**** Definitions/Routines in BIF1.A and BIF1B.A:
595+
596+MOVE ( source target count --- )
597+ Copy/move count words from source to target. Moves ascending
598+ addresses, so that overlapping only works if the source is
599+ above the destination.
600+
601+CMOVE ( source target count --- )
602+ Copy/move count bytes from source to target. Moves ascending
603+ addresses, so that overlapping only works if the source is
604+ above the destination.
605+
606+U* ( u1 u2 --- ud )
607+USTAR Multiplies the top two unsigned integers, yielding a double
608+ integer product.
609+
610+U/ ( ud u --- uremainder uquotient )
611+USLASH Divides the top unsigned integer into the second and third words
612+ on the stack as a single unsigned double integer, leaving the
613+ remainder and quotient (quotient on top) as unsigned integers.
614+
615+ The smaller the divisor, the more likely dropping the high word
616+ of the quotient loses significant bits.
617+
618+AND ( n1 n2 --- n )
619+ Bitwise and the top two integers.
620+
621+OR ( n1 n2 --- n )
622+ Bitwise or.
623+
624+XOR ( n1 n2 --- n )
625+ Bitwise exclusive or.
626+
627+SP@ ( --- adr )
628+SPFEH Fetch the parameter stack pointer (before it is pushed).
629+
630+SP! ( whatever --- nothing )
631+SPSTO Initialize the parameter stack pointer from the USER variable
632+ S0. Effectively clears the stack.
633+
634+RP! ( whatever *** nothing )
635+RPSTO Initialize the return stack pointer from the USER variable R0.
636+ Effectively aborts all in process definitions, except the active
637+ one. An emergency measure, to be sure.
638+
639+;S ( ip *** )
640+SEMIS Pop IP from return stack (return from high-level definition).
641+ Can be used in a screen to force interpretion to terminate.
642+
643+LEAVE ( limit index *** index index )
644+ Force the terminating condition for the innermost loop by
645+ copying its index to its limit. Termination is postponed until
646+ the next LOOP or +LOOP instruction is executed. The index
647+ remains available for use until the LOOP or +LOOP instruction is
648+ encountered.
649+
650+>R ( n --- ) ( *** n ) C
651+TOR Move top of parameter stack to top of return stack.
652+
653+R> ( --- n ) (n *** ) C
654+RFROM Move top of return stack to top of parameter stack.
655+
656+R ( --- n ) ( n *** n )
657+ Copy the top of return stack to top of parameter stack. A
658+ synonym for I.
659+
660+= ( n1 n2 --- n1=n2 )
661+EQ Flag true if n1 and n2 are equal, otherwise false.
662+
663+< ( n1 n2 --- n1<n2 )
664+LT Flag true if n1 is less than n2, otherwise false.
665+
666+0= ( n --- n=0 )
667+ZEQ Logically invert top of stack; or flag true if top is zero,
668+ otherwise false.
669+
670+0< ( n --- n<0 )
671+ZLESS Flag true if top is negative (MSbit set), otherwise false.
672+
673+> ( n1 n2 --- n1>n2 )
674+GT Flag true if n1 is greater than n2, false otherwise.
675+
676+{ vm_alu.c bif1.a
677++ ( n1 n2 --- n1+n2 )
678+ADD Add top two words.
679+
680+- ( n1 n2 --- n1-n2 )
681+SUB Subtract top two words.
682+}
683+
684+D+ ( d1 d2 --- d1+d2 )
685+DADD Add top two double integers.
686+
687+D- ( d1 d2 --- d1-d2 )
688+DSUB Subtract top two double integers.
689+
690+MINUS ( n --- -n )
691+ Negate (two's complement) top of stack.
692+
693+DMINUS ( d --- -d )
694+ Negate (two's complement) top two words on stack as a double
695+ integer.
696+
697+OVER ( n1 n2 --- n1 n2 n1 )
698+ Push a copy of the second word on stack.
699+
700+DROP ( n --- )
701+ Discard the top word on stack.
702+
703+SWAP ( n1 n2 --- n2 n1 )
704+ Swap the top two words on stack.
705+
706+DUP ( n1 --- n1 n1 )
707+ Push a copy of the top word on stack.
708+
709++! ( n adr --- )
710+ADDSTO Add the second word on stack to the word at the adr on top of
711+ stack.
712+
713+TOGGLE ( adr b --- )
714+TOG Exclusive or byte at adr with low byte of top word.
715+
716+C@ ( adr --- b )
717+CFEH Replace address on top of stack with the byte at the address.
718+ High byte of result is clear.
719+
720+C! ( b adr --- )
721+CSTO Store low byte of second word on stack at address on top of
722+ stack. High byte is ignored.
723+
724+ROT ( n1 n2 n3 --- n2 n3 n1 )
725+ Rotate the top three words on stack, bringing the third word to
726+ the top.
727+
728+BACK ( adr --- ) C
729+ Calculate a back reference from HERE and compile it. The result
730+ compiled is adr-HERE-2, being adjusted for post-increment
731+ addressing.
732+
733+NOT ( n --- ~n )
734+ Bit (one's) complement the top of stack.
735+
736+' ( --- ) compiling P
737+TICK ( --- adr ) interpreting
738+ { ' name } input
739+ Parse a symbol name from input and search, -DFIND, the
740+ dictionary for it; compile the address as a literal if
741+ compiling, otherwise just push it. Recursively searches parent
742+ vocabularies, aborts if the parsed symbol name is not found.
743+
744+--> ( --- ) P
745+NEXSCR Continue interpreting source code on the next screen.
746+
747+1ARRAY ( start end size --- )
748+ONEARR { 1ARRAY name } input
749+ Parse name and compile it as a linear array of size elements
750+ from start index to end index inclusive. The number of bytes in
751+ the array is (end-start+1)*size. The 1ARRAY characteristic is a
752+ direct page routine.
753+
754+UTILITIES ( --- )
755+UTIL The UTILITIES vocabulary.
756+
757+DP@ ( --- adr ) in UTILITIES
758+DPFEH Calculate and push the address of the direct page.
759+
760+DCONSTANT ( d --- )
761+DCON { DCONSTANT name } input
762+ Parse name and compile it as a double constant with a value of
763+ d. The DCONSTANT characteristic is a direct page routine.
764+
765+SWAB ( n --- ns )
766+ Swap the bytes of the top word on stack.
767+
768+SWAN ( n --- ns )
769+ Swap the nibbles of the top word on stack. The low-level code
770+ looks funny, but it was the fastest way I could think up.
771+
772+
773+**** Definitions/Routines in BIF2.A and BIF2B.A:
774+
775+Increments and decrements for top of stack:
776+1+ ADD1 ( n --- n+1 )
777+1- SUB1 ( n --- n-1 )
778+2+ ADD2 ( n --- n+2 )
779+2- SUB2 ( n --- n-2 )
780+
781+Constants:
782+0 ZERO ( --- 0 )
783+1 ONE ( --- 1 )
784+-1 MONE ( --- -1 )
785+2 TWO ( --- 2 )
786+3 THREE ( --- 3 )
787+BL BL ( --- SP ) ASCII SPACE character
788+C/L CPERL ( --- 32 ) The number of columns per line on the
789+ CRT. Determines the length of error messages and the
790+ width and length of screen listings, among other things.
791+FIRST ( --- adr ) The base of the disk buffer space.
792+LIMIT ( --- adr ) The limit of the disk buffer space.
793+B/BUF BPBUF ( --- 256 ) The size, in bytes, of a buffer.
794+B/SCR BPSCR ( --- 4 ) The size, in buffers, of a screen.
795+
796++ORIGIN ( n --- adr )
797+PORIG Calculate the address of the (n/2)th entry in the boot-up
798+ parameter table. (Adds the base of the boot-up table to n.)
799+
800+Variables:
801+TIB ( --- vadr ) Terminal Input Buffer address. Note
802+ that is a variable, so users may allocate their own
803+ buffers, but it must be @ed.
804+WARNING WARN ( --- vadr ) Availability of error messages on disk.
805+ Contains 1 if messages available, 0 if not, -1 if a disk
806+ error has occurred.
807+ In bif-c, add 2 for internal error strings.
808+FENCE ( --- vadr ) Boundary for FORGET.
809+DP DPC ( --- vadr ) Dictionary pointer, fetched by HERE.
810+ROOT ( --- vadr ) Current local/context interpretation
811+ vocabulary root. Not a fig variable.
812+BLK ( --- vadr ) Block being interpreted. Zero refers to
813+ terminal.
814+IN ( --- vadr ) Input buffer offset/cursor.
815+OUT ( --- vadr ) Output buffer offset/cursor.
816+SCR ( --- vadr ) Screen being edited. Unused in BIF.
817+OFFSET ( --- vadr ) Sector offset for LOADing screens, set
818+ by DRIVE to make a new drive the default.
819+STATE ( --- vadr ) Compiler/interpreter state.
820+BASE ( --- vadr ) Numeric conversion base.
821+DPL ( --- vadr ) Output decimal point locator.
822+FLD ( --- vadr ) Field width for I/O formatting.
823+CSP ( --- vadr ) Compiler stack mark for stack check.
824+R# RNUM ( --- vadr ) Editing cursor location. Unused in BIF.
825+HLD ( --- vadr ) Pointer to last HELD character in PAD.
826+FOREWARD FORE ( --- vadr ) Pointer to earliest definition in active
827+ forward block. Not fig.
828+CURRENT CURR ( --- vadr ) NFA of LATEST definition. Not fig.
829+PREV ( --- vadr ) Most Recently Used buffer.
830+USE ( --- vadr ) Least Recently Used buffer.
831+DROOT ( --- vadr ) Current defining/compiling vocabulary
832+ root. Not fig.
833+
834+HERE ( --- adr )
835+ Get contents of DP, with heap/stack overflow ERROR check. More
836+ than a pseudo-constant.
837+
838+ALLOT ( n --- )
839+ Increase heap (add n to DP), ERROR check stack/heap.
840+
841+, ( n --- )
842+COMMA Store word n at DP++, ERROR check stack/heap.
843+
844+C, ( b --- )
845+CCOMMA Store byte b at DP+, ERROR check stack/heap.
846+
847+SPACE ( --- )
848+ EMIT a SPACE.
849+
850+-DUP ( 0 --- 0 )
851+DDUP ( n --- n n )
852+ DUP if non-zero.
853+
854+?CST ( --- f )
855+QCST Push compile/interpret state bits.
856+
857+IF ( --- cdptr $4946 ) P,C
858+ Compile a 0BRANCH and dummy offset and push IF reference to fill
859+ in and IF control construct flag.
860+
861+ELSE ( cdptr1 $4946 --- cdptr2 $4946 ) P,C
862+ ERROR check IF flag, compile BRANCH with dummy offset, resolve
863+ IF reference (FILL-IN offset-2 to HERE at cdptr1), and leave
864+ reference to BRANCH for ELSE.
865+
866+
867+ENDIF ( cdptr $4946 --- ) P,C
868+ ERROR check IF flag, resolve IF reference (FILL-IN offset-2 to
869+ HERE at cdptr) and pop reference/flag.
870+
871+
872+**** Definitions/Routines in BIF3.A and BIF3B.A:
873+
874+LATEST ( --- symptr )
875+ Fetch CURRENT as a per-USER constant.
876+
877+Symbol table conversions:
878+LFA ( n --- n+LFAOFF ) Convert NFA (not PFA) to LFA.
879+ --> Convert header address to LFA.
880+CFA ( n --- n+CFAOFF ) Convert NFA (not PFA) to CFA.
881+ --> Convert header address to CFA.
882+GFA ( n --- n+GFAOFF ) Convert NFA (not PFA) to CFA.
883+ --> Convert header address to GFA.
884+PFA ( n --- n+PFAOFF ) Convert NFA to PFA.
885+ --> Convert header address to PFA.
886+NFA ( n --- n-PFAOFF ) Convert PFA to NFA.
887+ --> Convert PFA to header address.
888+ NFA is the address of the length byte in a symbol table header.
889+ --> Now we use the header address instead of the NFA.
890+ PFA is the address at which a high-level definition's icode list
891+ begins, or a variable's, constant's, or vocabulary's value is
892+ stored.
893+ CFA is where a definition's code begins, or where the jump to
894+ its characteristic is stored.
895+ LFA is the address of a definition's allocation link.
896+ GFA is the address of a definition's vocabulary link.
897+
898+!CSP ( --- )
899+STOCSP Save the parameter stack pointer in CSP for compiler checks.
900+
901+Set the conversion base:
902+HEX ( --- ) Sixteen.
903+DECIMAL DEC ( --- ) Ten.
904+OCTAL OCT ( --- ) Eight.
905+
906+FILL ( adr n b --- )
907+ Fill n bytes at adr with b.
908+
909+ERASE ( adr n --- )
910+ Fill n bytes with 0.
911+
912+BLANKS ( adr n --- )
913+ Fill n bytes with ASCII SPACE.
914+
915+HOLD ( c --- )
916+ Format a character at the left of the HLD output buffer.
917+
918+PAD ( --- adr )
919+ Give the address of the output PAD buffer. Not same as fig. PAD
920+ points to the end of a 34 byte buffer for numeric conversion.
921+
922+S->D ( n0 --- d0 )
923+STOD Sign extend n0 to a double integer.
924+
925++- ( n0 n1>=0 --- n0 )
926+CHS ( n0 n1<0 --- -n0 )
927+ Change sign of second iff top is negative.
928+
929+D+- ( d0 n0>=0 --- d0 )
930+DCHS ( d0 n0<0 --- -d0 )
931+ Change sign of second and third as double iff top is negative.
932+
933+ABS ( n>=0 --- n )
934+ ( n<0 --- -n )
935+ Change the top of stack to its absolute value.
936+
937+DABS ( d>=0 --- d )
938+ ( d<0 --- -d )
939+ Change the top double to its absolute value.
940+
941+MIN ( n0 n1 --- min(n0,n1) )
942+ Leave the minimum of the top two integers.
943+
944+MAX ( n0 n1 --- max(n0,n1) )
945+ Leave the maximum of the top two integers.
946+
947+[ ( --- ) P
948+LBRAK Clear the compile state bits (shift to interpret).
949+
950+] ( --- )
951+RBRAK Set the compile state bits (shift to compile).
952+
953+IMMEDIATE ( --- )
954+IMMED Toggle precedence bit of LATEST definition header. During
955+ compiling, most symbols scanned are compiled. IMMEDIATE
956+ definitions execute whenever the outer INTERPRETer scans them,
957+ but may be compiled via ' (TICK).
958+
959+SMUDGE ( --- )
960+ Toggle HIDDEN bit of LATEST definition header, to hide it until
961+ defined or reveal it after definition.
962+
963+COMPILE-ONLY ( --- )
964+COMPO Toggle compile only bit of LATEST definition header.
965+
966+COUNT ( strptr --- strptr+1 count )
967+ Convert counted string to string and count. (Fetch the byte at
968+ strptr, post-increment.)
969+
970+-TRAILING ( strptr count1 --- strptr count2 )
971+DTRAIL Supress trailing blanks (subtract count of trailing blanks from
972+ strptr).
973+
974+(MACHINE) ( ip *** ) C
975+XMACH Change from executing icodes to machine code in a definition by
976+ saving IP and jumping to it after popping the old IP.
977+
978+TYPE ( strptr count --- )
979+ EMIT count characters at strptr.
980+
981+CTS-TYPE ( adr --- ) in UTILITIES (bif-c)
982+CTD_TYPE TYPE the (byte) counted string at adr.
983+
984+(.") ( --- ) C
985+XDOTQ TYPE counted string out of instruction stream (updating IP).
986+
987+ID. ( symptr --- )
988+IDDOT Print definition's name from its NFA.
989+
990+FILL-IN ( cdptr --- ) C
991+FILLIN Resolve the reference at cdptr by writing the offset from
992+ cdptr+2 to HERE at cdptr. Offset is adjusted for post-increment
993+ IP (ldd ,y++).
994+
995+BEGIN ( --- cdptr $4245 ) P,C
996+ Push HERE for BACK reference for general (non-counting) loops,
997+ with BEGIN construct flag.
998+
999+AGAIN ( cdptr $4245 --- ) P,C
1000+ ERROR check BEGIN flag, compile BRANCH and BACK resolve it to
1001+ cdptr.
1002+
1003+UNTIL ( cdptr $4245 --- ) P,C
1004+ ERROR check BEGIN flag, compile 0BRANCH and BACK resolve it to
1005+ cdptr.
1006+
1007+WHILE ( $4245 --- $4245 cdptr $5748 ) P,C
1008+ ERROR check BEGIN flag, compile 0BRANCH with dummy offset, push
1009+ WHILE reference -- HERE -- /flag on top of BEGIN reference/flag.
1010+
1011+REPEAT ( cdptr1 $4245 cdptr2 $5748 --- ) P,C
1012+ ERROR check WHILE and BEGIN flags, compile BRANCH and BACK fill
1013+ cdptr1 reference, FILL-IN 0BRANCH reference at cdptr2.
1014+
1015+DO ( --- cdptr $444F ) P,C
1016+ Compile (DO), push HERE for BACK refenece, and push DO control
1017+ construct flag.
1018+
1019+
1020+**** Definitions/Routines in BIF4.A and BIF4B.A:
1021+
1022+M* ( n1 n2 --- d )
1023+MSTAR Multiply top two words as signed integers with a signed double
1024+ result.
1025+
1026+M/ ( d n --- remainder quotient )
1027+MSLASH Divide signed double dividend d (2nd & 3rd words) by signed
1028+ word divisor n (top) yielding signed word remainder and quotient.
1029+ Quotient is top, remainder takes sign of dividend.
1030+
1031+ Thus, dividend == quotient * divisor + remainder
1032+ with truncating toward zero.
1033+ This can overflow in quotient.
1034+
1035+* ( multiplier multiplicand --- product )
1036+STAR Signed word multiply.
1037+
1038+/MOD ( dividend divisor --- remainder quotient )
1039+SLAMOD M/ in word-only form, i. e., signed division of 2nd word by top
1040+ word yielding signed word quotient and remainder.
1041+
1042+/ ( dividend divisor --- quotient )
1043+SLASH Signed word divide without remainder.
1044+
1045+MOD ( dividend divisor --- remainder )
1046+ Remainder function, result takes sign of dividend.
1047+
1048+*/MOD ( multiplier multiplicand divisor --- remainder quotient )
1049+SSMOD Signed precise division of product: multiply 2nd and 3rd
1050+ words on stack and divide the 31-bit product by the top word,
1051+ leaving both quotient and remainder. Remainder takes sign of
1052+ product. Guaranteed not to lose significant bits.
1053+
1054+*/ ( multiplier multiplicand divisor --- quotient )
1055+STARSL */MOD without remainder.
1056+
1057+M/MOD ( ud1 u1 --- u2 ud2 )
1058+MSMOD U/ with an (unsigned) double quotient. Guaranteed not to lose
1059+ significant bits, if you are prepared to deal with them.
1060+
1061++BUF ( buffer1 --- buffer2 f )
1062+ADDBUF Bump to next buffer, flag false if result is PREVious buffer,
1063+ otherwise flag true. Used in the LRU allocation routines.
1064+
1065+UPDATE ( --- )
1066+ Mark PREVious buffer dirty, in need of being written out.
1067+
1068+EMPTY-BUFFERS ( --- )
1069+EMTBUF Mark all buffers empty. Standard method of discarding changes.
1070+
1071+DRIVE-OFFSET ( n --- eadr )
1072+DROFFS 1ARRAY of drive offsets (see DO1ARR in the description of the
1073+ virtual machine). Contains the size, in sectors, of four
1074+ drives, plus a fifth entry to end the table if all four drives
1075+ are defined. To make drive 2 a 40 track SS-DD drive:
1076+ 40 18 * 2 DRIVE-OFFSET !
1077+ (Formatting the extra tracks can be handled with OS-9.)
1078+
1079+DRIVE ( n --- )
1080+ Add up the sector offset to sector 0 of drive n and store it in
1081+ OFFSET. This changes the logically lowest drive for LOADING.
1082+
1083+R/W ( buffer sector f --- )
1084+RW Read or Write the specified (absolute -- ignores OFFSET) sector
1085+ from or to the specified buffer. A zero flag specifies write,
1086+ non-zero specifies read. Sector is an unsigned integer, buffer
1087+ is the buffer's address. Uses the CoCo ROM disk routines. This
1088+ is where you would want to handle double-sided drives.
1089+
1090+?ERROR ( 0 n --- ) ( *** )
1091+QERROR ( true n --- IN BLK ) ( anything *** nothing )
1092+ If flag is false, do nothing. If flag is true, issue error
1093+ MESSAGE and QUIT or ABORT, via ERROR. Leaves cursor position
1094+ (IN) and currently loading block number (BLK) on stack, for
1095+ analysis.
1096+
1097+?COMP ( --- ) ( *** )
1098+QCOMP ( --- IN BLK ) ( anything *** nothing )
1099+ ERROR if not compiling.
1100+
1101+?EXEC ( --- ) ( *** )
1102+QEXEC ( --- IN BLK ) ( anything *** nothing )
1103+ ERROR if not executing.
1104+
1105+?PAIRS ( n1 n2 --- ) ( *** )
1106+QPAIRS ( n1 n2 --- IN BLK ) ( anything *** nothing )
1107+ ERROR if n1 and n2 are unequal. MESSAGE says compiled
1108+ conditionals do not match.
1109+
1110+?CSP ( --- ) ( *** )
1111+QCSP ( --- IN BLK ) ( anything *** nothing )
1112+ ERROR if return/control stack is not at same level as last !CSP.
1113+ Used to indicate that a definition has been left incomplete.
1114+ *** Actually, this checks the parameter stack. ***
1115+
1116+?LOADING ( --- ) ( *** )
1117+QLOAD ( --- IN BLK ) ( anything *** nothing )
1118+ ERROR if not loading, i. e., if BLK is non-zero. [correction: if BLK _is_ zero!]
1119+
1120+COMPILE ( --- )
1121+COMP Compile an in-line literal value from the instruction stream.
1122+
1123+LOOP ( cdptr $444f --- ) P,C
1124+ ERROR check DO flag, compile (LOOP), fill in BACK reference.
1125+
1126++LOOP ( cdptr $444f --- ) P,C
1127+PLOOP ERROR check DO flag, compile (+LOOP), fill in BACK reference.
1128+
1129+LOAD ( n --- )
1130+ Begin interpretation of screen (block) n. See also NEXSRC,
1131+ SEMIS, and ***NULLL****GGGGGHHHHTHNiTHNiTHNi
1132+
1133+<BUILDS ( --- ) C
1134+BUILDS Build a header for DOES> definitions. Actually just compiles a
1135+ CONSTANT zero which can be overwritten later by DOES>. Note
1136+ that <BUILDS is not IMMEDIATE, and therefore executes during a
1137+ definition's run-time, rather than its compile-time. It is not
1138+ intended to be used directly, but rather so that one definition
1139+ can build another. Also, note that nothing particularly special
1140+ happens in the defining definition until DOES> executes. The
1141+ name <BUILDS is intended to be a reminder of what is about to
1142+ occur.
1143+
1144+DOES> ( --- ) ( IP *** ) C
1145+DOES Define run-time behavior of definitions compiled/defined by a
1146+ high-level defining definition -- the FORTH equivalent of a
1147+ compiler-compiler. DOES> assumes that the LATEST symbol table
1148+ entry has at least one word of parameter field, which <BUILDS
1149+ provides. Note that DOES> is also not IMMEDIATE. When the
1150+ defining word containing DOES> executes the DOES> icode, it
1151+ overwrites the LATEST symbol's CFA with jsr <XDOES, overwrites
1152+ the first word of that symbol's parameter field with its own IP,
1153+ and pops the previous IP from the return stack. The icodes which
1154+ follow DOES> in the stream do not execute at the defining word's
1155+ run-time. Examining XDOES in the virtual machine shows that the
1156+ defined word will execute those icodes which follow DOES> at its
1157+ own run-time. The advantage of this kind of behaviour, which
1158+ you will also note in ;CODE, is that the defined word can
1159+ contain both operations and data to be operated on. This is how
1160+ FORTH data objects define their own behavior. Finally, note
1161+ that the effective code field for DOES> definitions is four
1162+ bytes.
1163+
1164+;CODE ( --- ) P,C
1165+SCODE ?CSP to see if there are loose ends in the defining definition
1166+ before shifting to the assembler, compile (;CODE) in
1167+ the defining definition's instruction stream, shift to
1168+ interpreting, make the ASSEMBLER vocabulary current, and !CSP to
1169+ mark the stack in preparation for assembling low-level code.
1170+ Note that ;CODE, unlike DOES>, is IMMEDIATE, and compiles
1171+ (;CODE),which will do the actual work of changing the LATEST
1172+ definition's characteristic when the defining word runs.
1173+ Assembly is done by the interpreter, rather than the compiler.
1174+ I could have avoided the anomalous three-byte code fields by
1175+ having ;CODE compile in the direct page jumps to the actual
1176+ low-level characteristics in the defining definition, thus
1177+ allowing (;CODE) to write a two-byte direct-page jumps into the
1178+ code fields of defined words. But that's a lot of work!
1179+
1180+
1181+**** Definitions/Routines in BIF5.A and BIF5B.A:
1182+
1183+
1184+IP, ( --- ) C
1185+IPCOM COMPILE a literal out of the instruction stream, without
1186+ checking compiler state. Used by the assembler to stuff
1187+ op-codes into the instruction stream, since the assembler runs
1188+ in interpretation mode.
1189+
1190+?STACK ( --- ) ( *** )
1191+QSTACK ( --- IN BLK ) ( anything *** nothing )
1192+ ERROR if either stack out of bounds, or on evidence of stack
1193+ boundary problems. There is a word below the bottom of each
1194+ stack, which ABORT clears before it starts interpreting. In
1195+ addition to checking that both stacks have not overflowed, this
1196+ routine checks those two words, to see if underflow has
1197+ occurred.
1198+
1199+BUFFER ( n --- buffer )
1200+ Get a free buffer, assign it to block n, return buffer address.
1201+ Will free a buffer by writing it, if necessary. Does not
1202+ actually read the block. A bug in the fig LRU algorithm, which
1203+ I have not fixed, gives the PREVious buffer if USE gets set to
1204+ PREVious (the bug is that it happens). This bug sometimes
1205+ causes sector moves to become sector fills.
1206+
1207+BLOCK ( n --- buffer )
1208+ Get BUFFER containing block n, relative to OFFSET. If block n
1209+ is not in a buffer, bring it in. Returns buffer address.
1210+
1211+(LINE) ( line screen --- buffer C/L)
1212+XLINE Bring in the sector containing the specified line of the
1213+ specified screen. Returns the buffer address and the width of
1214+ the screen. Screen number is relative to OFFSET. The line
1215+ number may be beyond screen 4, (LINE) will get the appropriate
1216+ screen.
1217+
1218+.LINE ( line screen --- )
1219+DOTLIN Print the line of the screen as found by (LINE), suppress
1220+ trailing BLANKS.
1221+
1222+SPACES ( count --- )
1223+ EMIT count spaces, for non-zero, non-negative counts.
1224+
1225+<# ( --- )
1226+BEGHSH Initialize HLD for converting a double integer. Stores the PAD
1227+ address in HLD.
1228+
1229+#> ( d --- string length )
1230+ENDHSH Terminate numeric conversion, drop the number being converted,
1231+ leave the address of the conversion string and the length, ready
1232+ for TYPE.
1233+
1234+SIGN ( n d --- d )
1235+ Put sign of n (as a flag) in front of the conversion string.
1236+ Drop the sign flag.
1237+
1238+# ( d --- d/base )
1239+HASH Generate next most significant digit in the conversion BASE,
1240+ putting the digit in front of the conversion string.
1241+
1242+#S ( d --- dzero )
1243+HASHS Convert d to a numeric string using # until the result is zero.
1244+ Leave the double result on the stack for #> to drop.
1245+
1246+D.R ( d width --- )
1247+DDOTR Print d on the output device in the current conversion base,
1248+ with sign, right aligned in a field at least width wide.
1249+
1250+D. ( d --- )
1251+DDOT Print d on the output device in the current conversion base,
1252+ with sign, in free format with trailing space.
1253+
1254+.R ( n width --- )
1255+DOTR Print n on the output device in the current conversion base,
1256+ with sign, right aligned in a field at least width wide.
1257+
1258+. ( n --- )
1259+DOT Print n on the output device in the current conversion base,
1260+ with sign, in free format with trailing space.
1261+
1262+? ( adr --- )
1263+QDOT Print signed word at adr, per DOT.
1264+
1265+MESSAGE ( n --- )
1266+MESS If WARNING is 0, print "MESSAGE #n"; otherwise, print line n
1267+ relative to screen 4, the line number may be negative. Uses
1268+ .LINE, but counter-adjusts to be relative to the real drive 0.
1269+
1270+ In bif-c, add value of 2 for WARNING, for internal error message
1271+ strings.
1272+
1273+(ABORT) ( anything --- nothing ) ( anything *** nothing )
1274+IABORT An indirection for ABORT, for ERROR, which may be modified
1275+ carefully.
1276+
1277+ERROR ( anything line --- IN BLK ) ( anything *** nothing )
1278+ ( anything --- nothing ) ( anything *** nothing ) WARNING < 0
1279+ Prints out the last symbol scanned and MESSAGE number line. If
1280+ WARNING is less than zero, ABORTs through (ABORT), otherwise,
1281+ clears the parameter stack, pushes the INput cursor and
1282+ interpretaion BLK, and QUITs.
1283+
1284+EDITOR ( --- ) in EDITOR P
1285+ Set the current interpretation vocabulary to EDITOR.
1286+
1287+QSYNC ( --- ) in EDITOR
1288+ Synchronize the ECB cursor with R#.
1289+
1290+EBLK ( --- vadr ) in EDITOR
1291+ USER variable containing the current editing block.
1292+
1293+CURSOR ( --- adr ) in EDITOR
1294+ Calculates the address of the edit cursor, R#, within the
1295+ current editing block, bringing that block in if necessary.
1296+
1297+QDUMP ( adr --- ) in EDITOR
1298+ Dump the 256 bytes at adr to the screen memory, at the top half
1299+ of the screen (bottom half of screen memory).
1300+
1301+QARROW ( c --- c )
1302+ ( c --- 0 )
1303+ Adjust the cursor according to the key passed. If the key is a
1304+ cursor control key, return 0; otherwise, leave the key
1305+ unchanged. The regular back-arrow is used for cursor movement,
1306+ so the shifted back-arrow is used for destructive backspace.
1307+ Also, the up arrow is used for cursor movement, so caret is not
1308+ available without escaping. See QUICK.
1309+
1310+
1311+**** Definitions/Routines in BIF6.A and BIF6B.A:
1312+
1313+
1314+(NUMBER) ( d1 string --- d2 adr )
1315+INUMB Convert the text at string into a number, accumulating the
1316+ result into d1, leaving adr pointing to the first character not
1317+ converted. If DPL is non-negative at entry, accumulates the
1318+ number of characters converted into DPL.
1319+
1320+NUMBER ( ctstr --- d )
1321+ Convert text at ctstr to a double integer, taking the 0 ERROR if
1322+ the conversion is not valid. If a decimal point is present,
1323+ accumulate the count of digits to the decimal point's right into
1324+ DPL (negative DPL at exit indicates single precision). ctstr is
1325+ a counted string -- the first byte at ctstr is the length of the
1326+ string, but NUMBER ignores the count and expects a NUL
1327+ terminator instead.
1328+
1329+WORDPAD ( --- vadr )
1330+WORDPD The per-USER constant pointing to an intermediate
1331+ buffer for text scanning.
1332+
1333+WORD ( c --- )
1334+ Scan a string terminated by the character c or ASCII NUL out of
1335+ input; store symbol at WORDPAD with leading count byte and
1336+ trailing ASCII NUL. Leading c are passed over, per ENCLOSE.
1337+ Scans from BLK, or from TIB if BLK is zero. May overwrite the
1338+ numeric conversion pad, if really long (length > 31) symbols are
1339+ scanned.
1340+
1341+BS ( --- c )
1342+ The per-USER backspace constant.
1343+
1344+EXPECT ( buffer n --- )
1345+ Get up to n-1 characters from the keyboard, storing at buffer
1346+ and echoing, with backspace editing, quitting when a CR is read.
1347+ Terminate it with a NUL.
1348+
1349+QUERY ( --- )
1350+ EXPECT 128 (TWID) characters to TIB.
1351+
1352+ ( --- ) P
1353+NUBLK End interpretation of a line or screen, and/or prepare for a new
1354+ block. Note that the name of this definition is an empty
1355+ string, so it matches on the terminating NUL in the terminal or
1356+ block buffer.
1357+
1358+FIND ( namstr vocptr1 --- nfa vocptr2 )
1359+ Search a vocabulary, and its parents, if necessary, for a
1360+ definition called namstr. namstr is a counted (leading count
1361+ byte is ignored) string, vocptr1 is a pointer to a pointer to
1362+ a vocabulary tree or subtree. It will usually be the address of
1363+ the per-USER variable ROOT or DROOT, but may be a pointer to a
1364+ left or right link of an entry in the symbol tree. nfa will be
1365+ the name field address of the definition found, or a NULL.
1366+ vocptr2 will be the pointer-pointer to the last vocabulary
1367+ searched. vocptr2 will be the last vocabulary searche. See
1368+ (FIND).
1369+
1370+-DFIND ( --- nfa vocptr ) { -DFIND name } typical input
1371+DDFIND Parse a word, then FIND, first in the definition vocabulary,
1372+ then in the CONTEXT (interpretation) vocabulary, if necessary.
1373+ Returns the address of the symbol table entry or a NULL, and the
1374+ last vocabulary searched, per FIND.
1375+
1376+-IFIND ( --- nfa vocptr ) { -DFIND name } typical input
1377+DIFIND Same as -DFIND, except search the CONTEXT vocabulary first.
1378+
1379+NAME, ( --- ctStrPtr length )
1380+NCOMMA Store counted string at WORDPAD into dictionary, return HERE
1381+ pointer and length of string. Note that the count is not stored
1382+ in the dictionary, but that the address returned will be the
1383+ address to store the count at. (The length of the names of
1384+ definitions are stored after the actual names in the dictionary!)
1385+
1386+ But in BIF-C, the lengths are stored with the strings, and the
1387+ address returned points to where the counted string was stored.
1388+
1389+FORE_MARK ( --- )
1390+FOREMK Set forward reference bit in LATEST definition, if FOREWARD is
1391+ non-NULL.
1392+
1393+(INSTALL) ( nfa vocptr --- ) P
1394+PINSTA Install the header at nfa into the specified vocabulary, hiding
1395+ (SMUDGEing) any existing definitions of the same name in that
1396+ vocabulary. In BIF-6809, vocptr was a pointer to the parameter
1397+ field of the vocabulary, and we follow that in BIF-C v. 0.
1398+
1399+0! ( --- )
1400+INULL Store 0 word at NULL pointer (address 0).
1401+
1402+?0 ( --- )
1403+TNULL Set warning to -1 and jmp to ERROR if the word at address 0
1404+ (NULL pointer) is not 0.
1405+
1406+QUICK ( n --- ) in EDITOR
1407+ Quick and dirty editor; edits sectors, not screens. See above
1408+ description.
1409+
1410+NODE. ( nfa --- flag )
1411+NDOT ID. with some formatting, extra information useful for
1412+ debugging, and a keyboard pause/abort test. Returns flag less
1413+ than 0 if BREAK key was pressed.
1414+
1415+VISIT ( defptr vocptr --- )
1416+ Scan vocabulary at vocptr in ascending order, performing
1417+ definition at defptr at every node. defptr is an nfa, vocptr is
1418+ the pfa of a vocabulary, per FIND and ROOT/DROOT. The
1419+ definition to be executed will have parameters of the same form
1420+ as NDOT, doing something at a symbol tree node and leaving a
1421+ termination flag. VISIT checks for stack overflow and watches
1422+ the termination flag between executions. The VISITing
1423+ definition may have other parameters, but if it changes the
1424+ stack pointer from execution to execution VISIT will complain.
1425+
1426+VLIST ( --- )
1427+ Alphabetically list the definitions in the current vocabulary.
1428+
1429+
1430+**** Definitions/Routines in BIF7.A and BIF7B.A:
1431+
1432+
1433+CREATE ( --- ) { CREATE name } input
1434+ Parse a name (length < 32 characters) and create a header,
1435+ reporting first duplicate found in either the defining
1436+ vocabulary or the context (interpreting) vocabulary. (INSTALL)
1437+ the header in the local vocabulary.
1438+
1439+CONSTANT ( n --- )
1440+CONST { value CONSTANT name } typical input
1441+ CREATE a header, compile a call to XCON, compile the constant
1442+ value.
1443+
1444+VARIABLE ( init --- )
1445+VAR { init VARIABLE name } typical input
1446+ CREATE a header, compile a call to XVAR, compile the initial
1447+ value init.
1448+
1449+USER ( ub --- )
1450+USER { uboffset USER name } typical input
1451+ CREATE a header, compile a call to XUSER, compile the unsigned
1452+ byte offset in the per-USER table. The USER is entirely
1453+ responsible for maintaining allocation!
1454+
1455+: ( --- ) P
1456+COLON { : name sundry-activities ; } typical input
1457+ If executing, record the data stack mark in CSP, CREATE a
1458+ header, compile a call to XCOL, and set state to compile. (SCOMP
1459+ is defined in this file.) CONTEXT (interpretation) vocabulary
1460+ is unchanged.
1461+
1462+; ( --- ) P
1463+SEMI { : name sundry-activities ; } typical input
1464+ ERROR check data stack against mark in CSP, compile ;S, unSMUDGE
1465+ LATEST definition, and set state to interpretation.
1466+
1467+." ( --- ) P
1468+DOTQ { ." something-to-be-printed " } typical input
1469+ Use WORD to parse to trailing quote, if compiling, compile XDOTQ
1470+ and string parsed, otherwise, TYPE string.
1471+
1472+[COMPILE] ( --- ) P
1473+BCOMP { [COMPILE] name } typical use
1474+ -DFIND next WORD and COMPILE it, literally; used to compile
1475+ immediate definitions.
1476+
1477+INTERPRET ( --- )
1478+INTERP Interpret or compile, according to STATE. Searches words parsed
1479+ in dictionary first, via -IFIND, then checks for valid NUMBER.
1480+ Pushes or COMPILEs double literal if NUMBER leaves DPL
1481+ non-negative. ERROR checks the stack via ?STACK before
1482+ returning to its caller. Sensitive to COMPILE-ONLY bit in
1483+ headers.
1484+
1485+QUIT ( anything *** nothing )
1486+ Clear return stack. Then INTERPRET and, if not compiling,
1487+ prompt with OK, in infinite loop.
1488+
1489+BIF ( --- ) P
1490+ Makes BIF the current interpretation vocabulary.
1491+
1492+ASSEMBLER ( --- ) P
1493+ASMBLR Makes ASSEMBLER the current interpretation vocabulary. Might
1494+ ought not to be IMMEDIATE.
1495+
1496+DEFINITIONS ( --- )
1497+DEFS Makes the current interpretation vocabulary also the current
1498+ defining vocabulary.
1499+
1500+ABORT ( anything --- nothing ) ( anything *** nothing )
1501+ Clear parameter stack, intialize the NULL vector, set STATE to
1502+ interpret and BASE to DECIMAL, return to input from terminal,
1503+ restore DRIVE OFFSET to 0, set interpret and define vocabularies
1504+ to BIF, print out "6809 BIF Vx.x", and finally, QUIT. Used to
1505+ force the system to a known state and return control to the
1506+ standard INTERPRETer.
1507+
1508+VOCABULARY ( --- ) { VOCABULARY name } input
1509+VOCAB Create a vocabulary entry with a NULL local pointer, linked by
1510+ the parent pointer to the current defining vocabulary. The
1511+ vocabulary parameter passed to the various searching routines is
1512+ usually a pointer to the parameter field of a vocabulary. That
1513+ way, the root is functionally identically to a left or right
1514+ link in a node or leaf, particularly for insertion.
1515+
1516+( ( --- )
1517+PAREN Parse out a comment and toss it away. This is probably not
1518+ useful, but it leaves the first 32 characters in WORDPAD.
1519+
1520+DAD ( nfa --- name linkadr flag )
1521+ Search the parent vocabulary of the definition at nfa for nfa,
1522+ returning the address of the first character of the definition's
1523+ name, a pointer to the left or right link which links the
1524+ definition in, and a flag indicating whether the definition is
1525+ linked left or right. ERROR if the definition can't be found.
1526+ The return parameters are appropriate for REPEALing the
1527+ definition.
1528+
1529+REPEAL ( --- )
1530+ Remove the CURRENT/LATEST definition from the dictionary, from
1531+ the vocabulary in which it is defined. Updates CURRENT, alsoe
1532+ updates DROOT or ROOT and clears FOREWARD, if appropriate. If
1533+ the CURRENT definition is in a closed forward block, repeals the
1534+ entire block, so that forward references aren't pointing to
1535+ trash.
1536+
1537+ Except that I never got that last part written and working. So
1538+ you have to do that by hand. It does clear FOREWARD if FOREWARD
1539+ is pointing to the REPEALed definition.
1540+
1541+FORGET ( --- ) { FORGET name } input
1542+ Parse out name of definition to FORGET to, -DFIND it, then
1543+ REPEAL until it is removed from the dictionary. Will not FORGET
1544+ if definition is not found, if it is in a recursive block, or if
1545+ it is below FENCE; the ERROR message will include the offending
1546+ name.
1547+
1548+ (Does it really?)
1549+
1550+
1551+**** Definitions/Routines in BIFST.A
1552+
1553+
1554+COLD COLD boot. Initializes the system variables, prunes the
1555+ dictionary of everything beyond the initial FENCE, then WARM
1556+ boots.
1557+
1558+WARM Resets stack areas and per-USER variables, clears the buffers,
1559+ then yields control to BIF via ABORT.
1560+
1561+
1562+****
1563+Definitions on the SCREENs disk follow. The vocabulary names are
1564+abbreviated here under the definition names, A for ASSEMBLER, B for BIF,
1565+U for UTILITIES, ^a for ^asm-util.
1566+
1567+**** SCREEN 0
1568+Index to the screens disk.
1569+
1570+**** SCREEN 2
1571+Title page and copyright notice.
1572+
1573+**** SCREEN 3
1574+MON ( --- )
1575+- Call the debugging monitor: SWI followed by a jmp [,y++], so
1576+ that BIF can be continued.
1577+
1578+After screen 2 creates MON, it updates FENCE to protect MON from WARM
1579+boots. Will load in the active vocabulary.
1580+
1581+**** SCREENs 4 & 5
1582+Error and other Messages:
1583+0: number conversion/unknown definition, no message text.
1584+1: DATA STACK UNDERFLOW
1585+2: DICTIONARY FULL
1586+3: ADDRESS RESOLUTION ERROR for control structures
1587+4: HIDES DEFINITION IN some vocabulary
1588+5: NULL VECTOR WRITTEN
1589+6: DISC RANGE? disk sector number out of range
1590+7: DATA STACK OVERFLOW
1591+8: DISC ERROR! of some sort -- is your drive door closed?
1592+9: CAN'T EXECUTE A NULL!
1593+10: CONTROL STACK UNDERFLOW
1594+11: CONTROL STACK OVERFLOW
1595+12: ARRAY REFERENCE OUT OF BOUNDS
1596+13: ARRAY DIMENSION NOT VALID
1597+14: NO PROCEDURE TO ENTER
1598+15: ( was register error message for assembler )
1599+16:
1600+17: COMPILATION ONLY, USE IN DEFinition
1601+18: EXECUTION ONLY do not use while compiling
1602+19: CONDITIONALS NOT PAIRED where's your if/loop end statement?
1603+20: DEFINITION INCOMPLETE often same as 18, but hit ;
1604+21: IN PROTECTED DICTIONARY don't try to forget below FENCE.
1605+22: USE ONLY WHEN LOADING
1606+23: OFF CURRENT EDITING SCREEN an editor cursor problem
1607+24: DECLARE VOCABULARY
1608+25: DEFINITION NOT IN VOCABULARY
1609+26: IN FORWARD BLOCK
1610+27: ALLOCATION LIST CORRUPTED: LOST
1611+28: CAN'T REDEFINE nul! You tried to CREATE something without a name.
1612+29: NOT FORWARD REFERENCE
1613+30: ( was message about IMMEDIATE )
1614+31:
1615+32:
1616+33: HAS INCORRECT ADDRESS MODE for 6809
1617+34: HAS INCORRECT INDEX MODE for 6809
1618+35: OPERAND NOT REGISTER in 6809
1619+36: HAS ILLEGAL IMMEDIATE for 6809
1620+37: PC OFFSET MUST BE ABSOLUTE pc-relative addressing error
1621+38: ACCUMULATOR OFFSET REQUIRED for indexing mode
1622+39: ILLEGAL MEMORY INDIRECTION for 6809
1623+40: ILLEGAL INDEX BASE for 6809
1624+41: ILLEGAL TARGET SPECIFIED for 6809 addressing mode or register
1625+42: CAN'T STACK ON SELF for push/pull, try other stack pointer
1626+43: DUPLICATE IN LIST of operands
1627+44: REGISTER NOT STACK trying to push on a non-stack register?
1628+45: EMPTY REGISTER LIST best supply some registers
1629+46: IMMEDIATE OPERAND REQUIRED for 6809
1630+47: REQUIRES CONDITION for control operator
1631+48:
1632+49: COMPILE-TIME STACK UNDERFLOW
1633+50: COMPILE-TIME STACK OVERFLOW
1634+
1635+**** SCREEN 6
1636+
1637+BYTE-DUMP ( adr n --- )
1638+U Dump n bytes to output device, right adjusted in 4 character
1639+ columns. Field width is not big enough if BASE is six or less.
1640+
1641+DUMP ( adr n --- )
1642+B Formatted dump to output device, with ASCII interpretation.
1643+ Hard coded to 4 bytes per line.
1644+
1645+QLIST ( n --- )
1646+B QDUMP a block/sector and set the cursor to the middle of the
1647+ screen so the dump remains visible.
1648+
1649+QINDEX ( start end --- )
1650+B QLIST block/sectors from number start to end, inclusive.
1651+
1652+L/SCR ( --- n )
1653+U Calculate the number of terminal lines per disc screen at
1654+ run-time. Sixteen, at present.
1655+
1656+ULIST ( n --- flag )
1657+U List screen n, with line numbers in the current base, leave
1658+ BREAK key flag. Uses C/L, to automatically adjust for screen
1659+ width (if C/L is set), but you may not want to use this
1660+ definition if you set C/L to something besides 32 or 64.
1661+
1662+**** SCREEN 7
1663+
1664+LIST ( n --- )
1665+B ULIST screen n, line numbers in decimal.
1666+
1667+INDEX ( start end --- )
1668+B Print comment lines (line 0, and line 1 if C/L < 41) of screens
1669+ from start to end.
1670+
1671+TRIAD ( n --- )
1672+B List a printer page full of screens to the printer, formatted by
1673+ C/L. Line and screen number are in current base. Lists the
1674+ group containing screen n, will print 2 screens if C/L is 32,
1675+ three if C/L is 64. (Two may not fit well.)
1676+
1677+**** SCREEN 8
1678+
1679+HOME ( --- )
1680+U Put the cursor at the (CoCo 2) CRT screen HOME position.
1681+
1682+MID ( --- )
1683+U Put the cursor 8 lines down the (CoCo 2) CRT screen.
1684+
1685+CLS ( --- )
1686+B Clear the (CoCo 2) CRT screen.
1687+
1688+CAN-UP ( adr -- adr )
1689+U Clear the UPDATE bit (MSB) for the buffer whose block word is at
1690+ adr. The characters in the buffer should be stored at adr+2.
1691+
1692+W-BUF ( adr --- adr )
1693+U Write the characters at adr+2 to the sector specified at adr,
1694+ clear the UPDATE flag.
1695+
1696+SAVE-BUF ( adr --- adr )
1697+U W-BUF, if UPDATEd.
1698+
1699+QSAVE ( --- )
1700+B Save the PREViously edited buffer, if it was UPDATEd.
1701+
1702+SAVE-BUFFERS ( --- )
1703+B Write all buffers flagged for UPDATE, clear UPDATE bits.
1704+
1705+QCAN ( --- )
1706+B Cancel UPDATE of PREViously edited buffer.
1707+
1708+**** SCREEN 9
1709+
1710+CANCEL-UPDATES ( --- )
1711+B Cancel UPDATEs of all buffers.
1712+
1713+RE-QUICK ( --- )
1714+B Re-edit PREVious buffer.
1715+
1716+.BUF ( adr --- adr )
1717+U Dump buffer characters at adr+2, showing the sector number
1718+ indicated at adr.
1719+
1720+.BUFFERS ( --- )
1721+B Dump all buffers, with block number, per .BUF.
1722+
1723+.PREV ( --- )
1724+B Dump contents and block number of PREVious buffer, per .BUF.
1725+
1726+EDIT ( n --- )
1727+B QUICK edit block n, showing the block number.
1728+
1729+QPREV ( --- )
1730+B QUICK edit the PREVious block.
1731+
1732+**** SCREEN 10
1733+
1734+QOPY ( src dest --- )
1735+B Move content of block/sector src to block dest. BUG: Doesn't
1736+ copy if src is already in a buffer (problem with LRU).
1737+
1738+COPY ( src dest --- )
1739+B Copy SCREEN src to SCREEN dest. Uses QOPY, so you should
1740+ EMPTY-BUFFERS before using COPY.
1741+
1742+QBACK ( start end --- )
1743+B Copy blocks from start to end to the next higher disc, at the
1744+ same sector offset.
1745+
1746+EEDIT ( n --- )
1747+B Erase and then EDIT block n.
1748+
1749+**** SCREEN 11
1750+
1751+RES-ERROR ( --- )
1752+U ERROR #3
1753+
1754+FORWARD ( --- ) { FORWARD name } input
1755+B Compile a forward reference header: CREATE, set FOREWARD if not
1756+ already set, compile jmp to RES-ERROR, unSMUDGE header.
1757+
1758+:RESOLVE ( --- ) { :RESOLVE name } input P
1759+A If the characteristic of name is a jmp to RES-ERROR, make it
1760+ LATEST, re-SMUDGE it, change jmp address to HERE; if the header
1761+ of name is the base of the forward block, clear FOREWARD.
1762+ Forward blocks should end with the definition of the first
1763+ forward reference in the block, to maintain the block's
1764+ integrity. (However, the FOREWARD USER variable can be modified
1765+ by hand, if necessary.)
1766+
1767+:RES ( --- ) { :RES name } input
1768+B Do ASSEMBLER's resolve, then compile jmp <XCOL and switch state
1769+ to compile.
1770+
1771+;RES ( --- ) P
1772+B ; but SMUDGE LATEST one more time.
1773+
1774+**** SCREEN 11 does not continue LOADing! ****
1775+
1776+**** SCREEN 12
1777+
1778+PL ( --- )
1779+B Print 80 ASCII characters starting with '!'.
1780+
1781+PT ( --- )
1782+B PL until any key is hit.
1783+
1784+PTEST ( --- )
1785+B PT, but send the output to the printer.
1786+
1787+**** SCREEN 13
1788+
1789+SLIST ( start end --- )
1790+- ULIST SCREENs to printer from start to end inclusive.
1791+
1792+**** SCREEN 14
1793+This contains some experimental stuff that I was using to test my a
1794+Sardis Technologies disk controller.
1795+
1796+**** SCREEN 15
1797+
1798+NAME ( cfa --- )
1799+B Convert the CFA on the stack to an nfa and ID. it.
1800+
1801+NAMES ( adr n --- )
1802+B NAME n icodes at adr. Naively interprets anything as an icode.
1803+
1804+**** SCREEN 16
1805+**** The assembler starts here! ****
1806+
1807+^asm-util ( --- )
1808+A Vocabulary for assembler support stuff. (Note that the name is
1809+ in lower case and looks funny when editing until the cursor
1810+ moves over it.)
1811+
1812+DREG ( n --- ) { n DREG name } input -> compile-time
1813+^a ( --- d ) -> run-time
1814+ Define register double constants. Most significant word is
1815+ `RE', the index and operand encodings are masked into the least
1816+ significant word.
1817+
1818+xx ( --- d ) high word is HEX 5245
1819+A The register double constants in hex:
1820+ D 52458B00 A 52458608 B 52458509 PC 52458C05
1821+ U 52454003 S 52456004 Y 52452002 X 52450001
1822+ CC 5245EF0A DP 5245EF0B
1823+ Example: DP A EXG is exg dp,a
1824+
1825+# ( --- n )
1826+A Suffix constant for immediate values. Becomes the high byte:
1827+ 4 # A LD is lda #4
1828+
1829+DPREG ( --- adr )
1830+^a DP register emulator for the assembler. A per-USER variable at
1831+ offset HEX 42, initialized to whatever the load-time DP is.
1832+
1833+DPR ( --- adr )
1834+A Push the current DPREG value, as a constant. To use as an
1835+ absolute address, push a 0 or -1 after.
1836+ Example: DPR 7 + 0 JMP is jmp <7
1837+
1838+SETDP ( adr --- )
1839+A Set the DPREG value, masks the low byte of adr out.
1840+
1841+**** SCREEN 17
1842+
1843+OFF, (n b --- )
1844+^a Compile an index byte b with signed, constant, byte or word
1845+ offset, n. Sets bit 0 in the index byte if it compiles a word
1846+ offset.
1847+
1848+OP, ( u --- )
1849+^a Compile opcode u. Compiles 16 bits if high byte of u is
1850+ non-zero.
1851+
1852+ABS, ( adr u1 u2 --- )
1853+^a Compile an absolute address mode (direct page or extended)
1854+ op-code u1, oring u2 into u1 before compiling if the address is
1855+ not in the direct page.
1856+
1857+PCOFF ( adr n1 --- n2 flag )
1858+^a Generate a pc-relative offset n2 from adr, adjusted by n1 bytes
1859+ of op-code/index. Flags true if offset fit in a byte, false if
1860+ it required 16 bits.
1861+
1862+?ABS ( d --- adr flag )
1863+^a Convert high word of d to flag showing true if high word was 0
1864+ or -1, false otherwise. A 0 or -1 high word indicates an
1865+ absolute address as an operand.
1866+ Example: HEX .FF20 B OR is orb $FF20
1867+
1868+PCR, ( d b --- )
1869+^a ERROR if d is not absolute mode operand. Calculate offset and
1870+ compile index byte b and offset.
1871+
1872+**** SCREEN 18
1873+
1874+Auto-indexing address mode double constants, in ASSEMBLER vocabulary:
1875+-) ( --- 4155.0082 ) ,-r
1876+)++ ( --- 4155.0081 ) ,r++
1877+)+ ( --- 4155.0080 ) ,r+
1878+--) ( --- 4155.0083 ) ,--r
1879+ Example: )++ X , D ST is std ,x++
1880+
1881+MASK, ( b1 b2 --- )
1882+^a Compile the bit-or of the top two words's low bytes.
1883+
1884+REG, ( u b --- )
1885+^a Convert a register offset specified by u to its extension byte
1886+ representation, mask in the index register and indirection
1887+ specifier b, and compile the resulting index byte.
1888+
1889+IXOFF, ( n b --- )
1890+^a Generate the appropriate index extension byte for the constant
1891+ offset n and indirection level specified, mask in the index
1892+ register and indirection specifier b, and compile both the
1893+ extension byte and the offset. Handles zero and 5-bit offsets.
1894+
1895+EI, ( d b --- )
1896+^a Compile a (completely specified) extended-indirect extension
1897+ byte b and the absolute address d.
1898+
1899+**** SCREEN 19
1900+
1901+IX, ( d n --- )
1902+^a Compile an index mode address operand. n contains the index
1903+ register and indirection level encoding, d contains the offset
1904+ or auto-mode specification. Zero offset must be explicit. Does
1905+ not block out unsupported [,r+] and [,-r] modes.
1906+
1907+, ( d1 --- d2 )
1908+A Convert indexable register d1 to index mode specifier d2.
1909+ Examples: 0. X , B OR is orb ,x
1910+ A X , JMP is jmp a,x
1911+ TABLE 0 PC , X LEA is leax table,pcr
1912+
1913+) ( d1 --- d2 )
1914+A Convert indexable register, absolute address, or index operand
1915+ d1 to memory indirect operand. Note that this will NOT
1916+ interfere with comments.
1917+ Examples: TABLE 6 + 0 PC ) JMP is jmp [6,pcr]
1918+ )++ S ) JSR is jsr ,s++
1919+
1920+**** SCREEN 20
1921+
1922+ACCM ( n1 n2 n3 --- n4 )
1923+^a Convert op-code n1, register n2, and mask bits n3 to accumulator
1924+ encoded op-code n4. Used for encoding ACCM destination
1925+ op-codes.
1926+
1927+UNARY ( u --- ) >--> compile-time
1928+^a { u UNARY name } input >-/
1929+ ( do dx --- ) indexed modes >-\
1930+ ( d --- ) non-indexed modes >--> run-time
1931+ Unary op-code compiler -- compiles an assembler of unary
1932+ op-codes with op-code (u) and name. Run-time parameters: d is
1933+ the destination register or address, dx is the index
1934+ mode/register, do is the offset/auto mode.
1935+ Examples: A NEG is nega
1936+ 7. U , ROR is ror 7,u
1937+
1938+REG ( d adr --- d u sz ) -- JSR
1939+^a ( d adr --- u sz )
1940+ Encode binary destination register d into op-code from table at
1941+ adr. Table format is primary (byte), highest (byte), secondary
1942+ (word) secondary (word) .... Leave op-code u and size sz (-1 is
1943+ word, 0 is byte) of register encoded. Helps to reduce the
1944+ complexity of the binary operators op-code map, see BINARY
1945+ concerning constructing the tables.
1946+
1947+**** SCREEN 21
1948+
1949+#, ( n u sz --- )
1950+^a Compile an immediate op-code u with immediate operand n of size
1951+ byte, if sz == 0, or word, ERROR if op-code is ST or JSR.
1952+
1953+BINARY ( ul b ub --- ) >--> compile-time
1954+^a { ul b ub BINARY name } input >-/
1955+ ( ds --- ) JSR >-\
1956+ ( ds dd --- ) non-indexed mode >--> run-time
1957+ ( do dx dd --- ) indexed mode >-/
1958+ Compile an assembler of binary operators, with primary op-code
1959+ (accumulator form, any mode) ub, count of other codes (0, 1, or
1960+ 5) b, and optional list of other codes ul. The list of other
1961+ op-codes must be pushed on the stack in the order S, U, Y, X,
1962+ and D (LD, ST, and CMP), or must be just the op-code for D (ADD
1963+ and SUB). Page escape codes must be included in the op-codes.
1964+ Run-time operands: ds is the source, do is the source
1965+ offset/auto mode, dx is the index mode/register, dd is the
1966+ destination register. Example: 12 # D CMP is cmpd #12 -800. X )
1967+ X LD is ldx [-800,x]
1968+
1969+REG-REG ( b --- ) { b REG-REG name } input -> compile-time
1970+^a ( d1 d2 --- ) -> run-time
1971+ Compile an assembler of register d1 to register d2 moves.
1972+ Examples: D Y EXG is exg d,y
1973+ A CC TFR is tfr a,c
1974+
1975+**** SCREEN 22
1976+
1977+REG-BITS ( n --- vadr )
1978+^a 1ARRAY of register bits for push/pull extension byte. The
1979+ Undefined slots set all bits to stabilize PACK. Use the low
1980+ word of a register specifier to index the array (see the DREG
1981+ constants).
1982+
1983+PACK ( n dl n --- n b )
1984+^ Pack register list dl into result byte b. Terminates when the
1985+ n, which is not the high word of a register specifier, is DUPed
1986+ and compared to HEX 5245; thus, any word or double which won't
1987+ be interpreted as a register specifier (see DREG) will terminate
1988+ the list, including the stack hole. ERRORs on attempt to push a
1989+ stack register on itself. May underflow the parameter
1990+ stack if the stack hole is corrupted with HEX 5245, of course,
1991+ but will not attempt to draw more than 8 doubles from the stack
1992+ unless REG-BITS is corrupted.
1993+
1994+MOVEM ( b --- ) { b MOVEM name } input -> compile-time
1995+^a ( n dl d --- n ) -> run-time
1996+ Compile a push or pull instruction assembler. d is the stack
1997+ register to push or pull. See PACK.
1998+ Example: D X Y U PSH is pshu d,x,y
1999+ (But don't leave stray register specifiers on the stack!)
2000+
2001+**** SCREEN 23
2002+
2003+BR ( d1 d2 --- )
2004+A Assemble a branch on condition d2 to absolute address d1.
2005+ Converts to PC relative, assembles a short branch if branch
2006+ target is close enough.
2007+ Example: LABEL 0 CCLR BR is bcc [LABEL]
2008+
2009+DCOND ( n --- ) { n DCOND name } input -> compile-time
2010+^a ( --- d )
2011+ Compile a branch condition constant; high word is HEX 434F.
2012+ Always (AL), never (NV), and subroutine (SR) are provided as
2013+ DCONDs.
2014+ Example: ' BMUL CFA 0 AL BR is bra BMUL
2015+
2016+CC-IMM ( b --- ) { b CC-IMM name } -> compile-time
2017+^a ( d --- ) -> run-time
2018+ Compile ORCC, ANDCC, EORCC, or CWAI assemblers. The assemblers
2019+ will ERROR if the operand is not immediate.
2020+ Example: HEX EF # CWAI is cwai #$EF
2021+
2022+IMPLY ( b --- ) { b IMPLY name } input >--> compile-time
2023+^a ( --- ) run-time
2024+ Compile assemblers of implicit operand instructions.
2025+ Example: NOP is nop
2026+
2027+**** The next two SCREENs contain op-code assemblers. ****
2028+See the compilers for run-time descriptions. The odd organization keeps
2029+the trees balanced. The assemblers, or, in other words, the mnemonics,
2030+are in the ASSEMBLER vocabulary.
2031+
2032+**** SCREEN 24
2033+
2034+BINARYs LD ST and CMP with their associated 16-bit register op-code
2035+ lists.
2036+MOVEMs PUL PSH UNARYs ROR ROL IMPLYs RTS RTI
2037+BINARY SBC DCOND SR (subroutine) REG-REG TFR
2038+UNARY TST BINARY SUB with D
2039+IMPLYs SWI2 SWI3 SWI SYNC BINARYs AND ADC
2040+UNARYs ASL ASR BINARY ADD with D IMPLY ABX
2041+DCOND CS UNARYs COM CLR DCOND AL (always)
2042+BINARY BIT UNARY DEC IMPLY DAA
2043+DCONDs HI MI EQ GE REG-REG EXG UNARY INC
2044+BINARY JSR UNARY JMP BINARY EOR
2045+DCONDs GT HS IMPLY NOP DCONDS LS PL
2046+
2047+**** SCREEN 25
2048+
2049+UNARYs LSR LSL DCONDs LT NE IMPLY MUL
2050+UNARY NEG BINARY OR CC-IMM ORCC
2051+DONCD NV (never) IMPLY SEX (blush) CC-IMMs ANDCC CWAI
2052+DCONDs VC VS CCLR (Carry CLeaR)
2053+
2054+EA-IX ( n --- vadr )
2055+^a 1ARRAY of translations from register (DREG) to LEA arguments.
2056+
2057+LEA ( do dx dd --- )
2058+A Assembler for LEA instructions. do is the offset/auto mode, dx
2059+ is the source index register, dr is the destination index
2060+ register.
2061+ Example: D Y , X LEA is leax d,y
2062+
2063+DCONDs LE LO
2064+
2065+**** SCREEN 26
2066+
2067+[CD] ( --- dcfa ) { [CD] name } input P
2068+A Produce the CFA of the following definition header, for use as a
2069+ jump or indexing target. If compiling, causes the code address
2070+ to be compiled as a double literal; otherwise, pushes the cfa as
2071+ a double, so the assemblers can use it for addressing.
2072+
2073+& ! ^ ( n1 n2 --- n3 )
2074+A Aliases for AND OR and XOR for the assembler vocabulary.
2075+
2076+NEXT ( --- )
2077+A Assembler the NEXT instruction, jmp [,y++].
2078+
2079+**** The assembler control constructs are patterned after FORTH
2080+control constructs, but test the Condition Code register.
2081+****
2082+
2083+**** SCREEN 27
2084+
2085+INVERTCC ( dcond --- ~dcond )
2086+^a Invert the assembler branch condition (double word) on top of
2087+ stack.
2088+
2089+LIF ( dcond --- daddr )
2090+A Mark HERE as a double with the address in the low word and HEX
2091+ 4146 in the high word. Assemble a long branch on the inverse of
2092+ the condition given, and leave the mark. Temporarily set the
2093+ branch address to the RES-ERROR routine.
2094+
2095+IF ( dcond --- daddr )
2096+A Same as LIF, but assembles short branch with 0 offset.
2097+
2098+**** SCREEN 28
2099+
2100+FILL-IN ( dadr --- )
2101+^a Resolve offset of branch at mark to HERE, handle two, three, and
2102+ four byte branches.
2103+
2104+**** SCREEN 29
2105+
2106+ELSE ( daddr1 --- daddr2 )
2107+A ERROR check the mark daddr1, mark HERE and assemble short branch
2108+ always, via IF, and FILL-IN the previously marked IF or LIF.
2109+
2110+LELSE ( daddr1 --- daddr2 )
2111+A Same as ELSE except mark and assemble long branch always via
2112+ LIF.
2113+
2114+ENDIF ( daddr --- )
2115+A ERROR check the mark, and resolve the IF or LIF.
2116+
2117+BEGIN ( --- daddr )
2118+A Mark indefinite loop beginning with HERE. High word of mark is
2119+ HEX 4142.
2120+
2121+UNTIL ( daddr dcond --- )
2122+A ERROR if daddr is not BEGIN mark; assemble branch on inverse of
2123+ condition dcond to address marked in daddr.
2124+
2125+WHILE ( daddr dcond --- adr daddr )
2126+A ERROR if daddr is not BEGIN mark; assemble forward branch on
2127+ inverse of condition dcond, leave BEGIN address on stack and
2128+ extend mark with WHILE address and mark, HEX 4157.
2129+
2130+REPEAT ( adr daddr --- )
2131+A ERROR if not WHILE mark, assemble a branch to the BEGIN address
2132+ and FILL-IN the WHILE address.
2133+
2134+LWHILE ( daddr dcond --- adr daddr )
2135+A Forced long branch version of WHILE.
2136+
2137+**** SCREEN 30
2138+
2139+:ASM ( --- )
2140+A CREATE a header and store the parameter stack pointer in CSP to
2141+ mark the stack for assembler control construct and other errors.
2142+
2143+;ASM ( --- )
2144+A ERROR check CSP and un-smudge the definion. NEXT must be
2145+ explicitly assembled.
2146+
2147+I-CODE ( --- )
2148+A Shift to high-level compiling. (Assembles jmp <XCOL, changes
2149+ state to compiling, changes interpretation vocabulary to
2150+ definition vocabulary.)
2151+
2152+MACHINE ( --- ) P
2153+A Shift to assembly language. (Compiles (MACHINE), changes state
2154+ to interpretation, sets interpretation vocabulary to assembler.)
2155+
2156+**** SCREEN 32
2157+ Some Doubles
2158+
2159+D! ( d adr --- )
2160+B Store double d at adr.
2161+
2162+D@ ( adr --- d )
2163+B Fetch double (two words) at adr.
2164+
2165+DOVER ( d1 d2 --- d1 d2 d1 )
2166+B Copy the second double (bytes 4-7) on the stack to the top.
2167+
2168+DSWAP ( d1 d2 --- d2 d1 )
2169+B Swap the top two doubles (bytes 0-3 with bytes 4-7).
2170+
2171+**** SCREEN 64
2172+
2173+ This is an example showing use of the dictionary to associate
2174+pairs, from one of the textbooks I have. I apologize to the source for
2175+not giving proper credit, but I can't find it. It is included to show
2176+use of DOES> and to show how having the symbol table handy at run-time
2177+can be taken advantage of. It builds pairs of objects linked to each
2178+other such that typing one in results in printing the other out.
2179+
2180+
2181+*******************************************************************************
2182+ Some Thoughts and Comments:
2183+
2184+
2185+Hey, it's not a professional package, so I can put this here if I want!
2186+
2187+One of the problems with BIF is the power of the 6809. It is all too
2188+easy to use 6809 instructions instead of icodes. This means that the
2189+6809 architecture gets woven into BIF, as mentioned at the end of the
2190+discussion on the virtual machine.
2191+
2192+BIF can probably be made to conform with one of the standards by moving
2193+the virtual machine routines to their associated definitions (XCOLON to
2194+COLON, XVAR to VARIABLE, etc.) and by making all code fields three-byte
2195+jumps (JSRs). Direct threading will probably not be a problem, as long
2196+as code fields are uniform in size.
2197+
2198+The constant shifting between modes which I have done makes a built-in
2199+debugger more complex, as well. One specific example is that using a
2200+macro instead of a jump to a NEXT inner interpreter makes debugging more
2201+complex. If there is an inner interpreter, and if the low level
2202+routines are known to be error free, the debugger can simply be a jump
2203+inserted in the NEXT routine. Use of a macro forces the debugger to be
2204+sensitive to the 6809 architecture, and requires either use of the SWI
2205+method (which can't be used in ROM), CPU emulation, or external
2206+breakpoint/single-step hardware. The latter method is more complete,
2207+but inserting a debugging routine in the inner interpreter is often all
2208+that is necessary.
2209+
2210+A possible inner interpreter for a direct threaded FORTH (could be
2211+located in the direct page):
2212+
2213+ NEXT ldx ,y++ 8~
2214+ jmp ,x 3~ 14~ (w/ jmp <NEXT)
2215+
2216+Or for indirect threading:
2217+ NEXT ldx ,y++ 8~
2218+ jmp [,x] 6~ 17~ (w/ jmp <NEXT)
2219+
2220+Compared to BIF:
2221+ jmp [,y++] 9~
2222+
2223+The apparent disadvantages of the above are at least partially offset by
2224+the fact that X will contain the CFA on entry to the characteristic
2225+routines. In other words, X can substitute for W, and there is no need
2226+to store the CFA of the executing low level routine in an external
2227+register (on the stack, in the case of BIF). Showing how this affects
2228+XCOL, for direct threading:
2229+
2230+ someDEF jmp XCOL 4~
2231+ . . .
2232+ XCOL pshs y 7~
2233+ leay 3,x 5~
2234+ jmp <next 3~ 19~, total 33~
2235+
2236+For indirect threading:
2237+
2238+ someDEF fdb XCOL 0~
2239+ . . .
2240+ XCOL pshs y 7~
2241+ leay 2,x 5~
2242+ jmp <NEXT 3~ 15~, total 32~
2243+
2244+Compared to BIF:
2245+ someDEF jsr <XCOL 7~
2246+ . . .
2247+ XCOL ldx ,s 5~
2248+ sty ,s 6~
2249+ tfr x,y (leay ,x) 6~ (4~)
2250+ jmp [,y++] 9~ 33~, total 42~
2251+
2252+SURPRISED? I was. Of course, the characteristic routines must be a
2253+little careful to use or save X before they clobber it, but that isn't
2254+as difficult as it might seem.
2255+
2256+The direct page might still be used to locate the per-USER table, or
2257+might even contain it. At first glance, it would appear too expensive
2258+to offset the DP register with a variable index. But compare the
2259+following to the code in BIF:
2260+
2261+ XUSER tfr dp,a 6~
2262+ ldb [,s++] 10~ (stored as byte offset)
2263+ pshu d 7~ (there's the address)
2264+ jmp [,y++] 9~ 32~ compared to 34~
2265+
2266+If X is used for the temporary W register as in the indirect threaded
2267+inner interpreter example above, we can get the following, which speaks
2268+for itself:
2269+
2270+ XUSER tfr dp,a 6~
2271+ clrb 2~ (showing word offset, )
2272+ addd 2,x 7~ (byte would be shorter)
2273+ pshu d 7~
2274+ jmp <NEXT 3~ 25~
2275+
2276+Ah, experience. What we have to go through to get it!
2277+
2278+The key to FORTH and its dialects is found in ;CODE and DOES>. By
2279+providing both characteristic behaviour and data allocation, FORTH words
2280+(symbols/definitions) are primitive objects. A full object-oriented
2281+language could be generated with FORTH, but then you would probably have
2282+SMALLTALK!. A standard compiling language keeps the symbol table, its
2283+data, and the code that accesses it entirely separate, and wastes a lot
2284+of code space doing so. Professional FORTH systems can strip the symbol
2285+table out of compiled applications, if necessary, but the symbol table
2286+is available at run-time until the programmer is satisfied that his
2287+program is bug-free. Moreover, the programmer has access to the same
2288+library used by the language, which is usually not the case with
2289+compiled languages, even with C.
2290+
2291+A careful examination of the overhead in FORTH shows that it is
2292+approximately the same as the overhead in a good C compiler. While it
2293+would appear that constantly moving stuff on and off the stack would be
2294+a hindrance to progress, a second look reveals that the accumulator
2295+bottleneck requires this kind of movement. I wish I had time and
2296+facilities to examine this specific question in relation to a large
2297+register set.
2298+
2299+I sometimes wonder if management paranoia (PROTECT OUR INTELLECTUAL
2300+PROPERTY!) is the primary reason FORTH, LISP, and SMALLTALK have not
2301+entirely supplanted the compiled languages. If so, why is management
2302+willing to hide, protect, and hang on to code, but not willing to hang
2303+on to the engineers in whose brains the technology really resides? Or
2304+in the converse, if management can see that it is sometimes necessary to
2305+let people go, why can't they see that there are some things that are
2306+not worth the cost of trying to protect their tools from? And why can't
2307+they see that a intellectual property stolen by copying still requires a
2308+large investment in somebody's time to learn to use it? Why doesn't
2309+public domain code get used? Because it costs better than an order of
2310+magnitude more to learn how to use it than it does to get it.
2311+
--- /dev/null
+++ b/BIFDOC.TXT~
@@ -0,0 +1,2319 @@
1+
2+ BIF Documentation
3+ By Joel Matthew Rees
4+ 19 January 1992,
5+ 8 April 2019
6+
7+
8+ BIF documentation Copyright Joel Matthew Rees 1992, 2019
9+
10+
11+In the spirit of fig-FORTH, the author grants permission as follows:
12+=========
13+Permission to use, copy, modify, and/or distribute this software for
14+any purpose with or without fee is hereby granted, provided that the
15+accompanying copyright notices and this permission notice appear in
16+all copies.
17+
18+THE SOFTWARE IS PROVIDED “AS IS” AND ISC DISCLAIMS ALL WARRANTIES
19+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
20+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY
21+SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
22+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
23+AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
24+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
25+SOFTWARE.
26+=========
27+
28+If the copyright notices in this file and the README.TXT file are
29+retained, including that file and this with your distribution will
30+fulfill the copyright notice obligation.
31+
32+But you really should include both anyway, just to be kind to the
33+people who receive it.
34+
35+Note that:
36+
37+BIF is architecturally derived from fig-FORTH. fig-FORTH comes courtesy
38+of the FORTH INTEREST GROUP, PO Box 1105, San Carlos, CA 94070.
39+
40+The author also grants permission to use and copy the source and object
41+code for BIF freely, with the same stipulations, i. e.,
42+that any distribution of significant portions of either must be
43+accompanied by this notice, and the additional stipulation that any
44+distribution of the entire code, whether source, object, or both, must
45+be accompanied by the entire documentation, including Copyright and
46+acknowledgements.
47+
48+This is not a commercial product; it was a student project, use it at
49+your own risk. No warranty whatsoever is made concerning it. (If, by
50+chance, anyone is interested in using BIF in a commercial product, I
51+would appreciate knowing about it in advance.) The author's intent is
52+only to make it available for experimentation, and it should be treated
53+as strictly experimental software. DO NOT ATTEMPT TO ACCESS ORDINARY
54+DISKS FORMATTED FOR USE BY OTHER OPERATING SYSTEMS WHILE BIF IS RUNNING!
55+
56+Contact as of January 2000:
57+ joel_rees@sannet.ne.jp
58+ http://www.page.sannet.ne.jp/joel_rees
59+ reiisi@nettaxi.com
60+ http://www.nettaxi.com/citizens/reiisi
61+
62+
63+*******************************************************************************
64+ General Information
65+
66+
67+BIF (BInary tree, fig-FORTH) is a dialect of FORTH for the Tandy Color
68+Computer. It is a direct-threaded version of the pre-FORTH-79 fORTH
69+interest group publication of FORTH (fig-FORTH), using a non-standard
70+binary tree dictionary structure. The direct-threading mechanism uses
71+the direct-page addressing mode of the 6809, and thus may not be easily
72+adaptable to FORTH-83. It also uses absolute addressing, and thus does
73+not comform to the requirements of OS-9. (I am working on an
74+indirect-threaded version of BIF for OS-9 in my spare time.)
75+
76+BIF.BIN is the executable object; after LOADMing it, EXEC the address
77+&H1300 (see below). BIFSOURC.ARC contains the archived (TC31) source
78+files; the assembler used is Disk EDTASM+. I used TSEdit to generate
79+the source files in EDTASM+ format:
80+
81+line-number SPACE [label] TAB mnemonic etc. LF
82+
83+Using a text editor to replace the macros with their expansions should
84+make it compatible with most other assemblers. An object which will run
85+under the EDTASM+ "stand-alone" debugger may be generated by changing
86+ORG $1200 in BIF.ASM to ORG $3F00.
87+
88+BIFSCREE.ARC contains the BIF/FORTH source for several utilities, the
89+assembler, and double integer definitions (TOOLS.G00) and a definition
90+pairing example (PAIRS.G28) useful for making paired lists. Using
91+TOOLS.G00 and PAIRS.G28 directly will require moving the two files to
92+their original granules, 0 and 28, on an ECB disk. Once they are moved,
93+protecting the BIF screens with ECB directory entries may be a good
94+idea. But resist the temptation to use a text editor on them. Messing
95+with the whitespace will move the source code out of alignment with the
96+physical FORTH/BIF screens, and thus cause the source code not to load.
97+
98+If you want to look at these two files with an editor, I suggest copying
99+them to a different disk and looking at the copies. Even my favorite
100+IBM PC editor, QEDIT, will insert a CR/LF at the end of every 512 bytes
101+on saving, which is not good. (I wonder how many letters from OS-9
102+users it would take to convince the folks at SEMWARE/Applied Systems
103+Technologies to make an OS-9 version of their editor?)
104+
105+For $5.00, to cover postage, time, and the cost of floppies, I will send
106+a copy of the BIF screens disk on a standard 5 1/4" (ECB formatted)
107+floppy. If you request the EDTASM+ compatible source code, I will send
108+that as well, on the same format disks. For $5.00 more, I will include
109+a photo-copy of the documentation (useful if you don't have a way to
110+print it).
111+
112+The documentation which follows is written in the standard FORTH
113+documentation style. It is not intended as a primer or study guide.
114+Brodie's Starting FORTH, Winfield's THE COMPLETE FORTH, or some other
115+text is suggested to those unfamiliar with FORTH. Much of the code and
116+examples should work as shown in the textbooks I recommend Leo Brodie's
117+work, because he points out most of the places the user will have to
118+refer to this documentation. Some of the descriptions are incomplete,
119+particularly where definitions are intended to be used inside other
120+definitions.
121+
122+The object contains a simple one-sector editor (for 32-column screens)
123+in the EDITOR vocabulary. It does not provide search and replace, but
124+it is sufficient, for the patient, to write code. My apologies for it.
125+I did not have a Color Computer 3 when I wrote the original code, and
126+haven't had the time to update it. Those with access to the fig-FORTH
127+Installation Manual should have no problem installing the editor shown
128+there.
129+
130+The assembler in the BIF screens is a full postfix assembler. The
131+double integer screens show a quick example of its use.
132+
133+
134+*******************************************************************************
135+ Getting BIF Running
136+
137+
138+Before you start, remember that BIF has the same post-fix grammar as
139+FORTH. Think Reverse Polish, as in HP calculators.
140+
141+Computer: Comments:
142+
143+ In Disk ECB, type:
144+LOADM "BIF.BIN" from whichever drive it is on, then remove all disks and
145+EXEC &H1300 BIF should tell you it is running with
146+6809 BIF V1.0
147+OK
148+ At this point, see if BIF is really running by typing
149+VLIST and hitting ENTER. You should see a listing of your
150+ main vocabulary (symbol table) which should run on for
151+ about 200 entries, and then the computer responds with
152+OK If this doesn't happen, you have a bad object file, get
153+ a new copy. Otherwise, you have BIF!
154+
155+ If you have my BIF screens disk, put it in drive 0.
156+ Then type
157+6 LOAD to load the utilities starting at screen 6. After the
158+ utilities are loaded, you can load the assembler by
159+ typing
160+DECIMAL 16 LOAD
161+
162+ If you don't have the BIF screens disk with the error
163+ messages, type
164+0 WARNING ! and BIF responds with
165+OK but now tells you error numbers instead of messages.
166+
167+Okay, a few examples:
168+
169+ 42 EMIT
170+
171+puts the ascii character 42 (asterisk if the current BASE is DECIMAL) on
172+the output device.
173+
174+ 5 6 * .
175+
176+prints the product of 5 and 6 (30, base ten) on the output device.
177+
178+ DECIMAL : CHARS 32 DO I . I EMIT CR LOOP ;
179+ HEX 45 CHARS
180+
181+will set up a BIF "word" called CHARS, which, being invoked on the second
182+line, will print the characters and hexadecimal ascii codes from SPACE
183+up to, but not including, DASH.
184+
185+The BIF screens disk should always be in drive 0 if you want real error
186+messages. If you want to look at the message text, the messages are at
187+the front of TOOLS.G00, after the directory screen and title screen.
188+Each message takes exactly 32 characters, including spaces and
189+non-printing characters. Numbering starts with 0. If you have some
190+other disk in drive 0 you will get funny and not exactly intelligent
191+error messages. I know it's weird, but I was following the fig-FORTH
192+model, which is designed for very limited memory.
193+
194+If you haven't been able to put the BIF screens disk together, you don't
195+really need it to play around with BIF, but do clear the WARNING
196+variable so BIF will know error messages are not available. Aside from
197+the error messages in drive 0, there is nothing special about screens
198+disks, except they do not have directory tracks. You should generally
199+not put them in your drives when running under BASIC (DECB), OS-9 or
200+some other system. By tradition, programmers use the first several
201+screens as a hand-typed directory. You can format fresh BIF disks with
202+either Disk Extended Color BASIC's DSKINI or OS-9's format. BIF ignores
203+the directory information both systems write, so you also generally
204+should not put a real DECB or OS-9 disk in while BIF is running.
205+
206+If you do format with OS-9, format single-sided (I used DECB's disk
207+interface routines so BIF can't do double sided) with as many tracks as
208+you want. To use the extra tracks, or a third or fourth drive, you will
209+need to modify the DRIVE-OFFSET array. Pick a standard disk
210+configuration and stick with it.
211+
212+An important word of warning. BIF, like FORTH, uses buffered I/O. Your
213+screens are not actually saved to disk until you cause the system to
214+need enough new buffers to write your editing back to the disk. To
215+force the system to save the buffers, give BIF the SAVE-BUFFERS command.
216+
217+
218+*******************************************************************************
219+ BIF's QUICK Editor
220+
221+
222+EDITOR gets you into the EDITOR vocabulary.
223+0 QLIST lets you look at the first sector of the directory.
224+4 B/SCR * QLIST lets you look at the first eight error messages.
225+DECIMAL makes sure your conversion base is base ten.
226+64 B/SCR * QUICK
227+ lets you edit the first sector of the pairing example.
228+ Use the cursor keys to move around; use the BREAK key to
229+ get out. If you modified something you don't want to
230+ change, type
231+EMPTY-BUFFERS and ENTER. If you want to make sure your changes are
232+ written to the disk, type
233+SAVE-BUFFERS and ENTER.
234+
235+The QUICK editor is in the EDITOR vocabulary. It is available at boot
236+up. You'll need to get into the EDITOR vocabulary, to access it. Pass
237+it a sector number, not a screen number. Multiplying by B/SCR (which
238+happens to be 4) will convert a screen number to a sector number. Add
239+1, 2, or 3 to the base sector number of a screen to get the sector
240+numbers for the second, third, and fourth sectors of that screen.
241+
242+The editor has no find/replace or block functions. Again I apologize
243+for the editor, but I found it surprisingly workable. Note that the
244+utility screens contain routines to move/copy sectors, so all is not
245+entirely mud. One more glitch. Lower case letters will show as VDG
246+codes until you run the cursor over them. What can I say?
247+
248+During editing, all arrow keys are cursor controls. Use SHIFT-LEFTARROW
249+for destructive backspace, SHIFT-DOWNARROW for `[' left bracket,
250+SHIFT-RIGHTARROW for `]' right bracket, SHIFT-UPARROW for `_' underscore
251+(back-arrow on CoCo2). SHIFT-CLEAR escapes the UP-ARROW to provide the
252+`^' caret. SHIFT-CLEAR also escapes itself to provide the backslash.
253+
254+Perhaps this is as good a place as any to mention a few points of
255+terminology. A block is a sector. Sectors are numbered sequentially
256+from 0. Sector numbering continues sequentially from drive n to drive
257+n+1, see DRIVE-OFFSET, but also see OFFSET. A SCREEN is a kilobyte
258+worth of blocks, in this case, four 256-byte sectors. SCREEN numbering
259+also begins with 0. (SCREENs are called SCREENs because a SCREEN can be
260+displayed on 16 lines of a 64-column CRT screen.) You will notice that
261+a CoCo 2 can't properly display and edit a whole SCREEN. Finally,
262+forward blocks are control constructs, not disk sectors.
263+
264+
265+*******************************************************************************
266+ The BIF Virtual Machine
267+
268+{ bifc_vm.h ---
269+fig 6809
270+UP [DP] pointer to the per-USER variable table (USER Pointer)
271+IP Y pointer to the next definition (Instruction Pointer)
272+RP S return/control stack pointer
273+SP U parameter/data stack pointer
274+W [S] pointer to executing definition's parameter field
275+}
276+ The BIF Virtual Machine
277+
278+fig 6809
279+{ bifc_vm.c bif.m bifdp.a
280+NEXT ( --- ) jmp [,y++] (macro in bif.m)
281+ Causes the next definition to execute.
282+
283+DOCOL ( *** IP ) jsr <XCOL (see bif.m, bifdp.a)
284+ Characteristic of a colon (:) definition. Begins execution of a
285+ high-level definition, i. e., nests the definition and begins
286+ processing icodes. Mechanically, it pushes the IP (Y register)
287+ and loads the Parameter Field Address of the definition which
288+ called it into the IP.
289+}
290+{ symbol.c bif.m bifdp.a
291+DOVAR ( --- vadr ) jsr <XVAR (bif.m, bifdp.a)
292+ Characteristic of a VARIABLE. A VARIABLE pushes its PFA address
293+ on the stack. The parameter field of a VARIABLE is the actual
294+ allocation of the variable, so that pushing its address allows
295+ its contents to be @ed (fetched). Ordinary arrays and strings
296+ that do not subscript themselves may be allocated by defining a
297+ variable and immediately ALLOTting the remaining space.
298+ VARIABLES are global to all users, and thus should have been
299+ hidden in resource monitors, but aren't.
300+
301+DOCON ( --- n ) jsr <XCON (bif.m, bifdp.a)
302+ Characteristic of a CONSTANT. A CONSTANT simply loads its value
303+ from its parameter field and pushes it on the stack.
304+
305+DOUSER ( --- vadr ) jsr <XUSER (bif.m, bifdp.a)
306+ Characteristic of a per-USER variable. USER variables are
307+ similiar to VARIABLEs, but are allocated (by hand!) in the
308+ per-user table. A USER variable's parameter field contains its
309+ offset in the per-user table.
310+
311+DOVOC ( --- ) jsr <XVOC (bif.m, bifdp.a)
312+ Characteristic of a VOCABULARY. A VOCABULARY stores a pointer
313+ to itself in the current interpretation ROOT per-USER variable.
314+ It contains a pointer to the definition at the root of its
315+ symbol table tree. This allows the symbol table routines to
316+ treat the root as a leaf node. This is also not standard FORTH!
317+
318+ ( --- PFA ) ( *** IP ) jsr <XDOES (routine in bifdp.a)
319+ Characteristic of a DOES> defined word. The characteristics of
320+ DOES> definitions are written in high-level icodes rather than
321+ machine level code. The first parameter word points to the
322+ high-level characteristic. This routine's job is to push the
323+ IP, load the high level characteristic pointer in IP, and leave
324+ the address following the characteristic pointer on the stack so
325+ the parameter field can be accessed.
326+
327+The following are not standard FORTH characteristics:
328+
329+DO1ARR ( index --- eadr ) jsr <X1ARR (bif.m, bifdp.a)
330+ Characteristic of a linear array. Linear arrays take the top
331+ word on the stack as an index to the array, and return the
332+ address of the element indexed. So this routine subtracts the
333+ base index of the array, limit checks the result, then
334+ multiplies by the size of the array elements. If the index is
335+ out of bounds, it returns a NULL pointer (0). At some point I
336+ intended to implement multi-dimensional arrays in a similar
337+ manner, but I haven't. It would be a quick and interesting
338+ project for anyone interested.
339+
340+DOUCON ( --- n ) jsr <XUCON (bif.m, bifdp.a)
341+ Characteristic of a USER variable treated as a CONSTANT, i. e.,
342+ fetches the value stored at the specified offset in the per-user
343+ table.
344+
345+ ( --- d ) jsr <XDCON (bifdp.a)
346+ Characteristic of a double integer constant; the parameter field
347+ contains two words instead of one, both of which get pushed.
348+}
349+{ unused
350+ADDTOP (MACRO in BIF.M) is not a characteristic; is used in several
351+ routines to add a value to the top of stack.
352+}
353+
354+One of the primary problems with extending BIF is that calls to the
355+built-in characteristics are not conform to ;CODE. Defining definitions
356+which use (;CODE) to establish the characteristics of the
357+sybmbols/definitions they define will hav a three-byte code field, where
358+the built-in compiling definitions -- VARIABLE, (1ARRAY, etc.,)
359+CONSTANT, USER, :, and VOCABULARY have two-byte code fields. One
360+specific example of the difficulties this can create is that
361+vocabularies with special properties built in BIF, rather than by hand,
362+can't be searched by BIF's symbol table search routine, -FIND. Of
363+course, XVOC could be moved to VOCABULARY, where it belongs, (and might
364+also be changed to a DOES> definition, but I don't think that's
365+necessary on the 6809).
366+
367+
368+*******************************************************************************
369+ The BIF Symbols/Definitions/Routines
370+
371+
372+I have added slightly to the FORTH documentation methods. I also show
373+the results on the return stack and in the input buffer, where
374+appropriate. The name on the left is the definition name, as it will be
375+found by ' (TICK) and the outer interpreter. To the right I indicate
376+precedence (P for higher Precedence than definition) and restrictions (C
377+for Compile-only). Below the name, I indicate the assembler source
378+label, where it is different from the name. The definitions on the
379+SCREENS disk also indicate screen and sector for the source.
380+
381+The parameters attempt to be mnemonic. It will help to remember that
382+there are no stack items smaller than 16 bits; character and byte
383+parameters will be integers with their high-bytes ignored. Double
384+integers are 32 bits. A further reminder, parameters are listed Pascal
385+order, first pushed first; thus, the right-most is at the top of stack,
386+or the lowest address. I specify a list of doubles pushed onto the
387+stack (used in the assembler) as dl. Finally, I will try to mean 16-bit
388+integer when I say word, but I may sometimes slip and mean (per FORTH
389+jargon) a definition/routine.
390+
391+Flags are slightly different than fig-FORTH -- true is set as -1, sensed
392+as non-zero. False is zero, of course.
393+
394+A number of routines (such as ENCLOSE) accept and return different
395+parameters than specified in fig-FORTH. I assume that those for whom
396+this fact may be of consequence will have copies of the standard and can
397+compare at their leisure.
398+
399+The definitions are not alphabetized, nor are they listed in order of
400+immediate interest, but they are organized by the source file they occur
401+in. The following file descriptions are generally accurate, but some
402+code is out of place.
403+
404+ BIF contains most of the virtual machine.
405+
406+ BIF.M contains the inner interpreter macro, some important
407+ symbol table offsets, and a few other general EQUates and
408+ macros.
409+
410+ BIFDP contains the rest of the virtual machine.
411+
412+ BIFU contains the allocation of the per-user system variables.
413+
414+ BIFST contains the boot up code and definitions.
415+
416+ BIF1 contains most of the calculator-style expression evaluator.
417+
418+ BIF2 is mostly constants and system variables, but contains the
419+ memory management primitives.
420+
421+ Most of BIF3 is code which interacts with system variables, for
422+ example, the words which set the conversion base to sixteen,
423+ ten, or eight.
424+
425+ BIF4 contains multiplication and division, and the disk
426+ interface primitives.
427+
428+ BIF5 is mostly output formatting.
429+
430+ BIF6 is mostly input formatting and terminal interface.
431+
432+ BIF7 contains most of the dictionary (interactive symbol table)
433+ machinery.
434+
435+Unless otherwise noted, all definitions are in the BIF vocabulary.
436+
437+There is much that is not sacred about FORTH and its dialects. For
438+many, the attraction of FORTH is the great abandon with which one may
439+play games with its inner workings. I have taken a number of liberties
440+and these routines still function. If you have an idea, back your disks
441+up and try it.
442+
443+
444+**** Definitions/Routines in BIF.ASM and BIFB.A:
445+{ vm_alu.c bif.asm
446+@ ( adr --- n )
447+FETCH Replace address on stack with the word at the address.
448+
449+
450+! ( n adr --- )
451+STORE Store second word on stack at address on top of stack.
452+
453+LIT ( --- n ) C
454+ Push the following word from the instruction stream as a
455+ literal, or immediate value.
456+
457+DLIT ( --- d ) C
458+ Push a double integer literal (see LIT).
459+}
460+
461+{ bifc_vm.c bif.asm
462+EXECUTE ( adr --- ) C
463+EXEC Jump to address on stack. Used by the "outer" interpreter to
464+ interactively invoke routines. (Not compile-only in fig.)
465+
466+0BRANCH ( f --- ) C
467+ZBR BRANCH if flag is zero.
468+
469+1BRANCH ( f --- ) C
470+TBR BRANCH if not zero. Not as useful as it might appear.
471+
472+BRANCH ( --- ) C
473+ Add the following word from the instruction stream to the
474+ instruction pointer (Y++). Causes a program branch.
475+}
476+
477+(LOOP) ( --- ) ( limit index *** limit index+1) C
478+XLOOP ( limit index *** )
479+ Counting loop primitive. The counter and limit are the top two
480+ words on the return stack. If the updated index/counter does
481+ not exceed the limit, a branch occurs. If it does, the branch
482+ does not occur, and the index and limit are dropped from the
483+ return stack.
484+
485+(+LOOP) ( n --- ) ( limit index *** limit index+n ) C
486+XPLOOP ( limit index *** )
487+ Loop with a variable increment. Terminates when the index
488+ crosses the boundary from one below the limit to the limit. A
489+ positive n will cause termination if the result index equals the
490+ limit. A negative n must cause the index to become less than
491+ the limit to cause loop termination.
492+
493+(DO) ( limit index --- ) ( *** limit index )
494+XDO Move the loop parameters to the return stack. Synonym for D>R.
495+
496+I ( --- index ) ( limit index *** limit index )
497+ Copy the loop index from the return stack. Synonym for R.
498+
499+J ( --- index2 ) ( index2 limit1 index1 *** index2 limit1 index1 )
500+ Copy the outer loop index from the return stack. As with (DO)
501+ and I, J may be useful outside looping contexts.
502+
503+DIGIT ( c base --- ff )
504+ ( c base --- n tf )
505+ Translate C in base, yielding a translation valid flag. If the
506+ translation is not valid in the specified base, only the false
507+ flag is returned.
508+
509+(FIND) ( name vocptr --- locptr f )
510+PFIND Search vocabulary for a symbol called name. Name is a pointer
511+ to a NUL terminated string of characters without count, vocptr
512+ is a pointer to a pointer to a definition (the length byte of a
513+ symbol table entry). Locptr is also a pointer to a pointer to a
514+ definition, such that, if the flag is false, a symbol with the
515+ name searched for may be inserted in proper order at that point.
516+ Vocptr and locptr may point to either the right or left entry of
517+ the order-parent entry in the symbol table, or to pointer to the
518+ root of a vocabulary. HIDDEN (smudged) definitions are
519+ lexically less than their name strings. Searches only the local
520+ vocabulary, from the order-parent node passed. Uses (REFIND).
521+
522+ vocptr is a pointer to the parameter field of a vocabulary
523+ header.
524+
525+ENCLOSE ( buffer c --- s length )
526+ENCLOS Scan buffer for a symbol delimited by c or ASCII NUL; return the
527+ length of the symbol scanned and the address of its first
528+ character. A length 0 and a pointer to a NUL means no symbol
529+ was scanned before NUL terminator was reached. (Buffer is the
530+ address of the buffer array to scan.)
531+
532+LITERAL ( n --- ) P
533+LITER ( n --- n ) if interpreting.
534+ Compile n as a literal, if compiling.
535+
536+DLITERAL ( d --- ) P
537+DLITER ( d --- d ) if interpreting.
538+ Compile d as a double literal, if compiling.
539+
540+EMIT ( c --- )
541+ Write c to the output device (screen or printer). Uses the ECB
542+ device number at address $6F, -2 is printer, 0 is screen.
543+
544+KEY ( --- c )
545+ ( --- BREAK )
546+ Wait for a key from the keyboard. If the key is BREAK, set the
547+ high byte (result $FF03).
548+
549+?TERMINAL ( --- f )
550+QTERM Scan keyboard, but do not wait. Return 0 if no key, BREAK
551+ ($ff03) if BREAK is pressed, or key currently pressed.
552+
553+CR ( --- )
554+ EMIT a Carriage Return (ASCII CR).
555+
556+(;CODE) ( --- ) ( IP *** ) C
557+XSCODE Compile the latest symbol as a reference to a ;CODE definition;
558+ overwrite the first three (3!) bytes of the code field of the
559+ symbol found by LATEST with a jump to the low-level
560+ characteristic code provided in the defining definition, and pop
561+ IP. The machine-level code which follows (;CODE) in the
562+ instruction stream is not executed by the defining symbol, but
563+ becomes the characteristic of the defined symbol. This is the
564+ usual way to generate the characteristics of VARIABLEs,
565+ CONSTANTs, etc., when FORTH compiles itself. BIF, however, was
566+ hand-optimized to take advantage of direct-page jumps. So its
567+ pre-compiled defining symbols with low-level characteristics
568+ look different from those compiled by BIF, having two bytes in
569+ their code fields instead of three.
570+
571+>PRT ( --- )
572+TOPRT Send output to printer via CoCo's ROM routines and the device
573+ number variable (see EMIT).
574+
575+>VID ( --- )
576+TOVID Send output to CRT, converse of >PRT.
577+
578+2* ( n --- n*2 )
579+LSHIFT Fast multiply by two.
580+
581+2/ ( n --- n/2 )
582+RSHIFT Fast divide by two.
583+
584+(REFIND) ( name vocptr --- name locptr f )
585+PREF Search vocabulary for the first symbol called name. (Will find
586+ HIDDEN/SMUDGEd definitions.) Name is a pointer to a string of
587+ characters without count, vocptr is a pointer to a pointer to a
588+ definition (the length byte of a symbol table entry). Locptr is
589+ also a pointer to a pointer to a definition, such that, if the
590+ pointer at the pointer is NULL, a symbol with the name searched
591+ for may be inserted in proper order at that point. Vocptr and
592+ locptr may be either the right or left entry of the order-parent
593+ entry in the symbol table, or a pointer to the root of a
594+ vocabulary. Flag f will indicate by offset whether the child or
595+ empty slot is a left link (LFTOFF), right link (RTOFF), or
596+ vocabulary (PFAOFF).
597+
598+ vocptr is a pointer to the parameter field of a vocabulary
599+ header.
600+
601+
602+**** Definitions/Routines in BIF1.A and BIF1B.A:
603+
604+MOVE ( source target count --- )
605+ Copy/move count words from source to target. Moves ascending
606+ addresses, so that overlapping only works if the source is
607+ above the destination.
608+
609+CMOVE ( source target count --- )
610+ Copy/move count bytes from source to target. Moves ascending
611+ addresses, so that overlapping only works if the source is
612+ above the destination.
613+
614+U* ( u1 u2 --- ud )
615+USTAR Multiplies the top two unsigned integers, yielding a double
616+ integer product.
617+
618+U/ ( ud u --- uremainder uquotient )
619+USLASH Divides the top unsigned integer into the second and third words
620+ on the stack as a single unsigned double integer, leaving the
621+ remainder and quotient (quotient on top) as unsigned integers.
622+
623+ The smaller the divisor, the more likely dropping the high word
624+ of the quotient loses significant bits.
625+
626+AND ( n1 n2 --- n )
627+ Bitwise and the top two integers.
628+
629+OR ( n1 n2 --- n )
630+ Bitwise or.
631+
632+XOR ( n1 n2 --- n )
633+ Bitwise exclusive or.
634+
635+SP@ ( --- adr )
636+SPFEH Fetch the parameter stack pointer (before it is pushed).
637+
638+SP! ( whatever --- nothing )
639+SPSTO Initialize the parameter stack pointer from the USER variable
640+ S0. Effectively clears the stack.
641+
642+RP! ( whatever *** nothing )
643+RPSTO Initialize the return stack pointer from the USER variable R0.
644+ Effectively aborts all in process definitions, except the active
645+ one. An emergency measure, to be sure.
646+
647+;S ( ip *** )
648+SEMIS Pop IP from return stack (return from high-level definition).
649+ Can be used in a screen to force interpretion to terminate.
650+
651+LEAVE ( limit index *** index index )
652+ Force the terminating condition for the innermost loop by
653+ copying its index to its limit. Termination is postponed until
654+ the next LOOP or +LOOP instruction is executed. The index
655+ remains available for use until the LOOP or +LOOP instruction is
656+ encountered.
657+
658+>R ( n --- ) ( *** n ) C
659+TOR Move top of parameter stack to top of return stack.
660+
661+R> ( --- n ) (n *** ) C
662+RFROM Move top of return stack to top of parameter stack.
663+
664+R ( --- n ) ( n *** n )
665+ Copy the top of return stack to top of parameter stack. A
666+ synonym for I.
667+
668+= ( n1 n2 --- n1=n2 )
669+EQ Flag true if n1 and n2 are equal, otherwise false.
670+
671+< ( n1 n2 --- n1<n2 )
672+LT Flag true if n1 is less than n2, otherwise false.
673+
674+0= ( n --- n=0 )
675+ZEQ Logically invert top of stack; or flag true if top is zero,
676+ otherwise false.
677+
678+0< ( n --- n<0 )
679+ZLESS Flag true if top is negative (MSbit set), otherwise false.
680+
681+> ( n1 n2 --- n1>n2 )
682+GT Flag true if n1 is greater than n2, false otherwise.
683+
684+{ vm_alu.c bif1.a
685++ ( n1 n2 --- n1+n2 )
686+ADD Add top two words.
687+
688+- ( n1 n2 --- n1-n2 )
689+SUB Subtract top two words.
690+}
691+
692+D+ ( d1 d2 --- d1+d2 )
693+DADD Add top two double integers.
694+
695+D- ( d1 d2 --- d1-d2 )
696+DSUB Subtract top two double integers.
697+
698+MINUS ( n --- -n )
699+ Negate (two's complement) top of stack.
700+
701+DMINUS ( d --- -d )
702+ Negate (two's complement) top two words on stack as a double
703+ integer.
704+
705+OVER ( n1 n2 --- n1 n2 n1 )
706+ Push a copy of the second word on stack.
707+
708+DROP ( n --- )
709+ Discard the top word on stack.
710+
711+SWAP ( n1 n2 --- n2 n1 )
712+ Swap the top two words on stack.
713+
714+DUP ( n1 --- n1 n1 )
715+ Push a copy of the top word on stack.
716+
717++! ( n adr --- )
718+ADDSTO Add the second word on stack to the word at the adr on top of
719+ stack.
720+
721+TOGGLE ( adr b --- )
722+TOG Exclusive or byte at adr with low byte of top word.
723+
724+C@ ( adr --- b )
725+CFEH Replace address on top of stack with the byte at the address.
726+ High byte of result is clear.
727+
728+C! ( b adr --- )
729+CSTO Store low byte of second word on stack at address on top of
730+ stack. High byte is ignored.
731+
732+ROT ( n1 n2 n3 --- n2 n3 n1 )
733+ Rotate the top three words on stack, bringing the third word to
734+ the top.
735+
736+BACK ( adr --- ) C
737+ Calculate a back reference from HERE and compile it. The result
738+ compiled is adr-HERE-2, being adjusted for post-increment
739+ addressing.
740+
741+NOT ( n --- ~n )
742+ Bit (one's) complement the top of stack.
743+
744+' ( --- ) compiling P
745+TICK ( --- adr ) interpreting
746+ { ' name } input
747+ Parse a symbol name from input and search, -DFIND, the
748+ dictionary for it; compile the address as a literal if
749+ compiling, otherwise just push it. Recursively searches parent
750+ vocabularies, aborts if the parsed symbol name is not found.
751+
752+--> ( --- ) P
753+NEXSCR Continue interpreting source code on the next screen.
754+
755+1ARRAY ( start end size --- )
756+ONEARR { 1ARRAY name } input
757+ Parse name and compile it as a linear array of size elements
758+ from start index to end index inclusive. The number of bytes in
759+ the array is (end-start+1)*size. The 1ARRAY characteristic is a
760+ direct page routine.
761+
762+UTILITIES ( --- )
763+UTIL The UTILITIES vocabulary.
764+
765+DP@ ( --- adr ) in UTILITIES
766+DPFEH Calculate and push the address of the direct page.
767+
768+DCONSTANT ( d --- )
769+DCON { DCONSTANT name } input
770+ Parse name and compile it as a double constant with a value of
771+ d. The DCONSTANT characteristic is a direct page routine.
772+
773+SWAB ( n --- ns )
774+ Swap the bytes of the top word on stack.
775+
776+SWAN ( n --- ns )
777+ Swap the nibbles of the top word on stack. The low-level code
778+ looks funny, but it was the fastest way I could think up.
779+
780+
781+**** Definitions/Routines in BIF2.A and BIF2B.A:
782+
783+Increments and decrements for top of stack:
784+1+ ADD1 ( n --- n+1 )
785+1- SUB1 ( n --- n-1 )
786+2+ ADD2 ( n --- n+2 )
787+2- SUB2 ( n --- n-2 )
788+
789+Constants:
790+0 ZERO ( --- 0 )
791+1 ONE ( --- 1 )
792+-1 MONE ( --- -1 )
793+2 TWO ( --- 2 )
794+3 THREE ( --- 3 )
795+BL BL ( --- SP ) ASCII SPACE character
796+C/L CPERL ( --- 32 ) The number of columns per line on the
797+ CRT. Determines the length of error messages and the
798+ width and length of screen listings, among other things.
799+FIRST ( --- adr ) The base of the disk buffer space.
800+LIMIT ( --- adr ) The limit of the disk buffer space.
801+B/BUF BPBUF ( --- 256 ) The size, in bytes, of a buffer.
802+B/SCR BPSCR ( --- 4 ) The size, in buffers, of a screen.
803+
804++ORIGIN ( n --- adr )
805+PORIG Calculate the address of the (n/2)th entry in the boot-up
806+ parameter table. (Adds the base of the boot-up table to n.)
807+
808+Variables:
809+TIB ( --- vadr ) Terminal Input Buffer address. Note
810+ that is a variable, so users may allocate their own
811+ buffers, but it must be @ed.
812+WARNING WARN ( --- vadr ) Availability of error messages on disk.
813+ Contains 1 if messages available, 0 if not, -1 if a disk
814+ error has occurred.
815+ In bif-c, add 2 for internal error strings.
816+FENCE ( --- vadr ) Boundary for FORGET.
817+DP DPC ( --- vadr ) Dictionary pointer, fetched by HERE.
818+ROOT ( --- vadr ) Current local/context interpretation
819+ vocabulary root. Not a fig variable.
820+BLK ( --- vadr ) Block being interpreted. Zero refers to
821+ terminal.
822+IN ( --- vadr ) Input buffer offset/cursor.
823+OUT ( --- vadr ) Output buffer offset/cursor.
824+SCR ( --- vadr ) Screen being edited. Unused in BIF.
825+OFFSET ( --- vadr ) Sector offset for LOADing screens, set
826+ by DRIVE to make a new drive the default.
827+STATE ( --- vadr ) Compiler/interpreter state.
828+BASE ( --- vadr ) Numeric conversion base.
829+DPL ( --- vadr ) Output decimal point locator.
830+FLD ( --- vadr ) Field width for I/O formatting.
831+CSP ( --- vadr ) Compiler stack mark for stack check.
832+R# RNUM ( --- vadr ) Editing cursor location. Unused in BIF.
833+HLD ( --- vadr ) Pointer to last HELD character in PAD.
834+FOREWARD FORE ( --- vadr ) Pointer to earliest definition in active
835+ forward block. Not fig.
836+CURRENT CURR ( --- vadr ) NFA of LATEST definition. Not fig.
837+PREV ( --- vadr ) Most Recently Used buffer.
838+USE ( --- vadr ) Least Recently Used buffer.
839+DROOT ( --- vadr ) Current defining/compiling vocabulary
840+ root. Not fig.
841+
842+HERE ( --- adr )
843+ Get contents of DP, with heap/stack overflow ERROR check. More
844+ than a pseudo-constant.
845+
846+ALLOT ( n --- )
847+ Increase heap (add n to DP), ERROR check stack/heap.
848+
849+, ( n --- )
850+COMMA Store word n at DP++, ERROR check stack/heap.
851+
852+C, ( b --- )
853+CCOMMA Store byte b at DP+, ERROR check stack/heap.
854+
855+SPACE ( --- )
856+ EMIT a SPACE.
857+
858+-DUP ( 0 --- 0 )
859+DDUP ( n --- n n )
860+ DUP if non-zero.
861+
862+?CST ( --- f )
863+QCST Push compile/interpret state bits.
864+
865+IF ( --- cdptr $4946 ) P,C
866+ Compile a 0BRANCH and dummy offset and push IF reference to fill
867+ in and IF control construct flag.
868+
869+ELSE ( cdptr1 $4946 --- cdptr2 $4946 ) P,C
870+ ERROR check IF flag, compile BRANCH with dummy offset, resolve
871+ IF reference (FILL-IN offset-2 to HERE at cdptr1), and leave
872+ reference to BRANCH for ELSE.
873+
874+
875+ENDIF ( cdptr $4946 --- ) P,C
876+ ERROR check IF flag, resolve IF reference (FILL-IN offset-2 to
877+ HERE at cdptr) and pop reference/flag.
878+
879+
880+**** Definitions/Routines in BIF3.A and BIF3B.A:
881+
882+LATEST ( --- symptr )
883+ Fetch CURRENT as a per-USER constant.
884+
885+Symbol table conversions:
886+LFA ( n --- n+LFAOFF ) Convert NFA (not PFA) to LFA.
887+ --> Convert header address to LFA.
888+CFA ( n --- n+CFAOFF ) Convert NFA (not PFA) to CFA.
889+ --> Convert header address to CFA.
890+GFA ( n --- n+GFAOFF ) Convert NFA (not PFA) to CFA.
891+ --> Convert header address to GFA.
892+PFA ( n --- n+PFAOFF ) Convert NFA to PFA.
893+ --> Convert header address to PFA.
894+NFA ( n --- n-PFAOFF ) Convert PFA to NFA.
895+ --> Convert PFA to header address.
896+ NFA is the address of the length byte in a symbol table header.
897+ --> Now we use the header address instead of the NFA.
898+ PFA is the address at which a high-level definition's icode list
899+ begins, or a variable's, constant's, or vocabulary's value is
900+ stored.
901+ CFA is where a definition's code begins, or where the jump to
902+ its characteristic is stored.
903+ LFA is the address of a definition's allocation link.
904+ GFA is the address of a definition's vocabulary link.
905+
906+!CSP ( --- )
907+STOCSP Save the parameter stack pointer in CSP for compiler checks.
908+
909+Set the conversion base:
910+HEX ( --- ) Sixteen.
911+DECIMAL DEC ( --- ) Ten.
912+OCTAL OCT ( --- ) Eight.
913+
914+FILL ( adr n b --- )
915+ Fill n bytes at adr with b.
916+
917+ERASE ( adr n --- )
918+ Fill n bytes with 0.
919+
920+BLANKS ( adr n --- )
921+ Fill n bytes with ASCII SPACE.
922+
923+HOLD ( c --- )
924+ Format a character at the left of the HLD output buffer.
925+
926+PAD ( --- adr )
927+ Give the address of the output PAD buffer. Not same as fig. PAD
928+ points to the end of a 34 byte buffer for numeric conversion.
929+
930+S->D ( n0 --- d0 )
931+STOD Sign extend n0 to a double integer.
932+
933++- ( n0 n1>=0 --- n0 )
934+CHS ( n0 n1<0 --- -n0 )
935+ Change sign of second iff top is negative.
936+
937+D+- ( d0 n0>=0 --- d0 )
938+DCHS ( d0 n0<0 --- -d0 )
939+ Change sign of second and third as double iff top is negative.
940+
941+ABS ( n>=0 --- n )
942+ ( n<0 --- -n )
943+ Change the top of stack to its absolute value.
944+
945+DABS ( d>=0 --- d )
946+ ( d<0 --- -d )
947+ Change the top double to its absolute value.
948+
949+MIN ( n0 n1 --- min(n0,n1) )
950+ Leave the minimum of the top two integers.
951+
952+MAX ( n0 n1 --- max(n0,n1) )
953+ Leave the maximum of the top two integers.
954+
955+[ ( --- ) P
956+LBRAK Clear the compile state bits (shift to interpret).
957+
958+] ( --- )
959+RBRAK Set the compile state bits (shift to compile).
960+
961+IMMEDIATE ( --- )
962+IMMED Toggle precedence bit of LATEST definition header. During
963+ compiling, most symbols scanned are compiled. IMMEDIATE
964+ definitions execute whenever the outer INTERPRETer scans them,
965+ but may be compiled via ' (TICK).
966+
967+SMUDGE ( --- )
968+ Toggle HIDDEN bit of LATEST definition header, to hide it until
969+ defined or reveal it after definition.
970+
971+COMPILE-ONLY ( --- )
972+COMPO Toggle compile only bit of LATEST definition header.
973+
974+COUNT ( strptr --- strptr+1 count )
975+ Convert counted string to string and count. (Fetch the byte at
976+ strptr, post-increment.)
977+
978+-TRAILING ( strptr count1 --- strptr count2 )
979+DTRAIL Supress trailing blanks (subtract count of trailing blanks from
980+ strptr).
981+
982+(MACHINE) ( ip *** ) C
983+XMACH Change from executing icodes to machine code in a definition by
984+ saving IP and jumping to it after popping the old IP.
985+
986+TYPE ( strptr count --- )
987+ EMIT count characters at strptr.
988+
989+CTS-TYPE ( adr --- ) in UTILITIES (bif-c)
990+CTD_TYPE TYPE the (byte) counted string at adr.
991+
992+(.") ( --- ) C
993+XDOTQ TYPE counted string out of instruction stream (updating IP).
994+
995+ID. ( symptr --- )
996+IDDOT Print definition's name from its NFA.
997+
998+FILL-IN ( cdptr --- ) C
999+FILLIN Resolve the reference at cdptr by writing the offset from
1000+ cdptr+2 to HERE at cdptr. Offset is adjusted for post-increment
1001+ IP (ldd ,y++).
1002+
1003+BEGIN ( --- cdptr $4245 ) P,C
1004+ Push HERE for BACK reference for general (non-counting) loops,
1005+ with BEGIN construct flag.
1006+
1007+AGAIN ( cdptr $4245 --- ) P,C
1008+ ERROR check BEGIN flag, compile BRANCH and BACK resolve it to
1009+ cdptr.
1010+
1011+UNTIL ( cdptr $4245 --- ) P,C
1012+ ERROR check BEGIN flag, compile 0BRANCH and BACK resolve it to
1013+ cdptr.
1014+
1015+WHILE ( $4245 --- $4245 cdptr $5748 ) P,C
1016+ ERROR check BEGIN flag, compile 0BRANCH with dummy offset, push
1017+ WHILE reference -- HERE -- /flag on top of BEGIN reference/flag.
1018+
1019+REPEAT ( cdptr1 $4245 cdptr2 $5748 --- ) P,C
1020+ ERROR check WHILE and BEGIN flags, compile BRANCH and BACK fill
1021+ cdptr1 reference, FILL-IN 0BRANCH reference at cdptr2.
1022+
1023+DO ( --- cdptr $444F ) P,C
1024+ Compile (DO), push HERE for BACK refenece, and push DO control
1025+ construct flag.
1026+
1027+
1028+**** Definitions/Routines in BIF4.A and BIF4B.A:
1029+
1030+M* ( n1 n2 --- d )
1031+MSTAR Multiply top two words as signed integers with a signed double
1032+ result.
1033+
1034+M/ ( d n --- remainder quotient )
1035+MSLASH Divide signed double dividend d (2nd & 3rd words) by signed
1036+ word divisor n (top) yielding signed word remainder and quotient.
1037+ Quotient is top, remainder takes sign of dividend.
1038+
1039+ Thus, dividend == quotient * divisor + remainder
1040+ with truncating toward zero.
1041+ This can overflow in quotient.
1042+
1043+* ( multiplier multiplicand --- product )
1044+STAR Signed word multiply.
1045+
1046+/MOD ( dividend divisor --- remainder quotient )
1047+SLAMOD M/ in word-only form, i. e., signed division of 2nd word by top
1048+ word yielding signed word quotient and remainder.
1049+
1050+/ ( dividend divisor --- quotient )
1051+SLASH Signed word divide without remainder.
1052+
1053+MOD ( dividend divisor --- remainder )
1054+ Remainder function, result takes sign of dividend.
1055+
1056+*/MOD ( multiplier multiplicand divisor --- remainder quotient )
1057+SSMOD Signed precise division of product: multiply 2nd and 3rd
1058+ words on stack and divide the 31-bit product by the top word,
1059+ leaving both quotient and remainder. Remainder takes sign of
1060+ product. Guaranteed not to lose significant bits.
1061+
1062+*/ ( multiplier multiplicand divisor --- quotient )
1063+STARSL */MOD without remainder.
1064+
1065+M/MOD ( ud1 u1 --- u2 ud2 )
1066+MSMOD U/ with an (unsigned) double quotient. Guaranteed not to lose
1067+ significant bits, if you are prepared to deal with them.
1068+
1069++BUF ( buffer1 --- buffer2 f )
1070+ADDBUF Bump to next buffer, flag false if result is PREVious buffer,
1071+ otherwise flag true. Used in the LRU allocation routines.
1072+
1073+UPDATE ( --- )
1074+ Mark PREVious buffer dirty, in need of being written out.
1075+
1076+EMPTY-BUFFERS ( --- )
1077+EMTBUF Mark all buffers empty. Standard method of discarding changes.
1078+
1079+DRIVE-OFFSET ( n --- eadr )
1080+DROFFS 1ARRAY of drive offsets (see DO1ARR in the description of the
1081+ virtual machine). Contains the size, in sectors, of four
1082+ drives, plus a fifth entry to end the table if all four drives
1083+ are defined. To make drive 2 a 40 track SS-DD drive:
1084+ 40 18 * 2 DRIVE-OFFSET !
1085+ (Formatting the extra tracks can be handled with OS-9.)
1086+
1087+DRIVE ( n --- )
1088+ Add up the sector offset to sector 0 of drive n and store it in
1089+ OFFSET. This changes the logically lowest drive for LOADING.
1090+
1091+R/W ( buffer sector f --- )
1092+RW Read or Write the specified (absolute -- ignores OFFSET) sector
1093+ from or to the specified buffer. A zero flag specifies write,
1094+ non-zero specifies read. Sector is an unsigned integer, buffer
1095+ is the buffer's address. Uses the CoCo ROM disk routines. This
1096+ is where you would want to handle double-sided drives.
1097+
1098+?ERROR ( 0 n --- ) ( *** )
1099+QERROR ( true n --- IN BLK ) ( anything *** nothing )
1100+ If flag is false, do nothing. If flag is true, issue error
1101+ MESSAGE and QUIT or ABORT, via ERROR. Leaves cursor position
1102+ (IN) and currently loading block number (BLK) on stack, for
1103+ analysis.
1104+
1105+?COMP ( --- ) ( *** )
1106+QCOMP ( --- IN BLK ) ( anything *** nothing )
1107+ ERROR if not compiling.
1108+
1109+?EXEC ( --- ) ( *** )
1110+QEXEC ( --- IN BLK ) ( anything *** nothing )
1111+ ERROR if not executing.
1112+
1113+?PAIRS ( n1 n2 --- ) ( *** )
1114+QPAIRS ( n1 n2 --- IN BLK ) ( anything *** nothing )
1115+ ERROR if n1 and n2 are unequal. MESSAGE says compiled
1116+ conditionals do not match.
1117+
1118+?CSP ( --- ) ( *** )
1119+QCSP ( --- IN BLK ) ( anything *** nothing )
1120+ ERROR if return/control stack is not at same level as last !CSP.
1121+ Used to indicate that a definition has been left incomplete.
1122+ *** Actually, this checks the parameter stack. ***
1123+
1124+?LOADING ( --- ) ( *** )
1125+QLOAD ( --- IN BLK ) ( anything *** nothing )
1126+ ERROR if not loading, i. e., if BLK is non-zero. [correction: if BLK _is_ zero!]
1127+
1128+COMPILE ( --- )
1129+COMP Compile an in-line literal value from the instruction stream.
1130+
1131+LOOP ( cdptr $444f --- ) P,C
1132+ ERROR check DO flag, compile (LOOP), fill in BACK reference.
1133+
1134++LOOP ( cdptr $444f --- ) P,C
1135+PLOOP ERROR check DO flag, compile (+LOOP), fill in BACK reference.
1136+
1137+LOAD ( n --- )
1138+ Begin interpretation of screen (block) n. See also NEXSRC,
1139+ SEMIS, and ***NULLL****GGGGGHHHHTHNiTHNiTHNi
1140+
1141+<BUILDS ( --- ) C
1142+BUILDS Build a header for DOES> definitions. Actually just compiles a
1143+ CONSTANT zero which can be overwritten later by DOES>. Note
1144+ that <BUILDS is not IMMEDIATE, and therefore executes during a
1145+ definition's run-time, rather than its compile-time. It is not
1146+ intended to be used directly, but rather so that one definition
1147+ can build another. Also, note that nothing particularly special
1148+ happens in the defining definition until DOES> executes. The
1149+ name <BUILDS is intended to be a reminder of what is about to
1150+ occur.
1151+
1152+DOES> ( --- ) ( IP *** ) C
1153+DOES Define run-time behavior of definitions compiled/defined by a
1154+ high-level defining definition -- the FORTH equivalent of a
1155+ compiler-compiler. DOES> assumes that the LATEST symbol table
1156+ entry has at least one word of parameter field, which <BUILDS
1157+ provides. Note that DOES> is also not IMMEDIATE. When the
1158+ defining word containing DOES> executes the DOES> icode, it
1159+ overwrites the LATEST symbol's CFA with jsr <XDOES, overwrites
1160+ the first word of that symbol's parameter field with its own IP,
1161+ and pops the previous IP from the return stack. The icodes which
1162+ follow DOES> in the stream do not execute at the defining word's
1163+ run-time. Examining XDOES in the virtual machine shows that the
1164+ defined word will execute those icodes which follow DOES> at its
1165+ own run-time. The advantage of this kind of behaviour, which
1166+ you will also note in ;CODE, is that the defined word can
1167+ contain both operations and data to be operated on. This is how
1168+ FORTH data objects define their own behavior. Finally, note
1169+ that the effective code field for DOES> definitions is four
1170+ bytes.
1171+
1172+;CODE ( --- ) P,C
1173+SCODE ?CSP to see if there are loose ends in the defining definition
1174+ before shifting to the assembler, compile (;CODE) in
1175+ the defining definition's instruction stream, shift to
1176+ interpreting, make the ASSEMBLER vocabulary current, and !CSP to
1177+ mark the stack in preparation for assembling low-level code.
1178+ Note that ;CODE, unlike DOES>, is IMMEDIATE, and compiles
1179+ (;CODE),which will do the actual work of changing the LATEST
1180+ definition's characteristic when the defining word runs.
1181+ Assembly is done by the interpreter, rather than the compiler.
1182+ I could have avoided the anomalous three-byte code fields by
1183+ having ;CODE compile in the direct page jumps to the actual
1184+ low-level characteristics in the defining definition, thus
1185+ allowing (;CODE) to write a two-byte direct-page jumps into the
1186+ code fields of defined words. But that's a lot of work!
1187+
1188+
1189+**** Definitions/Routines in BIF5.A and BIF5B.A:
1190+
1191+
1192+IP, ( --- ) C
1193+IPCOM COMPILE a literal out of the instruction stream, without
1194+ checking compiler state. Used by the assembler to stuff
1195+ op-codes into the instruction stream, since the assembler runs
1196+ in interpretation mode.
1197+
1198+?STACK ( --- ) ( *** )
1199+QSTACK ( --- IN BLK ) ( anything *** nothing )
1200+ ERROR if either stack out of bounds, or on evidence of stack
1201+ boundary problems. There is a word below the bottom of each
1202+ stack, which ABORT clears before it starts interpreting. In
1203+ addition to checking that both stacks have not overflowed, this
1204+ routine checks those two words, to see if underflow has
1205+ occurred.
1206+
1207+BUFFER ( n --- buffer )
1208+ Get a free buffer, assign it to block n, return buffer address.
1209+ Will free a buffer by writing it, if necessary. Does not
1210+ actually read the block. A bug in the fig LRU algorithm, which
1211+ I have not fixed, gives the PREVious buffer if USE gets set to
1212+ PREVious (the bug is that it happens). This bug sometimes
1213+ causes sector moves to become sector fills.
1214+
1215+BLOCK ( n --- buffer )
1216+ Get BUFFER containing block n, relative to OFFSET. If block n
1217+ is not in a buffer, bring it in. Returns buffer address.
1218+
1219+(LINE) ( line screen --- buffer C/L)
1220+XLINE Bring in the sector containing the specified line of the
1221+ specified screen. Returns the buffer address and the width of
1222+ the screen. Screen number is relative to OFFSET. The line
1223+ number may be beyond screen 4, (LINE) will get the appropriate
1224+ screen.
1225+
1226+.LINE ( line screen --- )
1227+DOTLIN Print the line of the screen as found by (LINE), suppress
1228+ trailing BLANKS.
1229+
1230+SPACES ( count --- )
1231+ EMIT count spaces, for non-zero, non-negative counts.
1232+
1233+<# ( --- )
1234+BEGHSH Initialize HLD for converting a double integer. Stores the PAD
1235+ address in HLD.
1236+
1237+#> ( d --- string length )
1238+ENDHSH Terminate numeric conversion, drop the number being converted,
1239+ leave the address of the conversion string and the length, ready
1240+ for TYPE.
1241+
1242+SIGN ( n d --- d )
1243+ Put sign of n (as a flag) in front of the conversion string.
1244+ Drop the sign flag.
1245+
1246+# ( d --- d/base )
1247+HASH Generate next most significant digit in the conversion BASE,
1248+ putting the digit in front of the conversion string.
1249+
1250+#S ( d --- dzero )
1251+HASHS Convert d to a numeric string using # until the result is zero.
1252+ Leave the double result on the stack for #> to drop.
1253+
1254+D.R ( d width --- )
1255+DDOTR Print d on the output device in the current conversion base,
1256+ with sign, right aligned in a field at least width wide.
1257+
1258+D. ( d --- )
1259+DDOT Print d on the output device in the current conversion base,
1260+ with sign, in free format with trailing space.
1261+
1262+.R ( n width --- )
1263+DOTR Print n on the output device in the current conversion base,
1264+ with sign, right aligned in a field at least width wide.
1265+
1266+. ( n --- )
1267+DOT Print n on the output device in the current conversion base,
1268+ with sign, in free format with trailing space.
1269+
1270+? ( adr --- )
1271+QDOT Print signed word at adr, per DOT.
1272+
1273+MESSAGE ( n --- )
1274+MESS If WARNING is 0, print "MESSAGE #n"; otherwise, print line n
1275+ relative to screen 4, the line number may be negative. Uses
1276+ .LINE, but counter-adjusts to be relative to the real drive 0.
1277+
1278+ In bif-c, add value of 2 for WARNING, for internal error message
1279+ strings.
1280+
1281+(ABORT) ( anything --- nothing ) ( anything *** nothing )
1282+IABORT An indirection for ABORT, for ERROR, which may be modified
1283+ carefully.
1284+
1285+ERROR ( anything line --- IN BLK ) ( anything *** nothing )
1286+ ( anything --- nothing ) ( anything *** nothing ) WARNING < 0
1287+ Prints out the last symbol scanned and MESSAGE number line. If
1288+ WARNING is less than zero, ABORTs through (ABORT), otherwise,
1289+ clears the parameter stack, pushes the INput cursor and
1290+ interpretaion BLK, and QUITs.
1291+
1292+EDITOR ( --- ) in EDITOR P
1293+ Set the current interpretation vocabulary to EDITOR.
1294+
1295+QSYNC ( --- ) in EDITOR
1296+ Synchronize the ECB cursor with R#.
1297+
1298+EBLK ( --- vadr ) in EDITOR
1299+ USER variable containing the current editing block.
1300+
1301+CURSOR ( --- adr ) in EDITOR
1302+ Calculates the address of the edit cursor, R#, within the
1303+ current editing block, bringing that block in if necessary.
1304+
1305+QDUMP ( adr --- ) in EDITOR
1306+ Dump the 256 bytes at adr to the screen memory, at the top half
1307+ of the screen (bottom half of screen memory).
1308+
1309+QARROW ( c --- c )
1310+ ( c --- 0 )
1311+ Adjust the cursor according to the key passed. If the key is a
1312+ cursor control key, return 0; otherwise, leave the key
1313+ unchanged. The regular back-arrow is used for cursor movement,
1314+ so the shifted back-arrow is used for destructive backspace.
1315+ Also, the up arrow is used for cursor movement, so caret is not
1316+ available without escaping. See QUICK.
1317+
1318+
1319+**** Definitions/Routines in BIF6.A and BIF6B.A:
1320+
1321+
1322+(NUMBER) ( d1 string --- d2 adr )
1323+INUMB Convert the text at string into a number, accumulating the
1324+ result into d1, leaving adr pointing to the first character not
1325+ converted. If DPL is non-negative at entry, accumulates the
1326+ number of characters converted into DPL.
1327+
1328+NUMBER ( ctstr --- d )
1329+ Convert text at ctstr to a double integer, taking the 0 ERROR if
1330+ the conversion is not valid. If a decimal point is present,
1331+ accumulate the count of digits to the decimal point's right into
1332+ DPL (negative DPL at exit indicates single precision). ctstr is
1333+ a counted string -- the first byte at ctstr is the length of the
1334+ string, but NUMBER ignores the count and expects a NUL
1335+ terminator instead.
1336+
1337+WORDPAD ( --- vadr )
1338+WORDPD The per-USER constant pointing to an intermediate
1339+ buffer for text scanning.
1340+
1341+WORD ( c --- )
1342+ Scan a string terminated by the character c or ASCII NUL out of
1343+ input; store symbol at WORDPAD with leading count byte and
1344+ trailing ASCII NUL. Leading c are passed over, per ENCLOSE.
1345+ Scans from BLK, or from TIB if BLK is zero. May overwrite the
1346+ numeric conversion pad, if really long (length > 31) symbols are
1347+ scanned.
1348+
1349+BS ( --- c )
1350+ The per-USER backspace constant.
1351+
1352+EXPECT ( buffer n --- )
1353+ Get up to n-1 characters from the keyboard, storing at buffer
1354+ and echoing, with backspace editing, quitting when a CR is read.
1355+ Terminate it with a NUL.
1356+
1357+QUERY ( --- )
1358+ EXPECT 128 (TWID) characters to TIB.
1359+
1360+ ( --- ) P
1361+NUBLK End interpretation of a line or screen, and/or prepare for a new
1362+ block. Note that the name of this definition is an empty
1363+ string, so it matches on the terminating NUL in the terminal or
1364+ block buffer.
1365+
1366+FIND ( namstr vocptr1 --- nfa vocptr2 )
1367+ Search a vocabulary, and its parents, if necessary, for a
1368+ definition called namstr. namstr is a counted (leading count
1369+ byte is ignored) string, vocptr1 is a pointer to a pointer to
1370+ a vocabulary tree or subtree. It will usually be the address of
1371+ the per-USER variable ROOT or DROOT, but may be a pointer to a
1372+ left or right link of an entry in the symbol tree. nfa will be
1373+ the name field address of the definition found, or a NULL.
1374+ vocptr2 will be the pointer-pointer to the last vocabulary
1375+ searched. vocptr2 will be the last vocabulary searche. See
1376+ (FIND).
1377+
1378+-DFIND ( --- nfa vocptr ) { -DFIND name } typical input
1379+DDFIND Parse a word, then FIND, first in the definition vocabulary,
1380+ then in the CONTEXT (interpretation) vocabulary, if necessary.
1381+ Returns the address of the symbol table entry or a NULL, and the
1382+ last vocabulary searched, per FIND.
1383+
1384+-IFIND ( --- nfa vocptr ) { -DFIND name } typical input
1385+DIFIND Same as -DFIND, except search the CONTEXT vocabulary first.
1386+
1387+NAME, ( --- ctStrPtr length )
1388+NCOMMA Store counted string at WORDPAD into dictionary, return HERE
1389+ pointer and length of string. Note that the count is not stored
1390+ in the dictionary, but that the address returned will be the
1391+ address to store the count at. (The length of the names of
1392+ definitions are stored after the actual names in the dictionary!)
1393+
1394+ But in BIF-C, the lengths are stored with the strings, and the
1395+ address returned points to where the counted string was stored.
1396+
1397+FORE_MARK ( --- )
1398+FOREMK Set forward reference bit in LATEST definition, if FOREWARD is
1399+ non-NULL.
1400+
1401+(INSTALL) ( nfa vocptr --- ) P
1402+PINSTA Install the header at nfa into the specified vocabulary, hiding
1403+ (SMUDGEing) any existing definitions of the same name in that
1404+ vocabulary. In BIF-6809, vocptr was a pointer to the parameter
1405+ field of the vocabulary, and we follow that in BIF-C v. 0.
1406+
1407+0! ( --- )
1408+INULL Store 0 word at NULL pointer (address 0).
1409+
1410+?0 ( --- )
1411+TNULL Set warning to -1 and jmp to ERROR if the word at address 0
1412+ (NULL pointer) is not 0.
1413+
1414+QUICK ( n --- ) in EDITOR
1415+ Quick and dirty editor; edits sectors, not screens. See above
1416+ description.
1417+
1418+NODE. ( nfa --- flag )
1419+NDOT ID. with some formatting, extra information useful for
1420+ debugging, and a keyboard pause/abort test. Returns flag less
1421+ than 0 if BREAK key was pressed.
1422+
1423+VISIT ( defptr vocptr --- )
1424+ Scan vocabulary at vocptr in ascending order, performing
1425+ definition at defptr at every node. defptr is an nfa, vocptr is
1426+ the pfa of a vocabulary, per FIND and ROOT/DROOT. The
1427+ definition to be executed will have parameters of the same form
1428+ as NDOT, doing something at a symbol tree node and leaving a
1429+ termination flag. VISIT checks for stack overflow and watches
1430+ the termination flag between executions. The VISITing
1431+ definition may have other parameters, but if it changes the
1432+ stack pointer from execution to execution VISIT will complain.
1433+
1434+VLIST ( --- )
1435+ Alphabetically list the definitions in the current vocabulary.
1436+
1437+
1438+**** Definitions/Routines in BIF7.A and BIF7B.A:
1439+
1440+
1441+CREATE ( --- ) { CREATE name } input
1442+ Parse a name (length < 32 characters) and create a header,
1443+ reporting first duplicate found in either the defining
1444+ vocabulary or the context (interpreting) vocabulary. (INSTALL)
1445+ the header in the local vocabulary.
1446+
1447+CONSTANT ( n --- )
1448+CONST { value CONSTANT name } typical input
1449+ CREATE a header, compile a call to XCON, compile the constant
1450+ value.
1451+
1452+VARIABLE ( init --- )
1453+VAR { init VARIABLE name } typical input
1454+ CREATE a header, compile a call to XVAR, compile the initial
1455+ value init.
1456+
1457+USER ( ub --- )
1458+USER { uboffset USER name } typical input
1459+ CREATE a header, compile a call to XUSER, compile the unsigned
1460+ byte offset in the per-USER table. The USER is entirely
1461+ responsible for maintaining allocation!
1462+
1463+: ( --- ) P
1464+COLON { : name sundry-activities ; } typical input
1465+ If executing, record the data stack mark in CSP, CREATE a
1466+ header, compile a call to XCOL, and set state to compile. (SCOMP
1467+ is defined in this file.) CONTEXT (interpretation) vocabulary
1468+ is unchanged.
1469+
1470+; ( --- ) P
1471+SEMI { : name sundry-activities ; } typical input
1472+ ERROR check data stack against mark in CSP, compile ;S, unSMUDGE
1473+ LATEST definition, and set state to interpretation.
1474+
1475+." ( --- ) P
1476+DOTQ { ." something-to-be-printed " } typical input
1477+ Use WORD to parse to trailing quote, if compiling, compile XDOTQ
1478+ and string parsed, otherwise, TYPE string.
1479+
1480+[COMPILE] ( --- ) P
1481+BCOMP { [COMPILE] name } typical use
1482+ -DFIND next WORD and COMPILE it, literally; used to compile
1483+ immediate definitions.
1484+
1485+INTERPRET ( --- )
1486+INTERP Interpret or compile, according to STATE. Searches words parsed
1487+ in dictionary first, via -IFIND, then checks for valid NUMBER.
1488+ Pushes or COMPILEs double literal if NUMBER leaves DPL
1489+ non-negative. ERROR checks the stack via ?STACK before
1490+ returning to its caller. Sensitive to COMPILE-ONLY bit in
1491+ headers.
1492+
1493+QUIT ( anything *** nothing )
1494+ Clear return stack. Then INTERPRET and, if not compiling,
1495+ prompt with OK, in infinite loop.
1496+
1497+BIF ( --- ) P
1498+ Makes BIF the current interpretation vocabulary.
1499+
1500+ASSEMBLER ( --- ) P
1501+ASMBLR Makes ASSEMBLER the current interpretation vocabulary. Might
1502+ ought not to be IMMEDIATE.
1503+
1504+DEFINITIONS ( --- )
1505+DEFS Makes the current interpretation vocabulary also the current
1506+ defining vocabulary.
1507+
1508+ABORT ( anything --- nothing ) ( anything *** nothing )
1509+ Clear parameter stack, intialize the NULL vector, set STATE to
1510+ interpret and BASE to DECIMAL, return to input from terminal,
1511+ restore DRIVE OFFSET to 0, set interpret and define vocabularies
1512+ to BIF, print out "6809 BIF Vx.x", and finally, QUIT. Used to
1513+ force the system to a known state and return control to the
1514+ standard INTERPRETer.
1515+
1516+VOCABULARY ( --- ) { VOCABULARY name } input
1517+VOCAB Create a vocabulary entry with a NULL local pointer, linked by
1518+ the parent pointer to the current defining vocabulary. The
1519+ vocabulary parameter passed to the various searching routines is
1520+ usually a pointer to the parameter field of a vocabulary. That
1521+ way, the root is functionally identically to a left or right
1522+ link in a node or leaf, particularly for insertion.
1523+
1524+( ( --- )
1525+PAREN Parse out a comment and toss it away. This is probably not
1526+ useful, but it leaves the first 32 characters in WORDPAD.
1527+
1528+DAD ( nfa --- name linkadr flag )
1529+ Search the parent vocabulary of the definition at nfa for nfa,
1530+ returning the address of the first character of the definition's
1531+ name, a pointer to the left or right link which links the
1532+ definition in, and a flag indicating whether the definition is
1533+ linked left or right. ERROR if the definition can't be found.
1534+ The return parameters are appropriate for REPEALing the
1535+ definition.
1536+
1537+REPEAL ( --- )
1538+ Remove the CURRENT/LATEST definition from the dictionary, from
1539+ the vocabulary in which it is defined. Updates CURRENT, alsoe
1540+ updates DROOT or ROOT and clears FOREWARD, if appropriate. If
1541+ the CURRENT definition is in a closed forward block, repeals the
1542+ entire block, so that forward references aren't pointing to
1543+ trash.
1544+
1545+ Except that I never got that last part written and working. So
1546+ you have to do that by hand. It does clear FOREWARD if FOREWARD
1547+ is pointing to the REPEALed definition.
1548+
1549+FORGET ( --- ) { FORGET name } input
1550+ Parse out name of definition to FORGET to, -DFIND it, then
1551+ REPEAL until it is removed from the dictionary. Will not FORGET
1552+ if definition is not found, if it is in a recursive block, or if
1553+ it is below FENCE; the ERROR message will include the offending
1554+ name.
1555+
1556+ (Does it really?)
1557+
1558+
1559+**** Definitions/Routines in BIFST.A
1560+
1561+
1562+COLD COLD boot. Initializes the system variables, prunes the
1563+ dictionary of everything beyond the initial FENCE, then WARM
1564+ boots.
1565+
1566+WARM Resets stack areas and per-USER variables, clears the buffers,
1567+ then yields control to BIF via ABORT.
1568+
1569+
1570+****
1571+Definitions on the SCREENs disk follow. The vocabulary names are
1572+abbreviated here under the definition names, A for ASSEMBLER, B for BIF,
1573+U for UTILITIES, ^a for ^asm-util.
1574+
1575+**** SCREEN 0
1576+Index to the screens disk.
1577+
1578+**** SCREEN 2
1579+Title page and copyright notice.
1580+
1581+**** SCREEN 3
1582+MON ( --- )
1583+- Call the debugging monitor: SWI followed by a jmp [,y++], so
1584+ that BIF can be continued.
1585+
1586+After screen 2 creates MON, it updates FENCE to protect MON from WARM
1587+boots. Will load in the active vocabulary.
1588+
1589+**** SCREENs 4 & 5
1590+Error and other Messages:
1591+0: number conversion/unknown definition, no message text.
1592+1: DATA STACK UNDERFLOW
1593+2: DICTIONARY FULL
1594+3: ADDRESS RESOLUTION ERROR for control structures
1595+4: HIDES DEFINITION IN some vocabulary
1596+5: NULL VECTOR WRITTEN
1597+6: DISC RANGE? disk sector number out of range
1598+7: DATA STACK OVERFLOW
1599+8: DISC ERROR! of some sort -- is your drive door closed?
1600+9: CAN'T EXECUTE A NULL!
1601+10: CONTROL STACK UNDERFLOW
1602+11: CONTROL STACK OVERFLOW
1603+12: ARRAY REFERENCE OUT OF BOUNDS
1604+13: ARRAY DIMENSION NOT VALID
1605+14: NO PROCEDURE TO ENTER
1606+15: ( was register error message for assembler )
1607+16:
1608+17: COMPILATION ONLY, USE IN DEFinition
1609+18: EXECUTION ONLY do not use while compiling
1610+19: CONDITIONALS NOT PAIRED where's your if/loop end statement?
1611+20: DEFINITION INCOMPLETE often same as 18, but hit ;
1612+21: IN PROTECTED DICTIONARY don't try to forget below FENCE.
1613+22: USE ONLY WHEN LOADING
1614+23: OFF CURRENT EDITING SCREEN an editor cursor problem
1615+24: DECLARE VOCABULARY
1616+25: DEFINITION NOT IN VOCABULARY
1617+26: IN FORWARD BLOCK
1618+27: ALLOCATION LIST CORRUPTED: LOST
1619+28: CAN'T REDEFINE nul! You tried to CREATE something without a name.
1620+29: NOT FORWARD REFERENCE
1621+30: ( was message about IMMEDIATE )
1622+31:
1623+32:
1624+33: HAS INCORRECT ADDRESS MODE for 6809
1625+34: HAS INCORRECT INDEX MODE for 6809
1626+35: OPERAND NOT REGISTER in 6809
1627+36: HAS ILLEGAL IMMEDIATE for 6809
1628+37: PC OFFSET MUST BE ABSOLUTE pc-relative addressing error
1629+38: ACCUMULATOR OFFSET REQUIRED for indexing mode
1630+39: ILLEGAL MEMORY INDIRECTION for 6809
1631+40: ILLEGAL INDEX BASE for 6809
1632+41: ILLEGAL TARGET SPECIFIED for 6809 addressing mode or register
1633+42: CAN'T STACK ON SELF for push/pull, try other stack pointer
1634+43: DUPLICATE IN LIST of operands
1635+44: REGISTER NOT STACK trying to push on a non-stack register?
1636+45: EMPTY REGISTER LIST best supply some registers
1637+46: IMMEDIATE OPERAND REQUIRED for 6809
1638+47: REQUIRES CONDITION for control operator
1639+48:
1640+49: COMPILE-TIME STACK UNDERFLOW
1641+50: COMPILE-TIME STACK OVERFLOW
1642+
1643+**** SCREEN 6
1644+
1645+BYTE-DUMP ( adr n --- )
1646+U Dump n bytes to output device, right adjusted in 4 character
1647+ columns. Field width is not big enough if BASE is six or less.
1648+
1649+DUMP ( adr n --- )
1650+B Formatted dump to output device, with ASCII interpretation.
1651+ Hard coded to 4 bytes per line.
1652+
1653+QLIST ( n --- )
1654+B QDUMP a block/sector and set the cursor to the middle of the
1655+ screen so the dump remains visible.
1656+
1657+QINDEX ( start end --- )
1658+B QLIST block/sectors from number start to end, inclusive.
1659+
1660+L/SCR ( --- n )
1661+U Calculate the number of terminal lines per disc screen at
1662+ run-time. Sixteen, at present.
1663+
1664+ULIST ( n --- flag )
1665+U List screen n, with line numbers in the current base, leave
1666+ BREAK key flag. Uses C/L, to automatically adjust for screen
1667+ width (if C/L is set), but you may not want to use this
1668+ definition if you set C/L to something besides 32 or 64.
1669+
1670+**** SCREEN 7
1671+
1672+LIST ( n --- )
1673+B ULIST screen n, line numbers in decimal.
1674+
1675+INDEX ( start end --- )
1676+B Print comment lines (line 0, and line 1 if C/L < 41) of screens
1677+ from start to end.
1678+
1679+TRIAD ( n --- )
1680+B List a printer page full of screens to the printer, formatted by
1681+ C/L. Line and screen number are in current base. Lists the
1682+ group containing screen n, will print 2 screens if C/L is 32,
1683+ three if C/L is 64. (Two may not fit well.)
1684+
1685+**** SCREEN 8
1686+
1687+HOME ( --- )
1688+U Put the cursor at the (CoCo 2) CRT screen HOME position.
1689+
1690+MID ( --- )
1691+U Put the cursor 8 lines down the (CoCo 2) CRT screen.
1692+
1693+CLS ( --- )
1694+B Clear the (CoCo 2) CRT screen.
1695+
1696+CAN-UP ( adr -- adr )
1697+U Clear the UPDATE bit (MSB) for the buffer whose block word is at
1698+ adr. The characters in the buffer should be stored at adr+2.
1699+
1700+W-BUF ( adr --- adr )
1701+U Write the characters at adr+2 to the sector specified at adr,
1702+ clear the UPDATE flag.
1703+
1704+SAVE-BUF ( adr --- adr )
1705+U W-BUF, if UPDATEd.
1706+
1707+QSAVE ( --- )
1708+B Save the PREViously edited buffer, if it was UPDATEd.
1709+
1710+SAVE-BUFFERS ( --- )
1711+B Write all buffers flagged for UPDATE, clear UPDATE bits.
1712+
1713+QCAN ( --- )
1714+B Cancel UPDATE of PREViously edited buffer.
1715+
1716+**** SCREEN 9
1717+
1718+CANCEL-UPDATES ( --- )
1719+B Cancel UPDATEs of all buffers.
1720+
1721+RE-QUICK ( --- )
1722+B Re-edit PREVious buffer.
1723+
1724+.BUF ( adr --- adr )
1725+U Dump buffer characters at adr+2, showing the sector number
1726+ indicated at adr.
1727+
1728+.BUFFERS ( --- )
1729+B Dump all buffers, with block number, per .BUF.
1730+
1731+.PREV ( --- )
1732+B Dump contents and block number of PREVious buffer, per .BUF.
1733+
1734+EDIT ( n --- )
1735+B QUICK edit block n, showing the block number.
1736+
1737+QPREV ( --- )
1738+B QUICK edit the PREVious block.
1739+
1740+**** SCREEN 10
1741+
1742+QOPY ( src dest --- )
1743+B Move content of block/sector src to block dest. BUG: Doesn't
1744+ copy if src is already in a buffer (problem with LRU).
1745+
1746+COPY ( src dest --- )
1747+B Copy SCREEN src to SCREEN dest. Uses QOPY, so you should
1748+ EMPTY-BUFFERS before using COPY.
1749+
1750+QBACK ( start end --- )
1751+B Copy blocks from start to end to the next higher disc, at the
1752+ same sector offset.
1753+
1754+EEDIT ( n --- )
1755+B Erase and then EDIT block n.
1756+
1757+**** SCREEN 11
1758+
1759+RES-ERROR ( --- )
1760+U ERROR #3
1761+
1762+FORWARD ( --- ) { FORWARD name } input
1763+B Compile a forward reference header: CREATE, set FOREWARD if not
1764+ already set, compile jmp to RES-ERROR, unSMUDGE header.
1765+
1766+:RESOLVE ( --- ) { :RESOLVE name } input P
1767+A If the characteristic of name is a jmp to RES-ERROR, make it
1768+ LATEST, re-SMUDGE it, change jmp address to HERE; if the header
1769+ of name is the base of the forward block, clear FOREWARD.
1770+ Forward blocks should end with the definition of the first
1771+ forward reference in the block, to maintain the block's
1772+ integrity. (However, the FOREWARD USER variable can be modified
1773+ by hand, if necessary.)
1774+
1775+:RES ( --- ) { :RES name } input
1776+B Do ASSEMBLER's resolve, then compile jmp <XCOL and switch state
1777+ to compile.
1778+
1779+;RES ( --- ) P
1780+B ; but SMUDGE LATEST one more time.
1781+
1782+**** SCREEN 11 does not continue LOADing! ****
1783+
1784+**** SCREEN 12
1785+
1786+PL ( --- )
1787+B Print 80 ASCII characters starting with '!'.
1788+
1789+PT ( --- )
1790+B PL until any key is hit.
1791+
1792+PTEST ( --- )
1793+B PT, but send the output to the printer.
1794+
1795+**** SCREEN 13
1796+
1797+SLIST ( start end --- )
1798+- ULIST SCREENs to printer from start to end inclusive.
1799+
1800+**** SCREEN 14
1801+This contains some experimental stuff that I was using to test my a
1802+Sardis Technologies disk controller.
1803+
1804+**** SCREEN 15
1805+
1806+NAME ( cfa --- )
1807+B Convert the CFA on the stack to an nfa and ID. it.
1808+
1809+NAMES ( adr n --- )
1810+B NAME n icodes at adr. Naively interprets anything as an icode.
1811+
1812+**** SCREEN 16
1813+**** The assembler starts here! ****
1814+
1815+^asm-util ( --- )
1816+A Vocabulary for assembler support stuff. (Note that the name is
1817+ in lower case and looks funny when editing until the cursor
1818+ moves over it.)
1819+
1820+DREG ( n --- ) { n DREG name } input -> compile-time
1821+^a ( --- d ) -> run-time
1822+ Define register double constants. Most significant word is
1823+ `RE', the index and operand encodings are masked into the least
1824+ significant word.
1825+
1826+xx ( --- d ) high word is HEX 5245
1827+A The register double constants in hex:
1828+ D 52458B00 A 52458608 B 52458509 PC 52458C05
1829+ U 52454003 S 52456004 Y 52452002 X 52450001
1830+ CC 5245EF0A DP 5245EF0B
1831+ Example: DP A EXG is exg dp,a
1832+
1833+# ( --- n )
1834+A Suffix constant for immediate values. Becomes the high byte:
1835+ 4 # A LD is lda #4
1836+
1837+DPREG ( --- adr )
1838+^a DP register emulator for the assembler. A per-USER variable at
1839+ offset HEX 42, initialized to whatever the load-time DP is.
1840+
1841+DPR ( --- adr )
1842+A Push the current DPREG value, as a constant. To use as an
1843+ absolute address, push a 0 or -1 after.
1844+ Example: DPR 7 + 0 JMP is jmp <7
1845+
1846+SETDP ( adr --- )
1847+A Set the DPREG value, masks the low byte of adr out.
1848+
1849+**** SCREEN 17
1850+
1851+OFF, (n b --- )
1852+^a Compile an index byte b with signed, constant, byte or word
1853+ offset, n. Sets bit 0 in the index byte if it compiles a word
1854+ offset.
1855+
1856+OP, ( u --- )
1857+^a Compile opcode u. Compiles 16 bits if high byte of u is
1858+ non-zero.
1859+
1860+ABS, ( adr u1 u2 --- )
1861+^a Compile an absolute address mode (direct page or extended)
1862+ op-code u1, oring u2 into u1 before compiling if the address is
1863+ not in the direct page.
1864+
1865+PCOFF ( adr n1 --- n2 flag )
1866+^a Generate a pc-relative offset n2 from adr, adjusted by n1 bytes
1867+ of op-code/index. Flags true if offset fit in a byte, false if
1868+ it required 16 bits.
1869+
1870+?ABS ( d --- adr flag )
1871+^a Convert high word of d to flag showing true if high word was 0
1872+ or -1, false otherwise. A 0 or -1 high word indicates an
1873+ absolute address as an operand.
1874+ Example: HEX .FF20 B OR is orb $FF20
1875+
1876+PCR, ( d b --- )
1877+^a ERROR if d is not absolute mode operand. Calculate offset and
1878+ compile index byte b and offset.
1879+
1880+**** SCREEN 18
1881+
1882+Auto-indexing address mode double constants, in ASSEMBLER vocabulary:
1883+-) ( --- 4155.0082 ) ,-r
1884+)++ ( --- 4155.0081 ) ,r++
1885+)+ ( --- 4155.0080 ) ,r+
1886+--) ( --- 4155.0083 ) ,--r
1887+ Example: )++ X , D ST is std ,x++
1888+
1889+MASK, ( b1 b2 --- )
1890+^a Compile the bit-or of the top two words's low bytes.
1891+
1892+REG, ( u b --- )
1893+^a Convert a register offset specified by u to its extension byte
1894+ representation, mask in the index register and indirection
1895+ specifier b, and compile the resulting index byte.
1896+
1897+IXOFF, ( n b --- )
1898+^a Generate the appropriate index extension byte for the constant
1899+ offset n and indirection level specified, mask in the index
1900+ register and indirection specifier b, and compile both the
1901+ extension byte and the offset. Handles zero and 5-bit offsets.
1902+
1903+EI, ( d b --- )
1904+^a Compile a (completely specified) extended-indirect extension
1905+ byte b and the absolute address d.
1906+
1907+**** SCREEN 19
1908+
1909+IX, ( d n --- )
1910+^a Compile an index mode address operand. n contains the index
1911+ register and indirection level encoding, d contains the offset
1912+ or auto-mode specification. Zero offset must be explicit. Does
1913+ not block out unsupported [,r+] and [,-r] modes.
1914+
1915+, ( d1 --- d2 )
1916+A Convert indexable register d1 to index mode specifier d2.
1917+ Examples: 0. X , B OR is orb ,x
1918+ A X , JMP is jmp a,x
1919+ TABLE 0 PC , X LEA is leax table,pcr
1920+
1921+) ( d1 --- d2 )
1922+A Convert indexable register, absolute address, or index operand
1923+ d1 to memory indirect operand. Note that this will NOT
1924+ interfere with comments.
1925+ Examples: TABLE 6 + 0 PC ) JMP is jmp [6,pcr]
1926+ )++ S ) JSR is jsr ,s++
1927+
1928+**** SCREEN 20
1929+
1930+ACCM ( n1 n2 n3 --- n4 )
1931+^a Convert op-code n1, register n2, and mask bits n3 to accumulator
1932+ encoded op-code n4. Used for encoding ACCM destination
1933+ op-codes.
1934+
1935+UNARY ( u --- ) >--> compile-time
1936+^a { u UNARY name } input >-/
1937+ ( do dx --- ) indexed modes >-\
1938+ ( d --- ) non-indexed modes >--> run-time
1939+ Unary op-code compiler -- compiles an assembler of unary
1940+ op-codes with op-code (u) and name. Run-time parameters: d is
1941+ the destination register or address, dx is the index
1942+ mode/register, do is the offset/auto mode.
1943+ Examples: A NEG is nega
1944+ 7. U , ROR is ror 7,u
1945+
1946+REG ( d adr --- d u sz ) -- JSR
1947+^a ( d adr --- u sz )
1948+ Encode binary destination register d into op-code from table at
1949+ adr. Table format is primary (byte), highest (byte), secondary
1950+ (word) secondary (word) .... Leave op-code u and size sz (-1 is
1951+ word, 0 is byte) of register encoded. Helps to reduce the
1952+ complexity of the binary operators op-code map, see BINARY
1953+ concerning constructing the tables.
1954+
1955+**** SCREEN 21
1956+
1957+#, ( n u sz --- )
1958+^a Compile an immediate op-code u with immediate operand n of size
1959+ byte, if sz == 0, or word, ERROR if op-code is ST or JSR.
1960+
1961+BINARY ( ul b ub --- ) >--> compile-time
1962+^a { ul b ub BINARY name } input >-/
1963+ ( ds --- ) JSR >-\
1964+ ( ds dd --- ) non-indexed mode >--> run-time
1965+ ( do dx dd --- ) indexed mode >-/
1966+ Compile an assembler of binary operators, with primary op-code
1967+ (accumulator form, any mode) ub, count of other codes (0, 1, or
1968+ 5) b, and optional list of other codes ul. The list of other
1969+ op-codes must be pushed on the stack in the order S, U, Y, X,
1970+ and D (LD, ST, and CMP), or must be just the op-code for D (ADD
1971+ and SUB). Page escape codes must be included in the op-codes.
1972+ Run-time operands: ds is the source, do is the source
1973+ offset/auto mode, dx is the index mode/register, dd is the
1974+ destination register. Example: 12 # D CMP is cmpd #12 -800. X )
1975+ X LD is ldx [-800,x]
1976+
1977+REG-REG ( b --- ) { b REG-REG name } input -> compile-time
1978+^a ( d1 d2 --- ) -> run-time
1979+ Compile an assembler of register d1 to register d2 moves.
1980+ Examples: D Y EXG is exg d,y
1981+ A CC TFR is tfr a,c
1982+
1983+**** SCREEN 22
1984+
1985+REG-BITS ( n --- vadr )
1986+^a 1ARRAY of register bits for push/pull extension byte. The
1987+ Undefined slots set all bits to stabilize PACK. Use the low
1988+ word of a register specifier to index the array (see the DREG
1989+ constants).
1990+
1991+PACK ( n dl n --- n b )
1992+^ Pack register list dl into result byte b. Terminates when the
1993+ n, which is not the high word of a register specifier, is DUPed
1994+ and compared to HEX 5245; thus, any word or double which won't
1995+ be interpreted as a register specifier (see DREG) will terminate
1996+ the list, including the stack hole. ERRORs on attempt to push a
1997+ stack register on itself. May underflow the parameter
1998+ stack if the stack hole is corrupted with HEX 5245, of course,
1999+ but will not attempt to draw more than 8 doubles from the stack
2000+ unless REG-BITS is corrupted.
2001+
2002+MOVEM ( b --- ) { b MOVEM name } input -> compile-time
2003+^a ( n dl d --- n ) -> run-time
2004+ Compile a push or pull instruction assembler. d is the stack
2005+ register to push or pull. See PACK.
2006+ Example: D X Y U PSH is pshu d,x,y
2007+ (But don't leave stray register specifiers on the stack!)
2008+
2009+**** SCREEN 23
2010+
2011+BR ( d1 d2 --- )
2012+A Assemble a branch on condition d2 to absolute address d1.
2013+ Converts to PC relative, assembles a short branch if branch
2014+ target is close enough.
2015+ Example: LABEL 0 CCLR BR is bcc [LABEL]
2016+
2017+DCOND ( n --- ) { n DCOND name } input -> compile-time
2018+^a ( --- d )
2019+ Compile a branch condition constant; high word is HEX 434F.
2020+ Always (AL), never (NV), and subroutine (SR) are provided as
2021+ DCONDs.
2022+ Example: ' BMUL CFA 0 AL BR is bra BMUL
2023+
2024+CC-IMM ( b --- ) { b CC-IMM name } -> compile-time
2025+^a ( d --- ) -> run-time
2026+ Compile ORCC, ANDCC, EORCC, or CWAI assemblers. The assemblers
2027+ will ERROR if the operand is not immediate.
2028+ Example: HEX EF # CWAI is cwai #$EF
2029+
2030+IMPLY ( b --- ) { b IMPLY name } input >--> compile-time
2031+^a ( --- ) run-time
2032+ Compile assemblers of implicit operand instructions.
2033+ Example: NOP is nop
2034+
2035+**** The next two SCREENs contain op-code assemblers. ****
2036+See the compilers for run-time descriptions. The odd organization keeps
2037+the trees balanced. The assemblers, or, in other words, the mnemonics,
2038+are in the ASSEMBLER vocabulary.
2039+
2040+**** SCREEN 24
2041+
2042+BINARYs LD ST and CMP with their associated 16-bit register op-code
2043+ lists.
2044+MOVEMs PUL PSH UNARYs ROR ROL IMPLYs RTS RTI
2045+BINARY SBC DCOND SR (subroutine) REG-REG TFR
2046+UNARY TST BINARY SUB with D
2047+IMPLYs SWI2 SWI3 SWI SYNC BINARYs AND ADC
2048+UNARYs ASL ASR BINARY ADD with D IMPLY ABX
2049+DCOND CS UNARYs COM CLR DCOND AL (always)
2050+BINARY BIT UNARY DEC IMPLY DAA
2051+DCONDs HI MI EQ GE REG-REG EXG UNARY INC
2052+BINARY JSR UNARY JMP BINARY EOR
2053+DCONDs GT HS IMPLY NOP DCONDS LS PL
2054+
2055+**** SCREEN 25
2056+
2057+UNARYs LSR LSL DCONDs LT NE IMPLY MUL
2058+UNARY NEG BINARY OR CC-IMM ORCC
2059+DONCD NV (never) IMPLY SEX (blush) CC-IMMs ANDCC CWAI
2060+DCONDs VC VS CCLR (Carry CLeaR)
2061+
2062+EA-IX ( n --- vadr )
2063+^a 1ARRAY of translations from register (DREG) to LEA arguments.
2064+
2065+LEA ( do dx dd --- )
2066+A Assembler for LEA instructions. do is the offset/auto mode, dx
2067+ is the source index register, dr is the destination index
2068+ register.
2069+ Example: D Y , X LEA is leax d,y
2070+
2071+DCONDs LE LO
2072+
2073+**** SCREEN 26
2074+
2075+[CD] ( --- dcfa ) { [CD] name } input P
2076+A Produce the CFA of the following definition header, for use as a
2077+ jump or indexing target. If compiling, causes the code address
2078+ to be compiled as a double literal; otherwise, pushes the cfa as
2079+ a double, so the assemblers can use it for addressing.
2080+
2081+& ! ^ ( n1 n2 --- n3 )
2082+A Aliases for AND OR and XOR for the assembler vocabulary.
2083+
2084+NEXT ( --- )
2085+A Assembler the NEXT instruction, jmp [,y++].
2086+
2087+**** The assembler control constructs are patterned after FORTH
2088+control constructs, but test the Condition Code register.
2089+****
2090+
2091+**** SCREEN 27
2092+
2093+INVERTCC ( dcond --- ~dcond )
2094+^a Invert the assembler branch condition (double word) on top of
2095+ stack.
2096+
2097+LIF ( dcond --- daddr )
2098+A Mark HERE as a double with the address in the low word and HEX
2099+ 4146 in the high word. Assemble a long branch on the inverse of
2100+ the condition given, and leave the mark. Temporarily set the
2101+ branch address to the RES-ERROR routine.
2102+
2103+IF ( dcond --- daddr )
2104+A Same as LIF, but assembles short branch with 0 offset.
2105+
2106+**** SCREEN 28
2107+
2108+FILL-IN ( dadr --- )
2109+^a Resolve offset of branch at mark to HERE, handle two, three, and
2110+ four byte branches.
2111+
2112+**** SCREEN 29
2113+
2114+ELSE ( daddr1 --- daddr2 )
2115+A ERROR check the mark daddr1, mark HERE and assemble short branch
2116+ always, via IF, and FILL-IN the previously marked IF or LIF.
2117+
2118+LELSE ( daddr1 --- daddr2 )
2119+A Same as ELSE except mark and assemble long branch always via
2120+ LIF.
2121+
2122+ENDIF ( daddr --- )
2123+A ERROR check the mark, and resolve the IF or LIF.
2124+
2125+BEGIN ( --- daddr )
2126+A Mark indefinite loop beginning with HERE. High word of mark is
2127+ HEX 4142.
2128+
2129+UNTIL ( daddr dcond --- )
2130+A ERROR if daddr is not BEGIN mark; assemble branch on inverse of
2131+ condition dcond to address marked in daddr.
2132+
2133+WHILE ( daddr dcond --- adr daddr )
2134+A ERROR if daddr is not BEGIN mark; assemble forward branch on
2135+ inverse of condition dcond, leave BEGIN address on stack and
2136+ extend mark with WHILE address and mark, HEX 4157.
2137+
2138+REPEAT ( adr daddr --- )
2139+A ERROR if not WHILE mark, assemble a branch to the BEGIN address
2140+ and FILL-IN the WHILE address.
2141+
2142+LWHILE ( daddr dcond --- adr daddr )
2143+A Forced long branch version of WHILE.
2144+
2145+**** SCREEN 30
2146+
2147+:ASM ( --- )
2148+A CREATE a header and store the parameter stack pointer in CSP to
2149+ mark the stack for assembler control construct and other errors.
2150+
2151+;ASM ( --- )
2152+A ERROR check CSP and un-smudge the definion. NEXT must be
2153+ explicitly assembled.
2154+
2155+I-CODE ( --- )
2156+A Shift to high-level compiling. (Assembles jmp <XCOL, changes
2157+ state to compiling, changes interpretation vocabulary to
2158+ definition vocabulary.)
2159+
2160+MACHINE ( --- ) P
2161+A Shift to assembly language. (Compiles (MACHINE), changes state
2162+ to interpretation, sets interpretation vocabulary to assembler.)
2163+
2164+**** SCREEN 32
2165+ Some Doubles
2166+
2167+D! ( d adr --- )
2168+B Store double d at adr.
2169+
2170+D@ ( adr --- d )
2171+B Fetch double (two words) at adr.
2172+
2173+DOVER ( d1 d2 --- d1 d2 d1 )
2174+B Copy the second double (bytes 4-7) on the stack to the top.
2175+
2176+DSWAP ( d1 d2 --- d2 d1 )
2177+B Swap the top two doubles (bytes 0-3 with bytes 4-7).
2178+
2179+**** SCREEN 64
2180+
2181+ This is an example showing use of the dictionary to associate
2182+pairs, from one of the textbooks I have. I apologize to the source for
2183+not giving proper credit, but I can't find it. It is included to show
2184+use of DOES> and to show how having the symbol table handy at run-time
2185+can be taken advantage of. It builds pairs of objects linked to each
2186+other such that typing one in results in printing the other out.
2187+
2188+
2189+*******************************************************************************
2190+ Some Thoughts and Comments:
2191+
2192+
2193+Hey, it's not a professional package, so I can put this here if I want!
2194+
2195+One of the problems with BIF is the power of the 6809. It is all too
2196+easy to use 6809 instructions instead of icodes. This means that the
2197+6809 architecture gets woven into BIF, as mentioned at the end of the
2198+discussion on the virtual machine.
2199+
2200+BIF can probably be made to conform with one of the standards by moving
2201+the virtual machine routines to their associated definitions (XCOLON to
2202+COLON, XVAR to VARIABLE, etc.) and by making all code fields three-byte
2203+jumps (JSRs). Direct threading will probably not be a problem, as long
2204+as code fields are uniform in size.
2205+
2206+The constant shifting between modes which I have done makes a built-in
2207+debugger more complex, as well. One specific example is that using a
2208+macro instead of a jump to a NEXT inner interpreter makes debugging more
2209+complex. If there is an inner interpreter, and if the low level
2210+routines are known to be error free, the debugger can simply be a jump
2211+inserted in the NEXT routine. Use of a macro forces the debugger to be
2212+sensitive to the 6809 architecture, and requires either use of the SWI
2213+method (which can't be used in ROM), CPU emulation, or external
2214+breakpoint/single-step hardware. The latter method is more complete,
2215+but inserting a debugging routine in the inner interpreter is often all
2216+that is necessary.
2217+
2218+A possible inner interpreter for a direct threaded FORTH (could be
2219+located in the direct page):
2220+
2221+ NEXT ldx ,y++ 8~
2222+ jmp ,x 3~ 14~ (w/ jmp <NEXT)
2223+
2224+Or for indirect threading:
2225+ NEXT ldx ,y++ 8~
2226+ jmp [,x] 6~ 17~ (w/ jmp <NEXT)
2227+
2228+Compared to BIF:
2229+ jmp [,y++] 9~
2230+
2231+The apparent disadvantages of the above are at least partially offset by
2232+the fact that X will contain the CFA on entry to the characteristic
2233+routines. In other words, X can substitute for W, and there is no need
2234+to store the CFA of the executing low level routine in an external
2235+register (on the stack, in the case of BIF). Showing how this affects
2236+XCOL, for direct threading:
2237+
2238+ someDEF jmp XCOL 4~
2239+ . . .
2240+ XCOL pshs y 7~
2241+ leay 3,x 5~
2242+ jmp <next 3~ 19~, total 33~
2243+
2244+For indirect threading:
2245+
2246+ someDEF fdb XCOL 0~
2247+ . . .
2248+ XCOL pshs y 7~
2249+ leay 2,x 5~
2250+ jmp <NEXT 3~ 15~, total 32~
2251+
2252+Compared to BIF:
2253+ someDEF jsr <XCOL 7~
2254+ . . .
2255+ XCOL ldx ,s 5~
2256+ sty ,s 6~
2257+ tfr x,y (leay ,x) 6~ (4~)
2258+ jmp [,y++] 9~ 33~, total 42~
2259+
2260+SURPRISED? I was. Of course, the characteristic routines must be a
2261+little careful to use or save X before they clobber it, but that isn't
2262+as difficult as it might seem.
2263+
2264+The direct page might still be used to locate the per-USER table, or
2265+might even contain it. At first glance, it would appear too expensive
2266+to offset the DP register with a variable index. But compare the
2267+following to the code in BIF:
2268+
2269+ XUSER tfr dp,a 6~
2270+ ldb [,s++] 10~ (stored as byte offset)
2271+ pshu d 7~ (there's the address)
2272+ jmp [,y++] 9~ 32~ compared to 34~
2273+
2274+If X is used for the temporary W register as in the indirect threaded
2275+inner interpreter example above, we can get the following, which speaks
2276+for itself:
2277+
2278+ XUSER tfr dp,a 6~
2279+ clrb 2~ (showing word offset, )
2280+ addd 2,x 7~ (byte would be shorter)
2281+ pshu d 7~
2282+ jmp <NEXT 3~ 25~
2283+
2284+Ah, experience. What we have to go through to get it!
2285+
2286+The key to FORTH and its dialects is found in ;CODE and DOES>. By
2287+providing both characteristic behaviour and data allocation, FORTH words
2288+(symbols/definitions) are primitive objects. A full object-oriented
2289+language could be generated with FORTH, but then you would probably have
2290+SMALLTALK!. A standard compiling language keeps the symbol table, its
2291+data, and the code that accesses it entirely separate, and wastes a lot
2292+of code space doing so. Professional FORTH systems can strip the symbol
2293+table out of compiled applications, if necessary, but the symbol table
2294+is available at run-time until the programmer is satisfied that his
2295+program is bug-free. Moreover, the programmer has access to the same
2296+library used by the language, which is usually not the case with
2297+compiled languages, even with C.
2298+
2299+A careful examination of the overhead in FORTH shows that it is
2300+approximately the same as the overhead in a good C compiler. While it
2301+would appear that constantly moving stuff on and off the stack would be
2302+a hindrance to progress, a second look reveals that the accumulator
2303+bottleneck requires this kind of movement. I wish I had time and
2304+facilities to examine this specific question in relation to a large
2305+register set.
2306+
2307+I sometimes wonder if management paranoia (PROTECT OUR INTELLECTUAL
2308+PROPERTY!) is the primary reason FORTH, LISP, and SMALLTALK have not
2309+entirely supplanted the compiled languages. If so, why is management
2310+willing to hide, protect, and hang on to code, but not willing to hang
2311+on to the engineers in whose brains the technology really resides? Or
2312+in the converse, if management can see that it is sometimes necessary to
2313+let people go, why can't they see that there are some things that are
2314+not worth the cost of trying to protect their tools from? And why can't
2315+they see that a intellectual property stolen by copying still requires a
2316+large investment in somebody's time to learn to use it? Why doesn't
2317+public domain code get used? Because it costs better than an order of
2318+magnitude more to learn how to use it than it does to get it.
2319+
--- /dev/null
+++ b/README.TXT
@@ -0,0 +1,255 @@
1+Information about BIF as of April 2019.
2+
3+ Joel Matthew Rees, Amagasaki, Hyogo, Japan.
4+ joel.rees@gmail.com
5+ http://reiisi.blogspot.com
6+ https://defining-computers.blogspot.com/
7+ etc.
8+ Copyright 2000, 2019 Joel Matthew Rees
9+
10+-----
11+
12+(The following can be found in its original form in the bif-c
13+repositories. bif-c is buggy, by the way.)
14+
15+-----
16+
17+BIF was a dialect of the early fig-standard FORTH. It was a student
18+project, not a commercial product, and no warranty has ever been made
19+concerning it, whatsoever. It was written on the Color Computer 2 in
20+6809 assembler; the assembler used was disk EDTASM+. It also ran on
21+the Color Computer 3, with the expected limitations of requiring the
22+32 column screen, etc.
23+
24+License information -- the rights to BIF and the materials with it,
25+and restrictions on distribution -- are described in the file
26+BIFDOC.TXT, which really should distributed with the source along with
27+this README.TXT.
28+
29+The short version of the licensing information is that I am distributing
30+BIF6809 under the essential terms of the Internet Systems Consortium
31+ISC License:
32+
33+=========
34+Permission to use, copy, modify, and/or distribute this software for
35+any purpose with or without fee is hereby granted, provided that the
36+accompanying copyright notices and this permission notice appear in
37+all copies.
38+
39+THE SOFTWARE IS PROVIDED “AS IS” AND ISC DISCLAIMS ALL WARRANTIES
40+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
41+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY
42+SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
43+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
44+AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
45+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
46+SOFTWARE.
47+=========
48+
49+I add here the stipulation that I claim right to the word "BIF" as
50+the name of a programming language.
51+
52+If you are going to distribute or redistribute the obect or source of
53+bif in any of its forms, it really makes no sense not to include the
54+BIFDOC.TXT and this README.TXT. If you do something like that and
55+you or anyone that gets the results has problems with it, and you come
56+to me looking for help, expect to be teased mercilessly about it. And
57+expect to be on the bottom of my priority list, not out of spite,
58+out of self-protection.
59+
60+-----
61+
62+I have reconstructed something approximating my source disks (using the
63+great emulator, xroar: https://www.6809.org.uk/xroar/ and the imgtool
64+distributed with MAME, along with the *nix tools). Some useful commands
65+are noted in commands.txt.
66+
67+The name of the disk image is (appropriately?) bifsource.dsk. It can be
68+directly attached by xroar's disk emulator tools, and should be similarly
69+useable with VCC, MAME, etc. al.
70+
71+-----
72+
73+The assembler source files are readable by the a variety of text editors,
74+that respond flexibly about line termination. But if you try editing them
75+with a normal editor and then assembling the result with EDTASM+, be very
76+careful about line termination. Be prepared to use *nix command line tools
77+like tr, cut, sed/awk, perl, etc.
78+
79+The source files retain the original line numbers as used by EDTASM+,
80+which is why you will want the *nix tools. But I have included source to a
81+short C program, stripln.c, which strips the line numbers. This program
82+may also be useful for converting line endings, if that is necessary. Look
83+for it in the junkbox directory, and be prepared to compile it.
84+
85+If you are under the burden of using Microsoft OSses, the Cygwin project
86+should be of quite a bit of assistance, including the *nix command line
87+tools and gcc and clang, etc.
88+
89+-----
90+
91+Macros are used in the source, but shouldn't cause too much confusion
92+to a programmer with assembler experience. If anyone is brave enough
93+to try to port it, key routines will be EMIT, KEY, ?TERMINAL, CR, R/W,
94+and several routines in the EDITOR vocabulary where I used direct
95+video I/O out of laziness.
96+
97+-----
98+
99+BIF might be useful for experimentation and for learning about FORTH,
100+for someone who has access to a Color Computer or an emulator. The
101+executable file may be run on the Color Computer by LOADMing it via
102+Color Computer Disk BASIC. (More details in BIFDOC.TXT.)
103+
104+It is assembled to be EXECed at hexadecimal 1300 (&H1300).
105+
106+-----
107+
108+One specific warning must be given:
109+
110+DO NOT ATTEMPT TO ACCESS ORDINARY DISKS FORMATTED FOR USE BY OTHER
111+OPERATING SYSTEMS WHILE BIF IS RUNNING! Because of disk buffering, it
112+will be difficult to avoid unintentional writes to the disk.
113+
114+If you do try looking at an OS-9 or Color Computer DOS (etc.) disk with
115+BIF, don't blame me if you destroy the directory and/or other valuable
116+data.
117+
118+-----
119+
120+I tried a re-write in C (bif-c), but it's not working well. Issues with
121+file systems (no real file system in BIF) and the current standardization
122+committees ideas about what is meaningful code, problems with my own
123+attention span, etc. keep it full of bugs. And I used a number of neat
124+tricks that get in the way in C.
125+
126+One thing I want to retain is the use of nested binary trees in the
127+symbol table.
128+
129+Incidentally, said re-write has been in process for over thirty years.
130+Real life keeps getting in the way.
131+
132+-----
133+
134+I am including source to a Q&D C program, 32col.c, which will re-format
135+files extracted from BIF disks for normal text editors. Mac-isms and
136+Codwarrior-isms can probably be discerned by comparing it with stripln.c,
137+mentioned above.
138+
139+When I brought the BIF high-level source with me, I used some feature of
140+Color Computer BASIC and BIF that I have forgotten to dump some of the
141+Forth style screen listings.
142+
143+The program stripln can be used to strip line numbers from such screen
144+listings, as well.
145+
146+The documentation is ASCII text, with CR/LF line termination, and should
147+be examined carefully by anyone considering a port. Bear in mind that
148+it was written toward Color Computer users.
149+
150+I apologize for not alphabetizing the FORTH words by name. I did it once
151+with a C program, but got too ambitious and lost the results in the
152+process of trying to split it up into modules. I haven't had enough time
153+to finish the modularization, yet, either. (Getting an iBook so I could
154+work on the train just gave me more things to do on the train.)
155+
156+Files in this distribution --
157+
158+6809 Assembly Language Source files:
159+
160+README.TXT
161+ this file.
162+BIFDOC.TXT
163+ general explanations, including descriptions of every word.
164+BIFU.I
165+ structure of the per-user variable page.
166+BIF.M
167+ macros, including the inner interpreter (basis of the virtual machine),
168+ the dictionary (symbol table) structure offsets,
169+ and invocations for the fundamental objects.
170+BIFDP.A
171+ things kept in the direct page,
172+ including the behaviours for the fundamental objects (was not a good idea after all),
173+ and the index to the per user variable page.
174+BIFST.A
175+ cold and warm boot routines and the initial value table for the per-user variable page.
176+BIF.ASM
177+ the main source file (includes other parts),
178+ basic expression evaluation, more of the inner interpreter,
179+ basic vocabulary access, basic symbol parsing.
180+BIFB.A
181+ basic I/O, more of the inner interpreter, extended expression evaluation,
182+ the rest of the basic symbol table access.
183+BIF1.A
184+ data movers, common expression evaluation,
185+ stack pointer access, more of the inner interpreter,
186+ high-level compiler.
187+BIF1B.A
188+ common expression evaluation, extended expression evaluation,
189+ innards of the high-level compiler, more of the high-level compiler,
190+ compiler directive.
191+BIF2.A
192+ more common expression evaluation, common constants,
193+ I/O constants, character typing constants,
194+ symbol table globals, compiler globals, parser globals, I/O globals.
195+BIF2B.A
196+ compiler globals, more high-level compiler,
197+ more common expression evaluation, formatted output.
198+BIF3.A
199+ more basic symbol table, symbol table, more compiler, more formatted output,
200+ more data movers, more low-level parser (formatted input), more I/O,
201+ more extended expression evaluation, more expression evaluation,
202+ more compiler directives, an extension to the inner interpreter.
203+BIF3B.A
204+ more formatted output, more innards of the high-level compiler,
205+ more high-level compiler.
206+BIF4.A
207+ more innards of the expression evaluator, more common expression evaluation,
208+ more I/O (buffer handling).
209+BIF4B.A
210+ more high-level compiler, more compiler directive.
211+BIF5.A
212+ more innards of the high-level compiler, more I/O (buffering),
213+ disk access, error handling, more formatted output.
214+BIF5B.A
215+ more error handling, screen-based sector (character) editor.
216+BIF6.A
217+ more parser (formatted input), I/O (terminal), compiler (input),
218+ symbol table (lookup).
219+BIF6B.A
220+ symbol table, compiler innards, null vector test,
221+ more screen-based sector editor.
222+BIF7.A
223+ compiler, formatted output, compiler directives
224+BIF7B.A
225+ error handling, symbol tables, compiler directives.
226+stripln.c,
227+32col.c,
228+ C language source and Macintosh executables for stripping line
229+ numbers and reformatting 32 column source code "screens". The two
230+ XXX.GXX.out files below are output of the 32col program.
231+
232+-----
233+
234+Hopefully, I will shortly have time to reconstruct useful things from the
235+following files on the tools.dsk disk image and/or the cs431 disk image:
236+
237+TOOLS.G00, TOOLS.G00.out
238+ FORTH source for disk listing, screen handling, definition dumping,
239+ sector copying, forward referencing, buffer maintenance,
240+ experimenting with hardware, double (32 bit) integer math, etc.,
241+ and a post-fix assembler.
242+PAIRS.G28, PAIRS.G28.out
243+ a "database" example from one of my FORTH books.
244+
245+and
246+
247+SCR33.ARR
248+ arrays for CS431.
249+SCR34.LOC
250+ some math for CS431.
251+SCR40.431
252+ test suite for CS431.
253+
254+
255+
--- /dev/null
+++ b/README.TXT~
@@ -0,0 +1,232 @@
1+Information about BIF as of April 2019.
2+
3+ Joel Rees, Amagasaki, Hyogo, Japan.
4+ joel.rees@gmail.com
5+ http://reiisi.blogspot.com
6+ https://defining-computers.blogspot.com/
7+ etc.
8+
9+-----
10+
11+(The following can be found in its original form in the bif-c
12+repositories. bif-c is buggy, by the way.)
13+
14+-----
15+
16+BIF was a dialect of the early fig-standard FORTH. It was a student
17+project, not a commercial product, and no warranty has ever been made
18+concerning it, whatsoever. It was written on the Color Computer 2 in
19+6809 assembler; the assembler used was disk EDTASM+. It also ran on
20+the Color Computer 3, with the expected limitations of requiring the
21+32 column screen, etc.
22+
23+License information -- the rights to BIF and restrictions on
24+distribution -- are described in the file BIFDOC.TXT, which really
25+should distributed with the source.
26+
27+I add here the stipulation that I claim right to the word "BIF" as
28+the name of a programming language.
29+
30+If you are going to distribute or redistribute the obect or source of
31+bif in any of its forms, it really makes no sense not to include the
32+BIFDOC.TXT. If you do something like that and you or anyone that gets
33+the results has problems with it, and you come to me looking for help,
34+expect to be teased mercilessly about it. And expect to be on the
35+bottom of my priority list (not out of spite, out of self-protection).
36+
37+-----
38+
39+I have reconstructed something approximating my source disks (using the
40+great emulator, xroar: https://www.6809.org.uk/xroar/ and the imgtool
41+distributed with MAME, along with the *nix tools). Some useful commands
42+are noted in commands.txt.
43+
44+The name of the disk image is (appropriately?) bifsource.dsk. It can be
45+directly attached by xroar's disk emulator tools, and should be similarly
46+useable with VCC, MAME, etc. al.
47+
48+-----
49+
50+The assembler source files are readable by the a variety of text editors,
51+that respond flexibly about line termination. But if you try editing them
52+with a normal editor and then assembling the result with EDTASM+, be very
53+careful about line termination. Be prepared to use *nix command line tools
54+like tr, cut, sed/awk, perl, etc.
55+
56+The source files retain the original line numbers as used by EDTASM+,
57+which is why you will want the *nix tools. But I have included source to a
58+short C program, stripln.c, which strips the line numbers. This program
59+may also be useful for converting line endings, if that is necessary. Look
60+for it in the junkbox directory, and be prepared to compile it.
61+
62+If you are under the burden of using Microsoft OSses, the Cygwin project
63+should be of quite a bit of assistance, including the *nix command line
64+tools and gcc and clang, etc.
65+
66+-----
67+
68+Macros are used in the source, but shouldn't cause too much confusion
69+to a programmer with assembler experience. If anyone is brave enough
70+to try to port it, key routines will be EMIT, KEY, ?TERMINAL, CR, R/W,
71+and several routines in the EDITOR vocabulary where I used direct
72+video I/O out of laziness.
73+
74+-----
75+
76+BIF might be useful for experimentation and for learning about FORTH,
77+for someone who has access to a Color Computer or an emulator. The
78+executable file may be run on the Color Computer by LOADMing it via
79+Color Computer Disk BASIC. (More details in BIFDOC.TXT.)
80+
81+It is assembled to be EXECed at hexadecimal 1300 (&H1300).
82+
83+-----
84+
85+One specific warning must be given:
86+
87+DO NOT ATTEMPT TO ACCESS ORDINARY DISKS FORMATTED FOR USE BY OTHER
88+OPERATING SYSTEMS WHILE BIF IS RUNNING! Because of disk buffering, it
89+will be difficult to avoid unintentional writes to the disk.
90+
91+If you do try looking at an OS-9 or Color Computer DOS (etc.) disk with
92+BIF, don't blame me if you destroy the directory and/or other valuable
93+data.
94+
95+-----
96+
97+I tried a re-write in C (bif-c), but it's not working well. Issues with
98+file systems (no real file system in BIF) and the current standardization
99+committees ideas about what is meaningful code, problems with my own
100+attention span, etc. keep it full of bugs. And I used a number of neat
101+tricks that get in the way in C.
102+
103+One thing I want to retain is the use of nested binary trees in the
104+symbol table.
105+
106+Incidentally, said re-write has been in process for over thirty years.
107+Real life keeps getting in the way.
108+
109+-----
110+
111+I am including source to a Q&D C program, 32col.c, which will re-format
112+files extracted from BIF disks for normal text editors. Mac-isms and
113+Codwarrior-isms can probably be discerned by comparing it with stripln.c,
114+mentioned above.
115+
116+When I brought the BIF high-level source with me, I used some feature of
117+Color Computer BASIC and BIF that I have forgotten to dump some of the
118+Forth style screen listings.
119+
120+The program stripln can be used to strip line numbers from such screen
121+listings, as well.
122+
123+The documentation is ASCII text, with CR/LF line termination, and should
124+be examined carefully by anyone considering a port. Bear in mind that
125+it was written toward Color Computer users.
126+
127+I apologize for not alphabetizing the FORTH words by name. I did it once
128+with a C program, but got too ambitious and lost the results in the
129+process of trying to split it up into modules. I haven't had enough time
130+to finish the modularization, yet, either. (Getting an iBook so I could
131+work on the train just gave me more things to do on the train.)
132+
133+Files in this distribution --
134+
135+6809 Assembly Language Source files:
136+
137+README.TXT
138+ this file.
139+BIFDOC.TXT
140+ general explanations, including descriptions of every word.
141+BIFU.I
142+ structure of the per-user variable page.
143+BIF.M
144+ macros, including the inner interpreter (basis of the virtual machine),
145+ the dictionary (symbol table) structure offsets,
146+ and invocations for the fundamental objects.
147+BIFDP.A
148+ things kept in the direct page,
149+ including the behaviours for the fundamental objects (was not a good idea after all),
150+ and the index to the per user variable page.
151+BIFST.A
152+ cold and warm boot routines and the initial value table for the per-user variable page.
153+BIF.ASM
154+ the main source file (includes other parts),
155+ basic expression evaluation, more of the inner interpreter,
156+ basic vocabulary access, basic symbol parsing.
157+BIFB.A
158+ basic I/O, more of the inner interpreter, extended expression evaluation,
159+ the rest of the basic symbol table access.
160+BIF1.A
161+ data movers, common expression evaluation,
162+ stack pointer access, more of the inner interpreter,
163+ high-level compiler.
164+BIF1B.A
165+ common expression evaluation, extended expression evaluation,
166+ innards of the high-level compiler, more of the high-level compiler,
167+ compiler directive.
168+BIF2.A
169+ more common expression evaluation, common constants,
170+ I/O constants, character typing constants,
171+ symbol table globals, compiler globals, parser globals, I/O globals.
172+BIF2B.A
173+ compiler globals, more high-level compiler,
174+ more common expression evaluation, formatted output.
175+BIF3.A
176+ more basic symbol table, symbol table, more compiler, more formatted output,
177+ more data movers, more low-level parser (formatted input), more I/O,
178+ more extended expression evaluation, more expression evaluation,
179+ more compiler directives, an extension to the inner interpreter.
180+BIF3B.A
181+ more formatted output, more innards of the high-level compiler,
182+ more high-level compiler.
183+BIF4.A
184+ more innards of the expression evaluator, more common expression evaluation,
185+ more I/O (buffer handling).
186+BIF4B.A
187+ more high-level compiler, more compiler directive.
188+BIF5.A
189+ more innards of the high-level compiler, more I/O (buffering),
190+ disk access, error handling, more formatted output.
191+BIF5B.A
192+ more error handling, screen-based sector (character) editor.
193+BIF6.A
194+ more parser (formatted input), I/O (terminal), compiler (input),
195+ symbol table (lookup).
196+BIF6B.A
197+ symbol table, compiler innards, null vector test,
198+ more screen-based sector editor.
199+BIF7.A
200+ compiler, formatted output, compiler directives
201+BIF7B.A
202+ error handling, symbol tables, compiler directives.
203+stripln.c,
204+32col.c,
205+ C language source and Macintosh executables for stripping line
206+ numbers and reformatting 32 column source code "screens". The two
207+ XXX.GXX.out files below are output of the 32col program.
208+
209+-----
210+
211+Hopefully, I will shortly have time to reconstruct useful things from the
212+following files on the tools.dsk disk image and/or the cs431 disk image:
213+
214+TOOLS.G00, TOOLS.G00.out
215+ FORTH source for disk listing, screen handling, definition dumping,
216+ sector copying, forward referencing, buffer maintenance,
217+ experimenting with hardware, double (32 bit) integer math, etc.,
218+ and a post-fix assembler.
219+PAIRS.G28, PAIRS.G28.out
220+ a "database" example from one of my FORTH books.
221+
222+and
223+
224+SCR33.ARR
225+ arrays for CS431.
226+SCR34.LOC
227+ some math for CS431.
228+SCR40.431
229+ test suite for CS431.
230+
231+
232+
--- /dev/null
+++ b/edtasm_v/cs431.dsk
@@ -0,0 +1 @@
1+0) Index to BIF HI-LEVEL disk 2) Title page, Copr. notice 3) MONITOR CALL TO DEBUG 4) ERROR MESSAGES 6) HIGH LEVEL TOOLS & UTILITIES 7) LIST, INDEX, TRIAD 8) HIGH LEVEL DISK & SCREEN 11) FORWARD REFERENCING 12) PERIPHERAL UTILITIES 13) SLIST 15) DUMP DEFINITION BY NAME 16) ASSEMBLER 32) DOUBLES IN ASSEMBLER 40) HLL COMPILER 64) PAIR ASSOCIATION EXAMPLE 66) A TRY AT DIVIDE BY CONSTANT 100) SARDIS DMC STUFF 144) HOOCH COMPILER REMAINS BIF EDITOR, UTILITIES, ASSEMBLER, AND EXAMPLES VERSION 1.0 COPYRIGHT 1989 JOEL MATTHEW REES THESE ALGORITHMS ARE EXPRESSED IN THREE LANGUAGES: BIF, BIF ASSEMBLER FOR THE MOTOROLA M6809 MICROPROCESSOR, AND HEXADECIMAL MACHINE CODE FORTHE M6809. THE TEXT IS ORGANIZED FOR EDITING ON A 32-COLUMN TERMINAL,SUCH AS IS FOUND ON A RADIO SHACK COLOR COMPUTER 2. THESE ALGORITHMS AND THEIR TEXT ARE INTENDED FOR NO PURPOSEOTHER THAN EXPERIMENTATION, AND NO CLAIMS OR WARRANTIES ARE MADECONCERNING THEIR USEFULNESS IN ANY PARTICULAR APPLICATION. PUBLISHED 1989 JOEL MATTHEW REES SOUTH SALT LAKE CITY, UTAH ( CALL TO MONITOR, IF SWI IS BREAKPOINT JMR-88OCT?? ) CREATE MON HEX 3F C, 6EB1 , SMUDGE HERE 1- FENCE ! ;S ( ERROR MESSAGES ) DATA STACK UNDERFLOW DICTIONARY FULL ADDRESS RESOLUTION ERROR HIDES DEFINITION IN NULL VECTOR WRITTEN DISC RANGE? DATA STACK OVERFLOW DISC ERROR! CAN'T EXECUTE A NULL! CONTROL STACK UNDERFLOW CONTROL STACK OVERFLOW ARRAY REFERENCE OUT OF BOUNDS ARRAY DIMENSION NOT VALID NO PROCEDURE TO ENTER ( WAS REGISTER ) COMPILATION ONLY, USE IN DEF EXECUTION ONLY CONDITIONALS NOT PAIRED DEFINITION INCOMPLETE IN PROTECTED DICTIONARY USE ONLY WHEN LOADING OFF CURRENT EDITING SCREEN DECLARE VOCABULARY DEFINITION NOT IN VOCABULARY IN FORWARD BLOCK ALLOCATION LIST CORRUPTED: LOST CAN'T REDEFINE nul! NOT FORWARD REFERENCE ( WAS IMMEDIATE ) ( MORE ERROR MESSAGES ) HAS INCORRECT ADDRESS MODE HAS INCORRECT INDEX MODE OPERAND NOT REGISTER HAS ILLEGAL IMMEDIATE PC OFFSET MUST BE ABSOLUTE ACCUMULATOR OFFSET REQUIRED ILLEGAL MEMORY INDIRECTION ILLEGAL INDEX BASE ILLEGAL TARGET SPECIFIED CAN'T STACK ON SELF DUPLICATE IN LIST REGISTER NOT STACK EMPTY REGISTER LIST IMMEDIATE OPERAND REQUIRED REQUIRES CONDITION COMPILE-TIME STACK UNDERFLOW COMPILE-TIME STACK OVERFLOW ( UTILITIES DUMP QLIST QINDEX ) ( L/SCR ULIST JMR-88NOV16) BIF DEFINITIONS HEX ( UTILITIES IS NOW IN KERNEL ) UTILITIES DEFINITIONS : BYTE-DUMP -DUP IF 0 DO DUP I + C@ 4 .R LOOP ENDIF DROP ; ( BASE > 6) BIF DEFINITIONS : DUMP -DUP IF OVER + SWAP DO I 0 6 D.R I 4 [ UTILITIES ] BYTE-DUMP [ BIF ] 3A EMIT I 4 TYPE CR ?TERMINAL 0< IF KEY 0< IF LEAVE ENDIF ENDIF 4 +LOOP ENDIF ; : QLIST BLOCK [ EDITOR ] QDUMP [ BIF ] 500 88 ! ( CENTER ) ; : QINDEX 1+ SWAP DO I QLIST ." SCREEN=" I 4 /MOD . 3A EMIT . ." BLOCK=" I . KEY 0< IF LEAVE ENDIF LOOP ; UTILITIES DEFINITIONS : L/SCR B/BUF B/SCR C/L */ ; : ULIST ( SCREEN N, FLAG BRK ) DUP SCR ! ." SCR # " . 0 ( F ) L/SCR 0 DO CR I 3 .R SPACE I SCR @ .LINE ?TERMINAL 0< IF ( BREAK? ) KEY 0< IF 1- LEAVE ENDIF ENDIF LOOP CR ; --> ( LIST INDEX TRIAD ) ( JMR-88NOV16 ) BIF DEFINITIONS : LIST ( WIDE OUTPUT ) DECIMAL CR UTILITIES ULIST BIF DROP ; : INDEX ( PRINT COMMENT LINES ) 0C EMIT ( FORM FEED ) CR 1+ SWAP DO CR I 3 .R SPACE 0 I .LINE C/L 49 < IF 1 I .LINE ENDIF ?TERMINAL 0< IF KEY 0< IF LEAVE ENDIF ENDIF LOOP ; : TRIAD ( LIST MULTIPLE ) >PRT 0C EMIT ( FORM FEED ) [ DECIMAL ] UTILITIES L/SCR BIF 22 > IF 2 ELSE 3 ENDIF >R R / R * DUP R> + SWAP DO I UTILITIES ULIST BIF 0< IF LEAVE ENDIF UTILITIES L/SCR BIF DUP 32 = SWAP 22 = OR NOT IF CR CR ENDIF LOOP >VID ; HEX -->( HOME CLS QSAVE SAVE-BUFFERS QCAN ) ( JMR-88DEC10 ) UTILITIES DEFINITIONS HEX : HOME 400 88 ! ; : MID 500 88 ! ; BIF DEFINITIONS : CLS 400 200 60 FILL UTILITIES HOME BIF ; UTILITIES DEFINITIONS : CAN-UP ( CANCEL UPDATE IN BUF) DUP @ 7FFF AND OVER ! ; : W-BUF ( WRITE BUF AT ADR ) DUP 2+ OVER @ 7FFF AND 0 R/W CAN-UP ; : SAVE-BUF ( IF UPDATED ) DUP @ 0< IF W-BUF ENDIF ; BIF DEFINITIONS : QSAVE PREV @ ( SAVE PREVIOUS ) UTILITIES SAVE-BUF BIF DROP ; : SAVE-BUFFERS PREV @ BEGIN UTILITIES SAVE-BUF BIF +BUF NOT UNTIL DROP ; : QCAN PREV @ ( CAN UP OF PREV ) UTILITIES CAN-UP BIF DROP ; --> ( CANCEL-UPDATES RE-QUICK .PREV .BUFFERS QPREV JMR-88DEC10 ) : CANCEL-UPDATES PREV @ BEGIN UTILITIES CAN-UP BIF +BUF NOT UNTIL DROP ; : RE-QUICK ( QUICK OLD PREVIOUS) PREV @ DUP @ 7FFF AND 0 ROT ! [ EDITOR ] QUICK BIF ; UTILITIES DEFINITIONS : .BUF ( QLIST BUFFER, . BLOCK ) DUP @ DUP 7FFF AND DUP QLIST MID ." BLOCK=" . 0< IF ." UPDATED" ENDIF CR ; BIF DEFINITIONS : .BUFFERS PREV @ ( .BUF, PAUSE) BEGIN UTILITIES .BUF BIF +BUF DROP KEY 0< ( BREAK? ) UNTIL DROP ; : .PREV PREV @ UTILITIES .BUF BIF DROP ; : EDIT DUP UTILITIES MID BIF ." BLOCK=" . CR [ EDITOR ] QUICK BIF PREV @ @ 0< IF ." UPDATED" ENDIF ; : QPREV PREV @ @ 7FFF AND EDIT ; -->( QOPY COPY QBACK BACK-UP ) ( JMR-88DEC11 ) : QOPY SWAP BLOCK SWAP BLOCK B/BUF 2/ MOVE UPDATE ; : COPY 2* 2* ( SCREEN ) SWAP 2* 2* DUP 4 + SWAP DO I OVER QOPY 1+ LOOP DROP ; : QBACK 1+ SWAP DO I QLIST I BLOCK DUP [ EDITOR ] QDUMP ." BLOCK " I . ." TO " 0 DRIVE-OFFSET @ I + DUP . KEY 59 = IF 0 R/W ( YES? ) ELSE DROP DROP ENDIF LOOP ; : EEDIT ( ERASE AND EDIT BLOCK ) DUP BLOCK 2- UTILITIES .BUF 2+ MID BIF ." BLOCK=" OVER . ." CLEAR?" CR KEY 59 = IF ( YES? ) B/BUF BLANKS UPDATE ELSE DROP ( DON'T CLEAR ) ENDIF EDIT ; --> ( RES-ERROR FORWARD :RESOLVE :RESOLVE ;RES JMR-16MAY89 ) UTILITIES DEFINITIONS HEX : RES-ERROR ( ADR RESOLUTION ) 3 ERROR ; BIF DEFINITIONS UTILITIES : FORWARD ( REFERENCE HEADER ) CREATE 7E C, ( JMP EXTENDED ) IP, [ ' RES-ERROR CFA , ] ( INIT TO RES-ERROR ) SMUDGE FOREWARD @ 0= IF ( EARLIEST? ) LATEST FOREWARD ! ENDIF ; ASSEMBLER DEFINITIONS UTILITIES : :RESOLVE ( :ASM FORWARD REFS ) ?EXEC !CSP [COMPILE] ' DUP CFA DUP 1+ SWAP C@ 7E - ( JMP) OVER @ ' RES-ERROR CFA - OR 1D ?ERROR ( HEADER? ) HERE SWAP ! ( LINK IT ) FOREWARD @ = IF ( END FORWD? ) 0 FOREWARD ! ENDIF ; IMMEDIATE BIF DEFINITIONS ASSEMBLER : :RES ( RESOLVE : FORWARDS ) [COMPILE] :RESOLVE [ BIF ] ( ASSEMBLE JMP <XCOL, COMPILE) IP, [ LATEST CFA @ , ] ] ; : ;RES [COMPILE] ; SMUDGE ; IMMEDIATE ( PL PTEST ) ( JMR-89AUG25 ) BIF DEFINITIONS DECIMAL : PL 79 0 DO I 33 + EMIT LOOP ; : PT ( PL UNTIL KEY PRESS ) BEGIN PL ?TERMINAL UNTIL ; : PTEST >PRT PT >VID ; ;S ( SLIST ) ( JMR-16OCT90 ) ROOT @ UTILITIES : SLIST ( LIST SCREENS TO PRT ) >PRT 1+ SWAP DO I ULIST 0< IF LEAVE ENDIF LOOP >VID ; ROOT ! ;S ( DISK ACCESS WORDS JMR-900228) HEX : CM! FF48 C! ; : ST@ FF48 C@ ; : TR! FF49 C! ; : TR@ FF49 C@ ; : SE! FF4A C! ; : SE@ FF4A C@ ; : DA! FF4B C! ; : DA@ FF4B C@ ; : DR FF40 ! ; : DWAIT BEGIN ST@ DUP 1 AND WHILE DROP REPEAT ; : 1I DR 40 CM! DWAIT 0 DR . ; : 1O DR 60 CM! DWAIT 0 DR . ; : IN 0 DO DUP 1I LOOP DROP ; : OUT 0 DO DUP 1O LOOP DROP ; : ?ADR 0 FF42 C! 0 FF46 C! 28 OR DR ( MOTOR ON, DBL DNS) C4 FF4C C! DWAIT . FF44 @ DROP 0 FF42 C! 0 FF46 C! FF4E ? FF4E ? FF4E ? ; ;S ( NAMES ) ( JMR-89MAY16 ) BIF DEFINITIONS HEX : NAME ( CFA TO NAME ) 2+ NFA ID. ; : NAMES ( DUMP BY NAME ) -DUP IF 2* OVER + SWAP ( 0? ) DO I 0 6 D.R ( ADR ) I @ DUP 0 5 D.R ( NUMERIC) 3A EMIT NAME CR ?TERMINAL 0< IF KEY 0< IF LEAVE ENDIF ENDIF 2 +LOOP ENDIF ; ;S ( ^asm-util DREG REGISTERS # DPREG DPR SETDP JMR-88DEC19 ) ASSEMBLER DEFINITIONS HEX VOCABULARY ^asm-util ( HIDDEN ) ^asm-util DEFINITIONS : DREG ( REGISTER OPERANDS ) 0FF0F AND 5245 DCONSTANT ; ASSEMBLER DEFINITIONS ^asm-util ( INDEX IN HI BYTE ) 8B00 DREG D 8608 DREG A 8509 DREG B 8C05 DREG PC 4003 DREG U 6004 DREG S 2002 DREG Y 0001 DREG X EF0A DREG CC EF0B DREG DP ( ALL OPERANDS ARE DBL INTS ) ( ABSOLUTE IS 0 OR -1 HI WORD ) ( DIRECT IS ABSOLUTE IN DPAGE ) 494D CONSTANT # ( HI WORD ) ^asm-util DEFINITIONS ( ASSEMBLY TIME DIRECT PAGE ) 42 USER DPREG ( EMULATOR ) ( INIT DPREG ) UTILITIES DP@ ASSEMBLER ^asm-util DPREG ! ASSEMBLER DEFINITIONS ( ACCESS DPREG ) : DPR [ ^asm-util ] DPREG BIF @ ; : SETDP 0FF00 AND [ ^asm-util ] DPREG BIF ! ; --> ( OFF, ABS, V, PCOFF PCR, ) ( JMR-89JAN2 ) ^asm-util DEFINITIONS : OFF, ( SET IX b0, COMPILE 2 ) OVER DUP 80 < SWAP -81 > AND IF C, C, ( SHORT ) ELSE 1 OR C, , ( LONG ) ENDIF ; : OP, ( COMPILE BYTE OR WORD ) DUP 0FF00 AND IF , ELSE C, ENDIF ; : ABS, >R ( COMPILE ABS ADR OP ) OVER 0FF00 AND DPR = IF R> DROP OP, C, ( DIR PAGE) ELSE R> OR OP, , ( EXT ) ENDIF ; : PCOFF ( ABSOLUTE TO PC REL ) HERE + 1+ - ( CALC OFFSET ) DUP 7F > OVER -80 < OR IF 1- 0 ( WORD OFF ) ELSE -1 ( BYTE OFF ) ENDIF ; : ?ABS ( TRUE IF ABSOLUTE ) DUP NOT 0= = ; ( USE T/F VAL) : PCR, ( COMPILE A PC REL INDEX) >R ?ABS NOT 25 ?ERROR 1 PCOFF IF R> C, C, ( BYTE ) ELSE R> 1 OR C, , ENDIF ; --> ( AUTO MASK, REG, IXOFF, EI, ) ( JMR-89JAN2 ) ASSEMBLER DEFINITIONS 4155.0082 DCONSTANT -) ( AUTO ) 4155.0081 DCONSTANT )++ ( REG ) 4155.0080 DCONSTANT )+ ( MODE ) 4155.0083 DCONSTANT --) ( CONS) ^asm-util DEFINITIONS : MASK, OR C, ; ( FOR POSTBYTE) : REG, ( REG OFF TO POST-BYTE ) SWAP DUP D DROP = OVER A DROP = OR OVER B DROP = OR NOT 26 ?ERROR SWAB OR C, ; ( REG, USES DUAL CODED REGS ) : IXOFF, ( REGISTER + CONSTANT ) OVER IF OVER ( NON-ZERO? ) DUP 0F > SWAP -10 < OR OVER 10 AND OR ( []? ) IF 88 OR OFF, ( EXTERNAL ) ELSE ( OFFSET IN POST-BYTE) SWAP 1F AND OR C, ENDIF ELSE 84 OR C, DROP ( 0 OFF ) ENDIF ; : EI, ( EXTENDED INDIRECT ) SWAP ?ABS NOT 27 ?ERROR C, , ; --> ( IX, , INDIRECT ) ( JMR-89JAN4 ) : IX, ( COMPILE AN INDEX MODE ) DUP 9F = IF EI, ELSE DUP 8F AND 8C = IF PCR, ELSE SWAP DUP 4155 = IF DROP MASK, ( AUTO ) ELSE DUP 5245 = IF DROP REG, ELSE ?ABS NOT 22 ?ERROR IXOFF, ENDIF ENDIF ENDIF ENDIF ; ASSEMBLER DEFINITIONS : , ( CONVERT TO INDEX ) 5245 = ( REGISTER? ) OVER 00FF AND DUP 0 > SWAP 6 < AND ( X Y U S PC ? ) AND NOT 28 ?ERROR SWAB 4958 ; : ) ( CONVERT TO INDIRECT ) DUP 5245 = ( REGISTER? ) IF ( ASSEMBLER ) , ELSE DUP [ ^asm-util ] ?ABS [ ASSEMBLER ] IF 4958.009F ELSE ( INDEX? ) DUP 4958 = NOT 27 ?ERROR ENDIF ENDIF ( SET BIT 4 ) SWAP 10 OR SWAP ; --> ( ACCM UNARY REG ) ( JMR-89JAN5 ) ^asm-util DEFINITIONS HEX : ACCM ( ENCODE ACCUMULATOR ) SWAP DUP 0FE AND ( A OR B? ) 8 = NOT 29 ?ERROR 1 AND ( MASK B IN? ) IF OR ELSE DROP ENDIF ; : UNARY ( OP-CODE COMPILER ) <BUILDS 0F AND C, ( OP-CODE ) DOES> C@ ( OP-CODE ) OVER 5245 = ( REGISTER? ) IF DUP 0E = 29 ?ERROR ( JMP?) 40 OR ROT 10 ACCM C, DROP ELSE OVER 4958 = ( INDEX? ) IF 60 OR C, DROP IX, ELSE SWAP ?ABS NOT 21 ?ERROR 70 ( EXT BITS ) ABS, ENDIF ENDIF ; : REG ( ENCODE TARGET REG ) DUP C@ 8D = IF C@ 1 ( JSR ) ELSE SWAP 5245 - 29 ?ERROR OVER DUP A DROP = SWAP B DROP = OR IF C@ SWAP 40 ACCM 0 ( BYTE) ELSE SWAP 00FF AND ( REG? ) OVER 1+ C@ ( CT? ) OVER > NOT 29 ?ERROR ( RANGE ) 2* + 2+ @ -1 ( WORD REG ) ENDIF ENDIF ; --> ( #, BINARY REG-REG ) ( JMR-89JAN12 ) : #, ( COMPILE AN IMMEDIATE ) SWAP DUP 0F AND 5 - ( BIT OK) OVER 5 AND 5 = ( ST OR JSR? ) AND 24 ?ERROR OP, IF BIF , [ ^asm-util ] ( WORD) ELSE C, ENDIF ; ( BYTE ) : BINARY ( OP-CODE COMPILER ) <BUILDS 8F AND C, ( A/B OP ) 05 AND DUP C, -DUP IF ( OP CT) 0 DO 11CF AND BIF , ( DXYUS) [ ^asm-util ] LOOP ENDIF DOES> REG ROT ( SOURCE ) DUP 4958 = IF ( INDEX ? ) DROP DROP 20 OR OP, IX, ELSE DUP 494D = ( IMMEDIATE? ) IF DROP #, ELSE ?ABS NOT 21 ?ERROR DROP 10 OR 20 ABS, ENDIF ENDIF ; : REG-REG ( OP-CODE COMPILER ) <BUILDS C, ( OP-CODE ) DOES> C@ C, ( OP-CODE ) 5245 = ROT 5245 = AND NOT 23 ?ERROR ( 2 REGS? ) 0F AND SWAP SWAN 0F0 AND OR C, ; --> ( REG-BITS PACK MOVEM ) ( JMR-89JAN12 ) 0 0B 1 1ARRAY REG-BITS ( PACK ) 0 REG-BITS ( INITIALIZE ) 06 OVER C! 1+ 10 OVER C! 1+ 20 OVER C! 1+ 40 OVER C! 1+ 40 OVER C! 1+ 80 OVER C! 1+ -1 OVER ! 2+ ( UNDEFINED ) 02 OVER C! 1+ 04 OVER C! 1+ 01 OVER C! 1+ 08 SWAP C! ( STABILIZE PACK: UNDEF=ALL ) : PACK >R 0 ( PSH/PUL LIST ) BEGIN OVER 5245 = WHILE SWAP DROP SWAP ( REG ) DUP R = 2A ?ERROR ( SELF? ) 0FF AND REG-BITS C@ ( BIT ) OVER OVER AND 2B ?ERROR OR REPEAT ( ^ IS DUPLICATE?) R> DROP ; : MOVEM ( OP-CODE COMPILER ) <BUILDS 0FD AND C, DOES> ( OP) C@ >R ( OP ) 5245 = OVER 1+ 0FE AND 4 = AND ( S OR U?) NOT 2C ?ERROR R> OVER U DROP = ( SELECT S/U) IF 2 OR ENDIF C, PACK DUP 0= 2D ?ERROR C, ; --> ( BR DCOND CC-IMM IMPLY ) ( JMR-89JAN13 ) ASSEMBLER DEFINITIONS : BR ( COMPILE CONDITIONAL BR ) 434F - 2F ?ERROR ( CONDITION?) [ ^asm-util ] SWAP ( ADR? ) ?ABS NOT 21 ?ERROR SWAP 1 PCOFF IF ( SHORT ) SWAP DUP 0< IF 0FF AND ( BSR ) ELSE 0F AND 20 OR ENDIF C, C, ( BOTH BYTES ) ELSE SWAP DUP 01000 AND IF SWAB 017 AND ( BSR/BRA ) ELSE 0F AND 1020 OR SWAP 1- SWAP ENDIF OP, BIF , ENDIF ; ASSEMBLER ^asm-util DEFINITIONS : DCOND ( CONDITIONAL OPERANDS) 434F DCONSTANT ; : CC-IMM ( OP-CODE COMPILER ) <BUILDS C, ( OP-CODE ) DOES> C@ C, ( OP-CODE ) 494D - 2E ?ERROR ( IMMEDIATE?) C, ; : IMPLY ( OP-CODE COMPILER ) <BUILDS BIF , ( OP-CODE ) DOES> @ OP, ; --> ( MNEMONICS ) ( JMR-89JAN13 ) ASSEMBLER DEFINITIONS ^asm-util 10CE 0CE 108E 8E 0CC 5 86 BINARY LD 10CF 0CF 108F 8F 0CD 5 87 BINARY ST 118C 1183 108C 8C 1083 5 81 BINARY CMP 35 MOVEM PUL 34 MOVEM PSH 46 UNARY ROR 49 UNARY ROL 39 IMPLY RTS 3B IMPLY RTI 0 82 BINARY SBC 978D DCOND SR 1F REG-REG TFR 4D UNARY TST 83 1 80 BINARY SUB 103F IMPLY SWI2 113F IMPLY SWI3 3F IMPLY SWI 13 IMPLY SYNC 0 84 BINARY AND 0 89 BINARY ADC 48 UNARY ASL 47 UNARY ASR 0C3 1 8B BINARY ADD 3A IMPLY ABX 5 DCOND CS 43 UNARY COM 4F UNARY CLR 1600 DCOND AL 0 85 BINARY BIT 4A UNARY DEC 19 IMPLY DAA 2 DCOND HI 0B DCOND MI 7 DCOND EQ 0C DCOND GE 1E REG-REG EXG 4C UNARY INC 0 8D BINARY JSR 4E UNARY JMP 0 88 BINARY EOR 0E DCOND GT 4 DCOND HS 12 IMPLY NOP 3 DCOND LS 0A DCOND PL --> ( MORE MNEMONICS ) ( JMR-89JAN13 ) 44 UNARY LSR 48 UNARY LSL 0D DCOND LT 6 DCOND NE 3D IMPLY MUL 40 UNARY NEG 0 8A BINARY OR 1A CC-IMM ORCC 1 DCOND NV 1D IMPLY SEX 1C CC-IMM ANDCC 3C CC-IMM CWAI 8 DCOND VC 9 DCOND VS 4 DCOND CCLR ( LO LE FOLLOW ) ^asm-util DEFINITIONS 1 4 1 1ARRAY EA-IX ( TRANSLATE) 1 EA-IX ( INITIALIZE ) 0 OVER C! 1+ 1 OVER C! 1+ 3 OVER C! 1+ 2 SWAP C! ASSEMBLER DEFINITIONS : LEA ( OP-CODE ASSEMBLER ) 5245 - 23 ?ERROR ( REGISTER?) 0F BIF AND [ ^asm-util ] EA-IX C@ 30 BIF OR C, 4958 - 21 ?ERROR ( INDEX? ) [ ^asm-util ] IX, ; 0F DCOND LE 5 DCOND LO --> ( [CD] & ! ^ NEXT ) ( JMR-89JAN17 ) ASSEMBLER DEFINITIONS BIF HEX : [CD] ( CFA OF DEF ) -IFIND DROP DUP 0= 0 ?ERROR CFA 0 [COMPILE] DLITERAL ; IMMEDIATE CREATE & [CD] AND JMP SMUDGE CREATE ! [CD] OR JMP SMUDGE CREATE ^ [CD] XOR JMP SMUDGE ASSEMBLER : NEXT )++ Y ) JMP ; --> ( INVERTCC LIF IF ) ( JMR-89FEB3 ) ^asm-util DEFINITIONS HEX CREATE INVERTCC ( CONDITIONS ) 0. U , X LD 434F # X CMP HERE DUP 2+ 0 NE BR ( CC? ) 2. U , D LD ( BSR? ) HERE DUP 2+ 0 MI BR A CLR 1 # B EOR ( TOGGLE CC ) HERE 4 + 0 NE BR ( ALWAYS? ) AL DROP SWAB # A LD 2. U , D ST NEXT ( FILL BR) 1+ HERE OVER 1+ - SWAP C! 1+ HERE OVER 1+ - SWAP C! 2F # D LD D U PSH ( TO ERROR) [CD] ERROR JMP SMUDGE ASSEMBLER DEFINITIONS : LIF ( MARK AND ASM LONG BR ) [ ^asm-util ] INVERTCC [ ASSEMBLER ] >R >R HERE 4146 ( MARK ) [ UTILITIES ] [CD] RES-ERROR [ ASSEMBLER ] R> R> BR ; : IF ( MARK AND ASM SHORT BR ) [ ^asm-util ] INVERTCC [ ASSEMBLER ] >R >R HERE 4146 ( MARK ) OVER 2+ 0 R> R> BR ; --> ( FILL-IN ) ( JMR-89FEB7 ) ^asm-util DEFINITIONS CREATE FILL-IN ( BR OFFSETS ) UTILITIES DP@ 0 X LD DP DP@ @ - ASSEMBLER 0 X , D LD 0. U , D SUB D U PSH ( OFFS) 2. U , X LD 0. X , D LD ( BR) 16 # A CMP ( ALWAYS? ) HERE DUP 2+ 0 EQ BR 0FE # A AND 0F0 # B AND 1020 # D CMP ( LONG? ) HERE DUP 2+ 0 EQ BR ( SHORT BRANCH ) 0F0 # A AND 20 # A CMP ( BR?) UTILITIES [CD] RES-ERROR ASSEMBLER NE BR 0. U , D LD 7E # D ADD A TST UTILITIES [CD] RES-ERROR ASSEMBLER NE BR ( TOO FAR? ) 80 # B SUB 1. X , B ST ( OFFSET ) HERE 4. U , U LEA NEXT ROT 1+ HERE OVER 1+ - SWAP C! 0. U , D LD ( LONG BR ALWAYS) 3 # D SUB 1. X , D ST DUP 0 AL BR SWAP 1+ HERE OVER 1+ - SWAP C! 0. U , D LD ( LONG BR COND ) 4 # D SUB 2. X , D ST 0 AL BR SMUDGE --> ( ELSE LELSE ENDIF ) ( JMR-89FEB6 ) ASSEMBLER DEFINITIONS HEX ^asm-util : ELSE ( SHORT BRANCH, RESOLVE) 4146 ?PAIRS >R NV IF R> FILL-IN ; : LELSE ( LONG BRANCH, RESOLVE) 4146 ?PAIRS >R NV LIF R> FILL-IN ; : ENDIF 4146 ?PAIRS FILL-IN ; : BEGIN HERE 4142 ; : UNTIL ( COND BR TO BEGIN ) >R >R 4142 ?PAIRS 0 R> R> INVERTCC BR ; : WHILE ( COND BR PAST REPEAT ) ROT 4142 ?PAIRS IF DROP 4157 ; : REPEAT ( LOOP, RESOLVE WHILE) 4157 ?PAIRS SWAP 0 AL BR FILL-IN ; : LWHILE ( LONG WHILE ) ROT 4142 ?PAIRS LIF DROP 4157 ; --> ( :ASM ;ASM ) ( JMR-89MAR28 ) ASSEMBLER DEFINITIONS HEX : :ASM CREATE !CSP ; : ;ASM ?CSP SMUDGE ; : I-CODE ( SHIFT TO HI-LEVEL ) [ ' :ASM CFA @ ] LITERAL [ BIF ] , ( ASMBL JMP <XCOL ) DROOT @ ROOT ! ] ; ( COMPILE) ASSEMBLER : MACHINE ( SHIFT TO LO-LEVEL ) COMPILE (MACHINE) ( IN DEF ) [COMPILE] [ ( NOW INTERPRET ) [COMPILE] ASSEMBLER ; IMMEDIATE ;S ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ( D! D@ ) ( JMR-89FEB16 ) BIF DEFINITIONS ASSEMBLER :ASM D! ( STORE DBL ) X U PUL D U PUL 0. X , D ST D U PUL 2. X , D ST NEXT ;ASM :ASM D@ ( FETCH DBL ) X U PUL 0. X , D LD 2. X , X LD D X U PSH NEXT ;ASM :ASM DOVER ( DOUBLE OVER DOUBLE) 4. U , D LD 6. U , X LD D X U PSH NEXT ;ASM :ASM DSWAP ( SWAP DOUBLES ) 4. U , D LD 0. U , X LD 4. U , X ST 0. U , D ST 6. U , D LD 2. U , X LD 6. U , X ST 2. U , D ST NEXT ;ASM ;S ( [& ,& ]& ) ( JMR-93MAR20 ) BIF DEFINITIONS HEX : [& ( START ARRAY INDEX LIST ) 0 0 4152 ; : ,& ( ACCUMULATE INDEX LIST ) ROT 4152 - 35 ?ERROR ( SPAN?) OVER - DUP F000 AND 33 ?ERROR 1+ SWAP >R ( SAVE LO ) DUP ROT * R> + ( NEW RELOC ) ROT 1+ DUP 7 > 34 ?ERROR SWAP 4152 ; : ]& ( COMPLETE THE ARRAY DEF ) DUP 1- FF00 AND 33 ?ERROR <BUILDS >R ,& DROP ( AR FLAG) R * ( NEW REL ) R> SWAP >R SWAP DUP , ( STORE COUNT ) 0 DO DUP , * LOOP ( SIZES ) DUP , ( ARR SZ ) R> , ( REL ) ALLOT ?STACK DOES> 0 ( SUM ) SWAP DUP 2+ SWAP @ ( COUNT ) 2* OVER + DUP >R ( SAVE END ) SWAP DO ( SUM OF PRODUCTS ) SWAP I @ * + 2 +LOOP R 2+ @ ( RELOCATE ) - DUP 0< OVER R @ < 0= ( BOUNDS? ) OR 0C ?ERROR R> 4 + + ; ( ^ LABEL LOCVOC ) ( JMR-93MAR21 ) BIF DEFINITIONS DECIMAL : ^ ( EXPONENT WITH ?ERROR ) -DUP 0= IF DROP 1 ( N 0 ^ ) ELSE OVER DUP 0= ( 0 N ^ ) SWAP 1 = OR ( 1 N ^ ) OVER 1 = OR ( N 1 ^ ) IF DROP ELSE 1 SWAP 0 DO OVER M* 54 ?ERROR LOOP SWAP DROP ENDIF ENDIF ; : LABEL ( --- ) ( BUILD GOTO ) <BUILDS IMMEDIATE COMPILE-ONLY 0 , DOES> DUP @ IF COMPILE BRANCH @ HERE - 2- , ELSE HERE SWAP ! ENDIF ; : LOCVOC VOCABULARY IMMEDIATE ; : GETNUMBER ( ADR N --- ) 1- OVER 1+ SWAP EXPECT BL ENCLOSE OVER + 0 SWAP C! NUMBER DROP ; : $ DUP . ; ( CS431 TESTPARAMS FACTORIAL ) ( JMR-93MAR24 ) DECIMAL 33 LOAD ( ARRAYS ) DECIMAL 34 LOAD ( ^ LABEL ) BIF DEFINITIONS LOCVOC CS431 CS431 DEFINITIONS DECIMAL 6805 VARIABLE X 6800 VARIABLE Y LOCVOC PARAMSLOCAL PARAMSLOCAL DEFINITIONS 0 VARIABLE A 0 VARIABLE B 0 VARIABLE C 0 VARIABLE X 0 2 2 1ARRAY D CS431 DEFINITIONS PARAMSLOCAL : TESTPARAMS ( N ADR --- ) 1 A ! 2 B ! 3 C ! 4 X ! 4 0 D ! 5 1 D ! 6 2 D ! SWAP ." BY-VAL WAS" . DUP @ 0 D @ * 2 D @ C @ / - 1 D @ A @ * B @ * + SWAP OVER 0 D @ / B @ * 2 D @ * OVER ! ." BY-VAL PARAMETER=" SWAP . ." BY-ADR PARAMETER=" @ . ." LOCAL X=" X @ . ; CS431 : FACTORIAL ( ADR --- ) [ SMUDGE ] ( RECURSIVE ) DUP @ 12 > IF ." TOO BIG " ELSE ." FACTOR" DUP ? DUP @ 2 > IF DUP @ 1- SP@ FACTORIAL OVER @ * OVER ! ENDIF ENDIF ." N!=" ? ; SMUDGE -->( CS431 RECORDS ) ( JMR-93MAR24 ) CS431 DEFINITIONS LOCVOC RECLOC RECLOC DEFINITIONS LOCVOC US US DEFINITIONS 0 VARIABLE ME 0 VARIABLE YOU 0 2 2 1ARRAY THEM RECLOC DEFINITIONS 0 VARIABLE X CS431 DEFINITIONS RECLOC : TESTRECORDS ( --- ) 1 X ! US 3 ME ! 6 YOU ! 2 0 THEM ! 4 1 THEM ! 6 2 THEM ! 2 THEM @ 10 * YOU @ / 1 THEM @ - 0 THEM @ + ME ! ." BEFORE CALL, US.ME=" ME ? ." US.THEM[2]=" 2 THEM ? ME @ 2 THEM TESTPARAMS ." AFTER CALL, LOCAL X=" X ? ." GLOBAL X=" CS431 X ? RECLOC US ." US.ME=" ME ? ." US.THEM[2]=" 2 THEM ? ; CS431 DEFINITIONS --> ( CS431 MAIN ) ( JMR-93MAR24 ) CS431 DEFINITIONS DECIMAL LOCVOC MAINLOC MAINLOC DEFINITIONS LABEL LOOPTO 0 VARIABLE A 0 VARIABLE B 0 VARIABLE C 0 VARIABLE D 0 VARIABLE E 0 VARIABLE F 0 VARIABLE G 0 VARIABLE I 0 VARIABLE J 0 VARIABLE K 0 VARIABLE X 0 VARIABLE CHOICE 0 VARIABLE RESULT [& -1 1 ,& 5 7 ,& 10 11 2 ]& ARRAY 0 79 1 1ARRAY STR 0 VARIABLE AA 0 VARIABLE BB 0 VARIABLE CC 0 VARIABLE DRES CS431 DEFINITIONS MAINLOC ( MIGHT AS WELL START HERE! ) : MAIN ( --- ) ( WE HOPE ) LOOPTO ." CHOICE (1 - 9): " 0 STR 80 GETNUMBER DUP CHOICE ! 0= IF ." I BE DONE!" QUIT ELSE CHOICE @ 1 = IF 1 A ! 2 B ! 3 C ! 4 D ! 5 E ! 6 F ! 7 G ! A @ B @ * $ C @ D @ * $ F @ B @ / $ D @ B @ / $ G @ 100 * $ --> ( CS431 CONTINUE MAIN ) E @ E @ * E @ * $ 23 C @ - $ B @ G @ B @ - * C @ * $ C @ A @ B @ D @ * + * E @ / $ A @ B @ + C @ + G @ F @ - D @ - * $ E @ F @ + G @ + A @ B @ + / $ G @ MINUS G @ - $ A @ MINUS B @ MINUS * G @ MINUS + $ F @ D @ * MINUS B @ C @ * MINUS / $ + + + + + + + + - + - + + RESULT ! ." RESULT=" RESULT ? ELSE CHOICE @ 2 = IF 2 AA ! 3 BB ! 4 CC ! AA @ AA @ ^ AA @ BB @ ^ + AA @ ^ AA @ CC @ ^ / DRES ! DRES @ RESULT ! ." RESULT=" RESULT ? ELSE CHOICE @ 3 = IF 2 -1 DO BIF I MAINLOC I ! 8 5 DO BIF I MAINLOC J ! 12 10 DO BIF I MAINLOC K ! ." ARRAY AT" I ? J ? K ? --> ( CS431 MAIN CONTINUED ) 0 STR 80 GETNUMBER I @ J @ K @ ARRAY ! LOOP LOOP LOOP 0 RESULT ! 2 -1 DO BIF I MAINLOC I ! 8 5 DO BIF I MAINLOC J ! 12 10 DO BIF I MAINLOC K ! I @ J @ K @ ARRAY @ RESULT +! LOOP LOOP LOOP ." RESULT=" RESULT ? ELSE CHOICE @ 4 = IF 21 0 DO BIF I MAINLOC I ! I @ 0= IF ." ZERO" ELSE I @ 10 < IF ." I=" I ? ELSE I @ 10 = IF 16 I ! R> DROP 16 >R ELSE ." NEAT-O" ENDIF ENDIF ENDIF 2 +LOOP ELSE CHOICE @ 5 = IF 2 A ! 4 B ! 0 X ! ." A BEFORE CALL=" A ? ." B BEFORE CALL=" B ? --> ( CS431 MAIN CONTINUED ) A @ B TESTPARAMS ." AFTER A=" A ? ." AFTER B=" B ? ." GLOBAL X=" CS431 X ? ." MAIN X=" MAINLOC X ? ELSE CHOICE @ 6 = IF 0 STR 80 GETNUMBER SP@ FACTORIAL ." ^:" 0 D. ELSE CHOICE @ 7 = IF TESTRECORDS ELSE CHOICE @ 8 = IF ." NO CASE " ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF ENDIF CHOICE @ 9 < IF LOOPTO ENDIF ." THE WRONG END TO PRINT" ; ;S
\ No newline at end of file
--- /dev/null
+++ b/edtasm_v/tools.dsk
@@ -0,0 +1 @@
1+0) Index to BIF HI-LEVEL disk 2) Title page, Copr. notice 3) MONITOR CALL TO DEBUG 4) ERROR MESSAGES 6) HIGH LEVEL TOOLS & UTILITIES 7) LIST, INDEX, TRIAD 8) HIGH LEVEL DISK & SCREEN 11) FORWARD REFERENCING 12) PERIPHERAL UTILITIES 13) SLIST 15) DUMP DEFINITION BY NAME 16) ASSEMBLER 32) DOUBLES IN ASSEMBLER 40) HLL COMPILER 64) PAIR ASSOCIATION EXAMPLE 66) A TRY AT DIVIDE BY CONSTANT 100) SARDIS DMC STUFF 144) HOOCH COMPILER REMAINS BIF EDITOR, UTILITIES, ASSEMBLER, AND EXAMPLES VERSION 1.0 COPYRIGHT 1989 JOEL MATTHEW REES THESE ALGORITHMS ARE EXPRESSED IN THREE LANGUAGES: BIF, BIF ASSEMBLER FOR THE MOTOROLA M6809 MICROPROCESSOR, AND HEXADECIMAL MACHINE CODE FORTHE M6809. THE TEXT IS ORGANIZED FOR EDITING ON A 32-COLUMN TERMINAL,SUCH AS IS FOUND ON A RADIO SHACK COLOR COMPUTER 2. THESE ALGORITHMS AND THEIR TEXT ARE INTENDED FOR NO PURPOSEOTHER THAN EXPERIMENTATION, AND NO CLAIMS OR WARRANTIES ARE MADECONCERNING THEIR USEFULNESS IN ANY PARTICULAR APPLICATION. PUBLISHED 1989 JOEL MATTHEW REES SOUTH SALT LAKE CITY, UTAH ( CALL TO MONITOR, IF SWI IS BREAKPOINT JMR-88OCT?? ) CREATE MON HEX 3F C, 6EB1 , SMUDGE HERE 1- FENCE ! ;S ( ERROR MESSAGES ) DATA STACK UNDERFLOW DICTIONARY FULL ADDRESS RESOLUTION ERROR HIDES DEFINITION IN NULL VECTOR WRITTEN DISC RANGE? DATA STACK OVERFLOW DISC ERROR! CAN'T EXECUTE A NULL! CONTROL STACK UNDERFLOW CONTROL STACK OVERFLOW ARRAY REFERENCE OUT OF BOUNDS ARRAY DIMENSION NOT VALID NO PROCEDURE TO ENTER ( WAS REGISTER ) COMPILATION ONLY, USE IN DEF EXECUTION ONLY CONDITIONALS NOT PAIRED DEFINITION INCOMPLETE IN PROTECTED DICTIONARY USE ONLY WHEN LOADING OFF CURRENT EDITING SCREEN DECLARE VOCABULARY DEFINITION NOT IN VOCABULARY IN FORWARD BLOCK ALLOCATION LIST CORRUPTED: LOST CAN'T REDEFINE nul! NOT FORWARD REFERENCE ( WAS IMMEDIATE ) ( MORE ERROR MESSAGES ) HAS INCORRECT ADDRESS MODE HAS INCORRECT INDEX MODE OPERAND NOT REGISTER HAS ILLEGAL IMMEDIATE PC OFFSET MUST BE ABSOLUTE ACCUMULATOR OFFSET REQUIRED ILLEGAL MEMORY INDIRECTION ILLEGAL INDEX BASE ILLEGAL TARGET SPECIFIED CAN'T STACK ON SELF DUPLICATE IN LIST REGISTER NOT STACK EMPTY REGISTER LIST IMMEDIATE OPERAND REQUIRED REQUIRES CONDITION COMPILE-TIME STACK UNDERFLOW COMPILE-TIME STACK OVERFLOW ( UTILITIES DUMP QLIST QINDEX ) ( L/SCR ULIST JMR-88NOV16) BIF DEFINITIONS HEX ( UTILITIES IS NOW IN KERNEL ) UTILITIES DEFINITIONS : BYTE-DUMP -DUP IF 0 DO DUP I + C@ 4 .R LOOP ENDIF DROP ; ( BASE > 6) BIF DEFINITIONS : DUMP -DUP IF OVER + SWAP DO I 0 6 D.R I 4 [ UTILITIES ] BYTE-DUMP [ BIF ] 3A EMIT I 4 TYPE CR ?TERMINAL 0< IF KEY 0< IF LEAVE ENDIF ENDIF 4 +LOOP ENDIF ; : QLIST BLOCK [ EDITOR ] QDUMP [ BIF ] 500 88 ! ( CENTER ) ; : QINDEX 1+ SWAP DO I QLIST ." SCREEN=" I 4 /MOD . 3A EMIT . ." BLOCK=" I . KEY 0< IF LEAVE ENDIF LOOP ; UTILITIES DEFINITIONS : L/SCR B/BUF B/SCR C/L */ ; : ULIST ( SCREEN N, FLAG BRK ) DUP SCR ! ." SCR # " . 0 ( F ) L/SCR 0 DO CR I 3 .R SPACE I SCR @ .LINE ?TERMINAL 0< IF ( BREAK? ) KEY 0< IF 1- LEAVE ENDIF ENDIF LOOP CR ; --> ( LIST INDEX TRIAD ) ( JMR-88NOV16 ) BIF DEFINITIONS : LIST ( WIDE OUTPUT ) DECIMAL CR UTILITIES ULIST BIF DROP ; : INDEX ( PRINT COMMENT LINES ) 0C EMIT ( FORM FEED ) CR 1+ SWAP DO CR I 3 .R SPACE 0 I .LINE C/L 49 < IF 1 I .LINE ENDIF ?TERMINAL 0< IF KEY 0< IF LEAVE ENDIF ENDIF LOOP ; : TRIAD ( LIST MULTIPLE ) >PRT 0C EMIT ( FORM FEED ) [ DECIMAL ] UTILITIES L/SCR BIF 22 > IF 2 ELSE 3 ENDIF >R R / R * DUP R> + SWAP DO I UTILITIES ULIST BIF 0< IF LEAVE ENDIF UTILITIES L/SCR BIF DUP 32 = SWAP 22 = OR NOT IF CR CR ENDIF LOOP >VID ; HEX -->( HOME CLS QSAVE SAVE-BUFFERS QCAN ) ( JMR-88DEC10 ) UTILITIES DEFINITIONS HEX : HOME 400 88 ! ; : MID 500 88 ! ; BIF DEFINITIONS : CLS 400 200 60 FILL UTILITIES HOME BIF ; UTILITIES DEFINITIONS : CAN-UP ( CANCEL UPDATE IN BUF) DUP @ 7FFF AND OVER ! ; : W-BUF ( WRITE BUF AT ADR ) DUP 2+ OVER @ 7FFF AND 0 R/W CAN-UP ; : SAVE-BUF ( IF UPDATED ) DUP @ 0< IF W-BUF ENDIF ; BIF DEFINITIONS : QSAVE PREV @ ( SAVE PREVIOUS ) UTILITIES SAVE-BUF BIF DROP ; : SAVE-BUFFERS PREV @ BEGIN UTILITIES SAVE-BUF BIF +BUF NOT UNTIL DROP ; : QCAN PREV @ ( CAN UP OF PREV ) UTILITIES CAN-UP BIF DROP ; --> ( CANCEL-UPDATES RE-QUICK .PREV .BUFFERS QPREV JMR-88DEC10 ) : CANCEL-UPDATES PREV @ BEGIN UTILITIES CAN-UP BIF +BUF NOT UNTIL DROP ; : RE-QUICK ( QUICK OLD PREVIOUS) PREV @ DUP @ 7FFF AND 0 ROT ! [ EDITOR ] QUICK BIF ; UTILITIES DEFINITIONS : .BUF ( QLIST BUFFER, . BLOCK ) DUP @ DUP 7FFF AND DUP QLIST MID ." BLOCK=" . 0< IF ." UPDATED" ENDIF CR ; BIF DEFINITIONS : .BUFFERS PREV @ ( .BUF, PAUSE) BEGIN UTILITIES .BUF BIF +BUF DROP KEY 0< ( BREAK? ) UNTIL DROP ; : .PREV PREV @ UTILITIES .BUF BIF DROP ; : EDIT DUP UTILITIES MID BIF ." BLOCK=" . CR [ EDITOR ] QUICK BIF PREV @ @ 0< IF ." UPDATED" ENDIF ; : QPREV PREV @ @ 7FFF AND EDIT ; -->( QOPY COPY QBACK BACK-UP ) ( JMR-88DEC11 ) : QOPY SWAP BLOCK SWAP BLOCK B/BUF 2/ MOVE UPDATE ; : COPY 2* 2* ( SCREEN ) SWAP 2* 2* DUP 4 + SWAP DO I OVER QOPY 1+ LOOP DROP ; : QBACK 1+ SWAP DO I QLIST I BLOCK DUP [ EDITOR ] QDUMP ." BLOCK " I . ." TO " 0 DRIVE-OFFSET @ I + DUP . KEY 59 = IF 0 R/W ( YES? ) ELSE DROP DROP ENDIF LOOP ; : EEDIT ( ERASE AND EDIT BLOCK ) DUP BLOCK 2- UTILITIES .BUF 2+ MID BIF ." BLOCK=" OVER . ." CLEAR?" CR KEY 59 = IF ( YES? ) B/BUF BLANKS UPDATE ELSE DROP ( DON'T CLEAR ) ENDIF EDIT ; --> ( RES-ERROR FORWARD :RESOLVE :RESOLVE ;RES JMR-16MAY89 ) UTILITIES DEFINITIONS HEX : RES-ERROR ( ADR RESOLUTION ) 3 ERROR ; BIF DEFINITIONS UTILITIES : FORWARD ( REFERENCE HEADER ) CREATE 7E C, ( JMP EXTENDED ) IP, [ ' RES-ERROR CFA , ] ( INIT TO RES-ERROR ) SMUDGE FOREWARD @ 0= IF ( EARLIEST? ) LATEST FOREWARD ! ENDIF ; ASSEMBLER DEFINITIONS UTILITIES : :RESOLVE ( :ASM FORWARD REFS ) ?EXEC !CSP [COMPILE] ' DUP CFA DUP 1+ SWAP C@ 7E - ( JMP) OVER @ ' RES-ERROR CFA - OR 1D ?ERROR ( HEADER? ) HERE SWAP ! ( LINK IT ) FOREWARD @ = IF ( END FORWD? ) 0 FOREWARD ! ENDIF ; IMMEDIATE BIF DEFINITIONS ASSEMBLER : :RES ( RESOLVE : FORWARDS ) [COMPILE] :RESOLVE [ BIF ] ( ASSEMBLE JMP <XCOL, COMPILE) IP, [ LATEST CFA @ , ] ] ; : ;RES [COMPILE] ; SMUDGE ; IMMEDIATE ( PL PTEST ) ( JMR-89AUG25 ) BIF DEFINITIONS DECIMAL : PL 79 0 DO I 33 + EMIT LOOP ; : PT ( PL UNTIL KEY PRESS ) BEGIN PL ?TERMINAL UNTIL ; : PTEST >PRT PT >VID ; ;S ( SLIST ) ( JMR-16OCT90 ) ROOT @ UTILITIES : SLIST ( LIST SCREENS TO PRT ) >PRT 1+ SWAP DO I ULIST 0< IF LEAVE ENDIF LOOP >VID ; ROOT ! ;S ( DISK ACCESS WORDS JMR-900228) HEX : CM! FF48 C! ; : ST@ FF48 C@ ; : TR! FF49 C! ; : TR@ FF49 C@ ; : SE! FF4A C! ; : SE@ FF4A C@ ; : DA! FF4B C! ; : DA@ FF4B C@ ; : DR FF40 ! ; : DWAIT BEGIN ST@ DUP 1 AND WHILE DROP REPEAT ; : 1I DR 40 CM! DWAIT 0 DR . ; : 1O DR 60 CM! DWAIT 0 DR . ; : IN 0 DO DUP 1I LOOP DROP ; : OUT 0 DO DUP 1O LOOP DROP ; : ?ADR 0 FF42 C! 0 FF46 C! 28 OR DR ( MOTOR ON, DBL DNS) C4 FF4C C! DWAIT . FF44 @ DROP 0 FF42 C! 0 FF46 C! FF4E ? FF4E ? FF4E ? ; ;S ( NAMES ) ( JMR-89MAY16 ) BIF DEFINITIONS HEX : NAME ( CFA TO NAME ) 2+ NFA ID. ; : NAMES ( DUMP BY NAME ) -DUP IF 2* OVER + SWAP ( 0? ) DO I 0 6 D.R ( ADR ) I @ DUP 0 5 D.R ( NUMERIC) 3A EMIT NAME CR ?TERMINAL 0< IF KEY 0< IF LEAVE ENDIF ENDIF 2 +LOOP ENDIF ; ;S ( ^asm-util DREG REGISTERS # DPREG DPR SETDP JMR-88DEC19 ) ASSEMBLER DEFINITIONS HEX VOCABULARY ^asm-util ( HIDDEN ) ^asm-util DEFINITIONS : DREG ( REGISTER OPERANDS ) 0FF0F AND 5245 DCONSTANT ; ASSEMBLER DEFINITIONS ^asm-util ( INDEX IN HI BYTE ) 8B00 DREG D 8608 DREG A 8509 DREG B 8C05 DREG PC 4003 DREG U 6004 DREG S 2002 DREG Y 0001 DREG X EF0A DREG CC EF0B DREG DP ( ALL OPERANDS ARE DBL INTS ) ( ABSOLUTE IS 0 OR -1 HI WORD ) ( DIRECT IS ABSOLUTE IN DPAGE ) 494D CONSTANT # ( HI WORD ) ^asm-util DEFINITIONS ( ASSEMBLY TIME DIRECT PAGE ) 42 USER DPREG ( EMULATOR ) ( INIT DPREG ) UTILITIES DP@ ASSEMBLER ^asm-util DPREG ! ASSEMBLER DEFINITIONS ( ACCESS DPREG ) : DPR [ ^asm-util ] DPREG BIF @ ; : SETDP 0FF00 AND [ ^asm-util ] DPREG BIF ! ; --> ( OFF, ABS, V, PCOFF PCR, ) ( JMR-89JAN2 ) ^asm-util DEFINITIONS : OFF, ( SET IX b0, COMPILE 2 ) OVER DUP 80 < SWAP -81 > AND IF C, C, ( SHORT ) ELSE 1 OR C, , ( LONG ) ENDIF ; : OP, ( COMPILE BYTE OR WORD ) DUP 0FF00 AND IF , ELSE C, ENDIF ; : ABS, >R ( COMPILE ABS ADR OP ) OVER 0FF00 AND DPR = IF R> DROP OP, C, ( DIR PAGE) ELSE R> OR OP, , ( EXT ) ENDIF ; : PCOFF ( ABSOLUTE TO PC REL ) HERE + 1+ - ( CALC OFFSET ) DUP 7F > OVER -80 < OR IF 1- 0 ( WORD OFF ) ELSE -1 ( BYTE OFF ) ENDIF ; : ?ABS ( TRUE IF ABSOLUTE ) DUP NOT 0= = ; ( USE T/F VAL) : PCR, ( COMPILE A PC REL INDEX) >R ?ABS NOT 25 ?ERROR 1 PCOFF IF R> C, C, ( BYTE ) ELSE R> 1 OR C, , ENDIF ; --> ( AUTO MASK, REG, IXOFF, EI, ) ( JMR-89JAN2 ) ASSEMBLER DEFINITIONS 4155.0082 DCONSTANT -) ( AUTO ) 4155.0081 DCONSTANT )++ ( REG ) 4155.0080 DCONSTANT )+ ( MODE ) 4155.0083 DCONSTANT --) ( CONS) ^asm-util DEFINITIONS : MASK, OR C, ; ( FOR POSTBYTE) : REG, ( REG OFF TO POST-BYTE ) SWAP DUP D DROP = OVER A DROP = OR OVER B DROP = OR NOT 26 ?ERROR SWAB OR C, ; ( REG, USES DUAL CODED REGS ) : IXOFF, ( REGISTER + CONSTANT ) OVER IF OVER ( NON-ZERO? ) DUP 0F > SWAP -10 < OR OVER 10 AND OR ( []? ) IF 88 OR OFF, ( EXTERNAL ) ELSE ( OFFSET IN POST-BYTE) SWAP 1F AND OR C, ENDIF ELSE 84 OR C, DROP ( 0 OFF ) ENDIF ; : EI, ( EXTENDED INDIRECT ) SWAP ?ABS NOT 27 ?ERROR C, , ; --> ( IX, , INDIRECT ) ( JMR-89JAN4 ) : IX, ( COMPILE AN INDEX MODE ) DUP 9F = IF EI, ELSE DUP 8F AND 8C = IF PCR, ELSE SWAP DUP 4155 = IF DROP MASK, ( AUTO ) ELSE DUP 5245 = IF DROP REG, ELSE ?ABS NOT 22 ?ERROR IXOFF, ENDIF ENDIF ENDIF ENDIF ; ASSEMBLER DEFINITIONS : , ( CONVERT TO INDEX ) 5245 = ( REGISTER? ) OVER 00FF AND DUP 0 > SWAP 6 < AND ( X Y U S PC ? ) AND NOT 28 ?ERROR SWAB 4958 ; : ) ( CONVERT TO INDIRECT ) DUP 5245 = ( REGISTER? ) IF ( ASSEMBLER ) , ELSE DUP [ ^asm-util ] ?ABS [ ASSEMBLER ] IF 4958.009F ELSE ( INDEX? ) DUP 4958 = NOT 27 ?ERROR ENDIF ENDIF ( SET BIT 4 ) SWAP 10 OR SWAP ; --> ( ACCM UNARY REG ) ( JMR-89JAN5 ) ^asm-util DEFINITIONS HEX : ACCM ( ENCODE ACCUMULATOR ) SWAP DUP 0FE AND ( A OR B? ) 8 = NOT 29 ?ERROR 1 AND ( MASK B IN? ) IF OR ELSE DROP ENDIF ; : UNARY ( OP-CODE COMPILER ) <BUILDS 0F AND C, ( OP-CODE ) DOES> C@ ( OP-CODE ) OVER 5245 = ( REGISTER? ) IF DUP 0E = 29 ?ERROR ( JMP?) 40 OR ROT 10 ACCM C, DROP ELSE OVER 4958 = ( INDEX? ) IF 60 OR C, DROP IX, ELSE SWAP ?ABS NOT 21 ?ERROR 70 ( EXT BITS ) ABS, ENDIF ENDIF ; : REG ( ENCODE TARGET REG ) DUP C@ 8D = IF C@ 1 ( JSR ) ELSE SWAP 5245 - 29 ?ERROR OVER DUP A DROP = SWAP B DROP = OR IF C@ SWAP 40 ACCM 0 ( BYTE) ELSE SWAP 00FF AND ( REG? ) OVER 1+ C@ ( CT? ) OVER > NOT 29 ?ERROR ( RANGE ) 2* + 2+ @ -1 ( WORD REG ) ENDIF ENDIF ; --> ( #, BINARY REG-REG ) ( JMR-89JAN12 ) : #, ( COMPILE AN IMMEDIATE ) SWAP DUP 0F AND 5 - ( BIT OK) OVER 5 AND 5 = ( ST OR JSR? ) AND 24 ?ERROR OP, IF BIF , [ ^asm-util ] ( WORD) ELSE C, ENDIF ; ( BYTE ) : BINARY ( OP-CODE COMPILER ) <BUILDS 8F AND C, ( A/B OP ) 05 AND DUP C, -DUP IF ( OP CT) 0 DO 11CF AND BIF , ( DXYUS) [ ^asm-util ] LOOP ENDIF DOES> REG ROT ( SOURCE ) DUP 4958 = IF ( INDEX ? ) DROP DROP 20 OR OP, IX, ELSE DUP 494D = ( IMMEDIATE? ) IF DROP #, ELSE ?ABS NOT 21 ?ERROR DROP 10 OR 20 ABS, ENDIF ENDIF ; : REG-REG ( OP-CODE COMPILER ) <BUILDS C, ( OP-CODE ) DOES> C@ C, ( OP-CODE ) 5245 = ROT 5245 = AND NOT 23 ?ERROR ( 2 REGS? ) 0F AND SWAP SWAN 0F0 AND OR C, ; --> ( REG-BITS PACK MOVEM ) ( JMR-89JAN12 ) 0 0B 1 1ARRAY REG-BITS ( PACK ) 0 REG-BITS ( INITIALIZE ) 06 OVER C! 1+ 10 OVER C! 1+ 20 OVER C! 1+ 40 OVER C! 1+ 40 OVER C! 1+ 80 OVER C! 1+ -1 OVER ! 2+ ( UNDEFINED ) 02 OVER C! 1+ 04 OVER C! 1+ 01 OVER C! 1+ 08 SWAP C! ( STABILIZE PACK: UNDEF=ALL ) : PACK >R 0 ( PSH/PUL LIST ) BEGIN OVER 5245 = WHILE SWAP DROP SWAP ( REG ) DUP R = 2A ?ERROR ( SELF? ) 0FF AND REG-BITS C@ ( BIT ) OVER OVER AND 2B ?ERROR OR REPEAT ( ^ IS DUPLICATE?) R> DROP ; : MOVEM ( OP-CODE COMPILER ) <BUILDS 0FD AND C, DOES> ( OP) C@ >R ( OP ) 5245 = OVER 1+ 0FE AND 4 = AND ( S OR U?) NOT 2C ?ERROR R> OVER U DROP = ( SELECT S/U) IF 2 OR ENDIF C, PACK DUP 0= 2D ?ERROR C, ; --> ( BR DCOND CC-IMM IMPLY ) ( JMR-89JAN13 ) ASSEMBLER DEFINITIONS : BR ( COMPILE CONDITIONAL BR ) 434F - 2F ?ERROR ( CONDITION?) [ ^asm-util ] SWAP ( ADR? ) ?ABS NOT 21 ?ERROR SWAP 1 PCOFF IF ( SHORT ) SWAP DUP 0< IF 0FF AND ( BSR ) ELSE 0F AND 20 OR ENDIF C, C, ( BOTH BYTES ) ELSE SWAP DUP 01000 AND IF SWAB 017 AND ( BSR/BRA ) ELSE 0F AND 1020 OR SWAP 1- SWAP ENDIF OP, BIF , ENDIF ; ASSEMBLER ^asm-util DEFINITIONS : DCOND ( CONDITIONAL OPERANDS) 434F DCONSTANT ; : CC-IMM ( OP-CODE COMPILER ) <BUILDS C, ( OP-CODE ) DOES> C@ C, ( OP-CODE ) 494D - 2E ?ERROR ( IMMEDIATE?) C, ; : IMPLY ( OP-CODE COMPILER ) <BUILDS BIF , ( OP-CODE ) DOES> @ OP, ; --> ( MNEMONICS ) ( JMR-89JAN13 ) ASSEMBLER DEFINITIONS ^asm-util 10CE 0CE 108E 8E 0CC 5 86 BINARY LD 10CF 0CF 108F 8F 0CD 5 87 BINARY ST 118C 1183 108C 8C 1083 5 81 BINARY CMP 35 MOVEM PUL 34 MOVEM PSH 46 UNARY ROR 49 UNARY ROL 39 IMPLY RTS 3B IMPLY RTI 0 82 BINARY SBC 978D DCOND SR 1F REG-REG TFR 4D UNARY TST 83 1 80 BINARY SUB 103F IMPLY SWI2 113F IMPLY SWI3 3F IMPLY SWI 13 IMPLY SYNC 0 84 BINARY AND 0 89 BINARY ADC 48 UNARY ASL 47 UNARY ASR 0C3 1 8B BINARY ADD 3A IMPLY ABX 5 DCOND CS 43 UNARY COM 4F UNARY CLR 1600 DCOND AL 0 85 BINARY BIT 4A UNARY DEC 19 IMPLY DAA 2 DCOND HI 0B DCOND MI 7 DCOND EQ 0C DCOND GE 1E REG-REG EXG 4C UNARY INC 0 8D BINARY JSR 4E UNARY JMP 0 88 BINARY EOR 0E DCOND GT 4 DCOND HS 12 IMPLY NOP 3 DCOND LS 0A DCOND PL --> ( MORE MNEMONICS ) ( JMR-89JAN13 ) 44 UNARY LSR 48 UNARY LSL 0D DCOND LT 6 DCOND NE 3D IMPLY MUL 40 UNARY NEG 0 8A BINARY OR 1A CC-IMM ORCC 1 DCOND NV 1D IMPLY SEX 1C CC-IMM ANDCC 3C CC-IMM CWAI 8 DCOND VC 9 DCOND VS 4 DCOND CCLR ( LO LE FOLLOW ) ^asm-util DEFINITIONS 1 4 1 1ARRAY EA-IX ( TRANSLATE) 1 EA-IX ( INITIALIZE ) 0 OVER C! 1+ 1 OVER C! 1+ 3 OVER C! 1+ 2 SWAP C! ASSEMBLER DEFINITIONS : LEA ( OP-CODE ASSEMBLER ) 5245 - 23 ?ERROR ( REGISTER?) 0F BIF AND [ ^asm-util ] EA-IX C@ 30 BIF OR C, 4958 - 21 ?ERROR ( INDEX? ) [ ^asm-util ] IX, ; 0F DCOND LE 5 DCOND LO --> ( [CD] & ! ^ NEXT ) ( JMR-89JAN17 ) ASSEMBLER DEFINITIONS BIF HEX : [CD] ( CFA OF DEF ) -IFIND DROP DUP 0= 0 ?ERROR CFA 0 [COMPILE] DLITERAL ; IMMEDIATE CREATE & [CD] AND JMP SMUDGE CREATE ! [CD] OR JMP SMUDGE CREATE ^ [CD] XOR JMP SMUDGE ASSEMBLER : NEXT )++ Y ) JMP ; --> ( INVERTCC LIF IF ) ( JMR-89FEB3 ) ^asm-util DEFINITIONS HEX CREATE INVERTCC ( CONDITIONS ) 0. U , X LD 434F # X CMP HERE DUP 2+ 0 NE BR ( CC? ) 2. U , D LD ( BSR? ) HERE DUP 2+ 0 MI BR A CLR 1 # B EOR ( TOGGLE CC ) HERE 4 + 0 NE BR ( ALWAYS? ) AL DROP SWAB # A LD 2. U , D ST NEXT ( FILL BR) 1+ HERE OVER 1+ - SWAP C! 1+ HERE OVER 1+ - SWAP C! 2F # D LD D U PSH ( TO ERROR) [CD] ERROR JMP SMUDGE ASSEMBLER DEFINITIONS : LIF ( MARK AND ASM LONG BR ) [ ^asm-util ] INVERTCC [ ASSEMBLER ] >R >R HERE 4146 ( MARK ) [ UTILITIES ] [CD] RES-ERROR [ ASSEMBLER ] R> R> BR ; : IF ( MARK AND ASM SHORT BR ) [ ^asm-util ] INVERTCC [ ASSEMBLER ] >R >R HERE 4146 ( MARK ) OVER 2+ 0 R> R> BR ; --> ( FILL-IN ) ( JMR-89FEB7 ) ^asm-util DEFINITIONS CREATE FILL-IN ( BR OFFSETS ) UTILITIES DP@ 0 X LD DP DP@ @ - ASSEMBLER 0 X , D LD 0. U , D SUB D U PSH ( OFFS) 2. U , X LD 0. X , D LD ( BR) 16 # A CMP ( ALWAYS? ) HERE DUP 2+ 0 EQ BR 0FE # A AND 0F0 # B AND 1020 # D CMP ( LONG? ) HERE DUP 2+ 0 EQ BR ( SHORT BRANCH ) 0F0 # A AND 20 # A CMP ( BR?) UTILITIES [CD] RES-ERROR ASSEMBLER NE BR 0. U , D LD 7E # D ADD A TST UTILITIES [CD] RES-ERROR ASSEMBLER NE BR ( TOO FAR? ) 80 # B SUB 1. X , B ST ( OFFSET ) HERE 4. U , U LEA NEXT ROT 1+ HERE OVER 1+ - SWAP C! 0. U , D LD ( LONG BR ALWAYS) 3 # D SUB 1. X , D ST DUP 0 AL BR SWAP 1+ HERE OVER 1+ - SWAP C! 0. U , D LD ( LONG BR COND ) 4 # D SUB 2. X , D ST 0 AL BR SMUDGE --> ( ELSE LELSE ENDIF ) ( JMR-89FEB6 ) ASSEMBLER DEFINITIONS HEX ^asm-util : ELSE ( SHORT BRANCH, RESOLVE) 4146 ?PAIRS >R NV IF R> FILL-IN ; : LELSE ( LONG BRANCH, RESOLVE) 4146 ?PAIRS >R NV LIF R> FILL-IN ; : ENDIF 4146 ?PAIRS FILL-IN ; : BEGIN HERE 4142 ; : UNTIL ( COND BR TO BEGIN ) >R >R 4142 ?PAIRS 0 R> R> INVERTCC BR ; : WHILE ( COND BR PAST REPEAT ) ROT 4142 ?PAIRS IF DROP 4157 ; : REPEAT ( LOOP, RESOLVE WHILE) 4157 ?PAIRS SWAP 0 AL BR FILL-IN ; : LWHILE ( LONG WHILE ) ROT 4142 ?PAIRS LIF DROP 4157 ; --> ( :ASM ;ASM ) ( JMR-89MAR28 ) ASSEMBLER DEFINITIONS HEX : :ASM CREATE !CSP ; : ;ASM ?CSP SMUDGE ; : I-CODE ( SHIFT TO HI-LEVEL ) [ ' :ASM CFA @ ] LITERAL [ BIF ] , ( ASMBL JMP <XCOL ) DROOT @ ROOT ! ] ; ( COMPILE) ASSEMBLER : MACHINE ( SHIFT TO LO-LEVEL ) COMPILE (MACHINE) ( IN DEF ) [COMPILE] [ ( NOW INTERPRET ) [COMPILE] ASSEMBLER ; IMMEDIATE ;S ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ( D! D@ ) ( JMR-89FEB16 ) BIF DEFINITIONS ASSEMBLER :ASM D! ( STORE DBL ) X U PUL D U PUL 0. X , D ST D U PUL 2. X , D ST NEXT ;ASM :ASM D@ ( FETCH DBL ) X U PUL 0. X , D LD 2. X , X LD D X U PSH NEXT ;ASM :ASM DOVER ( DOUBLE OVER DOUBLE) 4. U , D LD 6. U , X LD D X U PSH NEXT ;ASM :ASM DSWAP ( SWAP DOUBLES ) 4. U , D LD 0. U , X LD 4. U , X ST 0. U , D ST 6. U , D LD 2. U , X LD 6. U , X ST 2. U , D ST NEXT ;ASM ;S

差分はサイズ制限により省略されました。全ての差分を見るためにはローカルクライアントを利用してください。

旧リポジトリブラウザで表示