first header
This commit is contained in:
parent
f0a1e46ba1
commit
5cdc7ee0a1
51
README.md
51
README.md
@ -1,31 +1,32 @@
|
|||||||
# r16
|
# r16
|
||||||
|
|
||||||
| number | instruction | argument 1 | argument 2 | explanation |
|
| number | instruction | argument 1 | argument 2 | explanation |
|
||||||
|-------:|:-----------:|:----------:|:----------:|---------------------------------------------------|
|
|--------|-------------|------------|------------|---------------------------------------------------|
|
||||||
| 0x00 | HLT | | | halts the CPU |
|
| 0x00 | HLT | | | halts the CPU |
|
||||||
| 0x01 | ADD | value 1 | value 2 | ACU = value 1 + value 2 |
|
| 0x01 | ADD | value 1 | value 2 | ACU = value 1 + value 2 |
|
||||||
| 0x02 | SUB | value 1 | value 2 | ACU = value 1 - value 2 |
|
| 0x02 | SUB | value 1 | value 2 | ACU = value 1 - value 2 |
|
||||||
| 0x03 | MUL | value 1 | value 2 | ACU = value 1 * value 2 |
|
| 0x03 | MUL | value 1 | value 2 | ACU = value 1 * value 2 |
|
||||||
| 0x04 | DIV | value 1 | value 2 | ACU = value 1 / value 2 |
|
| 0x04 | DIV | value 1 | value 2 | ACU = value 1 / value 2 |
|
||||||
| 0x05 | LBS | value | amount | ACU = value << amount |
|
| 0x05 | LBS | value | amount | ACU = value << amount |
|
||||||
| 0x06 | RBS | value | amount | ACU = value << amount |
|
| 0x06 | RBS | value | amount | ACU = value << amount |
|
||||||
| 0x07 | BAN | value 1 | value 2 | ACU = value 1 & value 2 |
|
| 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 |
|
| 0x09 | BXO | value 1 | value 2 | ACU = value 1 ^ value 2 |
|
||||||
| 0x0A | BNO | value | | ACU = ~ value |
|
| 0x0A | BNO | value | | ACU = ~ value |
|
||||||
| 0x0B | PUS | value | | pushes value onto the stack |
|
| 0x0B | PUS | value | | pushes value onto the stack |
|
||||||
| 0x0C | POP | | | pops a value from the stack and stores it in ACU |
|
| 0x0C | POP | | | pops a value from the stack and stores it in ACU |
|
||||||
| 0x0D | JMP | address | | jumps to address |
|
| 0x0D | JMP | address | | jumps to address |
|
||||||
| 0x0E | JEQ | address | value | jumps to address, if value is equal to ACU |
|
| 0x0E | JEQ | address | value | jumps to address, if value is equal to ACU |
|
||||||
| 0x0F | JNZ | address | value | jumps to address, if value is not zero |
|
| 0x0F | JNZ | address | value | jumps to address, if value is not zero |
|
||||||
| 0x10 | CAL | address | | pushes PC + 1 to the stack, then jumps to address |
|
| 0x10 | CAL | address | | pushes PC + 1 to the stack, then jumps to address |
|
||||||
| 0x11 | RET | | | pops value from stack and jumps to it |
|
| 0x11 | RET | | | pops value from stack and jumps to it |
|
||||||
| 0x12 | REG | int type | address | registers int type to address |
|
| 0x12 | REG | int type | address | registers int type to address |
|
||||||
| 0x13 | INT | int type | | interrupts as int type |
|
| 0x13 | INT | int type | | interrupts as int type |
|
||||||
| 0x14 | INP | | | inputs a character into ACU |
|
| 0x14 | INP | | | inputs a character into ACU |
|
||||||
| 0x15 | OUT | value | | outputs value |
|
| 0x15 | OUT | value | | outputs value |
|
||||||
| 0x16 | DIN | location | | reads value from disk at location to ACU |
|
| 0x16 | DIN | location | | reads value from disk at location to ACU |
|
||||||
| 0x17 | DOT | location | value | writes value to disk at location |
|
| 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 |
|
| Number | Register | Usage |
|
||||||
|-------:|---------:|-----------------|
|
|-------:|---------:|-----------------|
|
||||||
|
56
emu/cpu_const.h
Normal file
56
emu/cpu_const.h
Normal 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
|
Loading…
Reference in New Issue
Block a user