I have the following assembly code
.global _start
.section .text
_start:
movq a, %rax
movq b, %rbx
imul %rbx, %rax
cmp %rbx, %rax
je gcd_calculated
ja l1
sub %rax, %rbx
jmp _start
l1:
sub %rbx, %rax
jmp _start
gcd_calculated:
div %rax
movq %rax, (c)
a,b are quads that I need to calculate their lcm and I need to assign the result to c
I get wrong results with the above code and I can't spot why.
generally, i'm relaying on the the lcm = (a*b)/gcd so I store a*b in %rax and then calculate the gcd which will be stored at %eax and finally divide between them.