ocpu/ocpu.org

7.9 KiB

ocpu

GRU ocpu - yet another cpu design

Features

  • little endian
  • 16-bit

Registers

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

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 Compare
PUSH 0x30 Push to stack
POP 0x31 Pop to stack
JMP 0x40 Jump
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
JE 0x46 Jump if equal
JL 0x47 Jump if lower
JH 0x48 Jump if higher
RTS 0x49 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

TODO: add instructions for setting flags

TODO: add more description

TODO: add ALU