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>cmp - Compare</title>
9  </head>
10  <body>
11    <h1>cmp - Compare</h1>
12
13    <h2>Calling Format</h2>
14    <div class="section">
15      <pre class="definition">
16cmp     mode0, mode1, src0, src1
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>mode0</th>
31          <td>
32            Comparison mode 0 (0: ==, 1: !=, 2: &lt;, 3: &lt;=, 4: &gt;, 5: &gt;=)<br>
33          </td>
34        </tr>
35        <tr>
36          <th>mode1</th>
37          <td>
38            Comparison mode 1 (0: ==, 1: !=, 2: &lt;, 3: &lt;=, 4: &gt;, 5: &gt;=)<br>
39          </td>
40        </tr>
41        <tr>
42          <th>src0</th>
43          <td>
44            A temporary register, an input register, or a floating-point constant register.<br>
45          </td>
46        </tr>
47        <tr>
48          <th>src1</th>
49          <td>
50            A temporary register, an input register, or a floating-point constant register.<br>
51          </td>
52        </tr>
53      </table>
54      <p class="notice">
55        You cannot specify a floating-point constant register for both <SPAN class="argument">src0</SPAN> and <SPAN class="argument">src1</SPAN>.<br> You cannot specify input registers using different indices for <SPAN class="argument">src0</SPAN> and <SPAN class="argument">src1</SPAN> at the same time.<br>
56      </p>
57    </div>
58
59    <h2>Overview</h2>
60    <div class="section">
61      <p>
62        Compares the contents of registers <SPAN class="argument">src0</SPAN> and <SPAN class="argument">src1</SPAN> and stores the result in the status registers.<br> It only compares the <CODE>x</CODE> and <CODE>y</CODE> components of <SPAN class="argument">src0</SPAN> and <SPAN class="argument">src1</SPAN>. (The <CODE>x</CODE> and <CODE>y</CODE> components after swizzling)<br>Status register 0 stores the result of comparing the <CODE>x</CODE> components based on the condition specified by <SPAN class="argument">mode0</SPAN>. Status register 1 stores the result of comparing the <CODE>y</CODE> components based on the condition specified by <SPAN class="argument">mode1</SPAN>. The status register is set to <CODE>1</CODE> if the comparison result is true, and it is set to <CODE>0</CODE> if the comparison result is false. The conditions are as follows:<br>If mode0 (or mode1) is 1: src0 == src1<br>If 2: src0 &lt; src1<br>If 3: src0 &lt;= src1<br>If 4: src0 &gt; src1<br>If 5: src0 &gt;= src1.<br>
63      </p>
64      <p class="notice">
65        Use this instruction to distinguish between infinity, negative infinity, and <CODE>NaN</CODE>. A value of <CODE>0x7f0000</CODE> indicates infinity, <CODE>0xff0000</CODE> indicates negative infinity, and any value greater than <CODE>0x7f0000</CODE> and less than <CODE>0xff0000</CODE> indicates <CODE>NaN</CODE>.<br>
66      </p>
67      <p class="warning">
68        Both status register 0 and 1 are always updated. It is not possible to update only one or the other.<br>
69      </p>
70    </div>
71
72    <h2>Operation</h2>
73    <div class="section">
74<pre class="definition">
75switch ( mode0 )
76{
77    case 0 : status_register0 = ( src0.x == src1.x ) ? 1 : 0 ; break ;
78    case 1 : status_register0 = ( src0.x != src1.x ) ? 1 : 0 ; break ;
79    case 2 : status_register0 = ( src0.x &lt;  src1.x ) ? 1 : 0 ; break ;
80    case 3 : status_register0 = ( src0.x &lt;= src1.x ) ? 1 : 0 ; break ;
81    case 4 : status_register0 = ( src0.x &gt;  src1.x ) ? 1 : 0 ; break ;
82    case 5 : status_register0 = ( src0.x &gt;= src1.x ) ? 1 : 0 ; break ;
83}
84switch ( mode1 )
85{
86    case 0 : status_register1 = ( src0.y == src1.y ) ? 1 : 0 ; break ;
87    case 1 : status_register1 = ( src0.y != src1.y ) ? 1 : 0 ; break ;
88    case 2 : status_register1 = ( src0.y &lt;  src1.y ) ? 1 : 0 ; break ;
89    case 3 : status_register1 = ( src0.y &lt;= src1.y ) ? 1 : 0 ; break ;
90    case 4 : status_register1 = ( src0.y &gt;  src1.y ) ? 1 : 0 ; break ;
91    case 5 : status_register1 = ( src0.y &gt;= src1.y ) ? 1 : 0 ; break ;
92}
93</pre>
94    </div>
95
96    <h2>Code Example</h2>
97    <div class="section">
98<pre class="definition">
99def     c0, 0, 1, 2, 3
100
101mov     r0, c0
102cmp     0, 0, r0, c0
103ifc     1, 1, 2
104    // This is executed when r0.x == 0
105endif
106</pre>
107    </div>
108
109    <h2>Timetable</h2>
110    <div class="section">
111      <table class="timetable">
112        <tr>
113          <th></th>
114          <th>1</th><th>2</th><th>3</th><th>4</th><th>5</th>
115        </tr>
116        <tr>
117          <th><CODE>cmp</CODE></th>
118          <td class="read">read</td>
119          <td class="CMP" colspan="2">CMP</td>
120          <td class="post">post</td>
121          <td class="write">write</td>
122          <td class="dummy"></td>
123        </tr>
124      </table>
125    </div>
126
127
128  <h2>Revision History</h2>
129  <div class="section">
130    <dl class="history">
131      <dt>2011/12/20</dt>
132      <dd>Initial version.<br />
133      </dd>
134    </dl>
135  </div>
136
137  <hr><p>CONFIDENTIAL</p></body>
138</html>