1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<html>
3<!-- This file documents the GNU Assembler "as".
4
5Copyright (C) 1991-2021 Free Software Foundation, Inc.
6
7Permission is granted to copy, distribute and/or modify this document
8under the terms of the GNU Free Documentation License, Version 1.3
9or any later version published by the Free Software Foundation;
10with no Invariant Sections, with no Front-Cover Texts, and with no
11Back-Cover Texts.  A copy of the license is included in the
12section entitled "GNU Free Documentation License".
13 -->
14<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
15<head>
16<title>Using as: MSP430 Profiling Capability</title>
17
18<meta name="description" content="Using as: MSP430 Profiling Capability">
19<meta name="keywords" content="Using as: MSP430 Profiling Capability">
20<meta name="resource-type" content="document">
21<meta name="distribution" content="global">
22<meta name="Generator" content="makeinfo">
23<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
24<link href="index.html#Top" rel="start" title="Top">
25<link href="AS-Index.html#AS-Index" rel="index" title="AS Index">
26<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
27<link href="MSP430_002dDependent.html#MSP430_002dDependent" rel="up" title="MSP430-Dependent">
28<link href="NDS32_002dDependent.html#NDS32_002dDependent" rel="next" title="NDS32-Dependent">
29<link href="MSP430-Opcodes.html#MSP430-Opcodes" rel="previous" title="MSP430 Opcodes">
30<style type="text/css">
31<!--
32a.summary-letter {text-decoration: none}
33blockquote.smallquotation {font-size: smaller}
34div.display {margin-left: 3.2em}
35div.example {margin-left: 3.2em}
36div.indentedblock {margin-left: 3.2em}
37div.lisp {margin-left: 3.2em}
38div.smalldisplay {margin-left: 3.2em}
39div.smallexample {margin-left: 3.2em}
40div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
41div.smalllisp {margin-left: 3.2em}
42kbd {font-style:oblique}
43pre.display {font-family: inherit}
44pre.format {font-family: inherit}
45pre.menu-comment {font-family: serif}
46pre.menu-preformatted {font-family: serif}
47pre.smalldisplay {font-family: inherit; font-size: smaller}
48pre.smallexample {font-size: smaller}
49pre.smallformat {font-family: inherit; font-size: smaller}
50pre.smalllisp {font-size: smaller}
51span.nocodebreak {white-space:nowrap}
52span.nolinebreak {white-space:nowrap}
53span.roman {font-family:serif; font-weight:normal}
54span.sansserif {font-family:sans-serif; font-weight:normal}
55ul.no-bullet {list-style: none}
56-->
57</style>
58
59
60</head>
61
62<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
63<a name="MSP430-Profiling-Capability"></a>
64<div class="header">
65<p>
66Previous: <a href="MSP430-Opcodes.html#MSP430-Opcodes" accesskey="p" rel="previous">MSP430 Opcodes</a>, Up: <a href="MSP430_002dDependent.html#MSP430_002dDependent" accesskey="u" rel="up">MSP430-Dependent</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="AS-Index.html#AS-Index" title="Index" rel="index">Index</a>]</p>
67</div>
68<hr>
69<a name="Profiling-Capability"></a>
70<h4 class="subsection">9.29.6 Profiling Capability</h4>
71
72<a name="index-MSP-430-profiling-capability"></a>
73<a name="index-profiling-capability-for-MSP-430"></a>
74<p>It is a performance hit to use gcc&rsquo;s profiling approach for this tiny target.
75Even more &ndash; jtag hardware facility does not perform any profiling functions.
76However we&rsquo;ve got gdb&rsquo;s built-in simulator where we can do anything.
77</p>
78<p>We define new section &lsquo;<samp>.profiler</samp>&rsquo; which holds all profiling information.
79We define new pseudo operation &lsquo;<samp>.profiler</samp>&rsquo; which will instruct assembler to
80add new profile entry to the object file. Profile should take place at the
81present address.
82</p>
83<p>Pseudo operation format:
84</p>
85<p>&lsquo;<samp>.profiler flags,function_to_profile [, cycle_corrector, extra]</samp>&rsquo;
86</p>
87
88<p>where:
89</p>
90<dl compact="compact">
91<dd>
92<dl compact="compact">
93<dd>
94<p>&lsquo;<samp>flags</samp>&rsquo; is a combination of the following characters:
95</p>
96</dd>
97<dt><code>s</code></dt>
98<dd><p>function entry
99</p></dd>
100<dt><code>x</code></dt>
101<dd><p>function exit
102</p></dd>
103<dt><code>i</code></dt>
104<dd><p>function is in init section
105</p></dd>
106<dt><code>f</code></dt>
107<dd><p>function is in fini section
108</p></dd>
109<dt><code>l</code></dt>
110<dd><p>library call
111</p></dd>
112<dt><code>c</code></dt>
113<dd><p>libc standard call
114</p></dd>
115<dt><code>d</code></dt>
116<dd><p>stack value demand
117</p></dd>
118<dt><code>I</code></dt>
119<dd><p>interrupt service routine
120</p></dd>
121<dt><code>P</code></dt>
122<dd><p>prologue start
123</p></dd>
124<dt><code>p</code></dt>
125<dd><p>prologue end
126</p></dd>
127<dt><code>E</code></dt>
128<dd><p>epilogue start
129</p></dd>
130<dt><code>e</code></dt>
131<dd><p>epilogue end
132</p></dd>
133<dt><code>j</code></dt>
134<dd><p>long jump / sjlj unwind
135</p></dd>
136<dt><code>a</code></dt>
137<dd><p>an arbitrary code fragment
138</p></dd>
139<dt><code>t</code></dt>
140<dd><p>extra parameter saved (a constant value like frame size)
141</p></dd>
142</dl>
143
144</dd>
145<dt><code>function_to_profile</code></dt>
146<dd><p>a function address
147</p></dd>
148<dt><code>cycle_corrector</code></dt>
149<dd><p>a value which should be added to the cycle counter, zero if omitted.
150</p></dd>
151<dt><code>extra</code></dt>
152<dd><p>any extra parameter, zero if omitted.
153</p>
154</dd>
155</dl>
156
157<p>For example:
158</p><div class="smallexample">
159<pre class="smallexample">.global fxx
160.type fxx,@function
161fxx:
162.LFrameOffset_fxx=0x08
163.profiler &quot;scdP&quot;, fxx     ; function entry.
164			  ; we also demand stack value to be saved
165  push r11
166  push r10
167  push r9
168  push r8
169.profiler &quot;cdpt&quot;,fxx,0, .LFrameOffset_fxx  ; check stack value at this point
170					  ; (this is a prologue end)
171					  ; note, that spare var filled with
172					  ; the farme size
173  mov r15,r8
174...
175.profiler cdE,fxx         ; check stack
176  pop r8
177  pop r9
178  pop r10
179  pop r11
180.profiler xcde,fxx,3      ; exit adds 3 to the cycle counter
181  ret                     ; cause 'ret' insn takes 3 cycles
182</pre></div>
183
184
185<hr>
186<div class="header">
187<p>
188Previous: <a href="MSP430-Opcodes.html#MSP430-Opcodes" accesskey="p" rel="previous">MSP430 Opcodes</a>, Up: <a href="MSP430_002dDependent.html#MSP430_002dDependent" accesskey="u" rel="up">MSP430-Dependent</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="AS-Index.html#AS-Index" title="Index" rel="index">Index</a>]</p>
189</div>
190
191
192
193</body>
194</html>
195