Not Yet Answered # euclidean GCD algorithm

wildgoose 420 Hey, so I wanna ask how I need to create a method who will remove word if in that word is 2 same chars. Example: "Potato" in this word there is a 2 "o" chars so this word will need to be removed. "Forum" in this word there is no ...

Hi I'm having a problem implementing a mini shopping cart drop down in the header to show the user all the products they have in their shopping cart. It seems the only solution for this is Ajax, and I've looked all over and can't find anything that I could possibly ...

0

I'm looking at your code, but I don't see your algorithm.

If you're trying to find the Greatest Common Denominator, then I'm not seeing the algorithm. Several methods for a GCD. One is inner, outer loop. Subtract tmp divisor each time, looking for a divisor == 0 vs divisor < remainder result. If not zero, increment the divisor, reset the dividend and start again. Fastest method though would be to start from divisor half the dividend, and decrement the divisor each time.

You aren't using recursion. I'm not aware of any Euclidean GCD algorithm that uses a Nx2 algorithm in its basis.

Can you post your logic in pseudo code to make it clearer!

I've added comments to your code but it isn't helping me understand the algorithm.

What happens if a0 is (0)? I'm assuming a1 is (1) as its being used as a shifter, but shouldn't that be a divisor instead of a multiplier?

```
; a0, a1 preset.
; Assuming a1 always == 1, as a down counter?
; If 1==1 exit
loop: beq $a0, $a1, exit
slt $t0, $a0, $a1 ; t0 = a0 << a1 ??? Why making # bigger to zero instead of smaller?
bne $t0, $zero, label ; jmp t0==0 label
sub $a0, $a0, $a1 ; a0 -= a1 ??? Only subtracting (1)
j loop
; Outer Loop
label: sub $a1, $a1, $a0 ; a1 -= a0
j loop
exit: add $v0, $zero, $a0 ; return a0
```

Instead of starting with assembly. Start with pseudo code or a higher programming language to get the logic flow in place

*Edited 6 Years Ago by wildgoose*: n/a

This article has been dead for over six months. Start a new discussion instead.

Recommended Articles

I don’t want at this stage work on a big separate project as I've already got plenty ...