1 |
/* |
/* |
2 |
* Copyright (C) 2006 Anders Gavare. All rights reserved. |
* Copyright (C) 2006-2007 Anders Gavare. All rights reserved. |
3 |
* |
* |
4 |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
5 |
* modification, are permitted provided that the following conditions are met: |
* modification, are permitted provided that the following conditions are met: |
25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: cpu_rca180x_instr.c,v 1.1 2006/08/28 16:25:59 debug Exp $ |
* $Id: cpu_rca180x_instr.c,v 1.3 2006/12/30 13:30:55 debug Exp $ |
29 |
* |
* |
30 |
* RCA180X instructions. |
* RCA180X instructions. |
31 |
* |
* |
250 |
|
|
251 |
/* Push return address to the stack: */ |
/* Push return address to the stack: */ |
252 |
cpu->cd.rca180x.sp -= sizeof(uint16_t); |
cpu->cd.rca180x.sp -= sizeof(uint16_t); |
253 |
cpu->memory_rw(cpu, cpu->mem, cpu->cd.rca180x.sp, (unsigned char *)&pc12, |
cpu->memory_rw(cpu, cpu->mem, cpu->cd.rca180x.sp, |
254 |
sizeof(pc12), MEM_WRITE, PHYSICAL); |
(unsigned char *)&pc12, sizeof(pc12), MEM_WRITE, PHYSICAL); |
255 |
|
|
256 |
cpu->cd.rca180x.next_ic = (struct rca180x_instr_call *) ic->arg[0]; |
cpu->cd.rca180x.next_ic = (struct rca180x_instr_call *) ic->arg[0]; |
257 |
} |
} |
265 |
uint16_t pc12; |
uint16_t pc12; |
266 |
|
|
267 |
/* Pop return address to the stack: */ |
/* Pop return address to the stack: */ |
268 |
cpu->memory_rw(cpu, cpu->mem, cpu->cd.rca180x.sp, (unsigned char *)&pc12, |
cpu->memory_rw(cpu, cpu->mem, cpu->cd.rca180x.sp, |
269 |
sizeof(pc12), MEM_READ, PHYSICAL); |
(unsigned char *)&pc12, sizeof(pc12), MEM_READ, PHYSICAL); |
270 |
cpu->cd.rca180x.sp += sizeof(uint16_t); |
cpu->cd.rca180x.sp += sizeof(uint16_t); |
271 |
|
|
272 |
cpu->pc = pc12 & 0xfff; |
cpu->pc = pc12 & 0xfff; |
380 |
int r; |
int r; |
381 |
for (r=0; r<=ic->arg[0]; r++) { |
for (r=0; r<=ic->arg[0]; r++) { |
382 |
cpu->memory_rw(cpu, cpu->mem, cpu->cd.rca180x.index++, |
cpu->memory_rw(cpu, cpu->mem, cpu->cd.rca180x.index++, |
383 |
&cpu->cd.rca180x.v[r], sizeof(uint8_t), MEM_WRITE, PHYSICAL); |
&cpu->cd.rca180x.v[r], sizeof(uint8_t), MEM_WRITE, |
384 |
|
PHYSICAL); |
385 |
} |
} |
386 |
} |
} |
387 |
|
|
437 |
/* |
/* |
438 |
* rca180x_instr_to_be_translated(): |
* rca180x_instr_to_be_translated(): |
439 |
* |
* |
440 |
* Translate an instruction word into an rca180x_instr_call. ic is filled in with |
* Translate an instruction word into an rca180x_instr_call. ic is filled in |
441 |
* valid data for the translated instruction, or a "nothing" instruction if |
* with valid data for the translated instruction, or a "nothing" instruction |
442 |
* there was a translation failure. The newly translated instruction is then |
* if there was a translation failure. The newly translated instruction is |
443 |
* executed. |
* then executed. |
444 |
*/ |
*/ |
445 |
X(to_be_translated) |
X(to_be_translated) |
446 |
{ |
{ |