Coldfire assembler

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
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



Re: Coldfire assembler
Quoted text here. Click to load it

Since anything larger than 256^2 will blow your 16 bit uint, why not use a
512 byte lookup table?  :^P

--
Ron Sharp.



Re: Coldfire assembler

Quoted text here. Click to load it

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



Re: Coldfire assembler
 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.


Re: Coldfire assembler
Quoted text here. Click to load it

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 ( snipped-for-privacy@yahoo.com) ( snipped-for-privacy@worldnet.att.net)
   Available for consulting/temporary embedded and systems.
We've slightly trimmed the long signature. Click to see the full one.
Re: Coldfire assembler
Quoted text here. Click to load it

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?



Thanks - Re: Coldfire assembler
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



Re: Coldfire assembler
Gary Kato said...
Quoted text here. Click to load it

No, I think you understand it completely.


Casey


Re: Coldfire assembler
Quoted text here. Click to load it

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

Re: Coldfire assembler
Gary Kato said...
Quoted text here. Click to load it

Well, I do my share of that as well.


Casey

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

You will find the solution there.

/jan

brg1dn$enm$ snipped-for-privacy@lacerta.tiscalinet.it...
Quoted text here. Click to load it



Re: Coldfire assembler
Just use multiplly.

My contribution to future homework assignments :)

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

http://www.eventhelix.com/RealtimeMantra/Basics/CToAssemblyTranslation.htm

http://www.eventhelix.com/RealtimeMantra/Basics/CToAssemblyTranslation2.htm

http://www.eventhelix.com/RealtimeMantra/Basics/CToAssemblyTranslation3.htm

Sandeep
--
http://www.EventHelix.com/EventStudio
EventStudio 2.0 - Go beyond UML Sequence Diagrams and Use Case Diagrams

Site Timeline