commit d25e210b0136a6cfe6588223ae8d522695aa9d54
parent dde5fd7a6dee0fedc3c69a5688edaca40ed1fec8
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Sat, 15 Oct 2022 19:19:44 -0400
Collapse OS: we have prompt!
Input is broken, but if you do:
f<< /app/cos/cvm.fs
cos
You will see the magic words spit out!
Diffstat:
6 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/fs/app/cos/cvm.fs b/fs/app/cos/cvm.fs
@@ -7,4 +7,6 @@ S" COSVM" findTypedef CType :export
COS_init vm COSVM mem
S" /app/cos/serial.bin" curpath :find# Path :open
tuck File :readall File :close
- begin 1 COS_steps drop key 'q' = until ;
+ ['] stdin vm COSVM iord !
+ ['] stdout vm COSVM iowr !
+ begin 100 COS_steps not until COS_printdbg ;
diff --git a/fs/cc/type.fs b/fs/cc/type.fs
@@ -124,7 +124,7 @@ struct[ CType
dup name NEXTWORD ! struct[ llnext begin ( ctype )
?dup while
dup name NEXTWORD ! dup nbelem if ( ctype )
- dup Struct size &+ dup type _typesize over nbelem * sallot
+ dup type _typesize over nbelem * sfield'
else ( ctype )
dup type _typesize case
1 of = sfieldb endof
diff --git a/fs/tests/app/cos/cvm.fs b/fs/tests/app/cos/cvm.fs
@@ -3,9 +3,12 @@ f<< /app/cos/cvm.fs
testbegin
\ Testing COS CVM
+0 value myres
COS_init
vm structbind COSVM vm
vm mem f" /tests/app/cos/dummy.bin" File :readall
+: iowr00 to myres ;
+' iowr00 vm iowr !
vm running #
\ The "dummy.bin" file is a test handcrafted binary with the equivalent of
\ but without any word name:
@@ -17,9 +20,10 @@ vm running #
\ CODE + 1c c, 07 c,
\ CODE >R $3e c, 07 c,
\ CODE (next) $09 c, $07 c,
-\ : BOOT 42 3 >R BEGIN 1 + NEXT BYE ;
+\ CODE PC! $33 c, $07 c,
+\ : BOOT 42 3 >R BEGIN 1 + NEXT 0 PC! BYE ;
50 COS_steps not #
COS_printdbg
-COS_pop 45 #eq
+myres 45 #eq
testend
diff --git a/fs/tests/app/cos/dummy.bin b/fs/tests/app/cos/dummy.bin
Binary files differ.
diff --git a/fs/xcomp/bootlo.fs b/fs/xcomp/bootlo.fs
@@ -244,9 +244,10 @@ does> ( 'struct )
_bkp sysdict @! _cur e>w structdict' ! ;
: sallot ( n -- ) _cur e>w structsz' +! ;
-: _sfield ( sz -- ) doer immediate
+: _sfield ( sz -- )
current _cur e>w structlastfield' @! ( next ) ,
- _cur e>w structsz , ( sz ) dup , sallot
+ _cur e>w structsz , ( sz ) dup , sallot ;
+: _svalue ( sz -- ) doer immediate _sfield
does> CELLSZ + @+ swap @ swap ( a? sz off )
compiling if ( sz off )
litn compile + 0 toptr @! ( sz toptr )
@@ -254,9 +255,10 @@ does> ( 'struct )
else ( a sz off )
rot + 0 toptr @! ( sz a toptr )
?dup not if ['] @ then rot ?b (woff) + execute then ;
-: sfield CELLSZ _sfield ;
-: sfieldw 2 _sfield ;
-: sfieldb 1 _sfield ;
+: sfield CELLSZ _svalue ;
+: sfieldw 2 _svalue ;
+: sfieldb 1 _svalue ;
+: sfield' ( sz -- ) _cur e>w structsz &+ _sfield ;
: smethod doer _cur e>w structsz , CELLSZ sallot does> @ over + @ execute ;
struct[ Struct
diff --git a/posix/dis.c b/posix/dis.c
@@ -143,8 +143,9 @@ struct call {
int arg;
};
-#define CALLCNT 21
+#define CALLCNT 22
struct call calls[CALLCNT] = {
+ {0x5f, "execute", ARGNONE},
{0x9e, "(br)", ARGINT},
{0xae, "(?br)", ARGINT},
{0x11a, "dup", ARGNONE},