109 lines
4.2 KiB
C
109 lines
4.2 KiB
C
#ifndef INCLUDED_CONSTANTS_H
|
|
#define INCLUDED_CONSTANTS_H
|
|
|
|
#include <stdint.h>
|
|
|
|
typedef uint16_t LispInst;
|
|
|
|
#define INST_NIL ((LispInst) 0)
|
|
#define INST_T ((LispInst) 1)
|
|
#define INST_STRING ((LispInst) 2)
|
|
#define INST_INT ((LispInst) 3)
|
|
#define INST_FLOAT ((LispInst) 4)
|
|
#define INST_CONS ((LispInst) 5)
|
|
#define INST_LIST ((LispInst) 6)
|
|
#define INST_VECTOR ((LispInst) 7)
|
|
#define INST_LENGTH ((LispInst) 8)
|
|
#define INST_INTERN_LIT ((LispInst) 9)
|
|
#define INST_INTERN_DYN ((LispInst) 10)
|
|
#define INST_TYPE_OF ((LispInst) 11)
|
|
#define INST_SYMBOL_NAME ((LispInst) 12)
|
|
#define INST_MOV ((LispInst) 13)
|
|
#define INST_FUNCALL ((LispInst) 14)
|
|
#define INST_RETVAL_COUNT ((LispInst) 15)
|
|
#define INST_GET_RETVAL_COUNT ((LispInst) 16)
|
|
#define INST_ENTER_LEXENV ((LispInst) 17)
|
|
#define INST_ENTER_BLOCK ((LispInst) 18)
|
|
#define INST_LEAVE_BLOCK ((LispInst) 19)
|
|
#define INST_SET_VALUE ((LispInst) 20)
|
|
#define INST_SET_FUNCTION ((LispInst) 21)
|
|
#define INST_GET_VALUE ((LispInst) 22)
|
|
#define INST_GET_FUNCTION ((LispInst) 23)
|
|
#define INST_BOUNDP ((LispInst) 24)
|
|
#define INST_FUNCTIONP ((LispInst) 25)
|
|
#define INST_NEWFUNCTION_LIT ((LispInst) 26)
|
|
#define INST_NEWFUNCTION_DYN ((LispInst) 27)
|
|
#define INST_PUT ((LispInst) 28)
|
|
#define INST_GET ((LispInst) 29)
|
|
#define INST_AND ((LispInst) 30)
|
|
#define INST_ANDN ((LispInst) 31)
|
|
#define INST_OR ((LispInst) 32)
|
|
#define INST_ORN ((LispInst) 33)
|
|
#define INST_XOR ((LispInst) 34)
|
|
#define INST_XORN ((LispInst) 35)
|
|
#define INST_NOT ((LispInst) 36)
|
|
#define INST_JMP ((LispInst) 37)
|
|
#define INST_CJMP ((LispInst) 38)
|
|
#define INST_CAR ((LispInst) 39)
|
|
#define INST_CDR ((LispInst) 40)
|
|
#define INST_SETCAR ((LispInst) 41)
|
|
#define INST_SETCDR ((LispInst) 42)
|
|
#define INST_GETELT_LIT ((LispInst) 43)
|
|
#define INST_GETELT_DYN ((LispInst) 44)
|
|
#define INST_SETELT_LIT ((LispInst) 45)
|
|
#define INST_SETELT_DYN ((LispInst) 46)
|
|
#define INST_EQ ((LispInst) 47)
|
|
#define INST_NUM_GT ((LispInst) 48)
|
|
#define INST_NUM_GE ((LispInst) 49)
|
|
#define INST_NUM_EQ ((LispInst) 50)
|
|
#define INST_NUM_LE ((LispInst) 51)
|
|
#define INST_NUM_LT ((LispInst) 52)
|
|
#define INST_ADD ((LispInst) 53)
|
|
#define INST_ADDN ((LispInst) 54)
|
|
#define INST_SUB ((LispInst) 55)
|
|
#define INST_SUBN ((LispInst) 56)
|
|
#define INST_MUL ((LispInst) 57)
|
|
#define INST_MULN ((LispInst) 58)
|
|
#define INST_DIV ((LispInst) 59)
|
|
#define INST_INT_DIV ((LispInst) 60)
|
|
#define INST_RECIP ((LispInst) 61)
|
|
#define INST_MOD ((LispInst) 62)
|
|
#define INST_SQRT ((LispInst) 63)
|
|
#define INST_POW ((LispInst) 64)
|
|
#define INST_LN ((LispInst) 65)
|
|
#define INST_EXP ((LispInst) 66)
|
|
#define INST_SIN ((LispInst) 67)
|
|
#define INST_COS ((LispInst) 68)
|
|
#define INST_TAN ((LispInst) 69)
|
|
#define INST_ASIN ((LispInst) 70)
|
|
#define INST_ACOS ((LispInst) 71)
|
|
#define INST_ATAN ((LispInst) 72)
|
|
#define INST_BITAND ((LispInst) 73)
|
|
#define INST_BITOR ((LispInst) 74)
|
|
#define INST_BITXOR ((LispInst) 75)
|
|
#define INST_BITNOR ((LispInst) 76)
|
|
#define INST_BITNEG ((LispInst) 77)
|
|
#define INST_LSH ((LispInst) 78)
|
|
#define INST_ASH ((LispInst) 79)
|
|
#define N_INSTRUCTIONS ((LispInst) 80)
|
|
|
|
extern const char *INSTRUCTION_NAMES[];
|
|
|
|
typedef uint8_t LispRegType;
|
|
typedef struct {
|
|
LispRegType type;
|
|
uint32_t which;
|
|
} LispReg;
|
|
|
|
#define REG_VAL ((LispRegType) 0)
|
|
#define REG_SAVED ((LispRegType) 1)
|
|
#define REG_ARG ((LispRegType) 2)
|
|
#define REG_RET ((LispRegType) 3)
|
|
#define N_REGISTTERS 4
|
|
|
|
extern const char *REGISTER_NAMES[];
|
|
|
|
#define SAME_REG(r1, r2) ((r1)->type == (r2)->type && (r1)->which == (r2)->which)
|
|
|
|
#endif
|