Forum : ST7/STM8
Original Post
Post Information | Post |
---|---|
April 10, 2010 - 6:17am
|
Hi, I may have run into a compiler bug accessing 32-bit integers in an array within a struct. In the code below, the last two bytes of the variable are written with the contents of the Y register instead of the X register, but Y is never loaded with a valid value. Here is a sample main.c: #pragma PREPRINT typedef struct { unsigned long ll[2]; } CANRxFrame; void main(void) { CANRxFrame f; f.ll[1] = 0x00FF00FF; while(1); } Here is a sample main.lst: RCSTM8 COMPILER V2.26.09.317, MAIN 04/09/10 21:13:02 QCW(0x00963FA0) RCSTM8 COMPILER V2.26.09.317, COMPILATION OF MODULE MAIN OBJECT MODULE PLACED IN C:\Documents and Settings\Brian\My Documents\stm8\rctest\main.obj COMPILER INVOKED BY: QUIET GENERATEDEPFILE CODE DB OJ(C:\Documents and Settings\Brian\My Documents\stm8\rctest\main.obj) PR(C:\Documents and Settings\Brian\My Documents\stm8\rctest\main.lst) PIN(C:\Program Files\Raisonance\Ride\Inc;C:\Program Files\Raisonance\Ride\Inc\ST7) STM8(SMALL) O(3,SIZE) NOINITSTATICVAR SMALLOBJECT ET(INT) stmt level source 1 #pragma PREPRINT 2 3 typedef struct { 4 unsigned long ll[2]; 5 } CANRxFrame; 6 7 void main(void) { 8 1 CANRxFrame f; 9 1 f.ll[1] = 0x00FF00FF; 10 1 while(1); 11 1 } 12 RCSTM8 COMPILER V2.26.09.317 ASSEMBLY LISTING OF GENERATED OBJECT CODE ; FUNCTION main (BEGIN) ; SOURCE LINE # 7 0000 5208 SUB SP,#008H ; SOURCE LINE # 9 0002 AE00FF LDW X,#000FFH 0005 1F05 F LDW (005H,SP),X 0007 1707 F LDW (007H,SP),Y 0009 ?WHILE_0001: ; SOURCE LINE # 10 0009 20FE JRA ?WHILE_0001 ; f struct (size=8-Alg)(size=8-Alg). variable in AUTO ; FUNCTION main (END) RCSTM8 COMPILER V2.26.09.317 MODULE INFORMATION: STATIC OVERLAYABLE CODE SIZE = 11 ---- CONSTANT SIZE = ---- ---- DATA SIZE = ---- ---- PAGE0 SIZE = ---- ---- BIT SIZE = ---- ---- END OF MODULE INFORMATION. RCSTM8 COMPILATION COMPLETE. 0 WARNING, 0 ERROR |
Hi Brian,
It is an optimization issue.
The workaround is to temporary switch it off with #pragma ot(6) and to switch it on with #pragma ot(7)
Otherwise you can contact our support (support at raisonance.com) and we'll send you a correct compiler.
Stéphane