From dff2cab108fe7f205233244c57c9bd4d3dd324f9 Mon Sep 17 00:00:00 2001 From: naci Date: Thu, 14 Nov 2024 03:14:19 +0300 Subject: [PATCH] Create CommutativeOrAssociative.asm --- testcases/CommutativeOrAssociative.asm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 testcases/CommutativeOrAssociative.asm diff --git a/testcases/CommutativeOrAssociative.asm b/testcases/CommutativeOrAssociative.asm new file mode 100644 index 0000000..a6936b0 --- /dev/null +++ b/testcases/CommutativeOrAssociative.asm @@ -0,0 +1,18 @@ +section .text + + +; The idea is taking +; %0 = add 10, %a +; %1 = add 5, %0 +; and transforming to +; %0 = add %a, 10 +; %1 = add %0, 5 +; now we can check if RHS is a constant, and fold the instruction +; %0 = add %a, 15 + +global main +main: +mov rax, 10 +add rax, rcx +sub rax, rcx +ret \ No newline at end of file