Sign in

username:

password:



Not a member?

Search motoroladsp



Search tips

Subscribe to motoroladsp



motoroladsp by Keywords

56303 | 563xx | 5680 | 56805 | 5680x | 56F80 | 56F800DEMO | 56F805 | 56f807 | 56F830 | ADC | Bootloader | Codec | CodeWarrior | CW5 | CW6 | Debugger | DSP56303 | DSP56303EVM | DSP563xx | DSP5680 | DSP56800 | DSP56807 | DSP56858 | DSP56858EVM | DSP56F803 | DSP56F805 | DSP56F807 | DSP56F80x | DSP56F826 | DSP56F827 | DSP56F8xx | EVM | FFT | Flash_over_jtag | GPIO | Interrupt | Interrupts | JTAG | LCD | Linker | MCF5307 | Metrowerks | Modulus | MSCAN | PCMaster | PWM | Quad | Rif | RTOS | SDK | SPI

Discussion Groups

Discussion Groups | Freescale DSPs | unsigned char on Tasking C for DSP563xx

Technical discussions about Freescale (Motorola) DSPs (including the DSP56000, DSP56300, DSP56600, 56800 DSPs).

  

Post a new Thread

unsigned char on Tasking C for DSP563xx - John Wygonski - Feb 5 18:38:00 2003



Question for C implementation experts:

unsigned char cksm;
cksm = 0xFF + 0xFF;
if ( cksm != 0xFE ) { // this is a problem? }

I am using the C tools from Tasking. Tasking's compiler documentation says
that unsigned char is 8-bit, with a range of 0 to 255U.

Now, I know enough to pay attention to this sort of thing because DSP563xx
chip can only access 24-bit words in memory, but, my C-level debugger
reports cksm=0xFE, yet my code functions as if cksm=0x1FE. Inspecting the
asm produced by the compiler shows that indeed the 24-bit quantity cksm (not
8-bit) is used to compare to 0xFF.

What should I expect the compiler to do here? Shouldn't I expect the
debugger from the same vendor to be consistent?

John Wygonski





(You need to be a member of motoroladsp -- send a blank email to motoroladsp-subscribe@yahoogroups.com )

RE: unsigned char on Tasking C for DSP563xx - Harrold Spier - Feb 6 8:27:00 2003


Although the char type is 8 bit, each char occupies one memory
word, because the DSP56xxx has no instructions to access one byte
efficiently.

By default the compiler does not clear or extend the excess bits
on a cast from a char or a short to an int or a long. For signed
values, the ANSI specification does not prescribe such behavior,
for unsigned values it requires overflow masking. By default the
compiler avoids the overhead involved by code to prevent overflows.
This is called 'Relaxed char/short arithmetic overflow masking'.

You can add the compiler option -AE to select forced conversions.

As you will see this will generate a lot of extra code. It is better
to avoid types smaller than int whenever possible, as they need more
instructions for conversions and do not save data space.

CrossView only evaluates the lower 8 bits of a word to get a
char value. To get the full 24 bits you can use the expression:

*((unsigned int *) &cksm)/n Harrold -----Original Message-----
From: John Wygonski [mailto:]
Sent: Wednesday, February 05, 2003 19:38
To:
Subject: [motoroladsp] unsigned char on Tasking C for DSP563xx Question for C implementation experts:

unsigned char cksm;
cksm = 0xFF + 0xFF;
if ( cksm != 0xFE ) { // this is a problem? }

I am using the C tools from Tasking. Tasking's compiler documentation
says that unsigned char is 8-bit, with a range of 0 to 255U.

Now, I know enough to pay attention to this sort of thing because
DSP563xx chip can only access 24-bit words in memory, but, my C-level
debugger reports cksm=0xFE, yet my code functions as if cksm=0x1FE.
Inspecting the asm produced by the compiler shows that indeed the 24-bit
quantity cksm (not
8-bit) is used to compare to 0xFF.

What should I expect the compiler to do here? Shouldn't I expect the
debugger from the same vendor to be consistent?

John Wygonski _____________________________________
/groups.php3




(You need to be a member of motoroladsp -- send a blank email to motoroladsp-subscribe@yahoogroups.com )