Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Multiplication vs. register shifting. Which is more efficient?

Status
Not open for further replies.

japz87

Newbie level 4
Joined
May 8, 2010
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Monterrey, NL, Mexico
Activity points
1,321
Hi there... I'm using C18 compiler and came up with this curiosity...

What would be more efficient for a shift operation, for example, if I want to shift a register 7 bits to the left...

register <<= 7;

OR

register *= 128;


thanks!

JAPZ
 

Yes, I'm aware of that... my doubt was because I know that the PIC18 has hardware multiplying so if I wanted to do a shift operation I thought maybe it would be more efficient multiplying my variable by powers of 2, instead of using the shift operand (<<).
 

yes it is
Unfortunately, most compilers are too stupid to understand that multiplying by a power of 2 is the same as shifting
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top