C– – Compiler

 

5.5.2 Variable Types

 

 

 

 

 

 

 

 

 

 

 

 

 

Type Name

Mnemonic

Range

Size in Bytes

Example

 

 

 

 

 

 

 

 

 

Integer

int

[–32768,32767]

2

int i,j;

 

 

Character

char

[0,255]

1

char c,d;

 

 

Array of integer

int

Not Applicable

Not Applicable

int array[12];

 

 

Array of characters

char

Not Applicable

forced to even

char text[20]

 

 

Pointer to integer

int *

Not Applicable

2

int *j;

 

 

Pointer to character

char *

Not Applicable

2

char *string;

 

 

 

 

 

 

 

 

Notes: 1) There is a major difference between an MSP50C6xx integer string and an array of integers: an array of integers is an ordered set of n 16 bit integers, whereas an integer string of length n represents a single integer with 16*n bits. In C– –, MSP50C6xx strings are declared as arrays of integers, but must be operated upon using the special purpose string arithmetic functions described below.

2)As in regular C, the above types can be qualified with the word unsigned.

3)There is another important qualifier that is special to C– – : constant. We made the mnemonic purposely different from the usual C const qualifier, because it is not exactly equivalent. It is used to initialize arrays in program ROM. A good use of it would be for a sine table, for example. The syntax is simple, for example:

constant int array[10]={1,2,3,4,5,6,7,8,9,10},dummy;

4)will create a series of DATA statements in the assembly language output file. Uninitialized constants (like dummy above) generate a warning and are initialized to zero. Constants are to be handled with care. Since they cannot be accessed the same way as RAM variables, special purpose functions have to be used to utilize constants in a program. The most general of these functions is xfer_const, which transfers values from the program ROM to the RAM. Also, constants MUST BE GLOBAL. Do not pass a constant as an argument.

5)The common C types float, struct, union and long are not implemented. (Note that long is a subset of string of integer).

5.5.3External References

All RAM allocations in the assembler are global. This results in the following -implications for C– – variables:

Only the file containing the main routine can contain global variable

-definitions.

Global variables referenced in other files must have been declared as ex-

-ternal (keyword extern) at the beginning of the file.

A function referenced in a file but not defined in that same file must be introduced with a function prototype in the file where it is referenced (no need for the extern keyword).

Code Development Tools

5-17

Page 313
Image 313
Texas Instruments MSP50C6xx manual Variable Types, External References, Type Name Mnemonic Range Size in Bytes Example