<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>

<head>
<title>binop/lit16</title>
<link rel=stylesheet href="opcode.css">
</head>

<body>

<h1>binop/lit16</h1>

<h2>Purpose</h2>

<p>
Perform the indicated binary op on the indicated register (first argument) and
literal value (second argument), storing the result in the destination register.
</p>

<h2>Details</h2>

<table class="instruc">
<thead>
<tr>
  <th>Op &amp; Format</th>
  <th>Mnemonic / Syntax</th>
  <th>Arguments</th>
</tr>
</thead>
<tbody>
<tr>
  <td>d0..d7 22s</td>
  <td><i>binop</i>/lit16 vA, vB, #+CCCC<br/>
    d0: add-int/lit16<br/>
    d1: rsub-int (reverse subtract)<br/>
    d2: mul-int/lit16<br/>
    d3: div-int/lit16<br/>
    d4: rem-int/lit16<br/>
    d5: and-int/lit16<br/>
    d6: or-int/lit16<br/>
    d7: xor-int/lit16
  </td>
  <td><code>A:</code> destination register (4 bits)<br/>
    <code>B:</code> source register (4 bits)<br/>
    <code>C:</code> signed int constant (16 bits)</td>
</tr>
</tbody>
</table>

<h2>Constraints</h2>

<ul>
  <li>
    Both A and B must be valid register indices in the current stackframe.
  </li>
  <li>
    Registers vA and vB must be defined. They must both contain integer values.
  </li>
  <li>
    C is an immediate, signed integer constant taken from the instruction stream
    (actually this means there are no special requirements for C at all).
  </li>
</ul>

<h2>Behavior</h2>

<ul>
  <li>
    The given operation &lt;binop&gt; is performed according to the semantics
    specified in table XXX.
  </li>
  <li>
    Argument C is sign-extended to 32 bits before.
  </li>
  <li>
    The result is stored in register vA, that is, vA'=vB &lt;binop&gt; vC.
  </li>
  <li>
    As usual, neighboring registers might get undefined, if vA was part of a
    register pair originally.
  </li>
</ul>

<h2>Exceptions</h2>

<ul>
  <li>
    ArithmeticException if an error occurs during the instruction.
  </li>
</ul>

</body>
</html>