[SOLVED] Keil C51 and how to make high speed code

Status
Not open for further replies.

js

Full Member level 5
Joined
Oct 9, 2005
Messages
266
Helped
38
Reputation
76
Reaction score
36
Trophy points
1,328
Activity points
2,670
---------------------------------------------------
#define iiMAX 100
unsigned char xdata Signals[iiMAX][2];
...
unsigned char Diff1;
unsigned int Difference;

indexArray=100;
Difference=0;
while (indexArray)
{
Diff1 = Signals[indexArray][0] - Signals[indexArray][1];
Difference = Difference + Diff1;
indexArray--;
}
---------------------------------------------------

I need this loop too be as speeder as possible ..... but if possible without assembly!
What you suggest?

p.s.
I need difference of two signal sampled 100 times.....
 

in KEIL there is code optimisation techinque which you can access from "options for targe1"
where you are selecting you chip,crystal speed, on chip memory etc..
there you have many tabs in one its tab you can select different code optimization technique like less code space, less data mem/ram or faster code.
 
Reactions: js

    js

    Points: 2
    Helpful Answer Positive Rating
This is true but I think that is good approach is more important and useful than options speed/size!
Maybe using of pointer will be solution.....
 


These are not things for regular use... the first thing i think is optimize the code..
Instead of optimizing the compiler i think it is a good design and code where you can achieve optimization... So the best thing would be code optimization rather than changing the compiler settings tooo much to suit your settings
 
Reactions: js

    js

    Points: 2
    Helpful Answer Positive Rating
I checked with Keil uV2 and found, that the generated code for your original text is already near to optimal, particularly by using register variables where ever possible. The only point, that could be improved is not recalulating the index and loading DPTR for each access to Signals. This can be basically improved by using a single pointer that is decremented or incremented.

Generally, you have to inspect the assembly listing and consider, what the compiler is doing and why? Apparently, you didn't yet.

To access the actual array memory space, indexArray has to be decremented at begin of the loop, by the way, e.g. while(indexArray--), otherwise you're reading out of bounds.
 
Reactions: js

    js

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…