Byte Packing in DSP BIOS

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Hi,

I want to know if there is any utility in DSP BIOS for byte packing
like "__attribute__((packed))" in linux. Plz let me know if there's
any.


Thanks and regards,
Nagendran V


Re: Byte Packing in DSP BIOS
On 17 May 2005 00:59:54 -0700, " snipped-for-privacy@gmail.com"

Quoted text here. Click to load it

Which TI DSP?  Some of them don't have 8-bit bytes, all memory and
registers are 16-bit wide.  And a lot of them require that 32-bit
values start on an even address.

That means a lot of them literally can't support packed structures,
because they literally won't address the memory correctly.

What DSP, and what is the reason you think you need to pack
structures?

--
Jack Klein
Home: http://JK-Technology.Com
We've slightly trimmed the long signature. Click to see the full one.
Re: Byte Packing in DSP BIOS

Quoted text here. Click to load it


It certainly would be possible for a compiler to generate correct
code, but it would be quite nasty :-).

Assuming you want to update a byte in a packed structure:

- load memory word into register
- make a copy into other register
- shift the byte to the low end of the register
- mask away the bits above the wanted byte
- perform all the operations you want on the byte
- shift the byte back to the original bit position
- mask (make a "hole") in the original register for the byte
- combined the modified byte with the original register by ORing
- store the combination back to memory as a full 32 bit value

If you have a 16 bit integer crossing the memory word boundary, you
would need to execute the above algorithm twice, once for the lower
memory and once for the upper memory word and need four registers
totally. For the memory word that contains the MSB of the desired
integer, the byte value is not shifted down to the LSB position of the
register but 8 positions to the left of LSB, so that it can be ORed
with the LSB in an other register and after manipulation split the
integer into these two registers and combining with the unmodified
part of each memory word and write back both memory words.

Certainly, the compiler could generate this code each time a byte or
unaligned integer is accessed, but it would generate quite a lot of
code for each memory reference.

Quoted text here. Click to load it

The only reason I can think of is handling a packed struct received
from an other system or creating a packed struct going to some
external system and that structure has been predefined e.g. in a
standard.

So in practice, it makes much more sense to define an unpacked
structure similar to the packed received frame and as the first step
after receiving the packed frame copy each field into the unpacked
internal structure. Just load each memory word of the packed structure
into a register and by shifting and masking extract each field and
store result into the unpacked structure fields.

Paul
    

Re: Byte Packing in DSP BIOS
Un bel giorno snipped-for-privacy@gmail.com digiṭ:

Quoted text here. Click to load it

Sadly, no (at least not in CCS 2.x compiler, I haven't seen 3.x yet).

--
asd

Re: Byte Packing in DSP BIOS

Quoted text here. Click to load it

__attribute__((packed)) is not a utility, it's a feature of a utility.
And it's not in Linux, it's in the usual Linux system compiler, GCC.

--
Hans-Bernhard Broeker ( snipped-for-privacy@physik.rwth-aachen.de)
Even if all the snow were burnt, ashes would remain.

Site Timeline