/[gxemul]/trunk/src/cpus/cpu_sh_instr.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/cpus/cpu_sh_instr.c

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

revision 33 by dpavlin, Mon Oct 8 16:20:58 2007 UTC revision 34 by dpavlin, Mon Oct 8 16:21:17 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   *  Copyright (C) 2005-2006  Anders Gavare.  All rights reserved.   *  Copyright (C) 2005-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:
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: cpu_sh_instr.c,v 1.44 2006/11/02 05:43:43 debug Exp $   *  $Id: cpu_sh_instr.c,v 1.49 2007/01/28 16:59:06 debug Exp $
29   *   *
30   *  SH instructions.   *  SH instructions.
31   *   *
# Line 196  X(tst_imm_r0) Line 196  X(tst_imm_r0)
196    
197    
198  /*  /*
199     *  xor_b_imm_r0_gbr:  mem[r0+gbr] |= imm
200     *  or_b_imm_r0_gbr:   mem[r0+gbr] ^= imm
201     *  and_b_imm_r0_gbr:  mem[r0+gbr] &= imm
202     *
203     *  arg[0] = imm
204     */
205    X(xor_b_imm_r0_gbr)
206    {
207            uint32_t addr = cpu->cd.sh.gbr + cpu->cd.sh.r[0];
208            uint8_t *p = (uint8_t *) cpu->cd.sh.host_store[addr >> 12];
209    
210            if (p != NULL) {
211                    p[addr & 0xfff] ^= ic->arg[0];
212            } else {
213                    uint8_t data;
214                    SYNCH_PC;
215                    if (!cpu->memory_rw(cpu, cpu->mem, addr, (unsigned char *)&data,
216                       sizeof(data), MEM_READ, CACHE_DATA)) {
217                            /*  Exception.  */
218                            return;
219                    }
220                    data ^= ic->arg[0];
221                    if (!cpu->memory_rw(cpu, cpu->mem, addr, (unsigned char *)&data,
222                       sizeof(data), MEM_WRITE, CACHE_DATA)) {
223                            /*  Exception.  */
224                            return;
225                    }
226            }
227    }
228    X(or_b_imm_r0_gbr)
229    {
230            uint32_t addr = cpu->cd.sh.gbr + cpu->cd.sh.r[0];
231            uint8_t *p = (uint8_t *) cpu->cd.sh.host_store[addr >> 12];
232    
233            if (p != NULL) {
234                    p[addr & 0xfff] |= ic->arg[0];
235            } else {
236                    uint8_t data;
237                    SYNCH_PC;
238                    if (!cpu->memory_rw(cpu, cpu->mem, addr, (unsigned char *)&data,
239                       sizeof(data), MEM_READ, CACHE_DATA)) {
240                            /*  Exception.  */
241                            return;
242                    }
243                    data |= ic->arg[0];
244                    if (!cpu->memory_rw(cpu, cpu->mem, addr, (unsigned char *)&data,
245                       sizeof(data), MEM_WRITE, CACHE_DATA)) {
246                            /*  Exception.  */
247                            return;
248                    }
249            }
250    }
251    X(and_b_imm_r0_gbr)
252    {
253            uint32_t addr = cpu->cd.sh.gbr + cpu->cd.sh.r[0];
254            uint8_t *p = (uint8_t *) cpu->cd.sh.host_store[addr >> 12];
255    
256            if (p != NULL) {
257                    p[addr & 0xfff] &= ic->arg[0];
258            } else {
259                    uint8_t data;
260                    SYNCH_PC;
261                    if (!cpu->memory_rw(cpu, cpu->mem, addr, (unsigned char *)&data,
262                       sizeof(data), MEM_READ, CACHE_DATA)) {
263                            /*  Exception.  */
264                            return;
265                    }
266                    data &= ic->arg[0];
267                    if (!cpu->memory_rw(cpu, cpu->mem, addr, (unsigned char *)&data,
268                       sizeof(data), MEM_WRITE, CACHE_DATA)) {
269                            /*  Exception.  */
270                            return;
271                    }
272            }
273    }
274    
275    
276    /*
277   *  mov_imm_rn:  Set rn to a signed 8-bit value   *  mov_imm_rn:  Set rn to a signed 8-bit value
278   *  add_imm_rn:  Add a signed 8-bit value to Rn   *  add_imm_rn:  Add a signed 8-bit value to Rn
279   *   *
# Line 1954  X(ldtlb) Line 2032  X(ldtlb)
2032          cpu->cd.sh.utlb_hi[urc] = cpu->cd.sh.pteh;          cpu->cd.sh.utlb_hi[urc] = cpu->cd.sh.pteh;
2033          cpu->cd.sh.utlb_lo[urc] = cpu->cd.sh.ptel;          cpu->cd.sh.utlb_lo[urc] = cpu->cd.sh.ptel;
2034    
2035          if ((old_lo & SH4_PTEL_SZ_MASK) == SH4_PTEL_SZ_4K)          /*  Invalidate the old mapping, if it belonged to the same ASID:  */
2036                  cpu->invalidate_translation_caches(cpu,          if ((old_hi & SH4_PTEH_ASID_MASK) ==
2037                      old_hi & 0xfffff000, INVALIDATE_VADDR);              (cpu->cd.sh.pteh & SH4_PTEH_ASID_MASK)) {
2038          else                  if ((old_lo & SH4_PTEL_SZ_MASK) == SH4_PTEL_SZ_4K)
2039                  cpu->invalidate_translation_caches(cpu,                          cpu->invalidate_translation_caches(cpu,
2040                      old_hi & 0xfffff000, INVALIDATE_ALL);                              old_hi & 0xfffff000, INVALIDATE_VADDR);
2041                    else
2042                            cpu->invalidate_translation_caches(cpu,
2043                                old_hi & 0xfffff000, INVALIDATE_ALL);
2044            }
2045  }  }
2046    
2047    
# Line 2808  X(to_be_translated) Line 2890  X(to_be_translated)
2890                          /*  STC Rm_BANK, Rn  */                          /*  STC Rm_BANK, Rn  */
2891                          ic->f = instr(copy_privileged_register);                          ic->f = instr(copy_privileged_register);
2892                          ic->arg[0] = (size_t)&cpu->cd.sh.r_bank[(lo8 >> 4) & 7];                          ic->arg[0] = (size_t)&cpu->cd.sh.r_bank[(lo8 >> 4) & 7];
2893                  } else if (iword == 0x00ff) {                  } else if (iword == SH_INVALID_INSTR) {
2894                          /*  PROM emulation specifically for Dreamcast  */                          /*  PROM emulation specifically for Dreamcast  */
2895                          ic->f = instr(prom_emul_dreamcast);                          ic->f = instr(prom_emul_dreamcast);
2896                  } else {                  } else {
# Line 3113  X(to_be_translated) Line 3195  X(to_be_translated)
3195                          case 0x1b:      /*  TAS.B @Rn  */                          case 0x1b:      /*  TAS.B @Rn  */
3196                                  ic->f = instr(tas_b_rn);                                  ic->f = instr(tas_b_rn);
3197                                  break;                                  break;
3198                            case 0x1e:      /*  LDC Rm,GBR  */
3199                                    ic->f = instr(mov_rm_rn);
3200                                    ic->arg[0] = (size_t)&cpu->cd.sh.r[r8]; /* m */
3201                                    ic->arg[1] = (size_t)&cpu->cd.sh.gbr;
3202                                    break;
3203                          case 0x20:      /*  SHAL Rn  */                          case 0x20:      /*  SHAL Rn  */
3204                                  ic->f = instr(shll_rn);  /*  NOTE: shll  */                                  ic->f = instr(shll_rn);  /*  NOTE: shll  */
3205                                  break;                                  break;
# Line 3422  X(to_be_translated) Line 3509  X(to_be_translated)
3509                          ic->f = instr(or_imm_r0);                          ic->f = instr(or_imm_r0);
3510                          ic->arg[0] = lo8;                          ic->arg[0] = lo8;
3511                          break;                          break;
3512                    case 0xd:       /*  AND.B #imm,@(R0,GBR)  */
3513                            ic->f = instr(and_b_imm_r0_gbr);
3514                            ic->arg[0] = lo8;
3515                            break;
3516                    case 0xe:       /*  XOR.B #imm,@(R0,GBR)  */
3517                            ic->f = instr(xor_b_imm_r0_gbr);
3518                            ic->arg[0] = lo8;
3519                            break;
3520                    case 0xf:       /*  OR.B #imm,@(R0,GBR)  */
3521                            ic->f = instr(or_b_imm_r0_gbr);
3522                            ic->arg[0] = lo8;
3523                            break;
3524                  default:fatal("Unimplemented opcode 0x%x,0x%x\n",                  default:fatal("Unimplemented opcode 0x%x,0x%x\n",
3525                              main_opcode, r8);                              main_opcode, r8);
3526                          goto bad;                          goto bad;

Legend:
Removed from v.33  
changed lines
  Added in v.34

  ViewVC Help
Powered by ViewVC 1.1.26