I am using the memcpy function with identical parameters in two different locations. However, looking at the assembly code, there is a difference bewteen the two. Here is the output from the list file:
This one works correctly
470: memcpy((uchar *)&flash_data,(uchar *)&Flash_Data_1,sizeof(flash_data));
0002 95 [2] TSX
0003 89 [2] PSHX
0004 8b [2] PSHH
0005 450000 [3] LDHX @Flash_Data_1
0008 89 [2] PSHX
0009 8b [2] PSHH
000a ae07 [2] LDX #7
000c 8c [1] CLRH
000d cd0000 [6] JSR memcpy
0010 a704 [2] AIS #4
this one causes the mp to reboot
477: memcpy((uchar *)&flash_data,(uchar *)&Flash_Data_1,sizeof(flash_data));
002b 95 [2] TSX
002c 89 [2] PSHX
002d 8b [2] PSHH
002e 450000 [3] LDHX @Flash_Data_1
0031 89 [2] PSHX
0032 8b [2] PSHH
0033 ae07 [2] LDX #7
0035 cd0000 [6] JSR memcpy
0038 a704 [2] AIS #4
The only difference is the CLRH followign the LDX #7 command. The memcpy function uses the HX register to store the length value of the data you are copying. Because the H register is not being cleared, my length value is garbage.
Is this a known bug? Are there any workarounds?
I am using CodeWarrior IDE version 5.7.0 Build 1932 for target MC9S08GT32. Thanks for any help you can give.
frogman_sr