<html lang="en"> <head> <title>MSP430 Profiling Capability - Using as</title> <meta http-equiv="Content-Type" content="text/html"> <meta name="description" content="Using as"> <meta name="generator" content="makeinfo 4.13"> <link title="Top" rel="start" href="index.html#Top"> <link rel="up" href="MSP430_002dDependent.html#MSP430_002dDependent" title="MSP430-Dependent"> <link rel="prev" href="MSP430-Opcodes.html#MSP430-Opcodes" title="MSP430 Opcodes"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <!-- This file documents the GNU Assembler "as". Copyright (C) 1991-2015 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled ``GNU Free Documentation License''. --> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } --></style> </head> <body> <div class="node"> <a name="MSP430-Profiling-Capability"></a> <p> Previous: <a rel="previous" accesskey="p" href="MSP430-Opcodes.html#MSP430-Opcodes">MSP430 Opcodes</a>, Up: <a rel="up" accesskey="u" href="MSP430_002dDependent.html#MSP430_002dDependent">MSP430-Dependent</a> <hr> </div> <h4 class="subsection">9.29.6 Profiling Capability</h4> <p><a name="index-MSP-430-profiling-capability-1656"></a><a name="index-profiling-capability-for-MSP-430-1657"></a>It is a performance hit to use gcc's profiling approach for this tiny target. Even more – jtag hardware facility does not perform any profiling functions. However we've got gdb's built-in simulator where we can do anything. <p>We define new section ‘<samp><span class="samp">.profiler</span></samp>’ which holds all profiling information. We define new pseudo operation ‘<samp><span class="samp">.profiler</span></samp>’ which will instruct assembler to add new profile entry to the object file. Profile should take place at the present address. <p>Pseudo operation format: <p>‘<samp><span class="samp">.profiler flags,function_to_profile [, cycle_corrector, extra]</span></samp>’ <p>where: <dl> <dl> ‘<samp><span class="samp">flags</span></samp>’ is a combination of the following characters: <dt><code>s</code><dd>function entry <br><dt><code>x</code><dd>function exit <br><dt><code>i</code><dd>function is in init section <br><dt><code>f</code><dd>function is in fini section <br><dt><code>l</code><dd>library call <br><dt><code>c</code><dd>libc standard call <br><dt><code>d</code><dd>stack value demand <br><dt><code>I</code><dd>interrupt service routine <br><dt><code>P</code><dd>prologue start <br><dt><code>p</code><dd>prologue end <br><dt><code>E</code><dd>epilogue start <br><dt><code>e</code><dd>epilogue end <br><dt><code>j</code><dd>long jump / sjlj unwind <br><dt><code>a</code><dd>an arbitrary code fragment <br><dt><code>t</code><dd>extra parameter saved (a constant value like frame size) </dl> <br><dt><code>function_to_profile</code><dd>a function address <br><dt><code>cycle_corrector</code><dd>a value which should be added to the cycle counter, zero if omitted. <br><dt><code>extra</code><dd>any extra parameter, zero if omitted. </dl> <p>For example: <pre class="smallexample"> .global fxx .type fxx,@function fxx: .LFrameOffset_fxx=0x08 .profiler "scdP", fxx ; function entry. ; we also demand stack value to be saved push r11 push r10 push r9 push r8 .profiler "cdpt",fxx,0, .LFrameOffset_fxx ; check stack value at this point ; (this is a prologue end) ; note, that spare var filled with ; the farme size mov r15,r8 ... .profiler cdE,fxx ; check stack pop r8 pop r9 pop r10 pop r11 .profiler xcde,fxx,3 ; exit adds 3 to the cycle counter ret ; cause 'ret' insn takes 3 cycles </pre> <!-- Copyright (C) 2013-2015 Free Software Foundation, Inc. --> <!-- This is part of the GAS manual. --> <!-- For copying conditions, see the file as.texinfo. --> <!-- man end --> </body></html>