commit last oldspec
parent
eb304476bc
commit
6f587c9333
@ -0,0 +1,158 @@
|
||||
## LRIS CPU/ASM specification (wip)
|
||||
~~shamelessly ripped off~~ very inspired by 6502 because it's the only thing i kinda know
|
||||
|
||||
### Registers
|
||||
| Register | Purpose | Size |
|
||||
| --- | --- | --- |
|
||||
| ACC | Stores the result of any calculation opcodes (if in ACC mode) | 1 byte |
|
||||
| RAX | General purpose register | 1 byte |
|
||||
| RAY | General purpose register | 1 byte |
|
||||
|
||||
### Memory
|
||||
- Up to 64kib of RAM
|
||||
- Up to 64kib of Program ROM
|
||||
|
||||
### Addressing Modes
|
||||
#### Absolute
|
||||
Directly reads from a 2 byte memory address with instruction.
|
||||
```
|
||||
LDX $0A2F
|
||||
```
|
||||
<sub><sup>Note: 1 byte addresses should be padded by the assembler.</sup></sub>
|
||||
|
||||
#### Literal
|
||||
Uses a literal byte, in place of reading from a memory address.
|
||||
```
|
||||
LDX #0A2F
|
||||
```
|
||||
<sub><sup>Note: 1 byte addresses should be padded by the assembler.</sup></sub>
|
||||
|
||||
### Opcodes
|
||||
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 `INC`)
|
||||
|
||||
#### NOP- No Operation
|
||||
seriously?
|
||||
| Addressing | Action | Opcode | Size |
|
||||
| --- | --- | --- | --- |
|
||||
| N/A | NOP | `$00` | 1 byte |
|
||||
|
||||
#### INC - Increment
|
||||
what do you think it does
|
||||
| Addressing | Action | Opcode | Size |
|
||||
| --- | --- | --- | --- |
|
||||
| Absolute | Increments the value at specified memory address | `$01` | 3 bytes |
|
||||
| Accumulator | Increments the accumulator | `$02` | 1 byte |
|
||||
| RX | Increments the RAX register | `$03` | 1 byte |
|
||||
| RY | Increments the RAY register | `$04` | 1 byte |
|
||||
|
||||
#### DNC - Decrement
|
||||
what do you think it does (pt. 2)
|
||||
| Addressing | Action | Opcode | Size |
|
||||
| --- | --- | --- | --- |
|
||||
| Absolute | Decrements the value at specified memory address | `$05` | 3 bytes |
|
||||
| Accumulator | Decrements the accumulator | `$06` | 1 byte |
|
||||
| RX | Decrements the RAX register | `$07` | 1 byte |
|
||||
| RY | Decrements the RAY register | `$08` | 1 byte |
|
||||
|
||||
#### JIE - Jump If Equal
|
||||
jumps if something is equal to other something
|
||||
| Addressing | Action | Opcode | Size |
|
||||
| --- | --- | --- | --- |
|
||||
| Absolute/Literal | Sets PRC to value if memory address is equal to other memory address | `$10` | 7 bytes |
|
||||
| Register/Literal | Sets PRC to value if RAX and RAY are equal | `$11` | 1 byte |
|
||||
|
||||
#### JMP - Jump
|
||||
jumps unconditionally
|
||||
| Addressing | Action | Opcode | Size |
|
||||
| --- | --- | --- | --- |
|
||||
| Literal | Sets PRC to a literal value | `$1A` | 3 bytes
|
||||
| Absolute | Sets PRC to the value of a byte in memory | `$1B` | 3 bytes
|
||||
|
||||
##### Example:
|
||||
```
|
||||
;OP PRC ADDR ADDR
|
||||
JIE 0x00A2 0x0013 0x0014
|
||||
```
|
||||
|
||||
#### LDX - Load [RA]X
|
||||
loads a value into RAX
|
||||
| Addressing | Action | Opcode | Size |
|
||||
| --- | --- | --- | --- |
|
||||
| Absolute | Loads the value of another byte of memory into RAX | `$20` | 3 bytes |
|
||||
| Literal | Loads a literal byte into RAX | `$21` | 2 bytes |
|
||||
|
||||
#### LDY - Load [RA]Y
|
||||
loads a value into RAY
|
||||
| Addressing | Action | Opcode | Size |
|
||||
| --- | --- | --- | --- |
|
||||
| Absolute | Loads the value of another byte of memory into RAY | `$22` | 3 bytes |
|
||||
| Literal | Loads a literal byte into RAY | `$23` | 2 bytes |
|
||||
|
||||
#### LDA - Load A(ccumulator)
|
||||
loads a value into the accumulator
|
||||
| Addressing | Action | Opcode | Size |
|
||||
| --- | --- | --- | --- |
|
||||
| Absolute | Loads the value of another byte of memory into ACC | `$24` | 3 bytes |
|
||||
| Literal | Loads a literal byte into ACC | `$25` | 2 bytes |
|
||||
|
||||
#### LOD - Load Address
|
||||
loads a value into an address
|
||||
| Addressing | Action | Opcode | Size |
|
||||
| --- | --- | --- | --- |
|
||||
| Absolute | Loads the value of another byte of memory into the memory address | `$26` | 5 bytes |
|
||||
| Literal | Loads a literal byte into the memory address | `$27` | 4 bytes |
|
||||
|
||||
#### STX - Store [RA]X
|
||||
stores RAX into a memory address
|
||||
| Addressing | Action | Opcode | Size |
|
||||
| --- | --- | --- | --- |
|
||||
| Absolute | Loads the value of RAX into a byte of memory | `$2A` | 3 bytes |
|
||||
|
||||
#### STY - Store [RA]Y
|
||||
stores RAY into a memory address
|
||||
| Addressing | Action | Opcode | Size |
|
||||
| --- | --- | --- | --- |
|
||||
| Absolute | Loads the value of RAY into a byte of memory | `$2B` | 3 bytes |
|
||||
|
||||
#### STA - Store A(ccumulator)
|
||||
stores the accumulator into a memory address
|
||||
| Addressing | Action | Opcode | Size |
|
||||
| --- | --- | --- | --- |
|
||||
| Absolute | Loads the value of ACC into a byte of memory | `$2C` | 3 bytes |
|
||||
|
||||
#### ADD - Adds Two Values
|
||||
adds two values of various source into a register or memory address
|
||||
| Addressing | Action | Opcode | Size |
|
||||
| --- | --- | --- | --- |
|
||||
| RAX | Adds RAX to the value in ACC, and stores it into ACC | `$40` | 1 byte |
|
||||
| RAY | Adds RAY to the value in ACC, and stores it into ACC | `$41` | 1 byte |
|
||||
| Absolute/Absolute | Adds the values of two memory addresses, and stores it into ACC | `$42` | 5 bytes |
|
||||
| Absolute/ACC | Adds the value of a memory address into the value in ACC, and stores it into ACC | `$43` | 3 bytes |
|
||||
|
||||
#### SUB - Subtracts Two Values
|
||||
subtracts two values of various source into a register or memory address
|
||||
| Addressing | Action | Opcode | Size |
|
||||
| --- | --- | --- | --- |
|
||||
| RAX | Subtracts RAX from the value in ACC, and stores it into ACC | `$45` | 1 byte |
|
||||
| RAY | Subtracts RAY from the value in ACC, and stores it into ACC | `$46` | 1 byte |
|
||||
| Absolute/Absolute | Subtracts the first address' value by the second address' value, and stores it into ACC | `$47` | 5 bytes |
|
||||
| Absolute/ACC | Subtracts the value of a memory address from the value in ACC, and stores it into ACC | `$48` | 3 bytes |
|
||||
|
||||
#### NAD - NAND
|
||||
if you don't know what a NAND is why are you looking at opcode documentation
|
||||
| Addressing | Action | Opcode | Size |
|
||||
| --- | --- | --- | --- |
|
||||
| Register | Performs a bitwise NAND on RAX and RAY and stores it into ACC | `$50` | 1 byte |
|
||||
|
||||
#### HLT - Halt Operation
|
||||
entirely stops execution and attempts to shutdown on hardware
|
||||
| Addressing | Action | Opcode | Size |
|
||||
| --- | --- | --- | --- |
|
||||
| N/A | | `$FC` | |
|
||||
|
||||
#### DBG - Debug
|
||||
(in emulators) print a view of memory
|
||||
(in hardware or an optimizing assembler) NOP
|
||||
| Addressing | Action | Opcode | Size |
|
||||
| --- | --- | --- | --- |
|
||||
| N/A | | `$FF` | |
|
Reference in new issue