first header

This commit is contained in:
Rose Apollo 2024-04-18 10:09:07 +00:00
parent f0a1e46ba1
commit 5cdc7ee0a1
2 changed files with 82 additions and 25 deletions

View File

@ -1,7 +1,7 @@
# r16
| number | instruction | argument 1 | argument 2 | explanation |
|-------:|:-----------:|:----------:|:----------:|---------------------------------------------------|
|--------|-------------|------------|------------|---------------------------------------------------|
| 0x00 | HLT | | | halts the CPU |
| 0x01 | ADD | value 1 | value 2 | ACU = value 1 + value 2 |
| 0x02 | SUB | value 1 | value 2 | ACU = value 1 - value 2 |
@ -10,7 +10,7 @@
| 0x05 | LBS | value | amount | ACU = value << amount |
| 0x06 | RBS | value | amount | ACU = value << amount |
| 0x07 | BAN | value 1 | value 2 | ACU = value 1 & value 2 |
| 0x08 | BOR | value 1 | value 2 | ACU = value 1 \| value 2 |
| 0x08 | BOR | value 1 | value 2 | ACU = value 1 \ |
| 0x09 | BXO | value 1 | value 2 | ACU = value 1 ^ value 2 |
| 0x0A | BNO | value | | ACU = ~ value |
| 0x0B | PUS | value | | pushes value onto the stack |
@ -26,6 +26,7 @@
| 0x15 | OUT | value | | outputs value |
| 0x16 | DIN | location | | reads value from disk at location to ACU |
| 0x17 | DOT | location | value | writes value to disk at location |
| 0x18 | MOV | value 1 | value 2 | move value 2 to value 1 |
| Number | Register | Usage |
|-------:|---------:|-----------------|

56
emu/cpu_const.h Normal file
View File

@ -0,0 +1,56 @@
#ifndef EMU_CPU_CONST_H
#define EMU_CPU_CONST_H
typedef enum
{
HLT = 0x00,
ADD = 0x01,
SUB = 0x02,
MUL = 0x03,
DIV = 0x04,
LBS = 0x05,
RBS = 0x06,
BAN = 0x07,
BOR = 0x08,
BXO = 0x09,
BNO = 0x0A,
PUS = 0x0B,
POP = 0x0C,
JMP = 0x0D,
JEQ = 0x0E,
JNZ = 0x0F,
CAL = 0x10,
RET = 0x11,
REG = 0x12,
INT = 0x13,
INP = 0x14,
OUT = 0x15,
DIN = 0x16,
DOT = 0x17,
MOV = 0x18
} CpuInstructions;
typedef enum
{
R0 = 0x0,
R1 = 0x1,
R2 = 0x2,
R3 = 0x3,
ACU = 0x4,
PC = 0x5,
SP = 0x6
} CpuRegisters;
typedef enum
{
value = 0x0,
register = 0x1,
ram = 0x2,
pointerInRegister = 0x3
} ArgumentInfo;
#define INSTRUCTION_BIT_MASK 0b1111111111110000
#define INSTRUCTION_ARG_1_INFO_MASK 0b0000000000001100
#define INSTRUCTION_ARG_2_INFO_MASK 0b0000000000000011
#endif