From 20834dcc57537cd95260a4a22f5d91a027adfd35 Mon Sep 17 00:00:00 2001 From: Carlos Maiolino Date: Thu, 10 Jul 2025 22:20:01 +0200 Subject: Add x86_64 asm Signed-off-by: Carlos Maiolino --- x86_64/mul_by_add.s | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 x86_64/mul_by_add.s (limited to 'x86_64/mul_by_add.s') diff --git a/x86_64/mul_by_add.s b/x86_64/mul_by_add.s new file mode 100644 index 0000000..3e8c360 --- /dev/null +++ b/x86_64/mul_by_add.s @@ -0,0 +1,25 @@ +# Do a multiplication without using mulq, resulting in a * b +.section .text +.globl _start + +.set OP, 1 # Set here the numbers to +.set OP2, 1 # be multiplied + +_start: + movq $OP2, %rcx + movq $0, %rax + + # We can't rely on loopq to drop exit the loop in case OP2 + # is 0, because the first iteraction will cause %rcx to be -1 + cmpq $OP2, %rax + je exit + + +addloop: + addq $OP, %rax + loopq addloop + +exit: + movq %rax, %rdi + movq $60, %rax + syscall -- cgit v1.2.3