Texas Instruments MSP50C614 manual Programming Example, Cmmfunc bidonint i1,char *i2 is valid, but

Models: MSP50C614

1 414
Download 414 pages 24.44 Kb
Page 351
Image 351

Implementation Details

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/Ccc 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º

Code Development Tools

5-51

Page 351
Image 351
Texas Instruments MSP50C614 manual Programming Example, Cmmfunc bidonint i1,char *i2 is valid, but, On Call, On RET