1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html xml:lang="en-US" lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
3  <head>
4    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5    <meta http-equiv="Content-Style-Type" content="text/css" />
6    <link rel="stylesheet" href="../css/manpage.css" type="text/css" />
7    <link rel="stylesheet" href="../css/timetable.css" type="text/css" />
8    <title>loop - Start loop statement</title>
9  </head>
10  <body>
11    <h1>loop - Start loop statement</h1>
12
13    <h2>Calling Format</h2>
14    <div class="section">
15      <pre class="definition">
16loop    src
17</pre>
18    </div>
19
20    <h2>Operands</h2>
21    <div class="section">
22      <table class="arguments">
23        <thead>
24          <tr>
25            <th>Name</th>
26            <td>Description</td>
27          </tr>
28        </thead>
29        <tr>
30          <th>src</th>
31          <td>
32            Integer register<br>
33          </td>
34        </tr>
35      </table>
36    </div>
37
38    <h2>Overview</h2>
39    <div class="section">
40      <p>
41        This is used together with <CODE>endloop</CODE>. It repeatedly executes the instructions between <CODE>loop</CODE> and <CODE>endloop</CODE> according to the contents of the integer register specified by <SPAN class="argument">src</SPAN>.<br> The integer register comprises a loop count, an initial value for the loop-counter register, and an amount by which to increment the loop-counter register, stored in the count, init, and step components, respectively. (Set the integer register to the <CODE>defi</CODE> instruction or uniform. For details, see &quot;<a href="../definition/defi.html">defi &ndash; Define integer constants</a>&quot; and &quot;<a href="../preprocess/bind_symbol.html">bind_symbol ( symbol_name , start_index [, end_index] )</a>&quot;.)<br> The loop-counter register (aL) is initialized when the <CODE>loop</CODE> instruction is executed. When control reaches <CODE>endloop</CODE>, the loop-counter register is incremented by the increment amount and control returns to the <CODE>loop</CODE> instruction.<br> After this process repeats one time more than the loop count in the integer register, the <CODE>loop</CODE> instruction ends and execution picks up from the next instruction after <CODE>endloop</CODE>.<br>
42      </p>
43      <p class="notice">
44        Up to four <CODE>loop</CODE> instructions can be nested.<br> If the loop-counter register were incremented by a negative number its value could become less than 0, but in such cases it will be set to 255 due to underflow.<br> Behavior is undefined if a floating-point constant register is offset by a value of 96 or greater.<br>
45      </p>
46      <p class="warning">
47        There must be at least one instruction between <CODE>loop</CODE> and <CODE>endloop</CODE>.<br>
48      </p>
49    </div>
50
51    <h2>Operation</h2>
52    <div class="section">
53<pre class="definition">
54for ( int i = 0, aL = src.init ; i &lt; src.count+1 ; i++, aL += src.step )
55{
56    ...
57}
58</pre>
59    </div>
60
61    <h2>Code Example</h2>
62    <div class="section">
63<pre class="definition">
64defi    i0, 10, 0, 1
65
66loop    i0
67    add r0, r0, c0[ aL ]    // Add the total of c0, c1, ... , c10 to r0
68endloop
69</pre>
70    </div>
71
72
73  <h2>Revision History</h2>
74  <div class="section">
75    <dl class="history">
76      <dt>2011/12/20</dt>
77      <dd>Initial version.<br />
78      </dd>
79    </dl>
80  </div>
81
82  <hr><p>CONFIDENTIAL</p></body>
83</html>