2017-09-08 01:55 AM
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, &sharpLength
loop: LD A, (scr + X) LD (dst + X), A DECW X JRNE loop RETThe 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.
#stm8-assembly #memcpy2017-09-08 08:06 AM
Hello,
what compiler?
Please post a minimum C code that shows the problem so that we can reproduce it.
Regards,
Luca
2017-09-10 11:10 PM
Hi Luca,
Attached stvd demo project, and a capture image descripts the result of running in my environment.
Environment:
Win10
STVD: version 4.3.10
Cosmic: CxSTM8 4.3.5
2017-09-11 09:40 AM
Hello,
the address 0 is used by the compiler to indicate the NULL pointer value, and that implies that there are a few things you cannot do with it, including using memcpy.
I would suggest to declare another variable before your array, so that it does not start at 0 anymore and you can access it safely in whatever way you want, but if you absolutely need to use memcpy at address 0 you can write your own version of it and use it instead of the default one.
Regards,
Luca (Cosmic)