diff --git a/src/zscript/vmbuilder.cpp b/src/zscript/vmbuilder.cpp index fd01190553..3f1757828f 100644 --- a/src/zscript/vmbuilder.cpp +++ b/src/zscript/vmbuilder.cpp @@ -427,6 +427,14 @@ size_t VMFunctionBuilder::Emit(int opcode, int opa, int opb, int opc) code[1] = opa; code[2] = opb; code[3] = opc; + if (opcode == OP_PARAM) + { + ParamChange(1); + } + else if (opcode == OP_CALL || opcode == OP_CALL_K) + { + ParamChange(-opb); + } return loc / 4; } diff --git a/src/zscript/vmbuilder.h b/src/zscript/vmbuilder.h index af43cbf8b6..a1c6dfe3f3 100644 --- a/src/zscript/vmbuilder.h +++ b/src/zscript/vmbuilder.h @@ -47,9 +47,6 @@ public: void FillAddressConstants(FVoidObj *konst, VM_ATAG *tags); void FillStringConstants(FString *strings); - // PARAM increases ActiveParam; CALL decreases it. - void ParamChange(int delta); - // Track available registers. RegAvailability Registers[4]; @@ -77,6 +74,9 @@ private: int ActiveParam; TArray Code; + + // PARAM increases ActiveParam; CALL decreases it. + void ParamChange(int delta); }; #endif