m16run.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* This file is part of the program psim.
  2. Copyright (C) 1998, Andrew Cagney <cagney@highland.com.au>
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation; either version 3 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #include "sim-main.h"
  15. #include "m16_idecode.h"
  16. #include "m32_idecode.h"
  17. #include "bfd.h"
  18. #define SD sd
  19. #define CPU cpu
  20. void
  21. sim_engine_run (SIM_DESC sd,
  22. int next_cpu_nr,
  23. int nr_cpus, /* ignore */
  24. int siggnal) /* ignore */
  25. {
  26. sim_cpu *cpu = STATE_CPU (sd, next_cpu_nr);
  27. address_word cia = CPU_PC_GET (cpu);
  28. while (1)
  29. {
  30. address_word nia;
  31. #if defined (ENGINE_ISSUE_PREFIX_HOOK)
  32. ENGINE_ISSUE_PREFIX_HOOK ();
  33. #endif
  34. if ((cia & 1))
  35. {
  36. m16_instruction_word instruction_0 = IMEM16 (cia);
  37. nia = m16_idecode_issue (sd, instruction_0, cia);
  38. }
  39. else
  40. {
  41. m32_instruction_word instruction_0 = IMEM32 (cia);
  42. nia = m32_idecode_issue (sd, instruction_0, cia);
  43. }
  44. #if defined (ENGINE_ISSUE_POSTFIX_HOOK)
  45. ENGINE_ISSUE_POSTFIX_HOOK ();
  46. #endif
  47. /* Update the instruction address */
  48. cia = nia;
  49. /* process any events */
  50. if (sim_events_tick (sd))
  51. {
  52. CPU_PC_SET (CPU, cia);
  53. sim_events_process (sd);
  54. cia = CPU_PC_GET (CPU);
  55. }
  56. }
  57. }