CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug Reports on this forum. Send them to support@ccsinfo.com

C statement placed wrong in the lst file... v5.95 & 5.94

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
hmmpic



Joined: 09 Mar 2010
Posts: 245
Location: Denmark

View user's profile Send private message

C statement placed wrong in the lst file... v5.95 & 5.94
PostPosted: Thu Sep 17, 2020 12:55 am     Reply with quote

C statement placed wrong in the lst file...

Small test c file and the generated lst file from version 5.95 and my old version 5.66.
In the latest 5.95 (and version 5.94 and maybe other) the c statement and generated assembler code are placed wrong.

Right: 5.66
Left: 5.95

Link to a pic.
http://s000.tinyupload.com/?file_id=03375643534854097575


Problem is random, some file look ok and other have the placement error...

Anyone see the same?
Ttelmah



Joined: 11 Mar 2010
Posts: 16408

View user's profile Send private message

PostPosted: Thu Sep 17, 2020 1:09 am     Reply with quote

The 'source line' placement, is only really for guidance. So it is deciding here
to put it after the generated code, instead of before. Not really important.
Why are you worried about this?. Sometimes the lines are miles away from
the actual assembler code.
Must admit it'd seem to make more logic to keep it at least roughly in
order, but it might actually give some quite interesting 'clues' about how
the optimiser approaches things.
hmmpic



Joined: 09 Mar 2010
Posts: 245
Location: Denmark

View user's profile Send private message

PostPosted: Thu Sep 17, 2020 1:22 am     Reply with quote

It have worked nice in my .66.
You cant compare file if the statement are placed random.
The included compare tools in the pcw compiler cant too.
Must hard to read in fast view when it is placed in random...
Try to remove all \n and space and other format guideline from a c file, most hard to read but it work:-)
PCM programmer



Joined: 06 Sep 2003
Posts: 21227

View user's profile Send private message

PostPosted: Thu Sep 17, 2020 1:23 am     Reply with quote

What PIC ? I made your .LST fragments into a source file and it works
fine with an 18F46K22. All addresses are in order:
Code:

CCS PCH C Compiler, Version 5.095, xxxxx     17-Sep-20 00:17

00000:  GOTO   MAIN
....................
.................... #include <18F46K22.h>

.................... #device PIC18F46K22
....................
.................... #list
....................
.................... #use delay(internal=4M)
.................... #use rs232(baud=9600, UART1, ERRORS)
....................
.................... void StaticVar()
00004:  MOVLW  10
00006:  MOVWF  i8_NoStatic
.................... {
.................... int8 i8_NoStatic=0x10;
.................... static int8 i8_Static=0x20;
....................
.................... i8_NoStatic=0x11;
00008:  MOVLW  11
0000A:  MOVWF  i8_NoStatic
.................... i8_Static=0x21;
0000C:  MOVLW  21
0000E:  MOVWF  i8_Static
00010:  GOTO   005A (RETURN)
.................... }
....................
.................... void Calc()
.................... {
.................... const int8 MaxAD=245;
.................... const int8 Decimal=MaxAD * 0.5;
.................... const int16 StateStep=0x20;
.................... static int8 stateold=255;
.................... int8 ad,state;
....................
.................... if(ad > MaxAD) ad = MaxAD;
00014:  MOVF   ad,W
00016:  SUBLW  F5
00018:  BC    001E
0001A:  MOVLW  F5
0001C:  MOVWF  ad
0001E:  GOTO   005C (RETURN)
....................
.................... }
....................
.................... //==================
.................... void main()
00022:  CLRF   TBLPTRU
00024:  BCF    RCON.IPEN
00026:  MOVLW  50
00028:  MOVWF  OSCCON
0002A:  BCF    OSCTUNE.PLLEN
0002C:  BCF    OSCTUNE.INTSRC
0002E:  CLRF   rs232_errors
00030:  BCF    BAUDCON1.BRG16
00032:  MOVLW  19
00034:  MOVWF  SPBRG1
00036:  MOVLW  A6
00038:  MOVWF  TXSTA1
0003A:  MOVLW  90
0003C:  MOVWF  RCSTA1
0003E:  MOVLB  F
00040:  CLRF   x38
00042:  CLRF   x39
00044:  CLRF   x3A
00046:  CLRF   x3B
00048:  CLRF   x3C
0004A:  CLRF   CM2CON1
0004C:  CLRF   CM2CON0
0004E:  CLRF   CM1CON0
00050:  MOVLW  20
00052:  MOVWF  05
00054:  SETF   06
.................... {         
.................... StaticVar();
00056:  MOVLB  0
00058:  BRA    0004
.................... Calc();
0005A:  BRA    0014
....................
....................
.................... while(TRUE);
0005C:  BRA    005C
.................... }
....................
0005E:  SLEEP

Test program:
Code:
#include <18F46K22.h>
#use delay(internal=4M)
#use rs232(baud=9600, UART1, ERRORS)

void StaticVar()
{
int8 i8_NoStatic=0x10;
static int8 i8_Static=0x20;

i8_NoStatic=0x11;
i8_Static=0x21;
}

void Calc()
{
const int8 MaxAD=245;
const int8 Decimal=MaxAD * 0.5;
const int16 StateStep=0x20;
static int8 stateold=255;
int8 ad,state;

if(ad > MaxAD) ad = MaxAD;
}

//======================================
void main()
{         
StaticVar();
Calc();

while(TRUE);
}
hmmpic



Joined: 09 Mar 2010
Posts: 245
Location: Denmark

View user's profile Send private message

PostPosted: Thu Sep 17, 2020 1:29 am     Reply with quote

I see the same on some file no problem and other have problem...

Test code and PIC.

Code:

//#include <18f26k22.h>
#include <12f1840.h>

#use delay(clock=8M,int)
#ID CHECKSUM_PROGRAM
#ID CHECKSUM



void StaticVar(){
 int8 i8_Nostatic=0x10;
 static int8 i8_Static=0x20;
 
 I8_Nostatic=0x11;
 i8_Static=0x21;
}



void Calc(){
 const int8 MaxAD = 245;//ad res 0..255 but pot only get about 245 for max.
 const int8 Decimal= MaxAD*0.5;//245*0,5=122 samme som at lægge 0.5 til.
 const int16 StateStep=20;//max step
 
 static int8 stateold=255;
 int8 ad,state;
   
 if (ad>MaxAD) {ad=MaxAD;}
 
 state = (ad*StateStep+Decimal)/MaxAD;//245*0,5=122 samme som at lægge 0.5 til.
}


void main(void){
 StaticVar();
 
 Calc();
}
hmmpic



Joined: 09 Mar 2010
Posts: 245
Location: Denmark

View user's profile Send private message

PostPosted: Thu Sep 17, 2020 1:38 am     Reply with quote

When using the #ID CHECKSUM_PROGRAM then the problem is there!
Ttelmah



Joined: 11 Mar 2010
Posts: 16408

View user's profile Send private message

PostPosted: Thu Sep 17, 2020 1:58 am     Reply with quote

Question.. How can you have two #ID statements?. Makes no sense.
Presumably the second will override the first.

However it looks as if when you specify #ID CHECKSUM_PROGRAM, the
compiler is re-ordering the fie when it calculates the checksum. :(
hmmpic



Joined: 09 Mar 2010
Posts: 245
Location: Denmark

View user's profile Send private message

PostPosted: Thu Sep 17, 2020 2:08 am     Reply with quote

Right!
The c code file are for error testing only!
It was me reporting some of the bug fix for the 5.95 and one fix was the #ID statement for checksum. Therefore not a production file just for compiler testing.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group