Jump to content
Sign in to follow this  
DoubleA

C2c++ Paging Bug With Code Size 2k+

Recommended Posts

Bug description:

Complied code does not work correctly, when assembled code is near 2K or over in size. With optimization on max. code fits within 2K , the code work fine. Turn all optimization off the code is over 2K, and code does not work, starts running random pieces of the code. I think program memory page selecting is not correctly.

 

Steps to reproduce:

As long as the complied code is at least 2K or over the code will fail to work correctly, if at all. Even if the optimization is fully on or off. My current and previous project have accessed const char *”xxx” all the way through the code, I think this maybe a caused.

 

I will try debug assembled code in few weeks, (Going to do the project’s PCB) with a Microchip ICD2.

 

Pavel – I can send you code if want ?

 

Target: PIC16F88 & PIC16F628

IDE version: 5.6

Compiler: Compiler C2C++

Compiler version: 5.6e

 

OS: Windows 2000 SP4

 

Comments:

Has anyone had this problem ?

java script:emoticon(':o')

smilie

Share this post


Link to post
Share on other sites

I'm not aware of any paging problems in C2C++ compiler. Please send me a project that exibits this error and description how to reproduce it.

 

Regards,

Pavel

Share this post


Link to post
Share on other sites

I have the same problem with the 16f876.

 

If a function is in the code bank 1, the change page bank operation is referred to bank 0.

 

This is the asm code generated by c2c (resumed). if you examine the sequence for the call to _lcd_m_config, you can see that ther is not the changes to correct pages. (Left column is the position memory)

 

This is the bank 0 ;-)

...

002A 00153 _delay_ms

002A 2FF8 00154 goto _delay_ms__code

002B 00155 _lcd_m_config

002B 2809 00156 goto _lcd_m_config__code

002C 00157 _inicia

002C 158A 00158 bsf PCLATH, 3

002D 120A 00159 bcf PCLATH, 4

...

 

00AE 1D03 00314 btfss STATUS, Z

00AF 28B3 00315 goto label_0110

00B0 00316 label_0111

00B0 202B 00317 call _lcd_m_config

00B1 118A 00318 bcf PCLATH, 3

00B2 120A 00319 bcf PCLATH, 4

00B3 00320 label_0110

 

...

This is the bank 1 ;-)

 

0809 02393 _lcd_m_config__code

0809 1283 02394 bcf STATUS, RP0

080A 1303 02395 bcf STATUS, RP1

080B 01D7 02396 clrf _tecla_lcd_m_config

080C 2016 02397 call _lcd_init

080D 118A 02398 bcf PCLATH, 3

080E 120A 02399 bcf PCLATH, 4

 

thank you for your good work.

Andres.

Share this post


Link to post
Share on other sites

I found a problem in the assembled code, used MPLAB simulator.

 

The complier code generated for the const char *"xxx" strings is generating the wrong offsets to some of the strings, this because when the a project code size is over a 2k page, the complier adds page switching code, but const char code account for extra two instructions for this therefore the address constant offset to the strings are incorrect by 2.

 

I found with my project in the simulator that code ends up in a 4 instruction endless loop, because of this.

 

Here is the code exmaple

 

from main asm code

;;;;;;;; if( string_match(manager) == 1)//check for " > " manager prompt

movlw D'9' ;; incorrect offset!!! Should be D’11’

movwf param00_string_match

call _string_match

bcf PCLATH, 3

bcf PCLATH, 4

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

 

const_param__code

movwf __const_ptr__W

movf PCLATH, W

movwf __const_ptr__PCLATH

movf __const_ptr__W, W

addlw LOW($+D'7' )

movlw HIGH($+D'6' )

btfsc STATUS, C

addlw 1

movwf PCLATH

movf __const_ptr__W, W

addwf PCL, F

movf __const_ptr__param00, W ;;access arr020 string

addlw LOW(arr020+D'1' ) ;; , offset to this address is 0 works fine

movlw HIGH(arr020+D'1' )

btfsc STATUS, C

addlw 1

movwf PCLATH

movf __const_ptr__param00, W

call arr020

bcf PCLATH, 3

bcf PCLATH, 4

goto const_ptr_finish

movf __const_ptr__param00, W ;;access arr000 string

addlw LOW(arr000+D'1' ) ;; , offset to this address is wrong off by -2

movlw HIGH(arr000+D'1' ) ;;addresses “bcf PCLATH, 4” two lines up

btfsc STATUS, C

addlw 1

movwf PCLATH

movf __const_ptr__param00, W

call arr000

bcf PCLATH, 3

bcf PCLATH, 4

goto const_ptr_finish

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...