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>if-test</title> 7 <link rel=stylesheet href="opcode.css"> 8 </head> 9 10 <body> 11 12 <h1>if-test</h1> 13 14 <h2>Purpose</h2> 15 16 <p> 17 Branch to the given destination if the given two registers' values compare as 18 specified. 19 </p> 20 <p> 21 Note: The branch offset may not be 0. (A spin loop may be legally constructed 22 either by branching around a backward goto or by including a nop as a target 23 before the branch.) 24 </p> 25 26 <h2>Details</h2> 27 28 <table class="instruc"> 29 <thead> 30 <tr> 31 <th>Op & Format</th> 32 <th>Mnemonic / Syntax</th> 33 <th>Arguments</th> 34 </tr> 35 </thead> 36 <tbody> 37 <tr> 38 <td>32..37 22t</td> 39 <td>if-<i>test</i> vA, vB, +CCCC<br/> 40 32: if-eq<br/> 41 33: if-ne<br/> 42 34: if-lt<br/> 43 35: if-ge<br/> 44 36: if-gt<br/> 45 37: if-le<br/> 46 </td> 47 <td><code>A:</code> first register to test (4 bits)<br/> 48 <code>B:</code> second register to test (4 bits)<br/> 49 <code>C:</code> signed branch offset (16 bits)</td> 50 </tr> 51 </tbody> 52 </table> 53 54 <h2>Constraints</h2> 55 56 <ul> 57 <li> 58 A and B must be valid register indices for the current stack frame. 59 </li> 60 <li> 61 Registers vA and vB must not contain a reference value. 62 </li> 63 <li> 64 Registers vA and vB must not be part of a register pair. 65 </li> 66 <li> 67 Registers vA and vB must not contain a floating point value (???). 68 </li> 69 C must of a signed offset that, when added to the PC of the instruction, 70 points to a valid bytecode instruction inside the same method. 71 </li> 72 </ul> 73 74 <h2>Behavior</h2> 75 76 <ul> 77 <li> 78 The values of registers vA and vB are compared according to the <test> 79 condition. Two results are possible: 80 <ul> 81 <li> 82 The condition holds. The value of C is used as a signed offset to the 83 address of the if-<test> instruction. Execution continues at the 84 resulting address. 85 </li> 86 <li> 87 The condition does not hold. Execution continues at the instruction 88 following the if-<test> instruction. 89 </li> 90 </ul> 91 </li> 92 </ul> 93 94 <h2>Exceptions</h2> 95 96 <p> 97 None. 98 </p> 99 100 </body> 101 </html> 102