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.

The DLIB runtime environmentRuntime model attribute Value Description__reg_r4__reg_r5Note: The value free should be seen as the opposite of locked, that is, the register isfree to be used by the compiler.The easiest way to find the proper settings of the RTMODEL directive is to compile a C or<strong>C++</strong> module to generate an assembler file, and then examine the file.If you are using assembler routines in the C or <strong>C++</strong> code, refer to the chapter Assemblerdirectives in the <strong>MSP430</strong> <strong>IAR</strong> Assembler Reference Guide.Examplesfree or undefinedFor an example of using the runtime model attribute __rt_version for checkingmodule consistency on used calling convention, see Hints for a quick introduction to thecalling conventions, page 90.The following assembler source code provides a function that counts the number oftimes it has been called by increasing the register R4. The routine assumes that theapplication does not use R4 for anything else, that is, the register has been locked forusage. To ensure this, a runtime module attribute, __reg_r4, has been defined with avalue counter. This definition will ensure that this specific module can only be linkedwith either other modules containing the same definition, or with modules that do notset this attribute. Note that the compiler sets this attribute to free, unless the register islocked.RTMODEL "__reg_r4", "counter"MODULE myCounterPUBLIC myCounterRSEG CODE:CODE:NOROOT(1)myCounter: INC R4RETENDMODENDCorresponds to the use of the register, orundefined when the register is not used. Aroutine that assumes that the register islocked should set the attribute to a valueother than free.__rt_version 3 This runtime key is always present in allmodules generated by the <strong>MSP430</strong> <strong>IAR</strong>C/<strong>C++</strong> <strong>Compiler</strong>. If a major change in theruntime characteristics occurs, the value ofthis key changes.Table 21: Predefined runtime model attributes (Continued)Part 1. Using the compiler73

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

Saved successfully!

Ooh no, something went wrong!