Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
04/06/00 14:12
Read: times


 
#2128 - RE: Assembly Language vs C
Re: Math in C or Assembly Language

When it comes to doing realtime, mathematics, I only use assembly language.

If you know a lot of mathematics, assembly language and data structures, you can take extremely significant shortcuts in calculation run-times. You can tune your algorithm for the precision and speeds required. A built-in software package or C is a compromise for all users' requirements.

C mathematics or mathematic libraries are good for non-realtime applications. Its nice to calculate a sine or cosine without writting your own algorithm... but it can take a long time and grab some of your system resources.

An example from Real-Life:

Three years ago I was managing a project wherein a small 8-bit PIC microprocessor needed to sense a magnitude threshold in a two-dimensional plane. The programmer we hired downloaded a huge mathematics library and told me we needed a 16bit microprocessor running much faster.

I told him that he was incorrect and that it should only take about 20 or 30 lines of code. Of course he thought I was insane. I drove back to my office and opened up the PIC microprocessor programming guidebook for the first time and designed an algorithm and programmed it in 18 instructions (with no additional tables). I plotted its precision characteristics in a 3-D curve using Microsoft Excel, printed it out and delivered it the next day. In our subsequent meetings, the programmer never said anything... until about 2 weeks later. I arrived to talk about the project and he was all excited. Apparently it took him that long to figure out the way algorithm worked and become convinced that it worked.

As you can conclude from the description, sometimes the most obvious way of calculating something is not the most effecient. As I decomposed the mathematical problem, I saw that I had no need to do sines and cosines. It only took 18 lines of PIC code and a loop that executed at most 4 times.

The development of non-obvious algorithms is the big payoff in microprocessor firmware design.

-Jay C. Box

List of 16 messages in thread
TopicAuthorDate
Assembly Language vs C            01/01/70 00:00      
RE: Assembly Language vs C            01/01/70 00:00      
RE: Assembly Language vs C            01/01/70 00:00      
RE: Assembly Language vs C            01/01/70 00:00      
RE: Assembly Language vs C            01/01/70 00:00      
RE: Assembly Language vs C            01/01/70 00:00      
RE: Assembly Language vs C            01/01/70 00:00      
RE: Assembly Language vs C            01/01/70 00:00      
RE: Assembly Language vs C            01/01/70 00:00      
RE: Assembly Language vs C            01/01/70 00:00      
RE: Assembly Language vs C            01/01/70 00:00      
RE: Assembly Language vs C            01/01/70 00:00      
RE: Assembly Language vs C            01/01/70 00:00      
RE: Assembly Language vs C            01/01/70 00:00      
RE: Assembly Language vs C            01/01/70 00:00      
RE: Assembly Language vs C            01/01/70 00:00      

Back to Subject List