• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
3<html>
4
5<head>
6<title>cmp&lt;kind&gt;</title>
7<link rel=stylesheet href="opcode.css">
8</head>
9
10<body>
11
12<h1>cmp&lt;kind&gt;</h1>
13
14<h2>Purpose</h2>
15
16<p>
17Perform the indicated floating point or long comparison, storing 0 if the two
18arguments are equal, 1 if the second argument is larger, or -1 if the first
19argument is larger. The "bias" listed for the floating point operations
20indicates how NaN comparisons are treated: "Gt bias" instructions return 1 for
21NaN comparisons, and "lt bias" instructions return -1.
22</p>
23<p>
24For example, to check to see if floating point a < b, then it is advisable to
25use cmpg-float; a result of -1 indicates that the test was true, and the other
26values indicate it was false either due to a valid comparison or because one
27or the other values was NaN.
28</p>
29
30<h2>Details</h2>
31
32<table class="instruc">
33<thead>
34<tr>
35  <th>Op &amp; Format</th>
36  <th>Mnemonic / Syntax</th>
37  <th>Arguments</th>
38</tr>
39</thead>
40<tbody>
41<tr>
42  <td>2d..31 23x</td>
43  <td>cmp<i>kind</i> vAA, vBB, vCC<br/>
44    2d: cmpl-float <i>(lt bias)</i><br/>
45    2e: cmpg-float <i>(gt bias)</i><br/>
46    2f: cmpl-double <i>(lt bias)</i><br/>
47    30: cmpg-double <i>(gt bias)</i><br/>
48    31: cmp-long
49  </td>
50  <td><code>A:</code> destination register (8 bits)<br/>
51    <code>B:</code> first source register or pair<br/>
52    <code>C:</code> second source register or pair</td>
53</tr>
54</tbody>
55</table>
56
57<h2>Constraints</h2>
58
59<ul>
60  <li>
61    A, B and C must be valid register indices in the current stack frame.
62  </li>
63  <li>
64    For the two -float variants, both vB and vC must be of type float.
65  </li>
66  <li>
67    For the two -double variants, both vB and vC must be the lower part of a
68    register pair holding a double value.
69  </li>
70  <li>
71    For the -long variant, both both vB and vC must be the lower part of a
72    register pair holding a long value.
73  </li>
74</ul>
75
76<h2>Behavior</h2>
77
78<ul>
79  <li>
80    The values of registers vB and vC are compared. The result, which is stored
81    in vA, is one of the following three:
82    <ul>
83      <li>
84        If vB < vC, then vA'=-1.
85      </li>
86      <li>
87        If vB == vC, then vA'=0.
88      </li>
89      <li>
90        If vC > vC, then vA'=1.
91      </li>
92    </ul>
93  </li>
94  <li>
95    For the -float and -double variants, an addition "bias" specifies what
96    happens if one or both of the arguments are NaN:
97    <ul>
98      <li>
99        A "lt bias" results in vA'=-1.
100      </li>
101      <li>
102        A "gt bias" results in vA'=1.
103      </li>
104    </ul>
105  </li>
106  <li>
107    If v(A-1) is the lower half of a register pair, v(A-1)' becomes undefined.
108  </li>
109  <li>
110    If v(A+1) is the upper half of a register pair, v(A+1)' becomes undefined.
111  </li>
112</ul>
113
114<h2>Exceptions</h2>
115
116<p>
117None.
118</p>
119
120</body>
121</html>
122