2022-06-02 19:49:17 +02:00
|
|
|
The related ilo & napia virtual machines make use of blocks
|
|
|
|
for data storage. This implements a set of words for interacting
|
|
|
|
with the blocks from within RetroForth/Nga.
|
|
|
|
|
|
|
|
The exposed word set is compact:
|
|
|
|
|
|
|
|
block:set-file (s-)
|
|
|
|
block:read (na-)
|
|
|
|
block:write (na-)
|
|
|
|
|
|
|
|
~~~
|
|
|
|
{{
|
|
|
|
'Blocks var
|
|
|
|
'BlockFile var
|
|
|
|
|
|
|
|
:open (n-) @BlockFile swap file:open !Blocks ;
|
|
|
|
:close (-) @Blocks file:close ;
|
|
|
|
:seek (n-) #4096 n:mul @Blocks file:seek ;
|
|
|
|
:read (-n) #4 [ @Blocks file:read ] times pack ;
|
|
|
|
:store (an-a) swap store-next ;
|
2022-06-09 19:47:39 +02:00
|
|
|
:write (n-) unpack 'abcd 'bcda reorder #4 [ dup n:put sp @Blocks file:write ] times ;
|
2022-06-02 19:49:17 +02:00
|
|
|
---reveal---
|
|
|
|
:block:set-file (s-) s:keep !BlockFile ;
|
|
|
|
:block:read (na-)
|
|
|
|
file:R open swap seek #1024 [ read store ] times drop close ;
|
2022-06-09 19:47:39 +02:00
|
|
|
:block:write (na-)
|
|
|
|
file:R+ open swap seek #1024 [ fetch-next write ] times drop close ;
|
2022-06-02 19:49:17 +02:00
|
|
|
}}
|
|
|
|
~~~
|