AnsweredAssumed Answered

[STM8] When use memcpy() will copy the contents to the wrong address

Question asked by Jeffy Zhou on Sep 8, 2017
Latest reply on Sep 11, 2017 by luca

When the destination memory block is locate in zero page which the address is often rang from 0x0 to 0xff. For instance, if a destination memory start address is 0x0, the memory() will copy the contents to address from 0x100. The memory() disassembly instructions like:

      LDW X, #Length
loop: LD  A, (scr + X)
      LD (dst + X), A
      DECW X
      JRNE loop

The value of 'scr' and 'dst' is the address before 1 of start address of memory block. e.g. If the start address of "destination parameter" of memcpy() is 0x80, then the 'dst' should be 0x7f, and if the start address of it is 0x0, the 'dst' will be 0xff, then the contents will copy to the memory from 0x100.

I thinks this should be a compiler issue.