RE: DSP56F827: Condensing Strings, two 8bit cha rs into 16bits

Started by Wim de Haan May 12, 2004
Hello Boaz,

I had the same problem at DSP56F807 with Codewarrior. The only way for me to
solve it, was to put all strings in assembly:

global Fbatt_type
Fbatt_type dcb 'Battery type',0 ;
you must append the trailing 0 yourself


typedef struct {
unsigned ch2: 8;
unsigned ch1: 8;
} compressed_char;

extern compressed_char batt_type;

compressed_char *ptr;


/* Now:
ptr[0].ch1 == 'B'
ptr[0].ch2 == 'a'
ptr[1].ch1 == 't'
ptr[1].ch2 == 't'
and so on */

(I am still (endless) waiting for a new version of Codewarrior, which solves
this problem for me and also puts the strings in pflash instead of dflash.)

Kind regards,

Wim de Haan Exendis B.V.
W.J. de Haan 56, 6710 BB Ede
Keesomstraat 4, 6716 AB Ede
The Netherlands.
Tel: +31-(0)318 - 676305
Fax: +31-(0)318 - 676319
URL: <>

-----Original Message-----
From: bmbmz123 [mailto:]
Sent: dinsdag 11 mei 2004 19:12
Subject: [motoroladsp] DSP56F827: Condensing Strings, two 8bit chars into
16bits Hello,

I have many strings in my sw. The takes a lot of space.

The strings are defined as:
const char STRING1[] = {"HELLO"};

This puts the 8-bit ASCII codes in lsb of 16bits addresses. The
above string takes 6 words(with EOS=0x00 char).

I want to condense the strings, so that two ASCII chars will be in
one 16bits address.

How is this done?

What happens for a total of odd number of chars in the string? where
is the un-used space??