commit 77de26ef8046f92325397612716d79db4c587967
parent 37074fbe4318f5c2afa1f6152764712c9f68de1d
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Wed, 21 Sep 2022 13:58:44 -0400
cc/vm/i386: allow inc/dec of global variables
blkpack can now be compiled and ran on i386, with CRC matching and all.
It's pretty fast too!
Diffstat:
3 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/fs/cc/vm/i386.fs b/fs/cc/vm/i386.fs
@@ -246,9 +246,7 @@ struct+[ VMOp
\ post-inc/dec op1
\ It's a bit complicated here. Before we inc/dec, we need a copy of the current
\ value in a new register, which will be our result.
-\ For now, we only support op1=VM_STACKFRAME
: _ ( 'w -- )
- vmop loc VM_*STACKFRAME = vmop loc VM_*ARGSFRAME = or _assert
vmop :keep vmop :>reg vmop :swap vmop :compile rot execute
vmop :init vmop :pop ;
: vmop++, ['] inc, _ ;
diff --git a/fs/tests/cc/cc.fs b/fs/tests/cc/cc.fs
@@ -30,6 +30,8 @@ cnoop ( no result! ) scnt 0 #eq
42 ptrari 46 #eq
array 52 #eq
global 1234 #eq
+globalinc 1236 #eq
+globalinc 1238 #eq
42 142 sysword 142 #eq
capture helloworld S" Hello World!" #s=
42 40 50 isinrange 1 #eq
diff --git a/fs/tests/cc/test.c b/fs/tests/cc/test.c
@@ -120,6 +120,10 @@ int global2[3] = {4, 5, 6};
extern int global() {
return global1;
}
+extern int globalinc() {
+ global1++;
+ return ++global1;
+}
// "max" is a forth word defined in the system
extern int sysword(int a, int b) {
return max(a, b);