示例#1
0
void run( void ) {
    bool running = true;

    while ( running ){
        showRegs();
        int instr = fetch();
        decode( instr );
        eval( &running );
    }
    showRegs();
}
示例#2
0
文件: vm.c 项目: OlliV/pttk91
/**
 * Run program from memory.
 * @param state virtual machine state registers.
 * @param mem program memory space.
 * @param memsize size of program memory space.
 */
void vm_run(struct vm_state * state, uint32_t * mem)
{
    uint32_t instr = 0;
    int error_code;
    int rstate = 0;

    do {
        switch (rstate) {
        case 0: /* Fetch */
#if VM_DEBUG == 1
            showRegs(state);
#endif
            error_code = fetch(&instr, state, mem);
        break;

        case 1: /* Decode */
            error_code = decode(state, instr);
            break;

        case 2: /* Evaluate */
            error_code = eval(state, mem);
            break;

        default:
            error_code = 0;
            break;
        }
        /* Halt on runtime error */
        if (error_code != 0) {
            print_error_msg(error_code);
            state->running = 0;
        }

        if (++rstate > 2)
            rstate = 0;
    } while (state->running);

#if VM_DEBUG == 1
    showRegs(state);
#endif
 }
示例#3
0
文件: eve_vm.c 项目: sorakun/tinyVm
void run(tProgram * p)
{
    p->running = 1;
    p->pc = 0;
    while( p->running )
    {
        //showRegs();
        eval(p);
        fetch(p);
    }
    showRegs();
}