Texas Instruments MSP50C614 User Manual

Page 353

Advertising
background image

Implementation Details

5-53

Code Development Tools

free(mm2);

free(pp);

}

cmm_func main(int argc,char *argv)

{

int m1[4],m2[4],product[9];

xfer_const(m1,M1,STR_LENGTH(4));

xfer_const(m2,M2,STR_LENGTH(4));

string_multiply(product,STR_LENGTH(9),m1,STR_LENGTH(4),m2,STR_LENGTH(4));

}

5.10.5 Programming Example, C – – With Assembly Routines

There are several important considerations when using the C– – compiler. The
ram allocation must be coordinated so that a location is not accidentally used
twice. In assembly this is usually done with IRX files by making each label
equal to the location of the previous one, plus whatever storage space is
needed. All of the IRX files for a project are then combined in a master IRX file
so that the space for each sub file can be allocated. For example ( a master
IRX file ):

RAM_SIZE

equ

640

STACK

equ

2 * (RAM_SIZE – 14)

BEGIN_RAM

equ

0

RESERVED

equ BEGIN_RAM + 2 * 1

RAMSTART_INT

equ

RESERVED

include ”..\inter\inter_ram.irx”

RAMSTART_ASM

equ

RAMEND_INT

include

”. .\asm_ram.irx”

Here the sub files are inter_ram.irx and asm_ram.irx. The allocation for
inter_ram.irx begins at memory location 2. This is because the memory
location 0 is reserved for use by the C– – compiler. The allocation for
asm_ram.irx begins where the allocation ended for inter_ram.irx. More irx files
can be chained on in this manner, and all of the allocation is kept organized.
When C– – is added to a project, it is important to make sure that the C– –
variables are not allocated in locations already used by assembly variables.
This is accomplished with a dummy array, bogus, located in the file ram.irx. It
is simply an integer array that is included in the C– – program so that it is the
first variable allocated. By making its size equivalent to the amount of memory
used for assembly variables, the C– – variables that the user defines are
allocated in unused memory. It can be set by building the project and finding
the location of the last assembly variable. This can then be converted from
hexadecimal to decimal and divided by two ( because a C– – int is 16 bits ) to

Advertising