It is currently Thu Apr 09, 2020 6:23 am

 All times are UTC

 Page 1 of 1 [ 3 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: greatest common divisorPosted: Wed Dec 05, 2012 3:00 pm

Joined: Tue Dec 04, 2012 9:12 am
Posts: 5
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.

Top

 Post subject: Re: greatest common divisorPosted: Wed Dec 05, 2012 5:19 pm

Joined: Mon Dec 27, 2004 11:40 pm
Posts: 318
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.

Top

 Post subject: Re: greatest common divisorPosted: Thu Dec 06, 2012 3:46 pm

Joined: Tue Dec 04, 2012 9:12 am
Posts: 5
yup you're right I did it, after all I could use the same (Euklid) algorithm (and I did)

Thanks a lot.

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 3 posts ]

 All times are UTC