I'm using an ST72F264 and I'm programming in C with Metrowerks Codewarrior version 4.2.5.766. I'm writing this instruction: for(i=0;i{buff_data[i]=buff_rx[i+6];} where i is a local variable and data_lenght, buff_data[], buff_tx[] are declared in the file var.h that is included in main.c with: #include ''var.h'' When I debug with ST7 Visual Debug inDART-STX v.2.02 based on STVD 2.5.3, I receive this message from the output window: Program received signal SIGTRAP, Trace/breakpoint trap. _Startup () at START07.C:84 84 RSP and the debug is stopped. If I modify the C code in: j=data_lenght; for(i=0;(!((j-i)==0));i++) {buff_data[i]=buff_rx[i+6];} where i,j are local variables and buff_data[], buff_tx[] are declared in the file var.h, all works correctly. The disassembly window in the first case is: for(i=0;i0xf6fb 0x3FB9 CLR i 0xf6fd 0x2002 JRT 0xf701 buff_data[i]=buff_rx[i+6]; 0xf6ff 0xAD6B CALLR 0xf76c for(i=0;i0xf701 0xB6B9 LD A,i 0xf703 0x9097 LD Y,A 0xf705 0x5F CLR X 0xf706 0x4F CLR A 0xf707 0xCDFF1C CALL _CMPS 0xf70a 0x25F3 JRC 0xf6ff 0xf70c 0x2607 JRNE 0xf715 0xf70e 0x909F LD A,Y 0xf710 0xC1013A CP A,0x013a 0xf713 0x25EA JRC 0xf6ff while in the second case: j=data_lenght_ind; 0xf6bf 0xC6013A LD A,0x013a 0xf6c2 0xB7BA LD j,A for(i=0;(!((j-i)==0));i++) 0xf6c4 0x3FB9 CLR i 0xf6c6 0x2003 JRT 0xf6cb buff_data[i]=buff_rx[i+6]; 0xf6c8 0xCDF76C CALL 0xf76c for(i=0;(!((j-i)==0));i++) 0xf6cb 0xB6BA LD A,j 0xf6cd 0xBEB9 LD X,i 0xf6cf 0xB0B9 SUB A,i 0xf6d1 0xB7B8 LD _spill_1,A 0xf6d3 0x4F CLR A 0xf6d4 0xA200 SBC A,#0x00 0xf6d6 0xBAB8 OR A,_spill_1 0xf6d8 0x26EE JRNE 0xf6c8 I noted that all the problems are resolved if the function _CMPS called at address 0xf707 in the first case is not used. Can you help me? My main.prm file is: NAMES END SECTIONS MY_ZRAM = NO_INIT 0x0080 TO 0x00c5; MY_RAM = READ_WRITE 0x00c6 TO 0x14f; MY_ROM = READ_ONLY 0xF000 TO 0xFFDF; PLACEMENT DEFAULT_ROM, ROM_VAR, STRINGS INTO MY_ROM; _ZEROPAGE, DEFAULT_RAM INTO MY_RAM; _OVERLAP INTO MY_ZRAM; END STACKTOP 0x17F VECTOR ADDRESS 0xFFFE _Startup VECTOR ADDRESS 0xFFF2 INT_TIMER_A VECTOR ADDRESS 0xFFF0 REAL_TIME Thanks.
the first instruction doesn't make a sense to me. Think, there's something missing in your description. Also I can't understand the compiler result. If I apply the Metroworks compiler to your first instruction I get some error messages on the syntax.... WoRo
although I can't reproduce your error - it is good programming style to define variables like 'i' and 'data_length' as 'unsigned ...'. Using 'unsigned char' would prevent the compiler from calling the function _CMPS which is a signed comparison function. WoRo
Thanks for the informations but all variables are declared as unsigned char . If I do a cast to unsigned char before the 'for' instruction the result is the same and the problem is not resolved too.
the only option-part I have regards the memory model and is: -Ml (large memory model) I don't have the ~.lst file because I use a previous version of the compiler. I only have a ~.map file and others ~.o files. Thanks
I am using exactly the same version as you of the MetroWerks CodeWarrior and can get ~.lst-files. To get them you have to set the option 'Generate Listing File' of the compiler: Follow the menue Edit & ''project'' Settings [Alt+F7] & Compiler for ST7 - and then select Options & Output & [x] Generate Listing File You will find the ~.lst-file in the bin-folder when compiled. BUT...: As you have got the disambly window, there is all the information you/I need. Only the text has been scrambled by the text-converter of this forum - but that should be no problem any more. Anyway, studying your disambly window again and again I come to the conclusion, that the type of 'i' or/and 'data_lenght' can not be 'unsigned char' at the time it is used there. Please recheck your code thoroughly. Greetings WoRo