diff --git a/src/execution/mod.rs b/src/execution/mod.rs index 82a9651c..cbfc8166 100644 --- a/src/execution/mod.rs +++ b/src/execution/mod.rs @@ -272,6 +272,16 @@ impl<'b> RuntimeInstance<'b> { trace!("Instruction: i32.shr_u [{v2} {v1}] -> [{res}]"); stack.push_value(res.into()); } + // i32.rotl: [i32 i32] -> [i32] + 0x77 => { + let v1: i32 = stack.pop_value(ValType::NumType(NumType::I32)).into(); + let v2: i32 = stack.pop_value(ValType::NumType(NumType::I32)).into(); + + let res = v2.rotate_left(v1 as u32); + + trace!("Instruction: i32.rotl [{v2} {v1}] -> [{res}]"); + stack.push_value(res.into()); + } other => { trace!("Unknown instruction {other:#x}, skipping.."); } diff --git a/src/validation/code.rs b/src/validation/code.rs index 2d5bbe2e..894f9a14 100644 --- a/src/validation/code.rs +++ b/src/validation/code.rs @@ -223,6 +223,13 @@ fn read_instructions( value_stack.push_back(ValType::NumType(NumType::I32)); } + // i32.rotl: [i32 i32] -> [i32] + 0x77 => { + assert_pop_value_stack(value_stack, ValType::NumType(NumType::I32))?; + assert_pop_value_stack(value_stack, ValType::NumType(NumType::I32))?; + + value_stack.push_back(ValType::NumType(NumType::I32)); + } other => { return Err(Error::InvalidInstr(other)); }