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.

[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.
 
  • Like
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.....
 

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.

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
 
  • Like
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.
 
  • Like
Reactions: js

    js

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

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top