EASy68K
http://www.easy68k.com/EASy68Kforum/

greatest common divisor
http://www.easy68k.com/EASy68Kforum/viewtopic.php?f=6&t=1145
Page 1 of 1

Author:  simon11 [ Wed Dec 05, 2012 3:00 pm ]
Post subject:  greatest common divisor

Hi,I have to calculate the greatest common divisor of 16 bit whole numbers at $6000 adress and 16 bit whole number at $6010 adress.

The problem is that i cannot use the ordinary algorithm which I used in C i.e.

while(y)
{
t=x%y
x=y
y=t
}
//%=mod

because in DIVU I can only divide a constant with a data register.
Of course I don't want that someone solve the whole problem but if someone could give me an idea where to start from and how, it
would be great.
Thanks, greetings from Croatia.

Author:  lee [ Wed Dec 05, 2012 5:19 pm ]
Post subject:  Re: greatest common divisor

Quote:
because in DIVU I can only divide a constant with a data register.
DIVU divides a 32 bit destination data register by a 16 bit value that can be a constant, a word in memory or another data register.

The result of that divide is returned in the low word of the destination register, the remainder is returned in the high word of the destination register.

So if you want the unsigned 16 bit remainder just use SWAP on the destination register to move the remainder to the low word.

Lee.

Author:  simon11 [ Thu Dec 06, 2012 3:46 pm ]
Post subject:  Re: greatest common divisor

yup you're right I did it, after all I could use the same (Euklid) algorithm (and I did) :D

Thanks a lot. :)

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/