1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-02 08:30:55 +11:00

Compare commits

...

4 Commits

Author SHA1 Message Date
Virgil Dupras
2af959a13d Don't use IMMEDIATE in icore
Since the fix of its RAM addr, we use the wrong CURRENT in every
usage of IMMEDIATE in icore. We therefore have to manually set the
flag for all 3 immediate words in that unit.
2020-04-04 08:40:55 -04:00
Virgil Dupras
c972c70ab1 Use proper RAM addr for CURRENT in IMMEDIATE 2020-04-04 08:11:30 -04:00
Virgil Dupras
41cefb7460 Extract EMIT-dependent routines from core 2020-04-04 08:08:45 -04:00
Virgil Dupras
d013c572ad Use proper RAM addr for HERE in SCPY 2020-04-04 07:34:38 -04:00
6 changed files with 50 additions and 35 deletions

View File

@ -1,6 +1,6 @@
TARGETS = runbin/runbin forth/forth
# Those Forth source files are in a particular order
FORTHSRCS = core.fs str.fs parse.fs readln.fs fmt.fs z80a.fs
FORTHSRCS = core.fs print.fs str.fs parse.fs readln.fs fmt.fs z80a.fs
FORTHSRC_PATHS = ${FORTHSRCS:%=../forth/%} forth/run.fs
OBJS = emul.o libz80/libz80.o
SLATEST = ../tools/slatest

Binary file not shown.

View File

@ -118,29 +118,3 @@
( Set up initial SYSVNXT value, which is 2 bytes after its
own address )
46 RAM+ DUP 2 + SWAP !
: (print)
BEGIN
DUP C@ ( a c )
( exit if null )
DUP NOT IF 2DROP EXIT THEN
EMIT ( a )
1 + ( a+1 )
AGAIN
;
: ."
LIT
BEGIN
C< DUP ( c c )
( 34 is ASCII for " )
DUP 34 = IF DROP DROP 0 0 THEN
C,
0 = UNTIL
COMPILE (print)
; IMMEDIATE
: ABORT" [COMPILE] ." COMPILE ABORT ; IMMEDIATE
: (uflw) ABORT" stack underflow" ;
: (wnf) ABORT" word not found" ;

View File

@ -53,7 +53,11 @@
' ( get word )
-^ ( apply offset )
, ( write! )
; IMMEDIATE
;
( We can't use IMMEDIATE because the one we've just compiled
in z80c target's the *target*'s RAM addr, not the host's.
manually set namelen field. )
0x82 CURRENT @ 1 - C!
: RAM+
[ RAMSTART LITN ] _c +
@ -219,7 +223,10 @@
( : and ; have to be defined last because it can't be
executed now also, they can't have their real name
right away )
right away. We also can't use IMMEDIATE because the offset
used for CURRENT is the *target*'s RAM offset. we're still
on the host.
)
: X
_c (entry)
@ -235,15 +242,17 @@
( maybe number )
ELSE _c (parse*) _c @ EXECUTE _c LITN THEN
AGAIN
; IMMEDIATE
;
: Y
['] EXIT _c ,
_c R> _c DROP ( exit : )
; IMMEDIATE
;
( Give ":" and ";" their real name )
( Give ":" and ";" their real name and make them IMMEDIATE )
0x81 ' X 1 - C!
':' ' X 4 - C!
0x81 ' Y 1 - C!
';' ' Y 4 - C!
( Add dummy entry. we use CREATE because (entry) is, at this

30
forth/print.fs Normal file
View File

@ -0,0 +1,30 @@
( Words allowing printing strings. Require core )
( This used to be in core, but some drivers providing EMIT
are much much easier to write with access to core words,
and these words below need EMIT... )
: (print)
BEGIN
DUP C@ ( a c )
( exit if null )
DUP NOT IF 2DROP EXIT THEN
EMIT ( a )
1 + ( a+1 )
AGAIN
;
: ."
LIT
BEGIN
C< DUP ( c c )
( 34 is ASCII for " )
DUP 34 = IF DROP DROP 0 0 THEN
C,
0 = UNTIL
COMPILE (print)
; IMMEDIATE
: ABORT" [COMPILE] ." COMPILE ABORT ; IMMEDIATE
: (uflw) ABORT" stack underflow" ;
: (wnf) ABORT" word not found" ;

View File

@ -313,7 +313,8 @@ CODE R>
;CODE
CODE IMMEDIATE
CURRENT LDHL(nn),
( CURRENT == RAM+2 )
RAMSTART 0x02 + LDHL(nn),
HL DECss,
7 (HL) SETbr,
;CODE
@ -393,7 +394,8 @@ L1 FSET ( found )
CODE SCPY
HL POPqq,
chkPS,
DE HERE LDdd(nn),
( HERE == RAM+4 )
DE RAMSTART 0x04 + LDdd(nn),
B 0 LDrn,
L1 BSET ( loop )
A (HL) LDrr,
@ -404,7 +406,7 @@ L1 BSET ( loop )
A ORr,
JRNZ, L1 BWR ( loop )
DE A LD(dd)r
HERE DE LD(nn)dd,
RAMSTART 0x04 + DE LD(nn)dd,
;CODE
CODE (im1)