11.07.2015 Views

MSP430 IAR C/C++ Compiler reference guide - Rice University

MSP430 IAR C/C++ Compiler reference guide - Rice University

MSP430 IAR C/C++ Compiler reference guide - Rice University

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Assembler language interfaceRegisters used for returning valuesThe registers available for returning values are:Return values8-bit values16-bit values32-bit values64-bit valuesTable 24: Registers used for returning valuesPassed in registersR12R12R13:R12R15:R14:R13:R12Stack layoutIt is the responsibility of the caller to clean the stack after the called function hasreturned.Return value pointerIf a structure is returned, the caller passes a pointer to a location where the calledfunction should write the result. The pointer should be passed in the register R12.The called function must return the pointer in the register R12.EXAMPLESThe following section shows a series of declaration examples and the correspondingcalling conventions. The complexity of the examples increases towards the end.Example 1Assume that we have the following function declaration:int add1(int);This function takes one parameter in the register R12, and the return value is passed backto its caller in the register R12.The following assembler routine is compatible with the declaration; it will return a valuethat is one number higher than the value of its parameter:ADD.WRETA#1,R12; For the <strong>MSP430</strong>X architecturePart 1. Using the compiler95

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!