beautypg.com

Texas Instruments MSP50C6xx User Manual

Page 326

background image

Implementation Details

5-30

Here the sub files are inter_ram.irx and asm_ram.irx. The allocation for in-
ter_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 be-
gins 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 add-
ed to a project, it is important to make sure that the C– – variables are not allo-
cated 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 vari-
ables, 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 find the correct size for bogus. Bogus
can be made larger for extra safety as long as enough memory is left over for
the C– – variables and the stack. If space allows, it is a good idea to add a few
extra words to bogus in case assembly variables are added to the project with-
out modifying bogus.

It is also important not to alter the contents of registers R5 and R7. R7 is the
stack pointer and R5 is a frame pointer used in C to C function calls. Parame-
ters are passed on the stack and the return value is always int and always lo-
cated in a0. The stack usage for function calls is as follows.

C to C function call. The stack is shown after the operation on the bottom is
performed.