From: SourceForge.net <no...@so...> - 2009-06-07 14:00:22
|
Bugs item #2740884, was opened at 2009-04-07 16:37 Message generated for change (Comment added) made by wek_ You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=2740884&group_id=599 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: mcs51(8051) target Group: known bugs Status: Open Resolution: None Priority: 5 Private: No Submitted By: Frank Cornett (fcornett) Assigned to: Nobody/Anonymous (nobody) Summary: Incorrect assignment in array of structs Initial Comment: Code: #include "dp8051.h" //Define 8051 ports typedef struct{ unsigned char Fail; unsigned char Route; unsigned char xor; unsigned char RX_invert; } DT_SERDES_PORT; __xdata DT_SERDES_PORT doors[3]; void main(void){ unsigned char door; for (door = 0x01; door <= 0x02; door++){ doors[door].Route = 0x24; } for (door = 0x01; door <= 0x02; door++){ P2 = 0xAA;//Set 8051 ports to trigger display in Verilog P1 = doors[door].Route; P0 = door; } P3 = 0xA5;//Trigger simulation finish } This code is compiled and executed with a Verilog simulation of an 8051 processor. The output is: P0, P1, P2 = 01, 24, aa P0, P1, P2 = 02, 00, aa Note that the second element in the doors array is not assigned correctly. This behavior appears to be associated with loop reversal, since setting the compiler option --noloopreverse results in the following output: P0, P1, P2 = 01, 24, aa P0, P1, P2 = 02, 24, aa I've also observed that if the two for loops are combined into a single loop, the correct assignment occurs. Please refer to the attached tarball for more details. Thanks, Frank Cornett Cray Inc. ---------------------------------------------------------------------- Comment By: wek (wek_) Date: 2009-06-07 16:00 Message: Robert, once you are in it, please check out and fix also the inadequate tests for case INC_OP: and case DEC_OP: just a few lines below the case for PTR_OP you have just patched. The regression test function could include perhaps the following function: void bar(void) { char i; for (i = 1; i <= 2; i++) doors[i].Route++; } Jan Waclawek ---------------------------------------------------------------------- Comment By: Robert Larice (rlar) Date: 2009-06-07 15:27 Message: I propose the following patch to fix this https://sourceforge.net/tracker/?func=detail&aid=2802510&group_id=599&atid=300599 ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=100599&aid=2740884&group_id=599 |