From cc4166a814624585b30aeafd80511c63588200bc Mon Sep 17 00:00:00 2001 From: VegOwOtenks Date: Wed, 11 Sep 2024 00:26:54 +0200 Subject: [PATCH] Implement BranchNegative --- src/jvm.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/jvm.rs b/src/jvm.rs index 06a3e3e..1879548 100644 --- a/src/jvm.rs +++ b/src/jvm.rs @@ -765,6 +765,15 @@ impl JVM { } } + Instruction::BranchNegative(branch_offset) => { + let test_value = wrap_stackframe_error(class, method, frame.operand_stack.pop_int(0))?; + + if test_value < 0 { + frame.instruction_pointer -= offset as u32; + frame.instruction_pointer = if branch_offset < 0 { frame.instruction_pointer - branch_offset.abs() as u32} else { frame.instruction_pointer + branch_offset.abs() as u32}; + } + } + Instruction::BranchNonNull(branch_offset) => { let test_value = wrap_stackframe_error(class, method, frame.operand_stack.pop_reference(0))?;