The following bug fixes and additions were made to the original pceForth code.
- removed useless
rc
beforejp interp__
- replaced
jp interp__
byjp cont__
to skip BREAK key test in code when control flow is not jumping backward and no IO (with a few exceptions) jp cont__
with fetch-exec loop cycle takes 15 CPU cycles, 7 cycles saved (i.e. BREAK key test adds 40% overhead), BREAK key interruption is fully working by testing BREAK key indocol__xt
, when performing backward jumps and when performing IO- removed unused floating point words (float operations are not implemented in pceForth)
- optimized code that returns
TRUE
(-1 or $ffff) orFALSE
(0) by usingmv ba,$0000
,jpnz cont__
,dec ba
,jp cont__
or by usingmv ba,$ffff
,jpnz cont__
,inc ba
,jp cont__
- optimized
mv i,$00xx
tomv il,$xx
since the latter short version sets the I register high byte to 0 - fixed and optimized internal throws that removed the TOS
- optimized internal throws by setting the 8-bits
il
register and jumping to newthrow__
code - added
2VALUE
and2VALUE?
, updatedTO
and+TO
to setVALUE
and2VALUE
accordingly - replaced
(IS)
with standards-compliantDEFER!
- replaced
BEHAVIOR
with standards-compliantACTION-OF
using newDEFER@
- removed non-standard
MATCH?
- removed non-standard
RECURSIVE
(same asREVEAL
), not thatRECURSE
is preferred - replaced
M+
andM-
with Forth code instead of assembly to reduce code size - added standards-compliant
PARSE-NAME
- fixed
2CONSTANT
lo/hi cell order swapped - removed BLOCK (
BLK
,BLOCK
,BUFFER
,LOAD
,LIST
,THRU
) because blocks are not implemented andEVALUATE
does not even useBLK
- added standards-compliant
HOLDS
- removed
NO-IOERROR
constant that is always zero - optimized
dolit__xt
0, 1, 2, -1 with newdolit0_xt
,dolit1_xt
,dolit2_xt
,dolitm1_xt
- replaced
FALSE
andTRUE
with jump todolit0_
anddolitm1_
instead ofdocon__xt
- optimized
STDI
,STDO
,STDL
,R/O
,W/O
,R/W
with jump todolit0_xt
,dolit1_xt
,dolit2_xt
,dolit3_xt
- fixed
DRIVE-NAME
to return currentDRIVE
string (E: by default) when drive is not specified - renamed internal
FILE-NAME
toFILENAME
andDRIVE-NAME
toDRIVENAME
- changed internal
FNP
toVALUE FNP
instead ofVARIABLE FNP
to reduce code size - added standards-compliant
BUFFER:
- added standards-compliant
SAVE-INPUT
andRESTORE-INPUT
- added
K
- removed
ALLOCP
that is unused - added standards-compliant
S\"
implemented with new\"-PARSE
- changed old graphics words
PSET
,PRESET
, etc to newGMODE
to set the mode (set, reset, flip),GPOINT
,GPOINT?
,GLINE
,GBOX
- added graphics words
GDOTS
,GDOTS?
,GDRAW
,GBLIT!
,GBLIT@
- replaced internal
POCKET#
,POCKET0
,POCKET1
,WHICH-POCKET
with newWHICH-POCKET
with internal storage - replaced internal
FILENAME#
,FILENAME0
,FILENAME1
,WHICH-FILENAME
with newWHICH-FILE
with internal storage - renamed
>FILENAME
to>FILE
, this takes a fileid to return a file status address (with 18 byte filename and 8 status bytes) and ior error code - renamed
FILENAME>STRING
toFILE>STRING
- renamed
STRING>FILENAME
toSTRING>FILE
- removed non-standard
SKIP-CHARS
, which is the same as relative file move with( d fileid ) SEEK-CUR SEEK-FILE
- fixed
RESIZE-FILE
to enlarge a file (but cannot truncate a file in Forth500) - fixed
FILE-STATUS
to comply with standard, returns file structure pointerf-addr
with file info - removed
FILE-SET
to set a file's attribute, it does not appear to work and there is a danger of losing files - fixed
WRITE-LINE
to add CR LF instead of just LF - fixed
FILE>STRING
when used after>FILE
- added
FIND-FILE
support for * and ? globs (can only use a single * for name and extension, such as . and foo*.*) - added
FILES
to list files on a drive, supports ? and * globbing - added
2TUCK
for consistency with2NIP
- removed
VERIFY-FILE
, which is not usable - renamed internal
FORGET-LIMIT
to the more conventionalFENCE
variable - renamed internal
CHECK-STACK
to the more conventional?STACK
- optimized
(;CODE)
assembly - added standards-compliant
BEGIN-STRUCTURE
,END-STRUCTURE
,+FIELD
,CFIELD:
,FIELD:
,2FIELD:
- optimized
CASE OF
with new(OF)
conditional jump that is faster and saves 6 bytes perOF-ENDOF
pair - changed
DOUBLE-NUMBER
to>DOUBLE
with optimized code to reduce code size - fixed
D+!
bug that was missing apopu ba
to set new TOS - changed to case-insensitve Forth, words can be typed in upper/lower/mixed case
- updated the filename-related words to automatically change the current drive letter (stored in
DRIVE
) when specified - fixed
2/
andD2/
that removed the sign, should perform an arithmetic shift right, not a logical shift right - replace
mv ba,0
withsub ba,ba
when possible (but the latter sets flags), saving >40 bytes - added dictionary underflow and overflow checks to
ALLOT
and to all of the comma words - added
CELL
(same as1 CELLS
) - replaced
(UNINIT)
non-standard -59 exception "execution of an uninitialized deferred word" with a system-defined -256 exception - fixed
(DO2LIT)
lo/hi cell order swapped - fixed
FORGET
memory leak (did not forget old link cell and old name) - added
INCLUDE
- added
VALUE TTY
to support redirectingEMIT
andTYPE
output (default isSTDO
for screen output,STDL
to print) - added
PRINTER
to connect to a printer (e.g. CE-126P) and check printer status - optimized
?STACK
stack check in assembly - added stack overflow/underflow checks to all loop words
- changed return address size from 3 bytes to 2 bytes (1 cell) for standard Forth compliance, support "caller cancelling" with
R>DROP
and "continuation passing" - reduced
MOVE
code size - replaced
S=
machine code with Forth code to callCOMPARE
, saving 50 bytes - optimized
DNEGATE
,D2*
,D+
andD-
- added
-CHARS
used by-TRAILING
andF.
- added
(DORET)
to return from a colon definition instead of(EXIT)
, this allows a futureSEE
to list a colon definition correctly - added
'char'
literals (standard Forth <cnum%gt;), also permits'char
literals without a closing quote - replaced
WITHIN
Forth code by faster assembly code of the same size - reduced code of
(?DO)
by reusing(DO)
- reduced code of
(+TO)
and(D+2TO)
by reusing+!
andD+!
- reduced code of
EVALUATE
andINCLUDE-FILE
, both now useSAVE-INPUT N>R
andNR> RESTORE-INPUT
which is more logical - changed
LAST
andLAST-XT
toVALUE
instead ofVARIABLE
- changed
(COLON-SYS)
,(ORIG)
,(DEST)
,(DO-SYS)
constants to CREATEed words without data that return a unique address - changed
SOURCE
definition to a2VALUE
and removed(SOURCE)
- removed
(REFILL)
and inlined its code into(QUIT)
- optimized
FIND-WORD
dictionary search - added
PAUSE
to display text in reverse video and wait for a keypress ifTTY
is the keyboard (redirecting to printer does not wait for a key) - updated
WORDS
andFILES
to break with BREAK and C/CE at the (more) prompt - optimized
>NAME
to increase speed and reduce code size - added missing
REQUIRE
andREQUIRED
- automatically close open
SOURCE-ID
file when an exception is raised, e.g. whenINCLUDE
fails - improved exception reporting, showing the initial part of the input that caused the exception
- replaced
>BINARY
with>DIGIT
in assembly, shorter and faster - added Forth standard FLOAT (complete) and FLOAT-EXT (most) words
- fixed
F/
double fp when divided by single fp returning garbage by the function driver syscall: make both arguments double fp if one is double fp - added blinking cursor at start and after an exception or
ABORT
andQUIT
which are otherwise silent - improved
OK[]
prompt to also report the depth of the floating point stack, when not empty - improved
EDIT
to fix long line editing issues and to reduce code size - added new
FLOATEXT.FTH
with additional words to complete FLOATEXT - optimized
DECIMAL
,HEX
,UNUSED
to reduce code size - added
FVALUE
andFVALUE?
, changed the correspondingTO
part of this code to assignFVALUE
- added missing extra words
F0>
andF0<>
- added
TAPE
andCLOAD
to load raw data and compile Forth source code from cassette tape - reduduced code size by rewriting
?COMP
,HIDE
,REVEAL
,IMMEDIATE
in assembly - reduduced code size by refactoring
VALUE?
,2VALUE?
,FVALUE?
,COLON?
,MARKER?
to reuse and share code - renamed some of the internal
(...)
words to shorter names to reduce code size - changed
(UNDEF)
andCHECK-NAME
to assembly to increase speed and reduce code size - removed variable
HP
and optimized<#
,HOLD
and#>
in assembly to increase speed and reduce code size - changed
MS
to allow BREAK - replaced "illegal" instruction
mv a,il
withmv ba,i
andmv il,a
withmv i,ba
that perform the same operation anyway - optimized assembly code of all filesystem-related words to reduce code size
- added new
SEE.FTH
,NQUEENS.FTH
and updatedDEBUGGER.FTH
- fixed a floating point exception -46 problem that caused the system to hang without progress
- fixed
GPOINT?
returns 0, 1 or -1 (Sharp E500 technical manual does not mention that A=255 can be returned) - added
FLOATING-STACK
andMAX-FLOAT
toENVIRONMENT?
queries (obsolescentFLOATING
andFLOATING-EXT
are not included) - optimized
[
,]
,DEPTH
,HIDE
,REVEAL
,IMMEDIATE
,ABORT
,QUIT
in assembly code - fixed
TO
with floating point values, floating point stack imbalance - added new
FF.FTH
example with definition ofFF.
to display floating point values as fractions - slightly better optimized
D*
,/MOD
,D/MOD
,UMD*
,UM/MOD
,M*/
- improved error reporting at multiple source locations when files are imported
- optimized
D*
,UMD*
,M*/
to reduce code size - corrected
<error 0
message withINCLUDE
when an exception occurred - added stack overflow/underflow checks to
SP!
andFP!
- increased floating point stack to 10 floats
- added
COMPLEX.FTH
and updatedFLOATEXT.FTH
- updated BREAK exception to display
Break
instead of<Error -28
- updated
REPRESENT
to produce 12 or 13 non-rounded digits for single floating point results - updated double floating point computation results to round to 20 digits rather than ignoring the guard digits
- fixed
EKEY?
issue - fixed
M*/
regression issue
- increased colon call-return execution speed by 20%, using
yi
andzi
20 bit address registers with a fixed 11th segment: this optimizes all 16 to 20 bit address conversions by moving a 16 bit address throughyi
orzi
to obtain a 20 bit address - increased execution speed of single and double integer literals, variables, values, constants, single and double integer store and fetch, single integer arithmetic involving addition and subtraction, and single and double integer stack operations
- fixed
MOVE
when source and destination address are equal - added RUN and PRO display annunciators: RUN lights up when interpreting and PRO lights up when compiling from the prompt
- changed
WORDS
to no longer display inaccessible smudged (hidden) words (e.g. when their definition failed to compile) - changed
FENCE
to a value instead of a variable - added
FORTH
,VOCABULARY
,DEFINITIONS
,CURRENT
andCONTEXT
words - corrected minor errors and omissions in the manual
- removed unused
CS-ROLL
- added
RDROP
(same asR>DROP
) - improved manual