mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-02 08:20:57 +11:00
Compare commits
No commits in common. "ed2b91411a5d73bd54fc8f2623ecd1c535689b5d" and "02e6979a46fc98de7baa78732f35935cdbd93c4a" have entirely different histories.
ed2b91411a
...
02e6979a46
1
blk/004
1
blk/004
@ -1,2 +1 @@
|
|||||||
21 How blocks are organized 22 Addressed devices
|
21 How blocks are organized 22 Addressed devices
|
||||||
23 Branching
|
|
||||||
|
11
blk/023
11
blk/023
@ -1,11 +0,0 @@
|
|||||||
Branching
|
|
||||||
|
|
||||||
Branching in Collapse OS is limited to 8-bit. This represents
|
|
||||||
64 word references forward or backward. While this might seem
|
|
||||||
a bit tight at first, having this limit saves us a non-
|
|
||||||
negligible amount of resource usage.
|
|
||||||
|
|
||||||
The reasoning behind this intentional limit is that huge
|
|
||||||
branches are generally a indicator that a logic ought to be
|
|
||||||
simplified. So here's one more constraint for you to help you
|
|
||||||
towards simplicity.
|
|
13
blk/353
13
blk/353
@ -1,14 +1,13 @@
|
|||||||
: RAM+ [ RAMSTART LITN ] + ; : BIN+ [ BIN( @ LITN ] + ;
|
: RAM+ [ RAMSTART LITN ] + ;
|
||||||
|
: BIN+ [ BIN( @ LITN ] + ;
|
||||||
: HERE 0x04 RAM+ ;
|
: HERE 0x04 RAM+ ;
|
||||||
: CURRENT* 0x51 RAM+ ; : CURRENT CURRENT* @ ;
|
: CURRENT* 0x51 RAM+ ;
|
||||||
|
: CURRENT CURRENT* @ ;
|
||||||
: H@ HERE @ ;
|
: H@ HERE @ ;
|
||||||
: FIND ( w -- a f ) CURRENT @ SWAP _find ;
|
: FIND ( w -- a f ) CURRENT @ SWAP _find ;
|
||||||
: IN> 0x30 RAM+ ; ( current position in INBUF )
|
|
||||||
: IN( 0x32 RAM+ @ ; ( points to INBUF )
|
|
||||||
: IN) 0x40 ( buffer size ) IN( + ; ( INBUF's end )
|
|
||||||
: (infl) 0 IN( DUP IN> ! ! ; ( flush input buffer )
|
|
||||||
: QUIT
|
: QUIT
|
||||||
(resRS) 0 0x08 RAM+ ! ( C<* override ) (infl)
|
(resRS)
|
||||||
|
0 0x08 RAM+ ! ( 08 == C<* override )
|
||||||
LIT< (main) FIND DROP EXECUTE
|
LIT< (main) FIND DROP EXECUTE
|
||||||
;
|
;
|
||||||
1 25 LOADR+ ( xcomp core low )
|
1 25 LOADR+ ( xcomp core low )
|
||||||
|
11
blk/386
Normal file
11
blk/386
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
( current position in INBUF )
|
||||||
|
: IN> 0x30 RAM+ ;
|
||||||
|
( points to INBUF )
|
||||||
|
: IN( 0x32 RAM+ @ ;
|
||||||
|
( points to INBUF's end )
|
||||||
|
: IN) 0x40 ( buffer size ) IN( + ;
|
||||||
|
|
||||||
|
( flush input buffer )
|
||||||
|
( set IN> to IN( and set IN> @ to null )
|
||||||
|
: (infl) 0 IN( DUP IN> ! ! ;
|
||||||
|
|
3
blk/397
3
blk/397
@ -1,7 +1,6 @@
|
|||||||
( Now we have "as late as possible" stuff )
|
( Now we have "as late as possible" stuff )
|
||||||
: _bchk DUP 0x7f + 0xff > IF LIT< br-ovfl (print) ABORT THEN ;
|
|
||||||
: DO COMPILE 2>R H@ ; IMMEDIATE
|
: DO COMPILE 2>R H@ ; IMMEDIATE
|
||||||
: LOOP COMPILE (loop) H@ - _bchk , ; IMMEDIATE
|
: LOOP COMPILE (loop) H@ - , ; IMMEDIATE
|
||||||
( LEAVE is implemented in low xcomp )
|
( LEAVE is implemented in low xcomp )
|
||||||
: LITN 32 , , ( 32 == NUMBER ) ;
|
: LITN 32 , , ( 32 == NUMBER ) ;
|
||||||
( gets its name at the very end. can't comment afterwards )
|
( gets its name at the very end. can't comment afterwards )
|
||||||
|
13
blk/398
13
blk/398
@ -1,13 +1,14 @@
|
|||||||
: IF ( -- a | a: br cell addr )
|
: IF ( -- a | a: br cell addr )
|
||||||
COMPILE (?br) H@ 2 ALLOT ( br cell allot )
|
COMPILE (?br) H@ 2 ALLOT ( br cell allot )
|
||||||
; IMMEDIATE
|
; IMMEDIATE
|
||||||
: THEN ( a -- | a: br cell addr )
|
: THEN ( a -- | a: br cell addr )
|
||||||
DUP H@ -^ _bchk SWAP ( a-H a ) !
|
DUP H@ -^ SWAP ( a-H a ) !
|
||||||
; IMMEDIATE
|
; IMMEDIATE
|
||||||
: ELSE ( a1 -- a2 | a1: IF cell a2: ELSE cell )
|
: ELSE ( a1 -- a2 | a1: IF cell a2: ELSE cell )
|
||||||
COMPILE (br)
|
COMPILE (br)
|
||||||
2 ALLOT
|
2 ALLOT
|
||||||
[COMPILE] THEN
|
DUP H@ -^ SWAP ( a-H a )
|
||||||
H@ 2- ( push a. -2 for allot offset )
|
!
|
||||||
|
H@ 2- ( push a. -2 for allot offset )
|
||||||
; IMMEDIATE
|
; IMMEDIATE
|
||||||
|
|
||||||
|
4
blk/399
4
blk/399
@ -1,6 +1,6 @@
|
|||||||
: BEGIN H@ ; IMMEDIATE
|
: BEGIN H@ ; IMMEDIATE
|
||||||
: AGAIN COMPILE (br) H@ - _bchk , ; IMMEDIATE
|
: AGAIN COMPILE (br) H@ - , ; IMMEDIATE
|
||||||
: UNTIL COMPILE (?br) H@ - _bchk , ; IMMEDIATE
|
: UNTIL COMPILE (?br) H@ - , ; IMMEDIATE
|
||||||
: [ INTERPRET ; IMMEDIATE
|
: [ INTERPRET ; IMMEDIATE
|
||||||
: ] R> DROP ;
|
: ] R> DROP ;
|
||||||
: LIT< WORD 34 , SCPY 0 C, ; IMMEDIATE
|
: LIT< WORD 34 , SCPY 0 C, ; IMMEDIATE
|
||||||
|
BIN
emul/forth.bin
BIN
emul/forth.bin
Binary file not shown.
Loading…
Reference in New Issue
Block a user