Пример #1
0
int main(int argc, char *argv[])
{
	init_mdata();
	init_adata();

	printf("Loading file 'bytecode'\n");
	pc_t* pc = pc_new("bytecode");

	while (pc_safe(pc))
	{
		printf("ADDR: %x, OP: %x\n", pc->address, pc->line->op);
		pc_inc(pc, 1);
		pc_update(pc);
	}
	pc_inc(pc, -1);
	pc_branch(pc, 1);
	pc_update(pc);

	while (pc_safe(pc))
	{
		printf("ADDR: %x, OP: %x\n", pc->address, pc->line->op);
		pc_inc(pc, 1);
		pc_update(pc);
	}

	pc_return(pc);
	pc_update(pc);
	printf("ADDR: %x, OP: %x\n", pc->address, pc->line->op);

	pc_del(pc);
	return 0;
}
Пример #2
0
unsigned int cop421_execute(unsigned int cycles)
{
	unsigned int completed_cycles;
	
	for (completed_cycles = 0; completed_cycles < cycles; completed_cycles++)
	{
		
		// Store current instruction
		cur_inst = coprom[PC];
		inst_pc = PC;
		// Do preinstruction stuff
		preinst();
		pc_inc();		

		if (!g_skip)
		{
			if (cur_inst == 0x23 || cur_inst == 0x33 || (cur_inst >= 0x60 && cur_inst <= 0x63) || (cur_inst >= 0x68 && cur_inst <= 0x6b))
			{
				cur_operand = coprom[PC];
				pc_inc();
				execute_two_byte();
				
				// TODO: two byte instructions take two clocks?
				completed_cycles++; 
				counter_inc();
				counter_inc();
			}
	
			else // If its one byte
			{
				counter_inc();
				execute_one_byte();
			}
		}
		else
		{
			g_skip = 0;
			if (cur_inst == 0x23 || cur_inst == 0x33 || (cur_inst >= 0x60 && cur_inst <= 0x63) || (cur_inst >= 0x68 && cur_inst <= 0x6b))
			{
				pc_inc();
			}
			completed_cycles--; // TODO: a skipped instruction doesn't take a clock cycle?
		}
	}

	return completed_cycles;
}