EASy68K  
It is currently Fri Jun 05, 2020 3:40 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: greatest common divisor
PostPosted: Wed Dec 05, 2012 3:00 pm 
Offline

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
 Profile  
 
PostPosted: Wed Dec 05, 2012 5:19 pm 
Offline

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
 Profile  
 
PostPosted: Thu Dec 06, 2012 3:46 pm 
Offline

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) :D

Thanks a lot. :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group