diff --git a/Source/Doc/ROM_Applications.md b/Source/Doc/ROM_Applications.md index 5a1ae7f3..071abe5d 100644 --- a/Source/Doc/ROM_Applications.md +++ b/Source/Doc/ROM_Applications.md @@ -234,7 +234,7 @@ For those are who are not familiar with Forth, I recommend the wikipedia article (en.wikipedia.org/wiki/Forth_(programming_language)) and the Forth Interest Group website [www.forth.org](www.forth.org) -Important things to know: +## Important things to know Forth is case sensitive. @@ -244,18 +244,35 @@ To get a list of available words type ***WORDS*** To reset Forth to its initial state type ***COLD*** -Most code you will find on the internet will not run without modification. - -A glossary of available words is listed in the \Source\Forth\glosshi.txt glosslo.txt file. +Most of the code you find on the internet will not run unless modified or additional Forth +words are added to the dictionary. This implementation does not support loading or saving of programs. All programs need to be typed in. Additionally, screen editing and code blocks are not supported. +## Structure of Forth source files + +File | Description +--------------|----------------------------- +camel80.azm | Code Primitives + camel80d.azm | CPU Dependencies + camel80h.azm | High Level words + camel80r.azm | ROMWBW additions +glosshi.txt | Glossary of high level words +glosslo.txt | Glossary of low level words + +## ROMWBW Additions + Extensions and changes to this implementation compared to the original distribution are: -Source code has been converted from Z80mr assembler to Hector Peraza's zsm. +The source code has been converted from Z80mr assembler to Hector Peraza's zsm. + +An additional file camel80r.azm has been added for including additional words to +the dictionary at build time. However, as currently configured there is very little space +allocated for addition words. Exceeding the allocated ROM space will generate an error +message when building. -James Bowman's Double precision words have been added from his RC2014 version: +James Bowman's double precision words have been added from his RC2014 version: (https://github.com/jamesbowman/camelforth-z80) Word | Syntax | Description diff --git a/Source/Forth/camel80.azm b/Source/Forth/camel80.azm index c082ead8..a85639a9 100644 --- a/Source/Forth/camel80.azm +++ b/Source/Forth/camel80.azm @@ -75,7 +75,8 @@ HB_LOC EQU 0FD80h ; b1ackmai1er difficultylevelhigh@gmail.com ; 22-Jan 21 v1.02 Adjust for revised HBIOS ; proxy size. -; b1ackmai1er difficultylevelhigh@gmail.com +; b1ackmai1er difficultylevelhigh@gmail.com +; 07-Sep 21 v1.02 Separate additions. ; =============================================== ; Macros to define Forth headers ; HEAD label,length,name,action @@ -1070,13 +1071,21 @@ snext: next INCLUDE camel80d.azm ; CPU Dependencies INCLUDE camel80h.azm ; High Level words +INCLUDE camel80r.azm ; ROMWBW additions +;INCLUDE cameltst.azm ; Test Functions lastword EQU link ; nfa of last word in dict. enddict EQU $ ; user's code starts here ; force padding to page boundary - ds (FTH_SIZ-(enddict-reset)-1) - nop +IF ((enddict-reset) GT FTH_SIZ) + IF2 + FORTH SIZE ERROR + ENDIF +ELSE + ds (FTH_SIZ-(enddict-reset)-1) + nop +ENDIF .DEPHASE END diff --git a/Source/Forth/camel80d.azm b/Source/Forth/camel80d.azm index b2d15fda..8365b8c8 100644 --- a/Source/Forth/camel80d.azm +++ b/Source/Forth/camel80d.azm @@ -23,7 +23,7 @@ ; ; =============================================== ; CAMEL80D.AZM: CPU and Model Dependencies -; Source code is for the Z80MR macro assembler. +; Source code is for the ZSM macro assembler. ; Forth words are documented as follows: ;* NAME stack -- stack description ; Word names in upper case are from the ANS diff --git a/Source/Forth/camel80h.azm b/Source/Forth/camel80h.azm index 15f195ef..e28466ca 100644 --- a/Source/Forth/camel80h.azm +++ b/Source/Forth/camel80h.azm @@ -1011,75 +1011,6 @@ WDS1: DW DUP,COUNT,TYPE,SPACE,NFATOLFA,FETCH DOTS1: DW II,FETCH,UDOT,LIT,-2,XPLUSLOOP,DOTS1 DOTS2: DW EXIT -;C D. d -- display d signed - head DDOT,2,D.,docolon - DW LESSNUM,DUP,TOR,DABS,NUMS - DW RFROM,SIGN,NUMGREATER,TYPE,SPACE,EXIT - -;X D+ d1 d2 -- d1+d2 Add double numbers - head DPLUS,2,D+,docode - exx - pop bc ; BC'=d2lo - exx - pop hl ; HL=d1hi,BC=d2hi - exx - pop hl ; HL'=d1lo - add hl,bc - push hl ; 2OS=d1lo+d2lo - exx - adc hl,bc ; HL=d1hi+d2hi+cy - ld b,h - ld c,l - next - -;C 2>R d -- 2 to R - head TWOTOR,3,2!>R,docolon - DW SWOP,RFROM,SWOP,TOR,SWOP,TOR,TOR,EXIT - -;C 2R> d -- fetch 2 from R - head TWORFROM,3,2R!>,docolon - DW RFROM,RFROM,RFROM,SWOP,ROT,TOR,EXIT - -TNEGATE: - call docolon - DW TOR,TWODUP,OR,DUP,qbranch,TNEG1,DROP,DNEGATE,lit,1 -TNEG1: - DW RFROM,PLUS,NEGATE,EXIT - -qtneg: - call docolon - DW ZEROLESS,qbranch,qtneg1,TNEGATE -qtneg1: - DW EXIT - -TSTAR: - call docolon - DW TWODUP,XOR,TOR - DW TOR,DABS,RFROM,ABS - DW TWOTOR - DW RFETCH,UMSTAR,lit,0 - DW TWORFROM,UMSTAR - DW DPLUS - DW RFROM - DW qtneg - DW EXIT - -TDIV: - call docolon - DW OVER,TOR,TOR - DW DUP,qtneg - DW RFETCH,UMSLASHMOD - DW ROT,ROT - DW RFROM,UMSLASHMOD - DW NIP,SWOP - DW RFROM,ZEROLESS,qbranch,tdiv1,DNEGATE -tdiv1: - DW EXIT - -;C M*/ d1 n2 u3 -- d=(d1*n2)/u3 double precision mult. div - head MSTARSLASH,3,M*/,docolon - DW TOR,TSTAR,RFROM,TDIV,EXIT - ;Z COLD -- cold start Forth system ; UINIT U0 #INIT CMOVE init user area ; 80 COUNT INTERPRET interpret CP/M cmd @@ -1090,7 +1021,7 @@ tdiv1: ; DW LIT,80h,COUNT,INTERPRET DW XSQUOTE DB 59,0dh,0ah,0dh,0ah - DB 'Z80 CamelForth v1.02 25 Jan 1995, RomWBW 19 Oct 2019' + DB 'Z80 CamelForth v1.02 25 Jan 1995, RomWBW 07 Sep 2021' DB 0dh,0ah DW TYPE,ABORT ; ABORT never returns ; DON'T FORGET TO UPDATE THE BYTE COUNT IF YOU CHANGE THE SIZE OF THE BOOT MSG diff --git a/Source/Forth/camel80r.azm b/Source/Forth/camel80r.azm new file mode 100644 index 00000000..bd2989b4 --- /dev/null +++ b/Source/Forth/camel80r.azm @@ -0,0 +1,104 @@ +; LISTING 4. +; +; =============================================== +; CamelForth for the Zilog Z80 +; Copyright (c) 1994,1995 Bradford J. Rodriguez +; +; This program is free software; you can redistribute it and/or modify +; it under the terms of the GNU General Public License as published by +; the Free Software Foundation; either version 3 of the License, or +; (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this program. If not, see . + +; Commercial inquiries should be directed to the author at +; 115 First St., #105, Collingwood, Ontario L9Y 4W3 Canada +; or via email to bj@camelforth.com +; +; =============================================== +; CAMEL80R.AZM: ROMWBW additions +; Source code is for the ZSM assembler. +; Forth words are documented as follows: +;* NAME stack -- stack description +; Word names in upper case are from the ANS +; Forth Core word set. Names in lower case are +; "internal" implementation words & extensions. +; =============================================== + +; DOUBLE PRECISION WORDS ================== + +;C D. d -- display d signed + head DDOT,2,D.,docolon + DW LESSNUM,DUP,TOR,DABS,NUMS + DW RFROM,SIGN,NUMGREATER,TYPE,SPACE,EXIT + +;X D+ d1 d2 -- d1+d2 Add double numbers + head DPLUS,2,D+,docode + exx + pop bc ; BC'=d2lo + exx + pop hl ; HL=d1hi,BC=d2hi + exx + pop hl ; HL'=d1lo + add hl,bc + push hl ; 2OS=d1lo+d2lo + exx + adc hl,bc ; HL=d1hi+d2hi+cy + ld b,h + ld c,l + next + +;C 2>R d -- 2 to R + head TWOTOR,3,2!>R,docolon + DW SWOP,RFROM,SWOP,TOR,SWOP,TOR,TOR,EXIT + +;C 2R> d -- fetch 2 from R + head TWORFROM,3,2R!>,docolon + DW RFROM,RFROM,RFROM,SWOP,ROT,TOR,EXIT + +TNEGATE: + call docolon + DW TOR,TWODUP,OR,DUP,qbranch,TNEG1,DROP,DNEGATE,lit,1 +TNEG1: + DW RFROM,PLUS,NEGATE,EXIT + +qtneg: + call docolon + DW ZEROLESS,qbranch,qtneg1,TNEGATE +qtneg1: + DW EXIT + +TSTAR: + call docolon + DW TWODUP,XOR,TOR + DW TOR,DABS,RFROM,ABS + DW TWOTOR + DW RFETCH,UMSTAR,lit,0 + DW TWORFROM,UMSTAR + DW DPLUS + DW RFROM + DW qtneg + DW EXIT + +TDIV: + call docolon + DW OVER,TOR,TOR + DW DUP,qtneg + DW RFETCH,UMSLASHMOD + DW ROT,ROT + DW RFROM,UMSLASHMOD + DW NIP,SWOP + DW RFROM,ZEROLESS,qbranch,tdiv1,DNEGATE +tdiv1: + DW EXIT + +;C M*/ d1 n2 u3 -- d=(d1*n2)/u3 double precision mult. div + head MSTARSLASH,3,M*/,docolon + DW TOR,TSTAR,RFROM,TDIV,EXIT + diff --git a/Source/Forth/cameltst.azm b/Source/Forth/cameltst.azm index ad480ed2..d9f6ca39 100644 --- a/Source/Forth/cameltst.azm +++ b/Source/Forth/cameltst.azm @@ -18,7 +18,7 @@ ; =============================================== ;Z >< u1 -- u2 swap the bytes of TOS - head SWAB,2,><,docode + head SWAB,2,!>!<,docode ld a,b ld b,c ld c,a @@ -45,7 +45,7 @@ next ;Z >HEX c1 -- c2 convert nybble to hex char - head TOHEX,4,>HEX,docode + head TOHEX,4,!>HEX,docode ld a,c sub 0ah jr c,numeric diff --git a/Tools/cpm/bin/ZSM.COM b/Tools/cpm/bin/ZSM.COM index e7504177..72d3e62c 100644 Binary files a/Tools/cpm/bin/ZSM.COM and b/Tools/cpm/bin/ZSM.COM differ