TMS34010
C
Language
-
Object
Alignment/Conversions/Expressions
4.3
Object
Alignment
• All objects except structure members and array members
are
aligned on
a
16-bit
(one-word)
boundary. In other words,
with
the exception
of
structure and array members, all objects begin at
bit
addresses whose
four
LSBs
are
zeros. In addition, because
of
the
TMS34010's
bit
ad-
dressability, a pointer can
point
to any bit address. Signed objects
of
less than 16 bits
are
sign-extended
to
16 bits. Unsigned objects
of
less
than
16
bits
are
zero-extended
to
16
bits.
• Structure or array members
are
not
aligned
to
16-bit
boundaries.
How-
ever, the structure or array itself begins at a
16-bit
boundary. In the case
of
an
array
of
structures, only the first structure in the array
is
constrained
to
begin on a
16-bit
boundary.
For
additional information on array alignment,
see
Packing Structures and
Manipulating
Fields, Packing Structures and Manipulating Fields, on page
5-5. .
4.4
Conversions
K&R 6.1
K&R 6.3
4-6
Integer objects
are
always widened
to
32 bits when passed
as
arguments
to
a
function. Signed objects
of
less than 32 bits
are
sign-extended to 32 bits;
unsigned objects
of
less
t~an
32 bits
are
zero-extended to 32 bits.
The type
char
is
signed and is therefore sign-extended when widened
to
in-
teger type. Sign extension can be disabled by using the type
unsigned
char.
• Types float and double
are
converted to type integer by truncation.
• In
K&R
C,
all
floating-point
arithmetic is performed on double-precision
values. In ANSI and TMS3401 0
C,
however, single-precision values can
be used for
calculating any expression in
which
both operands have type
float. If either operand in
an
expression
has
type double, the other
op-
erand
is
converted
to
a double and the arithmetic
is
performed on
dou-
ble-precision values. Floating-point constants have type double
unless
they have
an
F suffix; also, integers have type float when they
are
im-
plicitly converted. Single-precision arithmetic
is
significantly faster,
but
causes a loss
of
precision. The
following
examples illustrate
cases
in
which
a single-precision value is used as-is or
is
converted to a double:
float
f;
double
d;
int
i;
f
+
f;
/*
Single
Precision
*/
f
+
d;
/*
Double
Precision
*/
f
+
1;
/*
Single
Precision
*/
f
+
1.0;
/*
Double
Precision
*/
f
+
l.OF;
/*
Single
Precision
*/
d *
(f
+
i)
;
/*
Add
using
Single,
multiply
*/
/*
using
Double
*/