language

some fools attempt at an interpreted language
Log | Files | Refs | README

is.c (1025B)


      1 #include <stdlib.h>
      2 
      3 #include "is.h"
      4 
      5 #include "fh.h"
      6 #include "bc.h"
      7 
      8 #include "ins_mdata.h"
      9 
     10 /* Takes an opcode, fills metadata about that opcode (given that it exists) in
     11  * the `bc_cont` structure
     12  *  byte_t   - opcode
     13  *  bc_cont* - Bytecode instruction
     14  */
     15 void get_opcode_mdata(byte_t byte, bc_cont* ins)
     16 {
     17 	ins->op    = byte;
     18 	ins->mdata = INS_MDATA[byte];
     19 	ins->adata = INS_ADATA[byte];
     20 }
     21 
     22 /* Fills in metadata in @param byte_t.
     23  * byte_t - un-expanded metadata
     24  * int*   - is number of params          [0]
     25  * int*   - int[3] detailing param types [1]
     26  *
     27  * For example, given a byte 11011011, it would break down into the following:
     28  * @param[1] = 3,
     29  * @param[2] = { 01, 10, 11 }
     30  */
     31 void unencode(byte_t byte, int* n, int* at)
     32 {
     33 	*n    = (byte & (3 << 6)) >> 6;
     34 	at[0] = (byte & (3 << 4)) >> 4;
     35 	at[1] = (byte & (3 << 2)) >> 2;
     36 	at[2] = (byte &  3)           ;
     37 }
     38 
     39 /* Sets up the datastructure to quickly queue for data.
     40  */
     41 void init_mdata(void)
     42 {
     43 	INS_MDATA_DEF();
     44 }
     45 
     46 void init_adata(void)
     47 {
     48 	INS_ADATA_DEF();
     49 }