View Single Post
  #7   Spotlight this post!  
Unread 05-01-2008, 01:12
Salik Syed Salik Syed is offline
Registered User
FRC #0701 (RoboVikes)
Team Role: Alumni
 
Join Date: Jan 2003
Rookie Year: 2001
Location: Stanford CA.
Posts: 514
Salik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud ofSalik Syed has much to be proud of
Send a message via AIM to Salik Syed
Re: How does division work?

Quote:
Originally Posted by comphappy View Post
If you need the extra places the most efficient way to do it will be to bit shift the dividend, and remember that any time you need to do a calculation, you need to bit shift the result back. using bit shift instead of multiplying by something like 10 will save you a few clock cycles.

multiplication 8-bit by 8-bit method (if you multiply by an arbitrary value such as 10)
see here http://www.dcc.unicamp.br/~celio/mc4...los/mul8x8.asm

Program Memory : 14 locations
# of cycles : 71
RAM : 5 locations
That is a really big waist

bit shift method
c equivalent
x<<1;

can be done with the single asm command lrol (load and rotate left)

I would warn against using this for the reasons outlined before (granted it *should* work)...
The key reason being that you as a programmer really shouldn't have to worry about things like that as it is the compilers problem. Most compilers are written so that operations are optimized (for special cases like the one above).
Unless you are writing hardware drivers you don't need to worry about assembly level optimization. Even hardware shaders (which are run directly on graphics cards) are now written in a C-like language rather than in assembly like before.
__________________
Team 701

Last edited by Salik Syed : 05-01-2008 at 01:14.