I have the following structure:
struct fence_struct { unsigned char mode; char sitename[13]; unsigned char sector_nr; unsigned char sector_tot; unsigned int start; unsigned int feeder_offset; unsigned int len; unsigned int line_len; unsigned char begin_far; unsigned int res_norm; unsigned int res_min; unsigned int res_max; unsigned char wire_amount; unsigned char wire_name[12]; }; xdata struct fence_struct fence;
strcpy(fence.sitename, "SITENAME");
;strcpy(fence.sitename, "SITENAME"); ;SOURCE LINE # 1535 MOV R0,#LOW (fence+01H) MOV R4,#HIGH (fence+01H) MOV R5,A MOV R3,#0FFH MOV R2,#HIGH (?SC_403) MOV R1,#LOW (?SC_403) LCALL ?C?STRCPY
;strcpy(fence.sitename, "SITENAME"); ;SOURCE LINE # 4306 MOV R0,#LOW (fence+01H) MOV R4,#HIGH (fence+01H) MOV R5,#01H MOV R3,#0FFH MOV R2,#HIGH (?SC_403) MOV R1,#LOW (?SC_403) LCALL ?C?STRCPY
What you found is not a bug. If it were, you should have demonstrated incorrect behaviour of the generated code. The bug, if any, is in your expectations. Note that the only actual difference between you two assembly outputs is
MOV R5,A
MOV R5,#01H
Your explanation sounds good, but it doesn't explain why the 1st call doesn't initialise the string correctly and the 2nd one does. Also, as a further test I've added the lines
fence.sitename[0] = '1'; fence.sitename[1] = '\0';
"The bug, if any, is in your expectations." Hans-Bernhard, I think he expected the code to work which seems pretty reasonable. Johann, which version of the compiler and linker are you using, and which optimisation settings have you selected? Stefan
I'm using C51 ver 7.01, linker ver 5.01 and optimisation level 8 - set to favour size.