commit 60e4b2ac049289106b344350bbf7bb83e95d484f
parent 2d16e13b89f2889aa5ab43d9d317c970c21aed8c
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Tue, 14 Jun 2022 13:32:17 -0400
cc: pointers!
Diffstat:
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/cc/gen.fs b/fs/cc/gen.fs
@@ -27,7 +27,7 @@ UOPSCNT wordtbl uopgentbl ( -- )
\ eax = effective address
LOPSCNT wordtbl lopgentbl ( -- )
'w noop ( & )
-:w ( * ) eax [eax] mov, ;
+:w ( * ) edi [edi] mov, ;
\ In binary Ops, the result is in EAX and the source operand is EBX.
BOPSCNT wordtbl bopgentblmiddle ( node -- node )
@@ -117,8 +117,7 @@ ASTIDCNT wordtbl gentbl ( node -- )
gennode bopgentblmiddle r@ data1 wexec eax push,
gennode ebx pop, bopgentblpost r> data1 wexec ;
:w ( LValueOp )
- dup firstchild ?dup not if _err then
- eax ebp mov, lvsfoff eax i32 add,
+ dup firstchild ?dup not if _err then gennode
( node ) data1 lopgentbl swap wexec ;
'w _err ( unused )
'w _err ( unused )
diff --git a/fs/tests/cc/cc.fs b/fs/tests/cc/cc.fs
@@ -13,4 +13,5 @@ variables 82 #eq
funcall 42 #eq
2 3 adder 5 #eq
42 plusone 43 #eq
+ptrget 42 #eq
testend
diff --git a/fs/tests/cc/test.c b/fs/tests/cc/test.c
@@ -26,8 +26,8 @@ int adder(int a, int b) {
int plusone(int x) {
return adder(x, 1);
}
-int pointers() {
+int ptrget() {
int a = 42;
int *b = &a;
- return a;
+ return *b;
}