コード例 #1
0
ファイル: fonctions.c プロジェクト: loicknuchel/MipsSimulator
int execute_instruction(MIPS simulateur, BP * breakpoint, INSTR * instruction_asm, char * error){
	unsigned int PC;
	int right;
	uint instruction;
	uint opcode;
	uint rs;
	uint rt;
	uint rd;
	uint sa;
	uint function;
	uint immediate;
	uint instr_index;
	uint reste;
	
	PC = get_pc(simulateur);
	instruction = assemble_mot(get_mem(simulateur, PC), get_mem(simulateur, PC+1), get_mem(simulateur, PC+2), get_mem(simulateur, PC+3));
	if(PC < file_sim->text || PC > file_sim->text + file_sim->sizetext){
		sprintf(error, "  ERROR. Execution forbiden outside of the section .text");
		return 2;
	}
	PC = PC+4;
	if(set_pc(simulateur, PC) == 2){
		RED
		printf("\n  execution Adress uncorrect\n");
		ENDCOLOR
		return 1;
	}
コード例 #2
0
ファイル: Debugger-vixl.cpp プロジェクト: Jar-win/Waterfox
void Debugger::DoBreakpoint(const Instruction* instr) {
  VIXL_ASSERT(instr->Mask(ExceptionMask) == BRK);

  printf("Hit breakpoint at pc=%p.\n", reinterpret_cast<const void*>(instr));
  set_debug_parameters(debug_parameters() | DBG_BREAK | DBG_ACTIVE);
  // Make the shell point to the brk instruction.
  set_pc(instr);
}
コード例 #3
0
ファイル: lc8670.c プロジェクト: jiangzhonghui/mame
void lc8670_cpu_device::state_import(const device_state_entry &entry)
{
	switch (entry.index())
	{
		case STATE_GENPC:
			set_pc(m_pc);
			break;
	}
}
コード例 #4
0
ファイル: sx_controller.hpp プロジェクト: DannyHavenith/sxsim
		void execute( const call &, int arg_addr8)
		{
			push( program_counter);
			set_pc( arg_addr8 | ((address_t( ram( sx_ram::STATUS)) & 0x00e0) << 4));

			if (stack.size() > sx_stack_size)
			{
				throw stack_overflow_exception( stack.back());
			}
		}
コード例 #5
0
ファイル: sx_controller.hpp プロジェクト: DannyHavenith/sxsim
		void set_state( const sx_state &s)
		{
			ram = s.ram;
			w = s.w;
			m = s.m;
			in_interrupt = s.in_interrupt;
			set_pc( s.pc);
			stack = s.stack;
			cycle_counter = s.cycle_counter;
		}
コード例 #6
0
int
hal_syscall_handler(void)
{
    CYG_ADDRWORD func, arg1, arg2, arg3, arg4;
    CYG_ADDRWORD err, sig;
    int retreg;
    target_register_t sr = get_register(REG_SR);

    if ((sr & CYGARC_SR_PM) == 0 || (sr & CYGARC_SR_BS) == 0) {
	// bank zero regs
	func = get_register(REG_B0R0);
	arg1 = get_register(REG_B0R1);
	arg2 = get_register(REG_B0R2);
	arg3 = get_register(REG_B0R3);
	arg4 = 0;
	retreg = REG_B0R0;
    } else {
	func = get_register(REG_B1R0);
	arg1 = get_register(REG_B1R1);
	arg2 = get_register(REG_B1R2);
	arg3 = get_register(REG_B1R3);
	retreg = REG_B1R0;
    }
 
    set_pc(get_pc()+2);

    if (func == SYS_exit) {
	// We want to stop in exit so that the user may poke around
	//  to see why his app exited.
        return SIGTRAP;
    }

    if (func == SYS_interrupt) {
	//  A console interrupt landed us here.
	//  Invoke the debug agent so as to cause a SIGINT.
        return SIGINT;
    }

    if (__do_syscall(func, arg1, arg2, arg3, arg4, &err, &sig)) {
        put_register(retreg, err);
	return (int)sig;
    }

    return SIGTRAP;
}
コード例 #7
0
ファイル: hal_stub.c プロジェクト: KarenHung/ecosgit
// Called at stub *kill*
static void 
handle_exception_exit( void )
{
#ifdef CYGPKG_REDBOOT
#ifdef CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
    {   // Reset the timer to default and cancel any callback
	extern void sys_profile_reset(void);
	sys_profile_reset();
    }
#endif // CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF
    set_pc((target_register_t)return_from_stub);
#else
    int i;

    for (i = 0; i < (sizeof(registers)/sizeof(registers[0])); i++)
	registers[i] = orig_registers[i];
#endif
}
コード例 #8
0
ファイル: sx_controller.hpp プロジェクト: DannyHavenith/sxsim
		void do_interrupt()
		{
			if (!in_interrupt)
			{
				in_interrupt = true;
				interrupt_state.pc = program_counter;
				interrupt_state.w = w;
				interrupt_state.fsr = ram( sx_ram::FSR);
				interrupt_state.status = ram( sx_ram::STATUS);
				ram( sx_ram::STATUS) &= 0x1f; // clear page bits.
				set_pc(0);
				set_nop_delay( 2);
			}
			else
			{
				if (throw_on_rtcc_overflow)
				{
					throw rtcc_overflow_exception(get_pc());
				}
			}
		}
コード例 #9
0
ファイル: lc8670.c プロジェクト: jiangzhonghui/mame
void lc8670_cpu_device::check_irqs()
{
	// update P3 interrupt
	check_p3int();

	if (m_irq_flag && !m_after_reti)
	{
		int irq = 0;
		UINT8 priority = 0;

		// highest priority IRQ
		if (!(REG_IE & 0x01) && (m_irq_flag & 0x02))
		{
			irq = 0x01;
			priority = 2;
		}
		else if (!(REG_IE & 0x02) && (m_irq_flag & 0x04))
		{
			irq = 0x02;
			priority = 2;
		}

		// high priority IRQ
		else if ((REG_IE & 0x80) && ((REG_IP<<3) & m_irq_flag))
		{
			for(int i=3; i<=10; i++)
				if ((m_irq_flag & (REG_IP<<3)) & (1<<i))
				{
					irq = i;
					priority = 1;
					break;
				}
		}

		// low priority IRQ
		else if ((REG_IE & 0x80) && (m_irq_flag & 0x02))
		{
			irq = 0x01;
			priority = 0;
		}
		else if ((REG_IE & 0x80) && (m_irq_flag & 0x04))
		{
			irq = 0x02;
			priority = 0;
		}
		else if (REG_IE & 0x80)
		{
			for(int i=3; i<=10; i++)
				if (m_irq_flag & (1<<i))
				{
					irq = i;
					priority = 0;
					break;
				}
		}

		// IRQ with less priority of current interrupt are not executed until the end of the current interrupt routine
		if (irq != 0 && ((m_irq_lev & (1<<priority)) || (priority == 0 && (m_irq_lev & 0x06)) || (priority == 1 && (m_irq_lev & 0x04))))
		{
			if (LOG_IRQ)    logerror("%s: interrupt %d (Priority=%d, Level=%d) delayed\n", tag(), irq, priority, m_irq_lev);
			irq = 0;
		}

		if (irq != 0)
		{
			if (LOG_IRQ)    logerror("%s: interrupt %d (Priority=%d, Level=%d) executed\n", tag(), irq, priority, m_irq_lev);

			m_irq_lev |= (1<<priority);

			push((m_pc>>0) & 0xff);
			push((m_pc>>8) & 0xff);

			set_pc(s_irq_vectors[irq]);

			REG_PCON &= ~HALT_MODE;     // interrupts resume from HALT state

			// clear the IRQ flag
			m_irq_flag &= ~(1<<irq);

			standard_irq_callback(irq);
		}
	}
コード例 #10
0
ファイル: gdb.c プロジェクト: JanmanX/KUDOS
/* return value: 0 if the simulator is to be killed,
 *               1 if the simulator is to be continued.
 */
static int process_gdb_loop(void)
{
  int addr;
  int length;
  int cpu_id;
  int step_cpu, other_cpu = 0;
  char *ptr;
  char type;
  int regnum;
  uint32_t val;

  regnum = regnum;
  step_cpu = other_cpu = 0;

  /* if the hardware is running, we dropped here because the user has
   * hit break in gdb, so we send a signal to GDB indicating that */
  if (hardware->running == 1) {
      remcomOutBuffer[0] = 'S';
      remcomOutBuffer[1] = '0';
      remcomOutBuffer[2] = '5';
      remcomOutBuffer[3] = 0;
      putpacket((unsigned char *)remcomOutBuffer);
  }

  while (1)
    {
      remcomOutBuffer[0] = 0;

      ptr = (char*)getpacket();
      if (ptr == NULL) {
          /* we didn't receive a valid packet, assume that
             the connection has been terminated */
          gdb_interface_close();

          return 1;
      }

      if (debug_packets) printf("from gdb:%s\n", ptr);
      switch (*ptr++) {
      case '?': /* `?' -- last signal */
          remcomOutBuffer[0] = 'S';
          remcomOutBuffer[1] = '0';
          remcomOutBuffer[2] = '1';
          remcomOutBuffer[3] = 0;
          break;
      case 'c':    /* cAA..AA    Continue at address AA..AA(optional) */
          if (hexToInt(&ptr, &addr))
              set_pc(step_cpu, addr);
          hardware->running = 1;
          return 1;
          break;
      case 'd': /* `d' -- toggle debug *(deprecated)* */
          debug_packets = (debug_packets + 1) % 2;
          break;
      case 'g':		/* return the value of the CPU registers */
          read_registers(other_cpu, remcomOutBuffer);
          break;
      case 'G':	   /* set the value of the CPU registers - return OK */
          write_registers(other_cpu, ptr);
          strcpy(remcomOutBuffer,"OK");
	  break;
      case 'H': /* `H'CT... -- set thread */
          type = *ptr++;
          if (hexToInt(&ptr, &cpu_id)) {
              if (cpu_id == -1 || cpu_id == 0) /* XXX all threads */
                  cpu_id = 1;
              if (type == 'c') {
                  step_cpu = cpu_id - 1; /* minus one because
                                            gdb threats start from 1
                                            and yams cpu's from 0. */
                  strcpy(remcomOutBuffer, "OK");
              } else if (type == 'g') {
                  other_cpu = cpu_id - 1; /* same here */
                  strcpy(remcomOutBuffer, "OK");
              } else
                  strcpy(remcomOutBuffer, "E01");
          } else
              strcpy(remcomOutBuffer, "E01");
          break;
      case 'k' : 	  /* kill the program */
          return 0;
          break;
      case 'm':	  /* mAA..AA,LLLL  Read LLLL bytes at address AA..AA */
          if (hexToInt(&ptr,&addr) &&*ptr++==','&& hexToInt(&ptr,&length)) {
              if (read_mem(addr, length, remcomOutBuffer))
                  strcpy(remcomOutBuffer, "E03");
          } else
              strcpy(remcomOutBuffer, "E01");
          break;
      case 'M': /* MAA..AA,LLLL: Write LLLL bytes at address AA.AA */
          if (hexToInt(&ptr, &addr) && *ptr++ == ','
              && hexToInt(&ptr, &length) && *ptr++ == ':') {
              if (!write_mem(addr, length, ptr))
                  strcpy(remcomOutBuffer, "OK");
              else
                  strcpy(remcomOutBuffer, "E03");
          }
          else
              strcpy(remcomOutBuffer, "E02");
          break;
      case 'p': /* `p'HEX NUMBER OF REGISTER -- read register packet */
          if (hexToInt(&ptr, &regnum) && regnum <= 73)
              sprintf(remcomOutBuffer, "%08x",
                      read_register(other_cpu, regnum));
          else
              sprintf(remcomOutBuffer, "E01");
          break;
      case 'P': /* `P'N...`='R... -- write register */
          if (hexToInt(&ptr, (int*)&regnum) && *ptr++=='=' && hexToInt(&ptr, (int*)&val)) {
              write_register(other_cpu, regnum, val);
              sprintf(remcomOutBuffer, "OK");
          } else
              sprintf(remcomOutBuffer, "E01");
      case 'q': /* `q'QUERY -- general query */
          if (!strcmp(ptr, "fThreadInfo")) {
              int i;
              char *ptr = remcomOutBuffer;
              ptr += sprintf(ptr, "m01");
              if (hardware->num_cpus > 1)
                  for (i = 1; i < hardware->num_cpus; i++)
                      ptr += sprintf(ptr, ",%02x", i + 1);
              sprintf(ptr, "l");
          }
          break;
      case 's': /* `s'ADDR -- step */
          command_step(1);
          sprintf(remcomOutBuffer, "S01");
          break;
      case 'T': /* `T'XX -- thread alive */
          if (hexToInt(&ptr, &cpu_id) && --cpu_id < hardware->num_cpus)
              strcpy(remcomOutBuffer, "OK");
          else
              strcpy(remcomOutBuffer, "E01");
          break;
      case 'z':   /* remove breakpoint: `Z'TYPE`,'ADDR`,'LENGTH */
          type = *ptr++;
          if (*ptr++== ',' && hexToInt(&ptr, &addr)
              && *ptr++ == ',' && hexToInt(&ptr, &length)) {
              if (type == '1') { /* hardware breakpoint */
                  command_breakpoint(0xFFFFFFFF);
                  strcpy(remcomOutBuffer, "OK");
              } else /* all others are unsupported */
                  strcpy(remcomOutBuffer, "E01");
          } else
              strcpy(remcomOutBuffer, "E02");
          break;
      case 'Z':  /* insert breakpoint: `Z'TYPE`,'ADDR`,'LENGTH */
          type = *ptr++;
          if (*ptr++== ',' && hexToInt(&ptr, &addr)
              && *ptr++ == ',' && hexToInt(&ptr, &length)) {
              if (type == '1') { /* hardware breakpoint */
                  command_breakpoint(addr);
                  strcpy(remcomOutBuffer, "OK");
              } else /* all others are unsupported */
                  strcpy(remcomOutBuffer, "E01");

          } else
              strcpy(remcomOutBuffer, "E02");
          break;
      default:
          break;
      }			/* switch */

      /* reply to the request */
      putpacket((unsigned char *)remcomOutBuffer);
      if (debug_packets) printf("to gdb: %s\n", remcomOutBuffer);
    }

}
コード例 #11
0
void initial_entry(int entry)
{
	set_pc(entry);
}
コード例 #12
0
ファイル: sx_controller.hpp プロジェクト: DannyHavenith/sxsim
		void execute( const jmp &, int addr9_)
		{
			set_pc( addr9_ | ((address_t( ram( sx_ram::STATUS)) & 0x00e0) << 4));
			set_nop_delay( 2);
		}
コード例 #13
0
ファイル: telnum.cpp プロジェクト: hexd0t/PAD2Praktikum
Telnum::Telnum(string stelnr, string sfname, string slname, string sstreet, int ihnr, int ipc, string slocation)
: telnr(stelnr), fname(sfname), lname(slname), street(sstreet), hnr(ihnr), pc(ipc), location(slocation) {
    set_telnum(stelnr); //ueberpruefen auf Gueltigkeit der Telefonnumer
    set_pc(ipc); //ueberpruefen auf Gueltigkeit der Plz
}