Implement BranchNegative

This commit is contained in:
VegOwOtenks 2024-09-11 00:26:54 +02:00
parent 49ce37402e
commit cc4166a814

View file

@ -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) => { Instruction::BranchNonNull(branch_offset) => {
let test_value = wrap_stackframe_error(class, method, frame.operand_stack.pop_reference(0))?; let test_value = wrap_stackframe_error(class, method, frame.operand_stack.pop_reference(0))?;