aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine/vm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sci/engine/vm.cpp')
-rw-r--r--engines/sci/engine/vm.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp
index 74a2841521..3535b278c0 100644
--- a/engines/sci/engine/vm.cpp
+++ b/engines/sci/engine/vm.cpp
@@ -120,7 +120,7 @@ extern const char *opcodeNames[]; // from scriptdebug.cpp
static reg_t read_var(EngineState *s, int type, int index) {
if (validate_variable(s->variables[type], s->stack_base, type, s->variablesMax[type], index)) {
- if (s->variables[type][index].getSegment() == 0xffff) {
+ if (s->variables[type][index].getSegment() == kUninitializedSegment) {
switch (type) {
case VAR_TEMP: {
// Uninitialized read on a temp
@@ -194,7 +194,7 @@ static void write_var(EngineState *s, int type, int index, reg_t value) {
// this happens at least in sq1/room 44 (slot-machine), because a send is missing parameters, then
// those parameters are taken from uninitialized stack and afterwards they are copied back into temps
// if we don't remove the segment, we would get false-positive uninitialized reads later
- if (type == VAR_TEMP && value.getSegment() == 0xffff)
+ if (type == VAR_TEMP && value.getSegment() == kUninitializedSegment)
value.setSegment(0);
s->variables[type][index] = value;
@@ -331,7 +331,7 @@ ExecStack *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, StackPt
assert(argp[0].toUint16() == argc); // The first argument is argc
ExecStack xstack(work_obj, send_obj, curSP, argc, argp,
- 0xFFFF, curFP, selector, -1, -1, -1, -1,
+ kUninitializedSegment, curFP, selector, -1, -1, -1, -1,
origin, stackType);
if (selectorType == kSelectorVariable)
@@ -360,7 +360,7 @@ static void addKernelCallToExecStack(EngineState *s, int kernelCallNr, int kerne
// Add stack frame to indicate we're executing a callk.
// This is useful in debugger backtraces if this
// kernel function calls a script itself.
- ExecStack xstack(NULL_REG, NULL_REG, NULL, argc, argv - 1, 0xFFFF, make_reg32(0, 0),
+ ExecStack xstack(NULL_REG, NULL_REG, argv + argc, argc, argv - 1, kUninitializedSegment, make_reg32(0, 0),
-1, kernelCallNr, kernelSubCallNr, -1, -1, s->_executionStack.size() - 1, EXEC_STACK_TYPE_KERNEL);
s->_executionStack.push_back(xstack);
}
@@ -884,7 +884,7 @@ void run_vm(EngineState *s) {
// We shouldn't initialize temp variables at all
// We put special segment 0xFFFF in there, so that uninitialized reads can get detected
for (int i = 0; i < opparams[0]; i++)
- s->xs->sp[i] = make_reg(0xffff, 0);
+ s->xs->sp[i] = make_reg(kUninitializedSegment, 0);
s->xs->sp += opparams[0];
break;
@@ -1114,6 +1114,8 @@ void run_vm(EngineState *s) {
case op_rest: // 0x2c (44)
// Pushes all or part of the parameter variable list on the stack
+ // Index 0 is argc, so normally this will be called as &rest 1 to
+ // forward all the arguments.
temp = (uint16) opparams[0]; // First argument
s->r_rest = MAX<int16>(s->xs->argc - temp + 1, 0); // +1 because temp counts the paramcount while argc doesn't