#+OPTIONS: toc:nil num:nil <:nil \n:nil ::nil timestamp:nil *:nil ':nil #+HTML_HEAD: #+EXPORT_FILE_NAME: index.html #+title: ocpu * GRU ocpu - yet another cpu design ** Features - little endian - 8-bit (maybe will be changed in future) ** Registers |----------+----------+-----------------| | Register | Category | Description | |----------+----------+-----------------| | A | General | 0x0A | |----------+----------+-----------------| | B | General | 0x0B | |----------+----------+-----------------| | C | General | 0x0C | |----------+----------+-----------------| | D | | 0x0D | |----------+----------+-----------------| | E | | 0x0E | |----------+----------+-----------------| | F | | 0x0F | |----------+----------+-----------------| | PC | Pointer | Program Counter | |----------+----------+-----------------| | SP | Poiner | Stack Pointer | |----------+----------+-----------------| | ZF | Flag | Zero Flag | |----------+----------+-----------------| | NF | Flag | Negative Flag | |----------+----------+-----------------| | CF | Flag | Carry Flag | | | | | |----------+----------+-----------------| | OF | Flag | Overflow Flag | ** 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 | | |--------------+--------+-------------------------------------------| | CMP | 0x25 | | |--------------+--------+-------------------------------------------| | PUSH | 0x30 | | |--------------+--------+-------------------------------------------| | POP | 0x31 | | |--------------+--------+-------------------------------------------| | JMP | 0x40 | | |--------------+--------+-------------------------------------------| | 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 | |--------------+--------+-------------------------------------------| | RTS | 0x42 | Return from subroutine | |--------------+--------+-------------------------------------------| | 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) 0x1* - Arithmetic (ADD, SUB and others) 0x2* - Logic (AND, OR and others) 0x3* - Stack Operations (PUSH, POP) 0x4* - Jumps 0x5* - Ports Operations 0x90 - NOP TODO: add interrupts TODO: add HLT TODO: make instructions for memory use