ocpu/ocpu.org

158 lines
7.9 KiB
Org Mode
Raw Normal View History

2021-10-15 09:18:37 +00:00
#+OPTIONS: toc:nil num:nil <:nil \n:nil ::nil timestamp:nil *:nil ':nil
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="style.css"/>
#+EXPORT_FILE_NAME: index.html
2021-10-15 08:17:02 +00:00
#+title: ocpu
2021-10-15 09:18:37 +00:00
* GRU ocpu - yet another cpu design
** Features
2021-10-15 08:17:02 +00:00
- little endian
2021-10-19 15:35:26 +00:00
- 16-bit
2021-10-15 08:17:02 +00:00
** Registers
2021-10-19 18:07:09 +00:00
|----------+----------+-------------------------|
| Register | Category | Description |
|----------+----------+-------------------------|
| AL | General | 0xA0, 8-bit |
|----------+----------+-------------------------|
| AH | General | 0xA1, 8-bit |
|----------+----------+-------------------------|
| A | General | 0xAA, 16-bit |
|----------+----------+-------------------------|
| BL | General | 0xB0, 8-bit |
|----------+----------+-------------------------|
| BH | General | 0xB1, 8-bit |
|----------+----------+-------------------------|
| B | General | 0xBB, 16-bit |
|----------+----------+-------------------------|
| CL | General | 0xC0, 8-bit |
|----------+----------+-------------------------|
| CH | General | 0xC1, 8-bit |
|----------+----------+-------------------------|
| C | General | 0xCC, 16-bit |
|----------+----------+-------------------------|
| DL | | 0xD0, 8-bit 4 |
|----------+----------+-------------------------|
| DH | | 0xD1, 8-bit |
|----------+----------+-------------------------|
| D | | 0xDD, 16-bit |
|----------+----------+-------------------------|
| EL | | 0xE0, 8-bit |
|----------+----------+-------------------------|
| EH | | 0xE1, 8-bit |
|----------+----------+-------------------------|
| E | | 0xEE, 16-bit |
|----------+----------+-------------------------|
| FL | | 0xF0, 8-bit |
|----------+----------+-------------------------|
| FH | | 0xF1, 8-bit |
|----------+----------+-------------------------|
| F | | 0xFF, 16-bit |
|----------+----------+-------------------------|
| PC | Pointer | Program Counter, 16-bit |
|----------+----------+-------------------------|
| SP | Poiner | Stack Pointer, 16-bit |
|----------+----------+-------------------------|
| ZF | Flag | Zero Flag |
|----------+----------+-------------------------|
| NF | Flag | Negative Flag |
|----------+----------+-------------------------|
| CF | Flag | Carry Flag |
| | | |
|----------+----------+-------------------------|
| OF | Flag | Overflow Flag |
2021-10-15 08:17:02 +00:00
** Instuctions
|--------------+--------+-------------------------------------------|
| Instructions | Opcode | Description |
|--------------+--------+-------------------------------------------|
| MOV | 0x01 | Place value to register. |
| | | Takes 2 bytes as arguments: |
| | | 1 - Opcode of register |
| | | 2 - Value |
| | | |
|--------------+--------+-------------------------------------------|
| ADD | 0x10 | |
|--------------+--------+-------------------------------------------|
| ADC | 0x11 | |
|--------------+--------+-------------------------------------------|
| SUB | 0x12 | |
|--------------+--------+-------------------------------------------|
| MUL | 0x13 | |
|--------------+--------+-------------------------------------------|
| DIV | 0x14 | |
|--------------+--------+-------------------------------------------|
| INC | 0x15 | Increment |
|--------------+--------+-------------------------------------------|
| DEC | 0x16 | Decrement |
|--------------+--------+-------------------------------------------|
| AND | 0x20 | |
|--------------+--------+-------------------------------------------|
| OR | 0x21 | |
|--------------+--------+-------------------------------------------|
| NOR | 0x22 | |
|--------------+--------+-------------------------------------------|
| XOR | 0x23 | |
|--------------+--------+-------------------------------------------|
| NAND | 0x24 | |
|--------------+--------+-------------------------------------------|
2021-10-15 10:23:42 +00:00
| CMP | 0x25 | Compare |
2021-10-15 08:17:02 +00:00
|--------------+--------+-------------------------------------------|
2021-10-15 10:23:42 +00:00
| PUSH | 0x30 | Push to stack |
2021-10-15 08:17:02 +00:00
|--------------+--------+-------------------------------------------|
2021-10-15 10:23:42 +00:00
| POP | 0x31 | Pop to stack |
2021-10-15 08:17:02 +00:00
|--------------+--------+-------------------------------------------|
2021-10-15 10:23:42 +00:00
| JMP | 0x40 | Jump |
2021-10-15 08:17:02 +00:00
|--------------+--------+-------------------------------------------|
| JSR | 0x41 | Jump to subroutine |
|--------------+--------+-------------------------------------------|
| JC | 0x42 | Jump with carry |
|--------------+--------+-------------------------------------------|
| JNC | 0x43 | Jump without carry |
|--------------+--------+-------------------------------------------|
| JZ | 0x44 | Jump if zero |
|--------------+--------+-------------------------------------------|
| JNZ | 0x45 | Jump if non-zero |
|--------------+--------+-------------------------------------------|
2021-10-15 10:23:42 +00:00
| JE | 0x46 | Jump if equal |
|--------------+--------+-------------------------------------------|
| JL | 0x47 | Jump if lower |
|--------------+--------+-------------------------------------------|
| JH | 0x48 | Jump if higher |
|--------------+--------+-------------------------------------------|
| RTS | 0x49 | Return from subroutine |
2021-10-15 08:17:02 +00:00
|--------------+--------+-------------------------------------------|
| INB | 0x50 | Copies value from I/O port to destination |
|--------------+--------+-------------------------------------------|
| OUTB | 0x51 | Copies value from operand to I/O port |
|--------------+--------+-------------------------------------------|
| NOP | 0x90 | No operation |
0x0* - MOV instructions (maybe it will for LDA or something)
2021-10-15 09:18:37 +00:00
2021-10-15 08:17:02 +00:00
0x1* - Arithmetic (ADD, SUB and others)
2021-10-15 09:18:37 +00:00
2021-10-15 08:17:02 +00:00
0x2* - Logic (AND, OR and others)
2021-10-15 09:18:37 +00:00
2021-10-15 08:17:02 +00:00
0x3* - Stack Operations (PUSH, POP)
2021-10-15 09:18:37 +00:00
2021-10-15 08:17:02 +00:00
0x4* - Jumps
2021-10-15 09:18:37 +00:00
2021-10-15 08:17:02 +00:00
0x5* - Ports Operations
0x90 - NOP
2021-10-15 09:18:37 +00:00
2021-10-15 08:17:02 +00:00
TODO: add interrupts
2021-10-15 09:18:37 +00:00
2021-10-15 08:17:02 +00:00
TODO: add HLT
2021-10-15 09:18:37 +00:00
2021-10-15 08:17:02 +00:00
TODO: make instructions for memory use
2021-10-17 11:11:46 +00:00
TODO: add instructions for setting flags
TODO: add more description
TODO: add ALU