Jump to content
Sign in to follow this  
vbk

Const string again

Recommended Posts

Hello!

 

My last message seemed to dissapear!

Ok, I try again!

 

I have problem with const strings.

And I have tried the scripts without luck.

The scripts seems to do some fix in the const_param__code section.

But what I can see so is the problem at the call of the print function (call to the const string).

It works good when not having so many strings.

In the example below you can se that movlw D'256' tries to put a number bigger than 8 bits into the 8bit W register.

And this will do a jump not to the right conststring!??!

 

Do sombody have a solution for this problem?

I am new on this and do not know how to fix it.

 

Best regards vbk

 

 

 

;;;;;;;;         	 printf("debug - Debug info\n\r");
movlw D'248'
movwf param00_printf
call _printf
bcf PCLATH, 3
bcf PCLATH, 4
;;;;;;;;         	 printf("temp - Temperature DS1820\n\r");
movlw D'256'
movwf param00_printf
call _printf
bcf PCLATH, 3
bcf PCLATH, 4
;;;;;;;;         	 printf("test - Finns ej!\n\r");
movlw D'264'
movwf param00_printf
call _printf
bcf PCLATH, 3
bcf PCLATH, 4

Share this post


Link to post
Share on other sites

Is it a compiler error to produce

asembler instructions like:

 

movlw D'264'

 

(The w-register is 8 bits wide?)

And that then produces the "many const string" problem?

Is or will there be any fix for this problem when you have man const strings?

Someone that have managed to use more than 25-30 const strings without having the problem with wrong program jumps?

Share this post


Link to post
Share on other sites

I've faced this problem. This is what i have found...

The problem lies here:

0100                  00612 const_param__code

0100   018A           00613         clrf PCLATH

0101   0782           00615         addwf PCL, F

0102   087B           00614         movf _const_ptr_param00, W

0103   3ED4           00617         addlw LOW(arr008+1)

0104   3001           00618         movlw HIGH(arr008+1)

 

etc..

 

if the const_param_code is called and the const string code lies across a 0xff - 0x100 boundary the recalculated program counter (addwf PCL,F) will be wrong because PCL is only eight bits.  if this is the case insert this code between the clrf and addwf

 

 

addlw LOW($+4)

btfsc STATUS, C

incf PCLATH,f

addlw -(LOW($+1))

 

 

however!!! if the start of the code (as in my piece) is past 0x100 but not across a boundary insert this code

 

 

incf PCLATH,f

 

 

bascially the PCLATH has to be set up before the recalculated program counter jump, 0 for 00-ff 1 for 100 -1ff, 2 for 200-2ff etc.  You can use scripts to do this.

hope this help

Share this post


Link to post
Share on other sites
Guest Pavel

Can anybody summarise all const strings topics (including the previous ones) and propose some universal code solution that will handle unlimited const strings table? Once this is done I'll add it to the compiler.

 

Regards,

Pavel

Share this post


Link to post
Share on other sites

i haven't tested this in all situations but it should work, however it does use a variable.

const_paramconst_ptr__param00, W
        .....

Share this post


Link to post
Share on other sites
Guest Pavel
i haven't tested this in all situations but it should work, however it does use a variable.

const_paramconst_ptr__param00, W
        .....

Sorry I don't understand what you want to say.

 

Regards,

Pavel

Share this post


Link to post
Share on other sites

sorry, this forum does weird things when two uderscores are used together, i'll try again

const_param_code
movwf w_temp	
movlw HIGH($)	
movwf PCLATH
movf w_temp,w

addlw LOW($+4)
btfsc STATUS, C
incf PCLATH,f
movf w_temp,w

addwf PCL, F
movf _const_ptr_param00, W

Share this post


Link to post
Share on other sites

mind you that doesn't help with having more than 32 (256/8)  strings, that would require a complete rewrite of the const string code. Need to find a way to give each string a sequential index number instead of multiples of 8, preferrably without doing extra subroutine calls.  tricky.

Share this post


Link to post
Share on other sites

I've tested this at all the different "org's" and it works, I haven't tested with 256 different strings but it should be ok.

jess

         include "p16F876.inc"

str_idx        equ 40
str_num equ 41
;-------------------------------
       org 0
       clrf PCLATH
       goto main
;-------------------------------
       org 4
       retfie
;-------------------------------
       org H'fc'
       org H'105'
       org H'1fe'
       org H'2ef'
       org H'2df'

const_str_code
       movwf str_num

       movlw HIGH($+7)
       movwf PCLATH
       movlw LOW($+5)
       addwf str_num,w
       btfsc STATUS,C
       incf PCLATH,f

       movf str_num,w
       addwf PCL, F        
       goto arr000
       goto arr001
       goto arr002


arr000  movlw HIGH($+7)
       movwf PCLATH
       movlw LOW($+5)
       addwf str_idx,w
       btfsc STATUS,C
       incf PCLATH,f

       movf str_idx, W
       addwf PCL, F
       retlw D'83'
       retlw D'84'
       retlw D'79'
       retlw D'80'
       retlw D'0'

arr001  movlw HIGH($+7)
       movwf PCLATH
       movlw LOW($+5)
       addwf str_idx,w
       btfsc STATUS,C
       incf PCLATH,f

       movf str_idx, W
       addwf PCL, F
       retlw D'82'
       retlw D'83'
       retlw D'84'
       retlw D'32'
       retlw D'0'

arr002  movlw HIGH($+7)
       movwf PCLATH
       movlw LOW($+5)
       addwf str_idx,w
       btfsc STATUS,C
       incf PCLATH,f

       movf str_idx, W
       addwf PCL, F
       retlw D'83'
       retlw D'69'
       retlw D'78'
       retlw D'68'
       retlw D'0'

;-------------------------------

main    movlw 3                                ;index
       movwf str_idx
       movlw 1                                ;array number
       call const_str_code
    
       end

Share this post


Link to post
Share on other sites
Guest Pavel

I'm looking for couple of people who are willing to do a quick test of the compiler with a new const string implementation. If you are such a person and you have big enough project that uses many const strings than send me a mail to support@picant.com

 

Regards,

Pavel

Share this post


Link to post
Share on other sites
Guest Pavel

The compiler from PiAntIDE 5.0 beta 2 implements new const string code generation scheme for PIC16 targets that with the limit of 84 strings.

 

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