commit b35f597e92712d51bfe40b313e15071cc5c6329b
parent 9d906041b67c7b4e68467676815e22ae7c862fe0
Author: Virgil Dupras <hsoft@hardcoded.net>
Date: Sat, 17 Sep 2022 08:33:01 -0400
cc/vm/i386: use only one VMOp in postops
Diffstat:
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/cc/vm/commonlo.fs b/fs/cc/vm/commonlo.fs
@@ -45,6 +45,9 @@ struct[ VMOp
: :push ( self -- arg loc&type ) dup >r :keep VM_NONE to r> loc ;
: :pop ( arg loc&type self -- )
dup >r :noop# dup $ff and r@ to type 8 rshift r@ to loc r> to arg ;
+ : :swap ( arg loc&type self -- arg loc&type )
+ >r >r >r \ V1=self V2=loc&type V3=arg
+ V1 :push r> r> ( arg loc&type ) r> :pop ;
]struct
create operands VMOp SZ 2 * allot
diff --git a/fs/cc/vm/i386.fs b/fs/cc/vm/i386.fs
@@ -246,12 +246,9 @@ struct+[ VMOp
\ 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
-\ TODO: don't use both ops for this and thus allow post-inc and post-dec to run
-\ on either on the 2 ops
: _ ( 'w -- )
- selop1 vmop loc VM_*STACKFRAME = vmop loc VM_*ARGSFRAME = or _assert
- selop2 noop# selop1 vmop loc vmop arg selop2 to vmop arg to vmop loc
- selop1 op>reg selop2 vmop :compile execute vmop :init selop1 ;
+ vmop loc VM_*STACKFRAME = vmop loc VM_*ARGSFRAME = or _assert
+ vmop :keep op>reg vmop :swap vmop :compile rot execute vmop :init vmop :pop ;
: vmop++, ['] inc, _ ;
: vmop--, ['] dec, _ ;