diff --git a/programs/shl_conditional_eq.zasm b/programs/shl_conditional_eq.zasm new file mode 100644 index 00000000..d5313d28 --- /dev/null +++ b/programs/shl_conditional_eq.zasm @@ -0,0 +1,14 @@ + .text + .file "shl_conditional_eq.zasm" + .globl __entry +__entry: +.func_begin0: + add 4, r0, r1 + add 1, r0, r2 + shl.eq r1, r2, r3 + sstore r0, r3 + ret +.func_end0: + + .note.GNU-stack + .rodata diff --git a/programs/shr_conditional_eq.zasm b/programs/shr_conditional_eq.zasm new file mode 100644 index 00000000..46197dbf --- /dev/null +++ b/programs/shr_conditional_eq.zasm @@ -0,0 +1,14 @@ + .text + .file "shr_conditional_eq.zasm" + .globl __entry +__entry: +.func_begin0: + add 8, r0, r1 + add 2, r0, r2 + shr.eq r1, r2, r3 + sstore r0, r3 + ret +.func_end0: + + .note.GNU-stack + .rodata diff --git a/tests/integration_test.rs b/tests/integration_test.rs index 6c301eb2..dee6f4d6 100644 --- a/tests/integration_test.rs +++ b/tests/integration_test.rs @@ -516,18 +516,18 @@ fn test_shr_stack() { assert_eq!(result, U256::from(1)); // 4 >> 2 = 1 } -// #[test] -// fn test_shl_conditional() { -// let bin_path = make_bin_path_asm("shl_conditional"); -// let vm_with_custom_flags = VMStateBuilder::new().eq_flag(true).build(); -// let (result, _) = run_program_with_custom_state(&bin_path, vm_with_custom_flags); -// assert_eq!(result, U256::from(8)); // 4 << 1 = 8 -// } - -// #[test] -// fn test_shr_conditional() { -// let bin_path = make_bin_path_asm("shr_conditional"); -// let vm_with_custom_flags = VMStateBuilder::new().gt_flag(true).build(); -// let (result, _) = run_program_with_custom_state(&bin_path, vm_with_custom_flags); -// assert_eq!(result, U256::from(2)); // 8 >> 2 = 2 -// } +#[test] +fn test_shl_conditional_eq_set() { + let bin_path = make_bin_path_asm("shl_conditional_eq"); + let vm_with_custom_flags = VMStateBuilder::new().eq_flag(true).build(); + let (result, _final_vm_state) = run_program_with_custom_state(&bin_path, vm_with_custom_flags); + assert_eq!(result, U256::from(8)); // 4 << 1 = 8 +} + +#[test] +fn test_shr_conditional_eq_set() { + let bin_path = make_bin_path_asm("shr_conditional_eq"); + let vm_with_custom_flags = VMStateBuilder::new().eq_flag(true).build(); + let (result, _) = run_program_with_custom_state(&bin_path, vm_with_custom_flags); + assert_eq!(result, U256::from(2)); // 8 >> 2 = 2 +}