This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

string allocation in bytes instead of words

Other Parts Discussed in Thread: TMS320F28035, TMS320F28027

Hi All,

I'm using the TMS320F28035 processor.

The CCS compiler translates strings into an assembler lines, such as:

$C$FSL1:        .string "789",0

This line allocates one word per character, which wastes half of the memory.

There is a similar assembly directive: .pstring, which stores two characters per word.

Is there a simple way to instruct the compiler to use pstring instead of the string directive?

If no, is there a way to run a "search replace" program on each of the assembler files, before the assembler converts them to objects?

Thanks, Isak.

  • Isak,

    C defines strings as character arrays, and a char is 16 bits on the C28x. If you create packed strings, you'll have to either unpack them at run-time or write a bunch of custom string-handling code. If you go that route, note that packed strings fill the most significant byte of each word first. This is the opposite order of the __byte() intrinsic. Probably the way to generate the strings is to manually put .pstring definitions in a separate assembly file.

    The compiler does have an option to skip assembly: --skip_assembler (-n for short). I don't see any way to activate it within CCS. You could try adding it as a manual flag, or leave CCS entirely and create a makefile for GNU Make. All of the compiler options can be found in SPRU514. The assembler options are in SPRU513. Both documents have information on the linker. This is getting into some really weird territory and is almost certainly a bad idea.

    Can you clarify how the C strings are causing trouble?

    Thanks,

  • Thanks for the reply.

    The reason of using pstrings is just to save space.

    Currently i'm using macros to inject assembly lines into the C file. This works fine. Just was wandering if there is a better way.

    I don't mind writing the necessary string functions, as I don't need many of them.

    Thanks.

  • I am doing something similar on my TMS320F28027. I have several receive buffers which are used to insure I miss no bytes coming in from the serial port. I notices these buffers are twice as big as they need to be because the char buffers are actually 16 bits in size. I am not familiar with the assembly in the C2000 family, but I can learn if needed. Just wondering if there is any C code or example method to compress these buffers as efficiently as possible. I am getting low on RAM and this would help.

  • Gary,

    You could use the __byte() compiler intrinsic to store the data into an 8-bit array. Note that you will need to use __byte() again later to read the data back out of the array. Compiler intrinsics are described in section 7.5.6 of the compiler guide (SPRU514).
  • Thanks Adam,

    I will give this a try.