Exemple #1
0
        public static void Main(string[] args)
        {
            SBIL_State state = new SBIL_State();

            byte[] romem = System.IO.File.ReadAllBytes(args[0]);
            byte[] dsmem = new byte[2048];
            byte[] rsmem = new byte[1024];
            SBIL_Funcs.SBIL_CreateState(state, romem, dsmem, rsmem);
            SBIL_ExitState result = SBIL_Funcs.SBIL_Run(state);

            if (result == SBIL_ExitState.YIELD)
            {
                int stack_size = SBIL_Funcs.SBIL_GetStackSize(state);
                Console.WriteLine("Stack Items: {0}", stack_size);
                SBIL_Type type = SBIL_Funcs.SBIL_GetItemType(state, stack_size - 1);
                Console.WriteLine("Item {0} type: {1}", stack_size - 1, type);
                if (type == SBIL_Type.INT)
                {
                    Console.WriteLine("Item {0} value: {1}", stack_size - 1, (int)SBIL_Funcs.SBIL_GetItem(state, stack_size - 1));
                }
            }

            Console.Write("Press any key to continue . . . ");
            Console.ReadKey(true);
        }
 public static void SBIL_CreateState(SBIL_State state, byte[] romem, byte[] dsmem, byte[] rsmem)
 {
     state.pc         = 0;
     state.dsp        = 0;
     state.rsp        = 0;
     state.stack_size = 0;
     state.dsmem      = dsmem;
     state.rsmem      = rsmem;
     state.romem      = romem;
 }
        public static SBIL_ExitState SBIL_Run(SBIL_State state)
        {
            SBIL_Internal_ExitState exitstate;

            while ((exitstate = SBIL_Internal_RunStep(state)) == SBIL_Internal_ExitState.CONTINUE)
            {
            }
            switch (exitstate)
            {
            case SBIL_Internal_ExitState.DONE:
                return(SBIL_ExitState.DONE);

            case SBIL_Internal_ExitState.YIELD:
                return(SBIL_ExitState.YIELD);

            case SBIL_Internal_ExitState.EXCEPTION:
            default:
                return(SBIL_ExitState.UNHANDLED_EXCEPT);
            }
        }
 private static SBIL_Internal_ExitState SBIL_Internal_RunStep(SBIL_State state)
 {
     throw new System.NotImplementedException();
 }
 public static object SBIL_GetItem(SBIL_State state, int index)
 {
     throw new System.NotImplementedException();
 }
 public static SBIL_Type SBIL_GetItemType(SBIL_State state, int index)
 {
     throw new System.NotImplementedException();
 }
 public static int SBIL_GetStackSize(SBIL_State state)
 {
     return(state.stack_size);
 }