mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-26 19:38:06 +11:00
Compare commits
3 Commits
986a40d3e2
...
c681cb639d
Author | SHA1 | Date | |
---|---|---|---|
|
c681cb639d | ||
|
c494917452 | ||
|
3c2e0dd9df |
2
blk/003
2
blk/003
@ -13,4 +13,4 @@ Contents
|
|||||||
4 Number literals 6 Compilation vs meta-comp.
|
4 Number literals 6 Compilation vs meta-comp.
|
||||||
8 Interpreter I/O 11 Signed-ness
|
8 Interpreter I/O 11 Signed-ness
|
||||||
14 Addressed devices 17 DOES>
|
14 Addressed devices 17 DOES>
|
||||||
|
18 Disk blocks
|
||||||
|
16
blk/018
Normal file
16
blk/018
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
Disk blocks
|
||||||
|
|
||||||
|
Disk blocks are Collapse OS' main access to permanent storage.
|
||||||
|
The system is exceedingly simple: blocks are contiguous
|
||||||
|
chunks of 1024 bytes each living on some permanent media such
|
||||||
|
as floppy disks or SD cards. They are mostly used for text,
|
||||||
|
either informational or source code, which is organized into
|
||||||
|
16 lines of 64 characters each.
|
||||||
|
|
||||||
|
Blocks are referred to by number, 0-indexed. They are read
|
||||||
|
through BLK@ and written through BLK!. When a block is read,
|
||||||
|
its 1024 bytes content is copied to an in-memory buffer
|
||||||
|
starting at BLK( and ending at BLK). Those read/write
|
||||||
|
operations are often implicit. For example, LIST calls BLK@.
|
||||||
|
|
||||||
|
(cont.)
|
16
blk/019
Normal file
16
blk/019
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
When a word modifies the buffer, it sets the buffer as dirty
|
||||||
|
by calling BLK!!. BLK@ checks, before it reads its buffer,
|
||||||
|
whether the current buffer is dirty and implicitly calls BLK!
|
||||||
|
when it is.
|
||||||
|
|
||||||
|
The index of the block currently in memory is kept in BLK>.
|
||||||
|
|
||||||
|
Many blocks contain code. That code can be interpreted through
|
||||||
|
LOAD. Programs stored in blocks frequently have "loader blocks"
|
||||||
|
that take care of loading all blocks relevant to the program.
|
||||||
|
|
||||||
|
Blocks spanning multipls disks are tricky. If your media isn't
|
||||||
|
large enough to hold all Collapse OS blocks in one unit, you'll
|
||||||
|
have to make it span multiple disks. Block reference in
|
||||||
|
informational texts aren't a problem: When you swap your disk,
|
||||||
|
you mentally adjust the block number you fetch. (cont.)
|
8
blk/020
Normal file
8
blk/020
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
However, absolute LOAD operations in Collapse OS aren't aware
|
||||||
|
of disk spanning and will not work properly in your spanned
|
||||||
|
system.
|
||||||
|
|
||||||
|
Although the usage of absolute LOAD calls are minimally used
|
||||||
|
(relative LOADs are preferred), they are sometimes unavoidable.
|
||||||
|
When you span Collapse OS over multiple disks, don't forget to
|
||||||
|
adjust those absolute LOADs.
|
2
blk/056
2
blk/056
@ -3,6 +3,8 @@ Logic
|
|||||||
= n1 n2 -- f Push true if n1 == n2
|
= n1 n2 -- f Push true if n1 == n2
|
||||||
< n1 n2 -- f Push true if n1 < n2
|
< n1 n2 -- f Push true if n1 < n2
|
||||||
> n1 n2 -- f Push true if n1 > n2
|
> n1 n2 -- f Push true if n1 > n2
|
||||||
|
>< n l h -- f Push true if l < n < h
|
||||||
|
=><= n l h -- f Push true if l <= n <= h
|
||||||
CMP n1 n2 -- n Compare n1 and n2 and set n to -1, 0, or 1.
|
CMP n1 n2 -- n Compare n1 and n2 and set n to -1, 0, or 1.
|
||||||
n=0: a1=a2. n=1: a1>a2. n=-1: a1<a2.
|
n=0: a1=a2. n=1: a1>a2. n=-1: a1<a2.
|
||||||
NOT f -- f Push the logical opposite of f
|
NOT f -- f Push the logical opposite of f
|
||||||
|
2
blk/064
2
blk/064
@ -8,7 +8,9 @@ FLUSH -- Write current block to disk if dirty.
|
|||||||
LIST n -- Prints the contents of the block n on screen
|
LIST n -- Prints the contents of the block n on screen
|
||||||
in the form of 16 lines of 64 columns.
|
in the form of 16 lines of 64 columns.
|
||||||
LOAD n -- Interprets Forth code from block n
|
LOAD n -- Interprets Forth code from block n
|
||||||
|
LOAD+ n -- Relative load. Loads active block + n.
|
||||||
LOADR n1 n2 -- Load block range between n1 and n2, inclusive.
|
LOADR n1 n2 -- Load block range between n1 and n2, inclusive.
|
||||||
|
LOADR+ n1 n2 -- Relative ranged load.
|
||||||
WIPE -- Empties current block
|
WIPE -- Empties current block
|
||||||
|
|
||||||
|
|
||||||
|
7
blk/102
7
blk/102
@ -1,9 +1,8 @@
|
|||||||
152 LOAD ( extras )
|
50 LOAD+ ( B152, extras )
|
||||||
103 107 LOADR
|
1 5 LOADR+
|
||||||
|
|
||||||
: BROWSE
|
: BROWSE
|
||||||
100 _LIST
|
L BEGIN
|
||||||
BEGIN
|
|
||||||
KEY CASE
|
KEY CASE
|
||||||
'Q' OF EXIT ENDOF
|
'Q' OF EXIT ENDOF
|
||||||
'B' OF B ENDOF
|
'B' OF B ENDOF
|
||||||
|
2
blk/152
2
blk/152
@ -1,3 +1,3 @@
|
|||||||
'? CASE NOT [IF]
|
'? CASE NOT [IF]
|
||||||
153 157 LOADR
|
1 5 LOADR+
|
||||||
[THEN] DROP ( from '? )
|
[THEN] DROP ( from '? )
|
||||||
|
2
blk/352
2
blk/352
@ -11,5 +11,5 @@ ACIA_MEM
|
|||||||
+4 ACIA(
|
+4 ACIA(
|
||||||
+6 ACIA) )
|
+6 ACIA) )
|
||||||
|
|
||||||
353 355 LOADR
|
1 3 LOADR+
|
||||||
|
|
||||||
|
2
blk/374
2
blk/374
@ -13,4 +13,4 @@
|
|||||||
DUP 20 = UNTIL
|
DUP 20 = UNTIL
|
||||||
DROP 0xff
|
DROP 0xff
|
||||||
;
|
;
|
||||||
375 386 LOADR
|
1 12 LOADR+
|
||||||
|
2
blk/393
2
blk/393
@ -12,4 +12,4 @@
|
|||||||
0 0x08 RAM+ ! ( 08 == C<* override )
|
0 0x08 RAM+ ! ( 08 == C<* override )
|
||||||
LIT< INTERPRET (find) DROP EXECUTE
|
LIT< INTERPRET (find) DROP EXECUTE
|
||||||
;
|
;
|
||||||
394 413 LOADR
|
1 20 LOADR+
|
||||||
|
4
blk/394
4
blk/394
@ -7,7 +7,9 @@
|
|||||||
: >= < NOT ;
|
: >= < NOT ;
|
||||||
: <= > NOT ;
|
: <= > NOT ;
|
||||||
: 0>= 0< NOT ;
|
: 0>= 0< NOT ;
|
||||||
|
( n l h -- f )
|
||||||
|
: >< 2 PICK > ( n l f ) ROT ROT > AND ;
|
||||||
|
: =><= 2 PICK >= ( n l f ) ROT ROT >= AND ;
|
||||||
( a -- a+1 c )
|
( a -- a+1 c )
|
||||||
: C@+ DUP C@ SWAP 1+ SWAP ;
|
: C@+ DUP C@ SWAP 1+ SWAP ;
|
||||||
( c a -- a+1 )
|
( c a -- a+1 )
|
||||||
|
5
blk/395
5
blk/395
@ -5,10 +5,9 @@
|
|||||||
: _pdacc
|
: _pdacc
|
||||||
DUP 0x21 < IF DROP 1 EXIT THEN
|
DUP 0x21 < IF DROP 1 EXIT THEN
|
||||||
( parse char )
|
( parse char )
|
||||||
'0' -
|
|
||||||
( if bad, return "r -1" )
|
( if bad, return "r -1" )
|
||||||
DUP 0< IF DROP -1 EXIT THEN ( bad )
|
'0' -
|
||||||
DUP 9 > IF DROP -1 EXIT THEN ( bad )
|
DUP 10 < NOT IF DROP -1 EXIT THEN
|
||||||
( good, add to running result )
|
( good, add to running result )
|
||||||
SWAP 10 * + ( r*10+n )
|
SWAP 10 * + ( r*10+n )
|
||||||
0 ( good )
|
0 ( good )
|
||||||
|
12
blk/399
12
blk/399
@ -1,14 +1,8 @@
|
|||||||
( returns negative value on error )
|
( returns negative value on error )
|
||||||
: _ ( c -- n )
|
: _ ( c -- n )
|
||||||
( '0' is ASCII 48 )
|
DUP '0' '9' =><= IF '0' - EXIT THEN
|
||||||
48 -
|
DUP 'a' 'f' =><= IF 0x57 ( 'a' - 10 ) - EXIT THEN
|
||||||
DUP 0< ( bad ) OVER 10 < ( good ) OR IF EXIT THEN
|
DROP -1 ( bad )
|
||||||
( 'a' is ASCII 97. 59 = 97 - 48 )
|
|
||||||
49 -
|
|
||||||
DUP 0< IF EXIT THEN ( bad )
|
|
||||||
DUP 6 < IF 10 + EXIT THEN ( good )
|
|
||||||
( bad )
|
|
||||||
255 -
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
7
blk/401
7
blk/401
@ -1,10 +1,7 @@
|
|||||||
( returns negative value on error )
|
( returns negative value on error )
|
||||||
: _ ( c -- n )
|
: _ ( c -- n )
|
||||||
( '0' is ASCII 48 )
|
DUP '0' '1' =><= IF '0' - EXIT THEN
|
||||||
48 -
|
DROP -1 ( bad )
|
||||||
DUP 0< ( bad ) OVER 2 < ( good ) OR IF EXIT THEN
|
|
||||||
( bad )
|
|
||||||
255 -
|
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
2
blk/444
2
blk/444
@ -8,7 +8,7 @@
|
|||||||
DROP
|
DROP
|
||||||
8 0 DO
|
8 0 DO
|
||||||
C@+
|
C@+
|
||||||
DUP 0x20 < OVER 0x7e > OR
|
DUP 0x20 0x7e =><= NOT
|
||||||
IF DROP '.' THEN
|
IF DROP '.' THEN
|
||||||
EMIT
|
EMIT
|
||||||
LOOP
|
LOOP
|
||||||
|
2
blk/459
2
blk/459
@ -1,2 +1,4 @@
|
|||||||
|
: LOAD+ BLK> @ + LOAD ;
|
||||||
( b1 b2 -- )
|
( b1 b2 -- )
|
||||||
: LOADR 1+ SWAP DO I DUP . NL LOAD LOOP ;
|
: LOADR 1+ SWAP DO I DUP . NL LOAD LOOP ;
|
||||||
|
: LOADR+ BLK> @ + SWAP BLK> @ + SWAP LOADR ;
|
||||||
|
BIN
emul/forth.bin
BIN
emul/forth.bin
Binary file not shown.
Loading…
Reference in New Issue
Block a user