Reply by Keith Larson August 8, 20072007-08-08
Hello Najam

Bill is right about programming in C and the sizeof() operator. If you
dig slightly into the ASM capabilities of the chip you will find the
following may be of help.

By populating the upper bits (rather than the lower bits) using an ASHR
instruction to load a char will properly sign extend the sign bit in one
instruction. If the bottom bits are populated you would need to first
left shift into a register, then right shift with sign extension.
Another interesting trick is that if the upper 16 bits are populated,
this can be used as a short floating point of 8 bits exponent and 8 bits
mantissa. The VC33 DSK was setup this way to allow this experiment.

The downside argument is that
1) Your code looks funny (a char in the upper 8 bits of a long?)
2) instructions that perform immediate bit wise operations work on the
lower 16 bits

What you decide may depend on your particular circumstance

Best regards,
Keith
Bill Finger wrote:

> Najam,
>
> As you might find by reading the documentation, the word size on the C3x
> platform is 32-bit, so all data is that size. Note that this effects the
> results of the sizeof() operator.
>
> To copy from the 8 bit memory to the 16 bit memory you could just use
> memcpy(). However, if your board is not designed quite right you'll get
> non-zero data in the high order bits, in which case you should drop down
> into assembly and use RPTS and AND3.
>
> Bill
>
> > -----Original Message-----
> > From: c...
> [mailto:c... ] On
> > Behalf Of e...@yahoo.com
> > Sent: Monday, August 06, 2007 7:51 AM
> > To: c...
> > Subject: [c3x] How to declare 8-bit or 16-bit data in C31.?
> >
> > Hi,
> >
> > I am using C31 processor , if i decalare "unsigned char" data
> > or "unsigned short" , the code composer shows 32-bit assigned to it .
> > Is it possible to decalare 8-bit or 16-bit data type for the C31.?
> >
> > Also if two memories one 8-bit wide and another 16-bit are
> > externallay attached to the C31, and if i want to move 8-bit
> > memory data into 16-bit memory data what would be the
> > efficient way to do it ?
> >
> >
> > Thanks.
> > N a j a m.
> >
> >
> >
Reply by Bill Finger August 7, 20072007-08-07
Najam,

As you might find by reading the documentation, the word size on the C3x
platform is 32-bit, so all data is that size. Note that this effects the
results of the sizeof() operator.

To copy from the 8 bit memory to the 16 bit memory you could just use
memcpy(). However, if your board is not designed quite right you'll get
non-zero data in the high order bits, in which case you should drop down
into assembly and use RPTS and AND3.

Bill

> -----Original Message-----
> From: c... [mailto:c...] On
> Behalf Of e...@yahoo.com
> Sent: Monday, August 06, 2007 7:51 AM
> To: c...
> Subject: [c3x] How to declare 8-bit or 16-bit data in C31.?
>
> Hi,
>
> I am using C31 processor , if i decalare "unsigned char" data
> or "unsigned short" , the code composer shows 32-bit assigned to it .
> Is it possible to decalare 8-bit or 16-bit data type for the C31.?
>
> Also if two memories one 8-bit wide and another 16-bit are
> externallay attached to the C31, and if i want to move 8-bit
> memory data into 16-bit memory data what would be the
> efficient way to do it ?
> Thanks.
> N a j a m.
>
Reply by engn...@yahoo.com August 6, 20072007-08-06
Hi,

I am using C31 processor , if i decalare "unsigned char" data or "unsigned short" , the code composer shows 32-bit assigned to it .
Is it possible to decalare 8-bit or 16-bit data type for the C31.?

Also if two memories one 8-bit wide and another 16-bit are externallay attached to the C31, and if i want to move 8-bit memory data into 16-bit memory data what would be the efficient way to do it ?
Thanks.
N a j a m.