ins_def.h (3714B)
1 /* `INS_DEF` provides instruction definitons 2 */ 3 4 #ifndef INS_DEF_H 5 #define INS_DEF_H 6 7 #include <stdlib.h> 8 #include <stdio.h> 9 10 #include "proc.h" 11 #include "rt.h" 12 #include "bc.h" 13 #include "stk.h" 14 #include "var.h" 15 #include "var_ops.h" 16 #include "pc.h" 17 #include "helper.h" 18 19 #define INS_DEC(op, function, description) INS_DEF[op] = function; INS_DESC[op] = description 20 21 // This array is populated by init_ins_def( void ); 22 void (*INS_DEF[0x100])(rt_t*, bc_cont*); 23 char* INS_DESC[0x100]; 24 25 /* Initializes INS_DEF with pointers to each instructions function 26 * Populates INS_DEF 27 */ 28 void init_ins_def( void ); 29 30 /* Checks if instruction exists. 31 * byte_t - opcode 32 */ 33 int ins_def_is_valid(bc_cont*); 34 35 void run_ins(rt_t*, bc_cont*); 36 37 /* Instruction subroutines. Each subroutine takes the following arguements: 38 * rt_t* - Runtime context 39 * bc_cont* - Instruction data 40 */ 41 void _ins_def_NULL (rt_t*, bc_cont*); 42 void _ins_def_SYNC (rt_t*, bc_cont*); 43 void _ins_def_PRINT (rt_t*, bc_cont*); 44 void _ins_def_DEBUG (rt_t*, bc_cont*); 45 void _ins_def_ARGB (rt_t*, bc_cont*); 46 void _ins_def_LIBC (rt_t*, bc_cont*); 47 48 void _ins_def_POP (rt_t*, bc_cont*); 49 void _ins_def_ROT (rt_t*, bc_cont*); 50 void _ins_def_DUP (rt_t*, bc_cont*); 51 void _ins_def_ROT_THREE(rt_t*, bc_cont*); 52 53 void _ins_def_DEC (rt_t*, bc_cont*); 54 void _ins_def_LOV (rt_t*, bc_cont*); 55 void _ins_def_STV (rt_t*, bc_cont*); 56 void _ins_def_CTV (rt_t*, bc_cont*); 57 void _ins_def_CTS (rt_t*, bc_cont*); 58 59 void _ins_def_TYPEOF (rt_t*, bc_cont*); 60 void _ins_def_CAST (rt_t*, bc_cont*); 61 62 void _ins_def_ADD (rt_t*, bc_cont*); 63 void _ins_def_SUB (rt_t*, bc_cont*); 64 void _ins_def_MULT (rt_t*, bc_cont*); 65 void _ins_def_DIV (rt_t*, bc_cont*); 66 void _ins_def_POW (rt_t*, bc_cont*); 67 void _ins_def_BRT (rt_t*, bc_cont*); 68 void _ins_def_SIN (rt_t*, bc_cont*); 69 void _ins_def_COS (rt_t*, bc_cont*); 70 void _ins_def_TAN (rt_t*, bc_cont*); 71 void _ins_def_ISIN (rt_t*, bc_cont*); 72 void _ins_def_ICOS (rt_t*, bc_cont*); 73 void _ins_def_ITAN (rt_t*, bc_cont*); 74 void _ins_def_MOD (rt_t*, bc_cont*); 75 void _ins_def_BOR (rt_t*, bc_cont*); 76 void _ins_def_BXOR (rt_t*, bc_cont*); 77 void _ins_def_BNAND (rt_t*, bc_cont*); 78 79 void _ins_def_GTHAN (rt_t*, bc_cont*); 80 void _ins_def_LTHAN (rt_t*, bc_cont*); 81 void _ins_def_GTHAN_EQ (rt_t*, bc_cont*); 82 void _ins_def_LTHAN_EQ (rt_t*, bc_cont*); 83 void _ins_def_EQ (rt_t*, bc_cont*); 84 void _ins_def_NEQ (rt_t*, bc_cont*); 85 void _ins_def_NOT (rt_t*, bc_cont*); 86 void _ins_def_OR (rt_t*, bc_cont*); 87 void _ins_def_AND (rt_t*, bc_cont*); 88 89 /* HELPER FUNCTIONS */ 90 void _ins_def_loop_break(rt_t*); 91 /* END HELPER FUNCTIONS */ 92 void _ins_def_STARTL (rt_t*, bc_cont*); 93 void _ins_def_CLOOP (rt_t*, bc_cont*); 94 void _ins_def_BREAK (rt_t*, bc_cont*); 95 void _ins_def_ENDL (rt_t*, bc_cont*); 96 97 /* HELPER FUNCTIONS */ 98 void _ins_def_branch_to_end_if(rt_t*); 99 /* END HELPER FUNCTIONS */ 100 void _ins_def_GOTO (rt_t*, bc_cont*); 101 void _ins_def_JUMPF (rt_t*, bc_cont*); 102 void _ins_def_IFDO (rt_t*, bc_cont*); 103 void _ins_def_ELSE (rt_t*, bc_cont*); 104 void _ins_def_DONE (rt_t*, bc_cont*); 105 void _ins_def_CALL (rt_t*, bc_cont*); 106 107 void _ins_def_GETN (rt_t*, bc_cont*); 108 void _ins_def_SETN (rt_t*, bc_cont*); 109 void _ins_def_CALLM (rt_t*, bc_cont*); 110 void _ins_def_INDEXO (rt_t*, bc_cont*); 111 void _ins_def_MODO (rt_t*, bc_cont*); 112 113 void _ins_def_RETURN (rt_t*, bc_cont*); 114 void _ins_def_NEW (rt_t*, bc_cont*); 115 void _ins_def_ENDCLASS (rt_t*, bc_cont*); 116 void _ins_def_DENS (rt_t*, bc_cont*); 117 void _ins_def_DECLASS (rt_t*, bc_cont*); 118 void _ins_def_DEFUN (rt_t*, bc_cont*); 119 120 #endif //INS_DEF_H