How can I get an efficient loop?

I have written the following code to perform a copy procedure between RAM and FLASH Memory:

unsigned char i;
i = 0x00;
do{
i --;
*(&FLASHADDRESS + j + i) = DataBuffer[i];
}while(i != 0x00);

Is there any better way to generate efficient(like DJNZ in assembler) code? :)
THS.

Parents
  • Is there any better way to generate efficient(like DJNZ in assembler) code?

    Generally, you shouldn't be trying to write your own memcpy() --- there's a nicely working one in the library, so use it.

    Second, if you're really all that worried about the performance, don't waste your time staring at C code --- inspect the generated assembly, or write the piece in assembly right away.

Reply
  • Is there any better way to generate efficient(like DJNZ in assembler) code?

    Generally, you shouldn't be trying to write your own memcpy() --- there's a nicely working one in the library, so use it.

    Second, if you're really all that worried about the performance, don't waste your time staring at C code --- inspect the generated assembly, or write the piece in assembly right away.

Children
More questions in this forum