Jump to content
Sign in to follow this  
bongo

Compiler Error: Jump To Wrong Page ??

Recommended Posts

I have code for a 16F876, using the program memory up to 0x1ee0.

the PCLATCH bits seem to get set wrong prior to a goto jump.

code:

 

180a  300f  movelw D'15'

180b  1283  bcf STATUS, RP0

180c  1703  bsf STATUS, RP1

180d  026b  subwf _i_LcdUpdate, W

180e  1d03  btfss STATUS, Z

180f  2817  goto label_0298

 

this goto jumps to address 1017, as the two msb's are preset to 10.

label_0298 is on address 1817, i.e. line 180b should read:

 

180b  xxxx  bsf STATUS, RP0

 

i.e. bit11 should get set instead of cleared.

 

am i wrong to think that this is a compiler error?

 

please help!

 

When i had only code up to about address 0x1c00, i.e. this procedure was located on a lower address, compilation was ok.

 

i use c2c 4.0.7e + mpasm 3.10

Share this post


Link to post
Share on other sites
Guest Pavel
i use c2c 4.0.7e + mpasm 3.10

Please try same C code with the latest compiler version 4.6

 

Regards,

Pavel

Share this post


Link to post
Share on other sites

ok, i tried...

i now downloaded version 4.60...to get the message 'too many input files'.

(the project consists of 12 .c files)

is there some kind of limitation?

 

btw:

i experimented further with version 4.0.7e:

when changing the order, the part of the program, that went wrong before, is now ok...

...but i see a good chance, that some other part, now located at the end of the program, has now been translated wrong, but i cannot recognize this yet, as i am still debugging this part of the code...

 

so is think, this is no final solution yet...

please help!

thanks!!

tino

Share this post


Link to post
Share on other sites
Guest Pavel
i now downloaded version 4.60...to get the message 'too many input files'.

(the project consists of 12 .c files)

is there some kind of limitation?

Hmmm, this is a good one. Let me check this. I'll do it tonight.

 

Regards,

Pavel

Share this post


Link to post
Share on other sites
Guest Pavel

The compiler updates 4.6.1 (C2C++ 1.6.1) that fix both the 'lost' .PAT scripts and the limit on the number of input files have been posted on the compiler http://www.picant.com/c2c/download.html page.

Please download and unzip the update into the same directory where you installed the C2C-plus (or C2C++) compiler.

 

Regards,

Pavel

Share this post


Link to post
Share on other sites

i tried version 4.6.1:

the result in this specific situation is better, but not objectively compareable:

the new release of the compiler does optimization about 100bytes better, i.e. the part of code, resulting in problems, is no longer located slightly above 0x1800, but now slightly below 0x1800.

therefore, setting the pclatch to '10' is ok.

i think i'll gonna try to add some code to get the whole thing a few memory addresses up, to check if pclatch is changed to '11' when above 0x1800.

to be shure that this problem is solved, it would be nice to know if you really have fixed this problem, or if it may randomly appear again.

thanks!

tino

Share this post


Link to post
Share on other sites

as you can see from the code snippet below, the problem is not solved in 4.6.1:

 

1803   160A    10558         bsf PCLATH, 4

                   10559         ;;;;;;;; if (i == 15) {

1804   300F    10560         movlw D'15'

1805   1283    10561         bcf STATUS, RP0

1806   1703    10562         bsf STATUS, RP1

1807   025B    10563         subwf _i_LcdUpdate, W

1808   1D03    10564         btfss STATUS, Z

1809   2811    10565         goto label_0298

                   10566         ;;;;;;;; LcdSetPos(40);

180A   3028    10567         movlw D'40'

180B   00D9    10568         movwf param00_LcdSetPos

180C   118A    10569         bcf PCLATH, 3

180D   120A    10570         bcf PCLATH, 4

180E   20BB    10571         call _LcdSetPos

180F   118A    10572         bcf PCLATH, 3

1810   160A    10573         bsf PCLATH, 4

                   10574         ;;;;;;;; }

                   10575         ;;;;;;;; }

1811              10576 label_0298

                   10577         ;;;;;;;;}

1811   1283     10578         bcf STATUS, RP0

 

instead of jumping from address 1809 to address 1811 (label_0298), the jump goes to address 1011, which is obviously wrong.

as i'm no pic assembler crack, i tried the whole thing in the simulator, and - the jump goes to 1011.

 

i think this must be a bug in the compiler. isn't it?

thanks for your help!

tino

Share this post


Link to post
Share on other sites

now, i have analyzed the code, generated by the 4.6.1 compiler:

i compiled always about the same code, with identical compiler settings, with always 1 instruction added in the beginning of the program. so, the analyzed part is always moved a few instructions within the memory.

so i can see, that the compiler did it's work not always very well. to me, this looks like making errors in the optimization, when sometimes removing the wrong instructions.

i.e. the pclatch is set twice in series, without any jump in between.

so the first setting, which is never used, could be removed. instead of this, sometimes, the second one, which is correct for the next jump, is removed.

when the none of them is removed, or the whole code is shifted further up, it works.

 

i can send you the code snippets or put them here, if this helps.

tino

Share this post


Link to post
Share on other sites
Guest Pavel

I didn't look into this issue while making 4.6.1 I need your sources to be able to reproduce and fix the problem. Please mail me:

 

- zipped  content of your project directory

- zipped content of your compiler scripts directory

- compile/optimization settings

 

Regards,

Pavel

Share this post


Link to post
Share on other sites
Guest pic-dude

I think if you add the following line

 

pagsel  

 

before each goto or call, the assembler will handle the page selection for you automatically.

 

pic-dude

Share this post


Link to post
Share on other sites
Guest Pavel
I think if you add the following line

 

pagsel 

 

before each goto or call, the assembler will handle the page selection for you automatically.

 

pic-dude

But I don't want to have page selection before every goto and call. There is lot of gotos that target the same page and don't need any page selection.

 

Regards,

Pavel

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...