Texas Instruments MSP50C614 User Manual

Page 351

Advertising
background image

Implementation Details

5-51

Code Development Tools

Function 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 MSP50P614/MSP50C614 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/C

cc and after a RET to load and

unload arguments to and from the stack. Of course, it would be a bad idea to
mess with the TOS register in the body of a function.

5.10.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 <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <math.h>

#include “cmm_back.h”

#endif

#include “cmm_func.h”

#include “cmm_macr.h”

Advertising