/[gxemul]/trunk/src/cpu_urisc.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/src/cpu_urisc.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 9 by dpavlin, Mon Oct 8 16:17:48 2007 UTC revision 10 by dpavlin, Mon Oct 8 16:18:27 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: cpu_urisc.c,v 1.6 2005/04/04 20:08:58 debug Exp $   *  $Id: cpu_urisc.c,v 1.8 2005/06/26 22:23:42 debug Exp $
29   *   *
30   *  URISC CPU emulation.  See http://en.wikipedia.org/wiki/URISC for more   *  URISC CPU emulation.  See http://en.wikipedia.org/wiki/URISC for more
31   *  information about the "instruction set".   *  information about the "instruction set".
# Line 93  extern int quiet_mode; Line 93  extern int quiet_mode;
93   *   *
94   *  Create a new URISC cpu object.   *  Create a new URISC cpu object.
95   */   */
96  struct cpu *urisc_cpu_new(struct memory *mem, struct machine *machine,  int urisc_cpu_new(struct cpu *cpu, struct memory *mem, struct machine *machine,
97          int cpu_id, char *cpu_type_name)          int cpu_id, char *cpu_type_name)
98  {  {
99          struct cpu *cpu;          if (strcmp(cpu_type_name, "URISC") != 0)
100                    return 0;
         if (cpu_type_name == NULL || strcmp(cpu_type_name, "URISC") != 0)  
                 return NULL;  
   
         cpu = malloc(sizeof(struct cpu));  
         if (cpu == NULL) {  
                 fprintf(stderr, "out of memory\n");  
                 exit(1);  
         }  
101    
102          memset(cpu, 0, sizeof(struct cpu));          cpu->memory_rw  = urisc_memory_rw;
103          cpu->memory_rw          = urisc_memory_rw;          cpu->byte_order = EMUL_BIG_ENDIAN;
         cpu->name               = cpu_type_name;  
         cpu->mem                = mem;  
         cpu->machine            = machine;  
         cpu->cpu_id             = cpu_id;  
         cpu->byte_order         = EMUL_BIG_ENDIAN;  
104    
105          cpu->cd.urisc.wordlen = 32;          cpu->cd.urisc.wordlen = 32;
106          cpu->cd.urisc.acc_in_mem = 0;          cpu->cd.urisc.acc_in_mem = 0;
# Line 130  struct cpu *urisc_cpu_new(struct memory Line 117  struct cpu *urisc_cpu_new(struct memory
117                  debug(")");                  debug(")");
118          }          }
119    
120          return cpu;          return 1;
121  }  }
122    
123    
# Line 178  void urisc_cpu_register_dump(struct cpu Line 165  void urisc_cpu_register_dump(struct cpu
165    
166          symbol = get_symbol_name(&cpu->machine->symbol_context,          symbol = get_symbol_name(&cpu->machine->symbol_context,
167              cpu->pc, &offset);              cpu->pc, &offset);
168          sprintf(tmps, "cpu%%i: pc  = 0x%%0%illx", (cpu->cd.urisc.wordlen/4));          snprintf(tmps, sizeof(tmps), "cpu%%i: pc  = 0x%%0%illx",
169                (cpu->cd.urisc.wordlen/4));
170          debug(tmps, x, (long long)cpu->pc);          debug(tmps, x, (long long)cpu->pc);
171          debug("  <%s>\n", symbol != NULL? symbol : " no symbol ");          debug("  <%s>\n", symbol != NULL? symbol : " no symbol ");
172          sprintf(tmps, "cpu%%i: acc = 0x%%0%illx\n", (cpu->cd.urisc.wordlen/4));          snprintf(tmps, sizeof(tmps), "cpu%%i: acc = 0x%%0%illx\n",
173                (cpu->cd.urisc.wordlen/4));
174          debug(tmps, x, (long long)cpu->cd.urisc.acc);          debug(tmps, x, (long long)cpu->cd.urisc.acc);
175  }  }
176    
# Line 216  int urisc_cpu_disassemble_instr(struct c Line 205  int urisc_cpu_disassemble_instr(struct c
205    
206          if (cpu->machine->ncpus > 1 && running)          if (cpu->machine->ncpus > 1 && running)
207                  debug("cpu%i: ", cpu->cpu_id);                  debug("cpu%i: ", cpu->cpu_id);
208          sprintf(tmps, "0x%%0%illx:  0x", nbytes * 2);          snprintf(tmps, sizeof(tmps), "0x%%0%illx:  0x", nbytes * 2);
209          debug(tmps, (long long)dumpaddr);          debug(tmps, (long long)dumpaddr);
210    
211          /*  TODO:  Little-endian?  */          /*  TODO:  Little-endian?  */
# Line 350  int urisc_cpu_run_instr(struct emul *emu Line 339  int urisc_cpu_run_instr(struct emul *emu
339          }          }
340    
341          if (cpu->machine->instruction_trace) {          if (cpu->machine->instruction_trace) {
342                  sprintf(tmps, "\t[mem=0x%%0%illx", nbytes * 2);                  snprintf(tmps, sizeof(tmps), "\t[mem=0x%%0%illx", nbytes * 2);
343                  debug(tmps, (long long)data);                  debug(tmps, (long long)data);
344                  sprintf(tmps, "; acc: 0x%%0%illx", nbytes * 2);                  snprintf(tmps, sizeof(tmps), "; acc: 0x%%0%illx", nbytes * 2);
345                  debug(tmps, (long long)cpu->cd.urisc.acc);                  debug(tmps, (long long)cpu->cd.urisc.acc);
346          }          }
347    
# Line 364  int urisc_cpu_run_instr(struct emul *emu Line 353  int urisc_cpu_run_instr(struct emul *emu
353          cpu->cd.urisc.acc = data;          cpu->cd.urisc.acc = data;
354    
355          if (cpu->machine->instruction_trace) {          if (cpu->machine->instruction_trace) {
356                  sprintf(tmps, " ==> 0x%%0%illx", nbytes * 2);                  snprintf(tmps, sizeof(tmps), " ==> 0x%%0%illx", nbytes * 2);
357                  debug(tmps, (long long)cpu->cd.urisc.acc);                  debug(tmps, (long long)cpu->cd.urisc.acc);
358                  if (skip)                  if (skip)
359                          debug(", SKIP");                          debug(", SKIP");

Legend:
Removed from v.9  
changed lines
  Added in v.10

  ViewVC Help
Powered by ViewVC 1.1.26