You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

501 lines
9.2 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title></title></head><body><h2>LRIS CPU/ASM specification (wip)</h2>
<p><del>shamelessly ripped off</del> very inspired by 6502 because its the only thing i kinda know</p>
<h3>Registers</h3>
<table>
<thead>
<tr>
<th>Register</th>
<th>Purpose</th>
<th>Size</th>
</tr>
</thead>
<tbody>
<tr>
<td>ACC</td>
<td>Stores the result of any calculation opcodes (if in ACC mode)</td>
<td>1 byte</td>
</tr>
<tr>
<td>RAX</td>
<td>General purpose register</td>
<td>1 byte</td>
</tr>
<tr>
<td>RAY</td>
<td>General purpose register</td>
<td>1 byte</td>
</tr>
</tbody>
</table>
<h3>Memory</h3>
<ul>
<li>Up to 64kib of RAM</li>
<li>Up to 64kib of Program ROM</li>
</ul>
<h3>Addressing Modes</h3>
<h4>Absolute</h4>
<p>Directly reads from a 2 byte memory address with instruction.</p>
<pre><code>LDX $0A2F
</code></pre>
<p><sub><sup>Note: 1 byte addresses should be padded by the assembler.</sup></sub></p>
<h4>Literal</h4>
<p>Uses a literal byte, in place of reading from a memory address.</p>
<pre><code>LDX #0A2F
</code></pre>
<p><sub><sup>Note: 1 byte addresses should be padded by the assembler.</sup></sub></p>
<h3>Opcodes</h3>
<p>NOTE: these do not specify a higher level assembly langauge, only the opcodes interpreted by the CPU itself (ie there cannot be 3 increments for the different registers that all use <code>INC</code>)</p>
<h4>NOP- No Operation</h4>
<p>seriously?</p>
<table>
<thead>
<tr>
<th>Addressing</th>
<th>Action</th>
<th>Opcode</th>
<th>Size</th>
</tr>
</thead>
<tbody>
<tr>
<td>N/A</td>
<td>NOP</td>
<td><code>$00</code></td>
<td>1 byte</td>
</tr>
</tbody>
</table>
<h4>INC - Increment</h4>
<p>what do you think it does</p>
<table>
<thead>
<tr>
<th>Addressing</th>
<th>Action</th>
<th>Opcode</th>
<th>Size</th>
</tr>
</thead>
<tbody>
<tr>
<td>Absolute</td>
<td>Increments the value at specified memory address</td>
<td><code>$01</code></td>
<td>3 bytes</td>
</tr>
<tr>
<td>Accumulator</td>
<td>Increments the accumulator</td>
<td><code>$02</code></td>
<td>1 byte</td>
</tr>
<tr>
<td>RX</td>
<td>Increments the RAX register</td>
<td><code>$03</code></td>
<td>1 byte</td>
</tr>
<tr>
<td>RY</td>
<td>Increments the RAY register</td>
<td><code>$04</code></td>
<td>1 byte</td>
</tr>
</tbody>
</table>
<h4>DNC - Decrement</h4>
<p>what do you think it does (pt. 2)</p>
<table>
<thead>
<tr>
<th>Addressing</th>
<th>Action</th>
<th>Opcode</th>
<th>Size</th>
</tr>
</thead>
<tbody>
<tr>
<td>Absolute</td>
<td>Decrements the value at specified memory address</td>
<td><code>$05</code></td>
<td>3 bytes</td>
</tr>
<tr>
<td>Accumulator</td>
<td>Decrements the accumulator</td>
<td><code>$06</code></td>
<td>1 byte</td>
</tr>
<tr>
<td>RX</td>
<td>Decrements the RAX register</td>
<td><code>$07</code></td>
<td>1 byte</td>
</tr>
<tr>
<td>RY</td>
<td>Decrements the RAY register</td>
<td><code>$08</code></td>
<td>1 byte</td>
</tr>
</tbody>
</table>
<h4>JIE - Jump If Equal</h4>
<p>jumps if something is equal to other something</p>
<table>
<thead>
<tr>
<th>Addressing</th>
<th>Action</th>
<th>Opcode</th>
<th>Size</th>
</tr>
</thead>
<tbody>
<tr>
<td>Absolute/Literal</td>
<td>Sets PRC to value if memory address is equal to other memory address</td>
<td><code>$10</code></td>
<td>7 bytes</td>
</tr>
<tr>
<td>Register/Literal</td>
<td>Sets PRC to value if RAX and RAY are equal</td>
<td><code>$11</code></td>
<td>1 byte</td>
</tr>
</tbody>
</table>
<h4>JMP - Jump</h4>
<p>jumps unconditionally</p>
<table>
<thead>
<tr>
<th>Addressing</th>
<th>Action</th>
<th>Opcode</th>
<th>Size</th>
</tr>
</thead>
<tbody>
<tr>
<td>Literal</td>
<td>Sets PRC to a literal value</td>
<td><code>$1A</code></td>
<td>3 bytes</td>
</tr>
<tr>
<td>Absolute</td>
<td>Sets PRC to the value of a byte in memory</td>
<td><code>$1B</code></td>
<td>3 bytes</td>
</tr>
</tbody>
</table>
<h5>Example:</h5>
<pre><code>;OP PRC ADDR ADDR
JIE 0x00A2 0x0013 0x0014
</code></pre>
<h4>LDX - Load [RA]X</h4>
<p>loads a value into RAX</p>
<table>
<thead>
<tr>
<th>Addressing</th>
<th>Action</th>
<th>Opcode</th>
<th>Size</th>
</tr>
</thead>
<tbody>
<tr>
<td>Absolute</td>
<td>Loads the value of another byte of memory into RAX</td>
<td><code>$20</code></td>
<td>3 bytes</td>
</tr>
<tr>
<td>Literal</td>
<td>Loads a literal byte into RAX</td>
<td><code>$21</code></td>
<td>2 bytes</td>
</tr>
</tbody>
</table>
<h4>LDY - Load [RA]Y</h4>
<p>loads a value into RAY</p>
<table>
<thead>
<tr>
<th>Addressing</th>
<th>Action</th>
<th>Opcode</th>
<th>Size</th>
</tr>
</thead>
<tbody>
<tr>
<td>Absolute</td>
<td>Loads the value of another byte of memory into RAY</td>
<td><code>$22</code></td>
<td>3 bytes</td>
</tr>
<tr>
<td>Literal</td>
<td>Loads a literal byte into RAY</td>
<td><code>$23</code></td>
<td>2 bytes</td>
</tr>
</tbody>
</table>
<h4>LDA - Load A(ccumulator)</h4>
<p>loads a value into the accumulator</p>
<table>
<thead>
<tr>
<th>Addressing</th>
<th>Action</th>
<th>Opcode</th>
<th>Size</th>
</tr>
</thead>
<tbody>
<tr>
<td>Absolute</td>
<td>Loads the value of another byte of memory into ACC</td>
<td><code>$24</code></td>
<td>3 bytes</td>
</tr>
<tr>
<td>Literal</td>
<td>Loads a literal byte into ACC</td>
<td><code>$25</code></td>
<td>2 bytes</td>
</tr>
</tbody>
</table>
<h4>LOD - Load Address</h4>
<p>loads a value into an address</p>
<table>
<thead>
<tr>
<th>Addressing</th>
<th>Action</th>
<th>Opcode</th>
<th>Size</th>
</tr>
</thead>
<tbody>
<tr>
<td>Absolute</td>
<td>Loads the value of another byte of memory into the memory address</td>
<td><code>$26</code></td>
<td>5 bytes</td>
</tr>
<tr>
<td>Literal</td>
<td>Loads a literal byte into the memory address</td>
<td><code>$27</code></td>
<td>4 bytes</td>
</tr>
</tbody>
</table>
<h4>STX - Store [RA]X</h4>
<p>stores RAX into a memory address</p>
<table>
<thead>
<tr>
<th>Addressing</th>
<th>Action</th>
<th>Opcode</th>
<th>Size</th>
</tr>
</thead>
<tbody>
<tr>
<td>Absolute</td>
<td>Loads the value of RAX into a byte of memory</td>
<td><code>$2A</code></td>
<td>3 bytes</td>
</tr>
</tbody>
</table>
<h4>STY - Store [RA]Y</h4>
<p>stores RAY into a memory address</p>
<table>
<thead>
<tr>
<th>Addressing</th>
<th>Action</th>
<th>Opcode</th>
<th>Size</th>
</tr>
</thead>
<tbody>
<tr>
<td>Absolute</td>
<td>Loads the value of RAY into a byte of memory</td>
<td><code>$2B</code></td>
<td>3 bytes</td>
</tr>
</tbody>
</table>
<h4>STA - Store A(ccumulator)</h4>
<p>stores the accumulator into a memory address</p>
<table>
<thead>
<tr>
<th>Addressing</th>
<th>Action</th>
<th>Opcode</th>
<th>Size</th>
</tr>
</thead>
<tbody>
<tr>
<td>Absolute</td>
<td>Loads the value of ACC into a byte of memory</td>
<td><code>$2C</code></td>
<td>3 bytes</td>
</tr>
</tbody>
</table>
<h4>ADD - Adds Two Values</h4>
<p>adds two values of various source into a register or memory address</p>
<table>
<thead>
<tr>
<th>Addressing</th>
<th>Action</th>
<th>Opcode</th>
<th>Size</th>
</tr>
</thead>
<tbody>
<tr>
<td>RAX</td>
<td>Adds RAX to the value in ACC, and stores it into ACC</td>
<td><code>$40</code></td>
<td>1 byte</td>
</tr>
<tr>
<td>RAY</td>
<td>Adds RAY to the value in ACC, and stores it into ACC</td>
<td><code>$41</code></td>
<td>1 byte</td>
</tr>
<tr>
<td>Absolute/Absolute</td>
<td>Adds the values of two memory addresses, and stores it into ACC</td>
<td><code>$42</code></td>
<td>5 bytes</td>
</tr>
<tr>
<td>Absolute/ACC</td>
<td>Adds the value of a memory address into the value in ACC, and stores it into ACC</td>
<td><code>$43</code></td>
<td>3 bytes</td>
</tr>
</tbody>
</table>
<h4>SUB - Subtracts Two Values</h4>
<p>subtracts two values of various source into a register or memory address</p>
<table>
<thead>
<tr>
<th>Addressing</th>
<th>Action</th>
<th>Opcode</th>
<th>Size</th>
</tr>
</thead>
<tbody>
<tr>
<td>RAX</td>
<td>Subtracts RAX from the value in ACC, and stores it into ACC</td>
<td><code>$45</code></td>
<td>1 byte</td>
</tr>
<tr>
<td>RAY</td>
<td>Subtracts RAY from the value in ACC, and stores it into ACC</td>
<td><code>$46</code></td>
<td>1 byte</td>
</tr>
<tr>
<td>Absolute/Absolute</td>
<td>Subtracts the first address value by the second address value, and stores it into ACC</td>
<td><code>$47</code></td>
<td>5 bytes</td>
</tr>
<tr>
<td>Absolute/ACC</td>
<td>Subtracts the value of a memory address from the value in ACC, and stores it into ACC</td>
<td><code>$48</code></td>
<td>3 bytes</td>
</tr>
</tbody>
</table>
<h4>NAD - NAND</h4>
<p>if you dont know what a NAND is why are you looking at opcode documentation</p>
<table>
<thead>
<tr>
<th>Addressing</th>
<th>Action</th>
<th>Opcode</th>
<th>Size</th>
</tr>
</thead>
<tbody>
<tr>
<td>Register</td>
<td>Performs a bitwise NAND on RAX and RAY and stores it into ACC</td>
<td><code>$50</code></td>
<td>1 byte</td>
</tr>
</tbody>
</table>
<h4>HLT - Halt Operation</h4>
<p>entirely stops execution and attempts to shutdown on hardware</p>
<table>
<thead>
<tr>
<th>Addressing</th>
<th>Action</th>
<th>Opcode</th>
<th>Size</th>
</tr>
</thead>
<tbody>
<tr>
<td>N/A</td>
<td></td>
<td><code>$FC</code></td>
<td></td>
</tr>
</tbody>
</table>
<h4>DBG - Debug</h4>
<p>(in emulators) print a view of memory<br />
(in hardware or an optimizing assembler) NOP</p>
<table>
<thead>
<tr>
<th>Addressing</th>
<th>Action</th>
<th>Opcode</th>
<th>Size</th>
</tr>
</thead>
<tbody>
<tr>
<td>N/A</td>
<td></td>
<td><code>$FF</code></td>
<td></td>
</tr>
</tbody>
</table>
</body></html>