mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-02 08:30:55 +11:00
Compare commits
4 Commits
80891d7ec1
...
2af959a13d
Author | SHA1 | Date | |
---|---|---|---|
|
2af959a13d | ||
|
c972c70ab1 | ||
|
41cefb7460 | ||
|
d013c572ad |
@ -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.
@ -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" ;
|
||||
|
@ -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
30
forth/print.fs
Normal 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" ;
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user