Exemplo n.º 1
0
static void doplusloop(void)
{
    ucell high, low;
    cell increment, startval, endval, offset;

    increment = POP();

    startval = POPR();
    endval = POPR();

    low = (ucell) startval;
    startval += increment;

    PC += sizeof(cell);

    if (increment >= 0) {
        high = (ucell) startval;
    } else {
        high = low;
        low = (ucell) startval;
    }

    if (endval - (low + 1) >= high - low) {
        offset = read_cell(cell2pointer(PC));
        PC += offset;

        PUSHR(endval);
        PUSHR(startval);
    }
}
Exemplo n.º 2
0
static void doloop(void)
{
    cell offset, startval, endval;

    startval = POPR() + 1;
    endval = POPR();

    PC += sizeof(cell);

    if (startval < endval) {
        offset = read_cell(cell2pointer(PC));
        PC += offset;
        PUSHR(endval);
        PUSHR(startval);
    }

}
Exemplo n.º 3
0
static void rto(void)
{
	ucell tmp = POPR();
#ifdef CONFIG_DEBUG_RSTACK
	printk("  R>: %x\n", tmp);
#endif
	PUSH(tmp);
}
Exemplo n.º 4
0
static void semis_dbg(void)
{
    struct debug_xt *debug_xt_item, *debug_xt_up = NULL;

    /* If current semis is in our debug xt list, disable debug mode */
    debug_xt_item = debug_xt_list;
    while (debug_xt_item->next) {
        if (debug_xt_item->xt_semis == PC) {
            if (debug_xt_item->mode != DEBUG_MODE_STEPUP) {
                /* Handle the normal case */
                fstrncpy(xtname, lfa2nfa(debug_xt_item->xt_docol - sizeof(cell)), MAXNFALEN);
                printf_console("\n[ Finished %s ] ", xtname);

                /* Reset to step mode in case we were in trace mode */
                debug_xt_item->mode = DEBUG_MODE_STEP;
            } else {
                /* This word requires execution of the debugger "Up"
                 * semantics. However we can't do this here since we
                 * are iterating through the debug list, and we need
                 * to change it. So we do it afterwards.
                 */
                debug_xt_up = debug_xt_item;
            }
        }

        debug_xt_item = debug_xt_item->next;
    }

    /* Execute debugger "Up" semantics if required */
    if (debug_xt_up) {
        /* Only add the parent word if it is not within the trampoline */
        if (rstack[rstackcnt] != (cell)pointer2cell(&trampoline[1])) {
            del_debug_xt(debug_xt_up->xt_docol);
            add_debug_xt(findxtfromcell(rstack[rstackcnt]));

            fstrncpy(xtname, lfa2nfa(findxtfromcell(rstack[rstackcnt]) - sizeof(cell)), MAXNFALEN);
            printf_console("\n[ Up to %s ] ", xtname);
        } else {
            fstrncpy(xtname, lfa2nfa(findxtfromcell(debug_xt_up->xt_docol) - sizeof(cell)), MAXNFALEN);
            printf_console("\n[ Finished %s (Unable to go up, hit trampoline) ] ", xtname);

            del_debug_xt(debug_xt_up->xt_docol);
        }

        debug_xt_up = NULL;
    }

    PC = POPR();
}
Exemplo n.º 5
0
/* Process 2OP Integer instructions */
bool eval_2OP_Int(struct lilith* vm, struct Instruction* c)
{
	#ifdef DEBUG
	char Name[20] = "ILLEGAL_2OP";
	#endif

	switch(c->raw_XOP)
	{
		case 0x0000: /* NEG */
		{
			#ifdef DEBUG
			strncpy(Name, "NEG", 19);
			#elif TRACE
			record_trace("NEG");
			#endif

			NEG(vm, c);
			break;
		}
		case 0x0001: /* ABS */
		{
			#ifdef DEBUG
			strncpy(Name, "ABS", 19);
			#elif TRACE
			record_trace("ABS");
			#endif

			ABS(vm, c);
			break;
		}
		case 0x0002: /* NABS */
		{
			#ifdef DEBUG
			strncpy(Name, "NABS", 19);
			#elif TRACE
			record_trace("NABS");
			#endif

			NABS(vm, c);
			break;
		}
		case 0x0003: /* SWAP */
		{
			#ifdef DEBUG
			strncpy(Name, "SWAP", 19);
			#elif TRACE
			record_trace("SWAP");
			#endif

			SWAP(vm, c);
			break;
		}
		case 0x0004: /* COPY */
		{
			#ifdef DEBUG
			strncpy(Name, "COPY", 19);
			#elif TRACE
			record_trace("COPY");
			#endif

			COPY(vm, c);
			break;
		}
		case 0x0005: /* MOVE */
		{
			#ifdef DEBUG
			strncpy(Name, "MOVE", 19);
			#elif TRACE
			record_trace("MOVE");
			#endif

			MOVE(vm, c);
			break;
		}
		case 0x0006: /* NOT */
		{
			#ifdef DEBUG
			strncpy(Name, "NOT", 19);
			#elif TRACE
			record_trace("NOT");
			#endif

			NOT(vm, c);
			break;
		}
		case 0x0100: /* BRANCH */
		{
			#ifdef DEBUG
			strncpy(Name, "BRANCH", 19);
			#elif TRACE
			record_trace("BRANCH");
			#endif

			BRANCH(vm, c);
			break;
		}
		case 0x0101: /* CALL */
		{
			#ifdef DEBUG
			strncpy(Name, "CALL", 19);
			#elif TRACE
			record_trace("CALL");
			#endif

			CALL(vm, c);
			break;
		}
		case 0x0200: /* PUSHR */
		{
			#ifdef DEBUG
			strncpy(Name, "PUSHR", 19);
			#elif TRACE
			record_trace("PUSHR");
			#endif

			PUSHR(vm, c);
			break;
		}
		case 0x0201: /* PUSH8 */
		{
			#ifdef DEBUG
			strncpy(Name, "PUSH8", 19);
			#elif TRACE
			record_trace("PUSH8");
			#endif

			PUSH8(vm, c);
			break;
		}
		case 0x0202: /* PUSH16 */
		{
			#ifdef DEBUG
			strncpy(Name, "PUSH16", 19);
			#elif TRACE
			record_trace("PUSH16");
			#endif

			PUSH16(vm, c);
			break;
		}
		case 0x0203: /* PUSH32 */
		{
			#ifdef DEBUG
			strncpy(Name, "PUSH32", 19);
			#elif TRACE
			record_trace("PUSH32");
			#endif

			PUSH32(vm, c);
			break;
		}
		case 0x0280: /* POPR */
		{
			#ifdef DEBUG
			strncpy(Name, "POPR", 19);
			#elif TRACE
			record_trace("POPR");
			#endif

			POPR(vm, c);
			break;
		}
		case 0x0281: /* POP8 */
		{
			#ifdef DEBUG
			strncpy(Name, "POP8", 19);
			#elif TRACE
			record_trace("POP8");
			#endif

			POP8(vm, c);
			break;
		}
		case 0x0282: /* POPU8 */
		{
			#ifdef DEBUG
			strncpy(Name, "POPU8", 19);
			#elif TRACE
			record_trace("POPU8");
			#endif

			POPU8(vm, c);
			break;
		}
		case 0x0283: /* POP16 */
		{
			#ifdef DEBUG
			strncpy(Name, "POP16", 19);
			#elif TRACE
			record_trace("POP16");
			#endif

			POP16(vm, c);
			break;
		}
		case 0x0284: /* POPU16 */
		{
			#ifdef DEBUG
			strncpy(Name, "POPU16", 19);
			#elif TRACE
			record_trace("POPU16");
			#endif

			POPU16(vm, c);
			break;
		}
		case 0x0285: /* POP32 */
		{
			#ifdef DEBUG
			strncpy(Name, "POP32", 19);
			#elif TRACE
			record_trace("POP32");
			#endif

			POP32(vm, c);
			break;
		}
		case 0x0286: /* POPU32 */
		{
			#ifdef DEBUG
			strncpy(Name, "POPU32", 19);
			#elif TRACE
			record_trace("POPU32");
			#endif

			POPU32(vm, c);
			break;
		}
		case 0x0300: /* CMPSKIP.G */
		{
			#ifdef DEBUG
			strncpy(Name, "CMPSKIP.G", 19);
			#elif TRACE
			record_trace("CMPSKIP.G");
			#endif

			CMPSKIP_G(vm, c);
			break;
		}
		case 0x0301: /* CMPSKIP.GE */
		{
			#ifdef DEBUG
			strncpy(Name, "CMPSKIP.GE", 19);
			#elif TRACE
			record_trace("CMPSKIP.GE");
			#endif

			CMPSKIP_GE(vm, c);
			break;
		}
		case 0x0302: /* CMPSKIP.E */
		{
			#ifdef DEBUG
			strncpy(Name, "CMPSKIP.E", 19);
			#elif TRACE
			record_trace("CMPSKIP.E");
			#endif

			CMPSKIP_E(vm, c);
			break;
		}
		case 0x0303: /* CMPSKIP.NE */
		{
			#ifdef DEBUG
			strncpy(Name, "CMPSKIP.NE", 19);
			#elif TRACE
			record_trace("CMPSKIP.NE");
			#endif

			CMPSKIP_NE(vm, c);
			break;
		}
		case 0x0304: /* CMPSKIP.LE */
		{
			#ifdef DEBUG
			strncpy(Name, "CMPSKIP.LE", 19);
			#elif TRACE
			record_trace("CMPSKIP.LE");
			#endif

			CMPSKIP_LE(vm, c);
			break;
		}
		case 0x0305: /* CMPSKIP.L */
		{
			#ifdef DEBUG
			strncpy(Name, "CMPSKIP.L", 19);
			#elif TRACE
			record_trace("CMPSKIP.L");
			#endif

			CMPSKIP_L(vm, c);
			break;
		}
		case 0x0380: /* CMPSKIPU.G */
		{
			#ifdef DEBUG
			strncpy(Name, "CMPSKIPU.G", 19);
			#elif TRACE
			record_trace("CMPSKIPU.G");
			#endif

			CMPSKIPU_G(vm, c);
			break;
		}
		case 0x0381: /* CMPSKIPU.GE */
		{
			#ifdef DEBUG
			strncpy(Name, "CMPSKIPU.GE", 19);
			#elif TRACE
			record_trace("CMPSKIPU.GE");
			#endif

			CMPSKIPU_GE(vm, c);
			break;
		}
		case 0x0384: /* CMPSKIPU.LE */
		{
			#ifdef DEBUG
			strncpy(Name, "CMPSKIPU.LE", 19);
			#elif TRACE
			record_trace("CMPSKIPU.LE");
			#endif

			CMPSKIPU_LE(vm, c);
			break;
		}
		case 0x0385: /* CMPSKIPU.L */
		{
			#ifdef DEBUG
			strncpy(Name, "CMPSKIPU.L", 19);
			#elif TRACE
			record_trace("CMPSKIPU.L");
			#endif

			CMPSKIPU_L(vm, c);
			break;
		}
		default:
		{
			illegal_instruction(vm, c);
			break;
		}
	}
	#ifdef DEBUG
	fprintf(stdout, "# %s reg%u reg%u\n", Name, c->reg0, c->reg1);
	#endif
	return false;
}
Exemplo n.º 6
0
static void semis(void)
{
    PC = POPR();
}