language

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

test.c (656B)


      1 #include <stdlib.h>
      2 #include <stdio.h>
      3 
      4 #include "pc.h"
      5 #include "fh.h"
      6 #include "is.h"
      7 #include "bc.h"
      8 
      9 int main(int argc, char *argv[])
     10 {
     11 	init_mdata();
     12 	init_adata();
     13 
     14 	printf("Loading file 'bytecode'\n");
     15 	pc_t* pc = pc_new("bytecode");
     16 
     17 	while (pc_safe(pc))
     18 	{
     19 		printf("ADDR: %lx, OP: %x\n", pc->address, pc->line->op);
     20 		pc_inc(pc, 1);
     21 		pc_update(pc);
     22 	}
     23 	pc_inc(pc, -1);
     24 	pc_branch(pc, 1);
     25 	pc_update(pc);
     26 
     27 	while (pc_safe(pc))
     28 	{
     29 		printf("ADDR: %lx, OP: %x\n", pc->address, pc->line->op);
     30 		pc_inc(pc, 1);
     31 		pc_update(pc);
     32 	}
     33 
     34 	pc_return(pc);
     35 	pc_update(pc);
     36 	printf("ADDR: %lx, OP: %x\n", pc->address, pc->line->op);
     37 
     38 	pc_del(pc);
     39 	return 0;
     40 }