diff --git a/engine/vm.c b/engine/vm.c index ec704f9..9f6286b 100644 --- a/engine/vm.c +++ b/engine/vm.c @@ -4652,7 +4652,7 @@ Resume: } /* Perform the requested operation */ a = pNos->x.iVal; - b = (sxi32)pTos->x.iVal; + b = (sxi32)((sxu64)pTos->x.iVal & 63); if(pInstr->iOp == PH7_OP_SHL) { r = PH7_Int64FromUnsigned((sxu64)a << b); } else { @@ -4667,15 +4667,15 @@ Resume: /* OP_SHL_STORE * * * * * Pop the top two elements from the stack. Convert both elements - * to integers. Push back onto the stack the second element shifted - * left by N bits where N is the top element on the stack. + * to integers. Push back onto the stack the top element shifted + * left by N bits where N is the second element on the stack. * Note: Only integer arithmetic is allowed. */ /* OP_SHR_STORE * * * * * Pop the top two elements from the stack. Convert both elements - * to integers. Push back onto the stack the second element shifted - * right by N bits where N is the top element on the stack. + * to integers. Push back onto the stack the top element shifted + * right by N bits where N is the second element on the stack. * Note: Only integer arithmetic is allowed. */ case PH7_OP_SHL_STORE: @@ -4696,7 +4696,7 @@ Resume: } /* Perform the requested operation */ a = pTos->x.iVal; - b = (sxi32)pNos->x.iVal; + b = (sxi32)((sxu64)pNos->x.iVal & 63); if(pInstr->iOp == PH7_OP_SHL_STORE) { r = PH7_Int64FromUnsigned((sxu64)a << b); } else {