Initial Commit
This commit is contained in:
@@ -0,0 +1,164 @@
|
||||
#ifndef __SAGITTARIUS_INST_H_
|
||||
#define __SAGITTARIUS_INST_H_
|
||||
#include <stdint.h>
|
||||
/**
|
||||
* Generally, an instruction is 8 bytes, with the first byte being the instruction definition, and the remaining 7 bytes being the instruction data.
|
||||
* Some special instructions take another full 8 bytes as data.
|
||||
*/
|
||||
typedef enum SagittariusInstDef
|
||||
{
|
||||
/**
|
||||
* Math function have 2 operands involved.
|
||||
* Layout:
|
||||
* |0|1|2|3|4|5|
|
||||
* |math2|type|operation|L reg|R reg|Dest reg|
|
||||
*/
|
||||
math2,
|
||||
/**
|
||||
* Math function have 1 operand involved.
|
||||
* Layout:
|
||||
* |0|1|2|3|4|
|
||||
* |math1|type|operation|L reg|Dest reg|
|
||||
*/
|
||||
math1,
|
||||
/**
|
||||
* Type conversion
|
||||
* Layout:
|
||||
* |0|1|2|3|4
|
||||
* |cvt|Src Reg| Src Type| Dst Reg| Dst Type|
|
||||
*/
|
||||
cvt,
|
||||
/**
|
||||
* Set register to a value.
|
||||
* Layout:
|
||||
* |0|1|2..7|8..15(another instruction struct)|
|
||||
* |set|length(1-8 bytes)|padding|payload|
|
||||
*/
|
||||
set,
|
||||
/**
|
||||
* Move data from one register to another.
|
||||
* Layout:
|
||||
* |0|1|2|3|
|
||||
* |mv|length(1-8 bytes)|Src Reg|Dest Reg|
|
||||
*
|
||||
*/
|
||||
mv,
|
||||
/**
|
||||
* Copy data from one register to another
|
||||
* Layout:
|
||||
* |0|1|2|3|
|
||||
* |cp|length(1-8 bytes)|Src Reg|Dest Reg|
|
||||
*/
|
||||
cp,
|
||||
|
||||
/**
|
||||
* Save data to destination memory
|
||||
* Layout:
|
||||
* |0|1|2|3|
|
||||
* |save|length(1-8 bytes)|Src Reg|Dest Mem Ptr (Reg ID)|
|
||||
*/
|
||||
save,
|
||||
/**
|
||||
* Load data from target memory
|
||||
* Layout:
|
||||
* |0|1|2|3|
|
||||
* |load|length(1-8 bytes)|Dest Reg|Src Mem Ptr (Reg ID)|
|
||||
*/
|
||||
load,
|
||||
/**
|
||||
* Jump to target PC.
|
||||
* Layout:
|
||||
* |0|1|2|3/3..6|
|
||||
* |jmp|mode selector: absolute/relative|value mode selector: register/immeidate|reg id/int32|
|
||||
*/
|
||||
jmp,
|
||||
/**
|
||||
* Jump to target PC.
|
||||
* Layout:
|
||||
* |0|1|2|3|4/4..7|
|
||||
* |jmp|mode selector: absolute/relative|value mode selector: register/immeidate|flag register|reg id/int32|
|
||||
*/
|
||||
jmp_if,
|
||||
/**
|
||||
* Call to PC.
|
||||
* Register Mode:
|
||||
* Layout:
|
||||
* |0|1|2|3|4|
|
||||
* |call|mode selector: absolute/relative|0|register to remember|register|
|
||||
* Immeidate Value Mode:
|
||||
*
|
||||
* |0|1|2|3|4..7|8..15|
|
||||
* |call|mode selector: absolute/relative|1|register to remember|padding|uint64_t|
|
||||
*/
|
||||
call,
|
||||
/**
|
||||
* Return
|
||||
* Layout:
|
||||
* |0|1|
|
||||
* |ret|reg to restore (normally sp)|
|
||||
*/
|
||||
ret,
|
||||
/**
|
||||
* Compare
|
||||
* Layout:
|
||||
*
|
||||
* |0|1|2|3|4|5|
|
||||
* |math2|type|operation|L reg|R reg|Dest reg|
|
||||
*/
|
||||
cmp,
|
||||
/**
|
||||
* Vector Math
|
||||
* Layout:
|
||||
* |0|1|2|3|4|5|6|
|
||||
* |math2|w|h|operation|L mem ptr reg|R mem ptr reg| Dest mem ptr reg|
|
||||
*/
|
||||
mathv,
|
||||
/**
|
||||
* Halt execution (Only resumeable from VM holder)
|
||||
* Layout:
|
||||
* |0|
|
||||
* |halt|
|
||||
*/
|
||||
halt,
|
||||
/**
|
||||
* System Call
|
||||
* Layout:
|
||||
* |0|1|2|
|
||||
* |syscall|namespace reg| function id reg|
|
||||
*/
|
||||
syscall,
|
||||
/**
|
||||
* Test System Call
|
||||
* Layout:
|
||||
* |0|1|2|3|
|
||||
* |tsyscall|namespace reg| function id reg| result reg|
|
||||
*/
|
||||
tsyscall,
|
||||
} SagittariusInstDef;
|
||||
typedef enum math2op
|
||||
{
|
||||
sag_math2_add,
|
||||
sag_math2_sub,
|
||||
sag_math2_mul,
|
||||
sag_math2_div,
|
||||
sag_math2_mod,
|
||||
sag_math2_pow,
|
||||
|
||||
} math2op;
|
||||
typedef enum math1op{
|
||||
sag_math1_sin,
|
||||
sag_math1_cos,
|
||||
sag_math1_tan,
|
||||
sag_math1_sinh,
|
||||
sag_math1_cosh,
|
||||
sag_math1_tanh,
|
||||
sag_math1_asin,
|
||||
sag_math1_acos,
|
||||
sag_math1_atan,
|
||||
sag_math1_abs,
|
||||
}math1op;
|
||||
typedef struct SagittariusInst
|
||||
{
|
||||
uint64_t data;
|
||||
} SagittariusInst;
|
||||
#endif
|
||||
Reference in New Issue
Block a user