From 5ee8d46e54e27fb27731b9f7deaa54fd78912369 Mon Sep 17 00:00:00 2001 From: G0lge Date: Tue, 23 Jul 2024 22:43:04 +0300 Subject: [PATCH] new test cases for branch solving --- testcases/test_branch_sf.asm | 15 +++++++++++++++ testcases/test_branch_zf.asm | 16 ++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 testcases/test_branch_sf.asm create mode 100644 testcases/test_branch_zf.asm diff --git a/testcases/test_branch_sf.asm b/testcases/test_branch_sf.asm new file mode 100644 index 0000000..b592bb1 --- /dev/null +++ b/testcases/test_branch_sf.asm @@ -0,0 +1,15 @@ +section .text + +global main +main: +cmp rax, 0 ; zf = rax-0 == 0 ; sf = rax-0 < 0; of = (rax ^ 0) < 0; .... + +jns cond_not_taken_sf ; sf == 0; if not taken, we can say rax is negative, so rax | 18446744073709551616 (sign bit is set) + +condition_taken_sf: ; so the basic block here will assume rax's msb is set + +shr rax, 63 ; rax will be 1 + +cond_not_taken_sf: ; but this basicblock wont assume rax is 0 + +ret \ No newline at end of file diff --git a/testcases/test_branch_zf.asm b/testcases/test_branch_zf.asm new file mode 100644 index 0000000..f6aef4d --- /dev/null +++ b/testcases/test_branch_zf.asm @@ -0,0 +1,16 @@ +section .text + +global main +main: +cmp rax, 0 ; zf = rax-0 == 0 ; sf = rax-0 < 0; of = (rax ^ 0) < 0; .... + +jnz cond_not_taken_zf ; zf == 0; if not taken, we can say rax is 0 for this branch, we can do this by rax & 0. + +condition_taken_zf: ; so the basic block here will assume rax is 0 + +inc rax ; rax will be 1 + +cond_not_taken_zf: ; but this basicblock wont assume rax is 0 + +ret +