mirror of
https://github.com/wwarthen/RomWBW.git
synced 2026-02-06 22:33:12 -06:00
forth updates
This commit is contained in:
@@ -246,7 +246,6 @@ 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.
|
||||
|
||||
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.
|
||||
@@ -255,6 +254,19 @@ Extensions and changes to this implementation compared to the original distribut
|
||||
|
||||
Source code has been converted from Z80mr assembler to Hector Peraza's zsm.
|
||||
|
||||
## Structure of Forth source files
|
||||
|
||||
File | Description
|
||||
--------------|-----------------------------
|
||||
camel80.azm | Code Primitives
|
||||
camel80d.azm | CPU Dependencies
|
||||
camel80h.azm | High Level words
|
||||
camel80r.asm | ROMWBW additions
|
||||
glosshi.txt | Glossary of high level words
|
||||
glosslo.txt | Glossary of low level words
|
||||
|
||||
## ROMWBW Additons
|
||||
|
||||
James Bowman's Double precision words have been added from his RC2014 version:
|
||||
(https://github.com/jamesbowman/camelforth-z80)
|
||||
|
||||
|
||||
@@ -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,6 +1071,8 @@ 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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
104
Source/Forth/camel80r.azm
Normal file
104
Source/Forth/camel80r.azm
Normal file
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
; 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
|
||||
|
||||
Reference in New Issue
Block a user