Hello all,
may you give me an explanation of following piece of code (target is ST10F276):
U8 ndata * Dest; U8 xhuge * Source; register U16 wTemp; while([condition]) { ..... wTemp = *((U16 xhuge *) Source); *((U8 ndata *) (Dest++)) = *((U8 ndata *) & wTemp); *((U8 ndata *) (Dest++)) = *((U8 ndata *) & wTemp + 1); Source += 2; ..... }
I understand that read operation (instructions) of data from xhuge pointer is very slow - therefore complete word is read out and stored into any register given by compiler.
But what is an advantage of write per Bytes? AFAIK the processor ST10F276 has 16bit wide bus, has not?
Thanks for your hints in advance,
Best regards Iggy
Perhaps a reason of this approach is:
premise: Word (16bit) storing into Dest always begins at even address (= default feature of such processor).
If Source starts at odd address, then only one Byte (not whole Word - 16bit) is copied into 1st Byte of destination Word. Afterwards per-Byte coyping must be performed, otherwise one Byte gap (2nd Byte of 1st destination Word) occurs in the Dest buffer.