2009-07-28 21:32:10 +00:00
|
|
|
// Copyright (C) 2003 Dolphin Project.
|
2009-07-06 02:10:26 +00:00
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official SVN repository and contact information can be found at
|
|
|
|
// http://code.google.com/p/dolphin-emu/
|
|
|
|
|
|
|
|
// Additional copyrights go to Duddie (c) 2005 (duddie@walla.com)
|
|
|
|
|
|
|
|
#ifndef _DSPTABLES_H
|
|
|
|
#define _DSPTABLES_H
|
|
|
|
|
2010-04-07 15:04:45 +00:00
|
|
|
//nclude "Common.h"
|
|
|
|
#include "DSPEmitter.h"
|
|
|
|
#include "DSPCommon.h"
|
2009-07-06 02:10:26 +00:00
|
|
|
|
|
|
|
// The non-ADDR ones that end with _D are the opposite one - if the bit specify
|
|
|
|
// ACC0, then ACC_D will be ACC1.
|
|
|
|
|
|
|
|
// The values of these are very important.
|
|
|
|
// For the reg ones, the value >> 8 is the base register.
|
|
|
|
// & 0x80 means it's a "D".
|
|
|
|
|
|
|
|
enum partype_t
|
|
|
|
{
|
|
|
|
P_NONE = 0x0000,
|
|
|
|
P_VAL = 0x0001,
|
|
|
|
P_IMM = 0x0002,
|
|
|
|
P_MEM = 0x0003,
|
|
|
|
P_STR = 0x0004,
|
|
|
|
P_ADDR_I = 0x0005,
|
|
|
|
P_ADDR_D = 0x0006,
|
|
|
|
P_REG = 0x8000,
|
|
|
|
P_REG04 = P_REG | 0x0400, // IX
|
|
|
|
P_REG08 = P_REG | 0x0800,
|
|
|
|
P_REG18 = P_REG | 0x1800,
|
|
|
|
P_REGM18 = P_REG | 0x1810, // used in multiply instructions
|
|
|
|
P_REG19 = P_REG | 0x1900,
|
|
|
|
P_REGM19 = P_REG | 0x1910, // used in multiply instructions
|
|
|
|
P_REG1A = P_REG | 0x1a80,
|
|
|
|
P_REG1C = P_REG | 0x1c00,
|
|
|
|
// P_ACC = P_REG | 0x1c10, // used for global accum (gcdsptool's value)
|
|
|
|
P_ACCL = P_REG | 0x1c00, // used for low part of accum
|
|
|
|
P_ACCM = P_REG | 0x1e00, // used for mid part of accum
|
|
|
|
// The following are not in gcdsptool
|
|
|
|
P_ACCM_D = P_REG | 0x1e80,
|
|
|
|
P_ACC = P_REG | 0x2000, // used for full accum.
|
2009-07-11 10:18:25 +00:00
|
|
|
P_ACC_D = P_REG | 0x2080,
|
2009-07-06 02:10:26 +00:00
|
|
|
P_AX = P_REG | 0x2200,
|
|
|
|
P_REGS_MASK = 0x03f80, // gcdsptool's value = 0x01f80
|
|
|
|
P_REF = P_REG | 0x4000,
|
|
|
|
P_PRG = P_REF | P_REG,
|
|
|
|
|
|
|
|
// The following seem like junk:
|
|
|
|
// P_REG10 = P_REG | 0x1000,
|
|
|
|
// P_AX_D = P_REG | 0x2280,
|
|
|
|
};
|
|
|
|
|
2009-08-10 09:20:12 +00:00
|
|
|
#define OPTABLE_SIZE 0xffff + 1
|
|
|
|
#define EXT_OPTABLE_SIZE 0xff + 1
|
2009-07-06 02:10:26 +00:00
|
|
|
|
2010-04-07 15:04:45 +00:00
|
|
|
typedef void (*dspIntFunc)(const UDSPInstruction);
|
|
|
|
typedef void (DSPEmitter::*dspJitFunc)(const UDSPInstruction);
|
2009-07-06 02:10:26 +00:00
|
|
|
|
|
|
|
struct param2_t
|
|
|
|
{
|
|
|
|
partype_t type;
|
|
|
|
u8 size;
|
|
|
|
u8 loc;
|
|
|
|
s8 lshift;
|
|
|
|
u16 mask;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
const char *name;
|
|
|
|
u16 opcode;
|
|
|
|
u16 opcode_mask;
|
|
|
|
|
2010-04-07 15:04:45 +00:00
|
|
|
dspIntFunc intFunc;
|
|
|
|
dspJitFunc jitFunc;
|
2009-07-06 02:10:26 +00:00
|
|
|
|
|
|
|
u8 size;
|
|
|
|
u8 param_count;
|
|
|
|
param2_t params[8];
|
2009-07-24 16:04:29 +00:00
|
|
|
bool extended;
|
2010-03-24 05:05:25 +00:00
|
|
|
bool branch;
|
2010-10-14 13:17:38 +00:00
|
|
|
bool uncond_branch;
|
2009-07-06 02:10:26 +00:00
|
|
|
} DSPOPCTemplate;
|
|
|
|
|
|
|
|
typedef DSPOPCTemplate opc_t;
|
|
|
|
|
|
|
|
// Opcodes
|
|
|
|
extern const DSPOPCTemplate opcodes[];
|
|
|
|
extern const int opcodes_size;
|
|
|
|
extern const DSPOPCTemplate opcodes_ext[];
|
|
|
|
extern const int opcodes_ext_size;
|
|
|
|
extern const DSPOPCTemplate cw;
|
|
|
|
|
2010-06-08 18:46:02 +00:00
|
|
|
#define WRITEBACKLOGSIZE 5
|
2009-08-19 21:37:24 +00:00
|
|
|
|
2010-03-29 01:18:05 +00:00
|
|
|
extern const DSPOPCTemplate *opTable[OPTABLE_SIZE];
|
|
|
|
extern const DSPOPCTemplate *extOpTable[EXT_OPTABLE_SIZE];
|
2009-08-19 21:37:24 +00:00
|
|
|
extern u16 writeBackLog[WRITEBACKLOGSIZE];
|
|
|
|
extern int writeBackLogIdx[WRITEBACKLOGSIZE];
|
2009-07-06 02:10:26 +00:00
|
|
|
|
|
|
|
// Predefined labels
|
|
|
|
struct pdlabel_t
|
|
|
|
{
|
|
|
|
u16 addr;
|
|
|
|
const char* name;
|
|
|
|
const char* description;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern const pdlabel_t regnames[];
|
|
|
|
extern const pdlabel_t pdlabels[];
|
|
|
|
extern const u32 pdlabels_size;
|
|
|
|
|
|
|
|
const char *pdname(u16 val);
|
|
|
|
const char *pdregname(int val);
|
|
|
|
const char *pdregnamelong(int val);
|
|
|
|
|
|
|
|
void InitInstructionTable();
|
2009-08-19 21:37:24 +00:00
|
|
|
void applyWriteBackLog();
|
|
|
|
void zeroWriteBackLog();
|
2010-03-08 21:25:35 +00:00
|
|
|
void zeroWriteBackLogPreserveAcc(u8 acc);
|
2009-07-06 02:10:26 +00:00
|
|
|
|
2010-03-29 01:18:05 +00:00
|
|
|
const DSPOPCTemplate *GetOpTemplate(const UDSPInstruction &inst);
|
|
|
|
|
2010-03-24 05:05:25 +00:00
|
|
|
inline void ExecuteInstruction(const UDSPInstruction inst)
|
2009-07-06 02:10:26 +00:00
|
|
|
{
|
2010-03-29 01:18:05 +00:00
|
|
|
const DSPOPCTemplate *tinst = GetOpTemplate(inst);
|
|
|
|
|
|
|
|
if (tinst->extended) {
|
2010-03-24 05:05:25 +00:00
|
|
|
if ((inst >> 12) == 0x3)
|
2010-04-07 15:04:45 +00:00
|
|
|
extOpTable[inst & 0x7F]->intFunc(inst);
|
2009-11-04 12:49:26 +00:00
|
|
|
else
|
2010-04-07 15:04:45 +00:00
|
|
|
extOpTable[inst & 0xFF]->intFunc(inst);
|
2009-11-04 12:49:26 +00:00
|
|
|
}
|
2010-04-07 15:04:45 +00:00
|
|
|
tinst->intFunc(inst);
|
2010-03-29 01:18:05 +00:00
|
|
|
if (tinst->extended) {
|
2009-08-19 21:37:24 +00:00
|
|
|
applyWriteBackLog();
|
2009-07-25 18:31:01 +00:00
|
|
|
}
|
2009-07-06 02:10:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // _DSPTABLES_H
|