Bit Field Description - Texas Instruments TI-89 Software Manual

Sierra c assembler
Hide thumbs Also See for TI-89:
Table of Contents

Advertisement

Section 2: Compiler
As previously stated, enumeration constants and variables can be used anywhere
integer types can be used except in assignments involving different enumeration
types. The following examples utilize the enumeration objects declared on the
previous page to demonstrate enum type checking across assignments:
2.9.6.

Bit Field Description

The C language allows integer data to be stored in spaces that differ in size from
those provided by the basic integer types. Such arbitrarily sized integers are
called bit fields. They are supported by allowing the width in bits of a structure or
union member to be specified using a colon and a constant expression after the
member declarator. In the following declaration, x.a is a 10-bit integer, x.b is a
12-bit integer, and x.c is a seven-bit integer:
The three members of this structure occupy a total of four bytes; internally, they
are packed into a space that has the same size and alignment as a long int.
Bit fields can be packed in any of the four basic integer types (for example, char,
short int, int, or long int). The size of the type determines the maximum
allowable bit field size. Bit field declarations can also include the signed and
unsigned type specifiers. The signed type specifier causes the bit field to be
interpreted as a signed quantity — the most significant bit of the bit field
(for example, the sign bit) is extended when extracting the contents of the field.
The unsigned type specifier can also be used, but has no effect since bit fields
are unsigned by default. Given the following initialization, the three bit field
members will have the values shown:
TI-89 / TI-92 Plus Sierra C Assembler Reference Manual
int i;
CA = sunny;
/* legal
i = 25;
/* legal
red = 36;
/* illegal, red is constant
car = boat;
/* legal
car = NJ;
/* illegal
FL = green;
/* illegal
boat = i;
/* legal
struct s {
long int a:10;
long int b:12, c:7;
} x;
struct t {
int i:3;
signed int j:3;
unsigned int k:3;
} y = { -1, -1, -1 };
y.i = 7
y.j = -1
y.k = 7
/* -1 bit pattern all 1's */
Not for Distribution
65
*/
*/
*/
*/
*/
*/
*/
Beta Version February 2, 2001

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ti-92 plusTi-89 plusTi-92 plus

Table of Contents