beautypg.com

Texas Instruments MSP50C6xx User Manual

Page 323

background image

Implementation Details

5-27

Code Development Tools

declarations ( or function prototypes) are introduced by the mnemonic

cmm_func

. We only allow the new style of function declarations /prototypes,

where the type of the arguments is declared within the function’s parentheses.
For example:

cmm_func bidon(int i1,char *i2)

is valid, but:

cmm_func bidon(i1,i2) int i1,char *i2;

is invalid.

Note: The exact implementation of the MSP50C6xx stack is as follows:

on CALL:

1) Increment R7

2) Transfer TOS (top of stack) register to *R7

3) Transfer return address to TOS register

on RET:

1) next PC = TOS

2) transfer *R7 to TOS

3) decrement R7

We can freely manipulate R7 before a CALL/Ccc and after a RET to load and
unload arguments to and from the stack. The TOS register should never be
altered in the body of a function.

5.6.4

Programming Example

The following example implements string multiplication (i.e., the multiplication
of 2 integer strings). The same source file (with the exception of the first line)
can be used for C– – or regular C. In the case of regular C, it has to be compiled
and linked with

cmm_func.c

#define _CMM /*must be present for C– –compiler ONLY*/

#ifdef _CMM

#else

#include

#include

#include

#include

#include “cmm_back.h”

#endif

#include “cmm_func.h”