Jump to content
Sign in to follow this  
PhracturedBlue

'rom' Command Not Working In Boostc

Recommended Posts

I am trying to use rom storage with boostC, but it doesn't work.

This is for a 16F88 processor

 

#include <system.h>
rom char *ptr="This is a very long text string";
void main()
{
}

 

and the resulting asm:

	ORG 0x00000000
GOTO	_startup
ORG 0x00000003
main
; { main; function begin
RETURN
; } main function end

ORG 0x00000004
_startup
MOVLW 0x00
BCF STATUS, RP0
BCF STATUS, RP1
MOVWF gbl_ptr
BCF PCLATH,3
BCF PCLATH,4
GOTO	main
END

Any ideas?

Share this post


Link to post
Share on other sites

PhracturedBlue,

 

The unreferenced string is optimised away!

Refer to it in the code, then you will see what you expect.

 

Regards

Dave

Share this post


Link to post
Share on other sites
PhracturedBlue,

 

The unreferenced string is optimised away!

Refer to it in the code, then you will see what you expect.

 

Regards

Dave

Sorry, that was a poor example. Here is one which doesn't actually work:

#include <system.h>
rom char *ptr="This is a very long text string";
void main()
{
	char buf1;
       char* buf;
       buf=ptr+5;
       buf1=buf[0];
}

The asm looks like:

main
; { main; function begin
MOVLW 0x05
BCF STATUS, RP0
BCF STATUS, RP1
ADDWF gbl_ptr, W
MOVWF CompTempVar36
MOVF gbl_ptr+D'1', W
MOVWF CompTempVar37
BTFSC STATUS,C
INCF CompTempVar37, F
MOVF CompTempVar36, W
MOVWF main_1_buf
MOVF CompTempVar37, W
MOVWF main_1_buf+D'1'
BCF STATUS,IRP
BTFSC main_1_buf+D'1',0
BSF STATUS,IRP
MOVF main_1_buf, W
MOVWF FSR
MOVLW 0x00
ADDWF FSR, F
MOVF INDF, W
MOVWF main_1_buf1
RETURN
; } main function end

ORG 0x0000001A
_startup
MOVLW 0x00
BCF STATUS, RP0
BCF STATUS, RP1
MOVWF gbl_ptr
BCF PCLATH,3
BCF PCLATH,4
GOTO	main
END

 

no reference to rom_get or the string. Are pointers to rom objects not supported?

What I am tyring to do is emulate this:

rom char *[] str = {"Test1", "Test2"};
...
my_fun(str[i]);

which doesn't work, because roms can only be strings. So I do it this way:

rom char* str = "Test1" "Test2"; //strings have a fixed length
...
char *ptr=str+(5*i);
my_fun(ptr);

Share this post


Link to post
Share on other sites

PhracturedBlue,

 

Try this for a start:

 

#include <system.h>
rom char *ptr="This is a very long text string";
void main()
{
      char buf1;
      buf1 = ptr[ 0 ];
}

 

Your code should have generated a compiler warning or error, because rom character pointers are a different data type to regular character pointers.

 

Regards

Dave

Share this post


Link to post
Share on other sites
PhracturedBlue,

 

Try this for a start:

...

yes that works.

Your code should have generated a compiler warning or error, because rom character pointers are a different data type to regular character pointers.

well no error/warning during comiling. During linking I get this:

 

Warning: cannot symbolize, no COFF equivalent data type for variable: 'ptr'

 

which is probably telling me there is a problem, though I still get 'Success' so I didn't notice this at first. Can you think of a better way to implement my example? I have a large number of strings, so it will waste a lot of ram if I need to define them each individually (each string ends up as its own variable, and takes a byte). My thoughts at the moment are to build my own jump-table rom implementation in ASM for my array of strings.

Share this post


Link to post
Share on other sites

PhracturedBlue

 

Warning: cannot symbolize, no COFF equivalent data type for variable: 'ptr'

 

This message means that symbol 'ptr' cannot be monitored when running the debugger, because the COFF file format used for the compiler/linker output does not support rom types (it is not a standard data type).

 

The code is successfully created, so should function as expected.

 

Don't try to build you own jump table. As code placement changes as you modify your code, the jump table will move around. Linker also doesn't like processing code that modifies PC (other than its own generated code).

 

Regards

Dave

Share this post


Link to post
Share on other sites

PhracturedBlue,

 

What about code like this.

I use the contiguation character so that I can spread strings across multiple lines.

 

#include <system.h>
rom char *msg ="/
string1\0/
string2\0/
string3\0/
string4\0/
string5\0/
";

void main()
{    
char i, c;
bit bad = false;
   for( i = 0; i < 5; i++ )
{
	char strNo = i;

	char strIndex = (strNo * 10) + 2;

	c = msg[ strIndex ];
	if( c != 's' )
		bad = true;
}

while( 1 );
}

 

 

Please note, this code has high lighted another slight problem.

The continution character (0x2F) and the newline (0x0A) is included in the string generated in ROM when they should not be. This will be fixed in a future version, so this code will become broken until the unless the index calculation (strIndex) is changed "* 10" is change to "* 9", and the + 2 removed.

 

Best therefore to have the string all on one line for now:

rom char *msg ="string1\0string2\0string3\0string4\0string5\0";

 

Regards

Dave

Edited by Dave

Share this post


Link to post
Share on other sites
This message means that symbol 'ptr' cannot be monitored when running the debugger, because the COFF file format used for the compiler/linker output does not support rom types (it is not a standard data type).

 

The code is successfully created, so should function as expected.

So this is definitely a bug (using the ptr method) since the code compiles cleanly with no relevant warning/error, and the rom data is not getting stored. The code in my second post can be used as a test case.

 

I tested your example, and it seems to work fine. Thanks. I'm so used to working with pointers, I didn't think of that.

 

I may actually use the 'flash read' method specified in the 16f88 datasheet instead though, since I can fit 2 ascii characters into a 14bit word, it will take half as much ROM for my string.

Share this post


Link to post
Share on other sites

Is there a solution or workaround for this problem yet?

 

The following code compiles, but with the COFF message, the strings don't appear on the LCD though.

 

rom char * T_MONDAY = "Monday";
rom char * T_TUESDAY = "Tuesday";
rom char * T_WEDNESDAY = "Wednesday";
rom char * T_THURSDAY = "Thursday";
rom char * T_FRIDAY = "Friday";
rom char * T_SATURDAY = "Saturday";
rom char * T_SUNDAY = "Sunday";

char* Week[]= { T_SUNDAY, T_MONDAY, T_TUESDAY, T_WEDNESDAY, T_THURSDAY, T_FRIDAY, T_SATURDAY };

 for(day=0;day<7;day++){
               lprintf(Week[day]);
       }

Edited by Haystack

Share this post


Link to post
Share on other sites

Your content will need to be approved by a moderator

Guest
You are commenting as a guest. If you have an account, please sign in.
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  

×