Coldfire assembler

Hello group,

does anybody of you know an easy way to get the 2nd power of an unsigned

16-bit number (eg. 2^2 = 4) No flags needed. After reading the Spec-sheet the only way I can think of is a loop. I am new to assembler so maybe my "C-thinking" hides an easier way.

Thanks a lot

Kai

Reply to
Kai Schülke
Loading thread data ...

Since anything larger than 256^2 will blow your 16 bit uint, why not use a

512 byte lookup table? :^P
--
Ron Sharp.
Reply to
Android Cat

Because - I confess - it is homework :-)) I know how to do it with loops, but given the (little) points you can get there must be an easier way to do it. It just makes me mad.

Anyway. If anybody could give me a hint that would be nice.

Good night

Kai

Reply to
Kai Schülke

Have you really thought about what taking the second power of something really means?

Let me just say your solution is one instruction. No loops needed.

Reply to
Gary Kato

Combining that with (16*a + b)^2 = 256*a^2 + 32 * a * b + b^2 with a and b 4 bit quantities, you can use some 16 entry tables and a single multiplication.

--
Chuck F (cbfalconer@yahoo.com) (cbfalconer@worldnet.att.net)
   Available for consulting/temporary embedded and systems.
     USE worldnet address!
Reply to
CBFalconer

Is there something I'm not understanding here? He just wants to square a 16-bit unsigned number, right? And this is Coldfire, which is the 68000 CPU, right? Can't he accomplish this with just a single multiplication?

Reply to
Gary Kato

Kai, read the Coldfire Programmer's Reference Manual, Chapter 4: Integer User Instructions.

You will find the solution there.

/jan

Kai Schülke schrieb in im Newsbeitrag: brg1dn$enm$ snipped-for-privacy@lacerta.tiscalinet.it...

Reply to
Jan Homuth

Thanks to all!!!

After having slept a night and read your coments it's obvious that it's only a single multiplication. I felt that there must be an easy way. If the easy one won't work I'll switch to the lookup-tables :-))

Thanks a lot, again

Bye

Kai

Reply to
Kai Schülke

No, I think you understand it completely.

Casey

Reply to
Casey

Ok, thanks. Sometimes(ok, maybe many times) there's a subtlety that I've missed.

Reply to
Gary Kato

Well, I do my share of that as well.

Casey

Reply to
Casey

Just use multiplly.

My contribution to future homework assignments :)

Also, the following articles will help you in learning ColdFire (68000) assembly.

formatting link

formatting link

formatting link

Sandeep

--

formatting link
EventStudio 2.0 - Go beyond UML Sequence Diagrams and Use Case Diagrams

Reply to
EventHelix.com

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.