Exemplo n.º 1
0
static void op1101(char *buffer, UINT32 pc, UINT16 opcode)
{
	const char *sym;
	sym = set_ea_info(0, (opcode & 0xff) * 4, EA_UINT8, EA_VALUE);
	set_ea_info(1, (opcode & 0xff) * 4 + ((pc + 2) & ~3), EA_UINT32, EA_ABS_PC);
	sprintf(buffer, "MOV.L   @(%s,PC),%s", sym, regname[Rn]);
}
Exemplo n.º 2
0
static void op0101(char *buffer, UINT32 pc, UINT16 opcode)
{
	const char *sym;
	sym = set_ea_info(0, (opcode & 15) * 4, EA_UINT8, EA_VALUE);
	set_ea_info(1, activecpu_get_reg(SH2_R0+Rm) + (opcode & 15) * 4, EA_UINT32, EA_MEM_RD);
	sprintf(buffer, "MOV.L   @(%s,%s),%s\n", sym, regname[Rm], regname[Rn]);
}
Exemplo n.º 3
0
static void op1001(char *buffer, UINT32 pc, UINT16 opcode)
{
	const char *sym;
	sym = set_ea_info(0, (opcode & 0xff) * 2, EA_UINT16, EA_VALUE);
	set_ea_info(0, (opcode & 0xff) * 2 + pc + 2, EA_UINT16, EA_MEM_RD);
	sprintf(buffer, "MOV.W   @(%s,PC),%s", sym, regname[Rn]);
}
Exemplo n.º 4
0
static void op0010(char *buffer, UINT32 pc, UINT16 opcode)
{
	switch (opcode & 15)
	{
	case  0:
		set_ea_info(0, activecpu_get_reg(SH2_R0+Rm), EA_UINT8, EA_MEM_WR);
		sprintf(buffer, "MOV.B   %s,@%s", regname[Rm], regname[Rn]);
		break;
	case  1:
		set_ea_info(0, activecpu_get_reg(SH2_R0+Rm), EA_UINT16, EA_MEM_WR);
		sprintf(buffer, "MOV.W   %s,@%s", regname[Rm], regname[Rn]);
		break;
	case  2:
		set_ea_info(0, activecpu_get_reg(SH2_R0+Rm), EA_UINT32, EA_MEM_WR);
		sprintf(buffer, "MOV.L   %s,@%s", regname[Rm], regname[Rn]);
		break;
	case  3:
		sprintf(buffer, "??????  $%04X", opcode);
		break;
	case  4:
		set_ea_info(0, activecpu_get_reg(SH2_R0+Rm) - 1, EA_UINT8, EA_MEM_WR);
		sprintf(buffer, "MOV.B   %s,@-%s", regname[Rm], regname[Rn]);
		break;
	case  5:
		set_ea_info(0, activecpu_get_reg(SH2_R0+Rm) - 2, EA_UINT16, EA_MEM_WR);
		sprintf(buffer, "MOV.W   %s,@-%s", regname[Rm], regname[Rn]);
		break;
	case  6:
		set_ea_info(0, activecpu_get_reg(SH2_R0+Rm) - 4, EA_UINT32, EA_MEM_WR);
		sprintf(buffer, "MOV.L   %s,@-%s", regname[Rm], regname[Rn]);
		break;
	case  7:
		sprintf(buffer, "DIV0S   %s,%s", regname[Rm], regname[Rn]);
		break;
	case  8:
		sprintf(buffer, "TST     %s,%s", regname[Rm], regname[Rn]);
		break;
	case  9:
		sprintf(buffer, "AND     %s,%s", regname[Rm], regname[Rn]);
		break;
	case 10:
		sprintf(buffer, "XOR     %s,%s", regname[Rm], regname[Rn]);
		break;
	case 11:
		sprintf(buffer, "OR      %s,%s", regname[Rm], regname[Rn]);
		break;
	case 12:
		sprintf(buffer, "CMP/STR %s,%s", regname[Rm], regname[Rn]);
		break;
	case 13:
		sprintf(buffer, "XTRCT   %s,%s", regname[Rm], regname[Rn]);
		break;
	case 14:
		sprintf(buffer, "MULU.W  %s,%s", regname[Rm], regname[Rn]);
		break;
	case 15:
		sprintf(buffer, "MULS.W  %s,%s", regname[Rm], regname[Rn]);
		break;
	}
}
Exemplo n.º 5
0
static void op0100(char *buffer, UINT32 pc, UINT16 opcode)
{
	switch(opcode & 0x3F)
	{
	case 0x00:
		sprintf(buffer, "SHLL    %s", regname[Rn]);
		break;
	case 0x01:
		sprintf(buffer, "SHLR    %s", regname[Rn]);
		break;
	case 0x02:
		set_ea_info(0, activecpu_get_reg(SH2_R0+Rn) - 4, EA_UINT32, EA_MEM_WR);
		sprintf(buffer, "STS.L   MACH,@-%s", regname[Rn]);
		break;
	case 0x03:
		set_ea_info(0, activecpu_get_reg(SH2_R0+Rn) - 4, EA_UINT32, EA_MEM_WR);
		sprintf(buffer, "STC.L   SR,@-%s", regname[Rn]);
		break;
	case 0x04:
		sprintf(buffer, "ROTL    %s", regname[Rn]);
		break;
	case 0x05:
		sprintf(buffer, "ROTR    %s", regname[Rn]);
		break;
	case 0x06:
		set_ea_info(0, activecpu_get_reg(SH2_R0+Rn), EA_UINT32, EA_MEM_RD);
		sprintf(buffer, "LDS.L   @%s+,MACH", regname[Rn]);
		break;
	case 0x07:
		set_ea_info(0, activecpu_get_reg(SH2_R0+Rn), EA_UINT32, EA_MEM_RD);
		sprintf(buffer, "LDC.L   @%s+,SR", regname[Rn]);
		break;
	case 0x08:
		sprintf(buffer, "SHLL2   %s", regname[Rn]);
		break;
	case 0x09:
		sprintf(buffer, "SHLR2   %s", regname[Rn]);
		break;
	case 0x0a:
		sprintf(buffer, "LDS     %s,MACH", regname[Rn]);
		break;
	case 0x0b:
		sprintf(buffer, "JSR     %s", regname[Rn]);
		break;
	case 0x0e:
		sprintf(buffer, "LDC     %s,SR", regname[Rn]);
		break;
	case 0x10:
		sprintf(buffer, "DT      %s", regname[Rn]);
		break;
	case 0x11:
		sprintf(buffer, "CMP/PZ  %s", regname[Rn]);
		break;
	case 0x12:
		sprintf(buffer, "STS.L   MACL,@-%s", regname[Rn]);
		break;
	case 0x13:
		sprintf(buffer, "STC.L   GBR,@-%s", regname[Rn]);
		break;
	case 0x15:
		sprintf(buffer, "CMP/PL  %s", regname[Rn]);
		break;
	case 0x16:
		set_ea_info(0, activecpu_get_reg(SH2_R0+Rn), EA_UINT32, EA_MEM_RD);
		sprintf(buffer, "LDS.L   @%s+,MACL", regname[Rn]);
		break;
	case 0x17:
		set_ea_info(0, activecpu_get_reg(SH2_R0+Rn), EA_UINT32, EA_MEM_RD);
		sprintf(buffer, "LDC.L   @%s+,GBR", regname[Rn]);
		break;
	case 0x18:
		sprintf(buffer, "SHLL8   %s", regname[Rn]);
		break;
	case 0x19:
		sprintf(buffer, "SHLR8   %s", regname[Rn]);
		break;
	case 0x1a:
		sprintf(buffer, "LDS     %s,MACL", regname[Rn]);
		break;
	case 0x1b:
		sprintf(buffer, "TAS     %s", regname[Rn]);
		break;
	case 0x1e:
		sprintf(buffer, "LDC     %s,GBR", regname[Rn]);
		break;
	case 0x20:
		sprintf(buffer, "SHAL    %s", regname[Rn]);
		break;
	case 0x21:
		sprintf(buffer, "SHAR    %s", regname[Rn]);
		break;
	case 0x22:
		set_ea_info(0, activecpu_get_reg(SH2_R0+Rn) - 4, EA_UINT32, EA_MEM_WR);
		sprintf(buffer, "STS.L   PR,@-%s", regname[Rn]);
		break;
	case 0x23:
		set_ea_info(0, activecpu_get_reg(SH2_R0+Rn) - 4, EA_UINT32, EA_MEM_WR);
		sprintf(buffer, "STC.L   VBR,@-%s", regname[Rn]);
		break;
	case 0x24:
		sprintf(buffer, "ROTCL   %s", regname[Rn]);
		break;
	case 0x25:
		sprintf(buffer, "ROTCR   %s", regname[Rn]);
		break;
	case 0x26:
		set_ea_info(0, activecpu_get_reg(SH2_R0+Rn), EA_UINT32, EA_MEM_RD);
		sprintf(buffer, "LDS.L   @%s+,PR", regname[Rn]);
		break;
	case 0x27:
		set_ea_info(0, activecpu_get_reg(SH2_R0+Rn), EA_UINT32, EA_MEM_RD);
		sprintf(buffer, "LDC.L   @%s+,VBR", regname[Rn]);
		break;
	case 0x28:
		sprintf(buffer, "SHLL16  %s", regname[Rn]);
		break;
	case 0x29:
		sprintf(buffer, "SHLR16  %s", regname[Rn]);
		break;
	case 0x2a:
		sprintf(buffer, "LDS     %s,PR", regname[Rn]);
		break;
	case 0x2b:
		sprintf(buffer, "JMP     %s", regname[Rn]);
		break;
	case 0x2e:
		sprintf(buffer, "LDC     %s,VBR", regname[Rn]);
		break;
	default:
		if ((opcode & 15) == 15)
		{
			set_ea_info(0, activecpu_get_reg(SH2_R0+Rm), EA_UINT32, EA_MEM_RD);
			set_ea_info(1, activecpu_get_reg(SH2_R0+Rn), EA_UINT32, EA_MEM_RD);
			sprintf(buffer, "MAC.W   @%s+,@%s+", regname[Rm], regname[Rn]);
		}
		else
			sprintf(buffer, "??????  $%04X", opcode);
	}
}
Exemplo n.º 6
0
static void op1100(char *buffer, UINT32 pc, UINT16 opcode)
{
	const char *sym;
	switch((opcode >> 8) & 15)
	{
	case  0:
		sym = set_ea_info(0, opcode & 0xff, EA_UINT8, EA_VALUE);
		set_ea_info(1, activecpu_get_reg(SH2_GBR) + (opcode & 0xff), EA_UINT8, EA_MEM_WR);
		sprintf(buffer, "MOV.B   R0,@(%s,GBR)", sym);
		break;
	case  1:
		sym = set_ea_info(0, (opcode & 0xff) * 2, EA_UINT16, EA_VALUE);
		set_ea_info(1, (opcode & 0xff) * 2 + activecpu_get_reg(SH2_GBR), EA_UINT16, EA_MEM_WR);
		sprintf(buffer, "MOV.W   R0,@(%s,GBR)", sym);
		break;
	case  2:
		sym = set_ea_info(0, (opcode & 0xff) * 4, EA_UINT16, EA_VALUE);
		set_ea_info(1, (opcode & 0xff) * 4 + activecpu_get_reg(SH2_GBR), EA_UINT32, EA_MEM_WR);
		sprintf(buffer, "MOV.L   R0,@(%s,GBR)", sym);
		break;
	case  3:
		sym = set_ea_info(0, opcode & 0xff, EA_UINT8, EA_VALUE);
		sprintf(buffer, "TRAPA   #%s", sym);
		break;
	case  4:
		sym = set_ea_info(0, opcode & 0xff, EA_UINT8, EA_VALUE);
		set_ea_info(1, activecpu_get_reg(SH2_GBR) + (opcode & 0xff), EA_UINT8, EA_MEM_RD);
		sprintf(buffer, "MOV.B   @(%s,GBR),R0", sym);
		break;
	case  5:
		sym = set_ea_info(0, (opcode & 0xff) * 2, EA_UINT16, EA_VALUE);
		set_ea_info(1, (opcode & 0xff) * 2 + activecpu_get_reg(SH2_GBR), EA_UINT16, EA_MEM_RD);
		sprintf(buffer, "MOV.W   @(%s,GBR),R0", sym);
		break;
	case  6:
		sym = set_ea_info(0, (opcode & 0xff) * 4, EA_UINT16, EA_VALUE);
		set_ea_info(1, (opcode & 0xff) * 4 + activecpu_get_reg(SH2_GBR), EA_UINT32, EA_MEM_RD);
		sprintf(buffer, "MOV.L   @(%s,GBR),R0", sym);
		break;
	case  7:
		sym = set_ea_info(0, (opcode & 0xff) * 4, EA_UINT16, EA_VALUE);
		set_ea_info(1, (opcode & 0xff) * 4 + pc + 2, EA_UINT32, EA_ABS_PC);
		sprintf(buffer, "MOVA    @(%s,PC),R0", sym);
		break;
	case  8:
		sym = set_ea_info(0, opcode & 0xff, EA_UINT8, EA_VALUE);
		sprintf(buffer, "TST     #%s,R0", sym);
		break;
	case  9:
		sym = set_ea_info(0, opcode & 0xff, EA_UINT8, EA_VALUE);
		sprintf(buffer, "AND     #%s,R0", sym);
		break;
	case 10:
		sym = set_ea_info(0, opcode & 0xff, EA_UINT8, EA_VALUE);
		sprintf(buffer, "XOR     #%s,R0", sym);
		break;
	case 11:
		sym = set_ea_info(0, opcode & 0xff, EA_UINT8, EA_VALUE);
		sprintf(buffer, "OR      #%s,R0", sym);
		break;
	case 12:
		sym = set_ea_info(0, opcode & 0xff, EA_UINT8, EA_VALUE);
		set_ea_info(1, activecpu_get_reg(SH2_R0) + activecpu_get_reg(SH2_GBR), EA_UINT8, EA_MEM_RD);
		sprintf(buffer, "TST.B   #%s,@(R0,GBR)", sym);
		break;
	case 13:
		sym = set_ea_info(0, opcode & 0xff, EA_UINT8, EA_VALUE);
		set_ea_info(1, activecpu_get_reg(SH2_R0) + activecpu_get_reg(SH2_GBR), EA_UINT8, EA_MEM_RDWR);
		sprintf(buffer, "AND.B   #%s,@(R0,GBR)", sym);
		break;
	case 14:
		sym = set_ea_info(0, opcode & 0xff, EA_UINT8, EA_VALUE);
		set_ea_info(1, activecpu_get_reg(SH2_R0) + activecpu_get_reg(SH2_GBR), EA_UINT8, EA_MEM_RDWR);
		sprintf(buffer, "XOR.B   #%s,@(R0,GBR)", sym);
		break;
	case 15:
		sym = set_ea_info(0, opcode & 0xff, EA_UINT8, EA_VALUE);
		set_ea_info(1, activecpu_get_reg(SH2_R0) + activecpu_get_reg(SH2_GBR), EA_UINT8, EA_MEM_RDWR);
		sprintf(buffer, "OR.B    #%s,@(R0,GBR)", sym);
		break;
	}
}
Exemplo n.º 7
0
static void op1011(char *buffer, UINT32 pc, UINT16 opcode)
{
	const char *sym;
	sym = set_ea_info(0, SIGNX12(opcode & 0xfff) * 2 + pc + 2, EA_UINT32, EA_ABS_PC);
	sprintf(buffer, "BSR     %s", sym);
}
Exemplo n.º 8
0
static void op1000(char *buffer, UINT32 pc, UINT16 opcode)
{
	const char *sym;
	switch((opcode >> 8) & 15)
	{
	case  0:
		sym = set_ea_info(0, (opcode & 15), EA_UINT8, EA_VALUE);
		set_ea_info(1, activecpu_get_reg(SH2_R0+Rm) + (opcode & 15), EA_UINT8, EA_MEM_WR);
		sprintf(buffer, "MOV.B   R0,@(%s,%s)", sym, regname[Rm]);
		break;
	case  1:
		sym = set_ea_info(0, (opcode & 15) * 2, EA_UINT8, EA_VALUE);
		set_ea_info(1, activecpu_get_reg(SH2_R0+Rm) + (opcode & 15)*2, EA_UINT16, EA_MEM_WR);
		sprintf(buffer, "MOV.W   R0,@(%s,%s)", sym, regname[Rm]);
		break;
	case  4:
		sym = set_ea_info(0, (opcode & 15), EA_UINT8, EA_VALUE);
		set_ea_info(1, activecpu_get_reg(SH2_R0+Rm) + (opcode & 15), EA_UINT8, EA_MEM_RD);
		sprintf(buffer, "MOV.B   @(%s,%s),R0", sym, regname[Rm]);
		break;
	case  5:
		sym = set_ea_info(0, (opcode & 15), EA_UINT8, EA_VALUE);
		set_ea_info(1, activecpu_get_reg(SH2_R0+Rm) + (opcode & 15)*2, EA_UINT16, EA_MEM_RD);
		sprintf(buffer, "MOV.W   @(%s,%s),R0", sym, regname[Rm]);
		break;
	case  8:
		sym = set_ea_info(0, (opcode & 0xff), EA_UINT8, EA_VALUE);
		sprintf(buffer, "CMP/EQ  #%s,R0", sym);
		break;
	case  9:
		sym = set_ea_info(0, pc, SIGNX8(opcode & 0xff) * 2 + 2, EA_REL_PC);
		sprintf(buffer, "BT      %s", sym);
		break;
	case 11:
		sym = set_ea_info(0, pc, SIGNX8(opcode & 0xff) * 2 + 2, EA_REL_PC);
		sprintf(buffer, "BF      %s", sym);
		break;
	case 13:
		sym = set_ea_info(0, pc, SIGNX8(opcode & 0xff) * 2 + 2, EA_REL_PC);
		sprintf(buffer, "BTS     %s", sym);
		break;
	case 15:
		sym = set_ea_info(0, pc, SIGNX8(opcode & 0xff) * 2 + 2, EA_REL_PC);
		sprintf(buffer, "BFS     %s", sym);
		break;
	default :
		sym = set_ea_info(0, opcode, EA_UINT16, EA_VALUE);
		sprintf(buffer, "invalid %s\n", sym);
	}
}
Exemplo n.º 9
0
static void op0111(char *buffer, UINT32 pc, UINT16 opcode)
{
	const char *sym;
	sym = set_ea_info(0, opcode & 0xff, EA_UINT8, EA_VALUE);
	sprintf(buffer, "ADD     #%s,%s\n", sym, regname[Rn]);
}
Exemplo n.º 10
0
unsigned Dasm7000 (char *buffer, unsigned pc)
{
	int opcode, i, size = 1;
	const char *sym1;
	
	opcode = cpu_readop(pc++);

	for( i=0; i<sizeof(opcodes) / sizeof(opcodeinfo); i++ )
	{
		if( opcode == opcodes[i].opcode )
		{
			/* We found a match */
			
			int 			j,k,vector;
			UINT8	a;
			INT8	b;
			UINT16	c;
			INT16	d;

			buffer += sprintf (buffer, "%s", opcodes[i].name);

			j=opcodes[i].operand;
							
			for( k=0; k<4; k++ )
			{
				switch( of[j].decode[k] )
				{
					case DONE:
						return size;
					case NONE:
						buffer += sprintf (buffer, "%s", of[j].opstr[k]);
						break;
					case UI8:
						a = (UINT8)cpu_readop( pc++ );
						buffer += sprintf(buffer, of[j].opstr[k], (unsigned int)a);
						size += 1;
						break;
					case I8:
						b = (INT8)cpu_readop( pc++ );
						buffer += sprintf (buffer, of[j].opstr[k], (INT8)b);
						size += 1;
						break;
					case UI16:
						c = (UINT16)cpu_readop(pc++);
						c <<= 8;
						c += cpu_readop(pc++);
						buffer += sprintf (buffer, of[j].opstr[k], (unsigned int)c);
						size += 2;
						break;
					case I16:
						d = (INT16)cpu_readop(pc++);
						d <<= 8;
						d += cpu_readop(pc++);
						buffer += sprintf (buffer, of[j].opstr[k], (signed int)d);
						size += 2;
						break;
					case PCREL:
						b = (INT8)cpu_readop( pc++ );
						sym1 = set_ea_info(EA_DST, pc, b, EA_REL_PC);
						buffer += sprintf (buffer, of[j].opstr[k], sym1);
						size += 1;
						break;
					case PCABS:
						c = (UINT16)cpu_readop(pc++);
						c <<= 8;
						c += cpu_readop(pc++);
						sym1 = set_ea_info(EA_DST, c, EA_UINT16, EA_ABS_PC);
						buffer += sprintf (buffer, of[j].opstr[k], sym1);
						size += 2;
						break;
					case TRAP:
						vector = 0xffff - ((0xff - opcode) * 2);
						c = (UINT16)((cpu_readop( vector-1 ) << 8) + cpu_readop( vector ));
						sym1 = set_ea_info(EA_DST, c, EA_UINT16, EA_ABS_PC);
						break;
				}
			}

			return size;
		}
	}

	/* No Match */
	strcpy (buffer, "Illegal Opcode");
	return size;
}
Exemplo n.º 11
0
unsigned sm8500_dasm( char *buffer, offs_t pc, UINT8 *oprom, UINT8 *opram, int bytes )
{
	const sm8500dasm *instr;
	const char *symbol, *symbol2;
	char *dst;
	UINT8 op;
	INT8 offset = 0;
	UINT16 ea = 0, ea2 = 0;
	int pos = 0;

	dst = buffer;

	op = oprom[pos++];

	instr = &mnemonic[op];

	if ( instr->arguments )
	{
		if ( instr->arguments != AM_1A || instr->arguments != AM_1B || instr->arguments != AM_4F ) {
			dst += sprintf( dst, "%-4s ", s_mnemonic[ instr->mnemonic ] );
		}
		switch( instr->arguments ) {
		case AM_R:
			ea = oprom[pos++];
			set_ea_info( 0, ea, EA_UINT8, instr->access );
			dst += sprintf( dst, "R%02Xh", ea );
			break;
		case AM_iR:
			ea = oprom[pos++];
			symbol = set_ea_info( 1, ea, EA_UINT8, EA_VALUE );
			ea = oprom[pos++];
			set_ea_info( 0, ea, EA_UINT8, instr->access );
			dst += sprintf( dst, "R%02Xh, %s", ea, symbol );
			break;
		case AM_iS:
			ea = oprom[pos++];
			symbol = set_ea_info( 1, ea, EA_UINT8, EA_VALUE );
			ea = oprom[pos++];
			set_ea_info( 0, ea, EA_UINT8, instr->access );
			dst += sprintf( dst, "RR%02Xh, %s", ea, symbol );
			break;
		case AM_Sw:
			ea2 = oprom[pos++];
			ea = oprom[pos++] << 8;
			ea += oprom[pos++];
			symbol = set_ea_info( 1, ea, EA_UINT16, EA_VALUE );
			set_ea_info( 0, ea2, EA_UINT16, instr->access );
			dst+= sprintf( dst, "RR%02Xh, %s", ea2, symbol );
			break;
		case AM_rib:
			ea = oprom[pos++];
			symbol = set_ea_info( 1, ea, EA_UINT8, EA_VALUE );
			set_ea_info( 0, (op & 0x07), EA_UINT8, instr->access );
			dst += sprintf( dst, "r%02Xh, %s", op & 0x07, symbol );
			break;
		case AM_riw:
			ea = oprom[pos++] << 8;
			ea += oprom[pos++];
			symbol = set_ea_info( 1, ea, EA_UINT16, EA_VALUE );
			set_ea_info( 0, (op & 0x07), EA_UINT16, instr->access );
			dst += sprintf( dst, "rr%02Xh, %s", sm8500_b2w[op & 0x07], symbol );
			break;
		case AM_rmb:
			ea = oprom[pos++];
			dst += sprintf( dst, "r%02Xh,", ( ea >> 3 ) & 0x07 );
			switch( ea & 0xC0 ) {
			case 0x00:
				dst += sprintf( dst, "@r%02Xh", ea & 0x07 ); break;
			case 0x40:
				dst += sprintf( dst, "(r%02Xh)+", ea & 0x07 ); break;
			case 0x80:
				ea2 = oprom[pos++];
				symbol2 = set_ea_info( 0, ea2, EA_UINT8, EA_VALUE );
				if ( ea & 0x07 ) {
					dst += sprintf( dst, "%s(r%02Xh)", symbol2, ea & 0x07 );
				} else {
					dst += sprintf( dst, "@%s", symbol2 );
				}
				break;
			case 0xC0:
				dst += sprintf( dst, "-(r%02Xh)", ea & 0x07 ); break;
			}
			break;
		case AM_mbr:
			ea = oprom[pos++];
			switch( ea & 0xC0 ) {
			case 0x00:
				dst += sprintf( dst, "@r%02Xh", ea & 0x07 ); break;
			case 0x40:
				dst += sprintf( dst, "(r%02Xh)+", ea & 0x07 ); break;
			case 0x80:
				ea2 = oprom[pos++];
				symbol2 = set_ea_info( 0, ea2, EA_UINT8, EA_VALUE );
				if ( ea & 0x07 ) {
					dst += sprintf( dst, "%s(r%02Xh)", symbol2, ea & 0x07 );
				} else {
					dst += sprintf( dst, "@%s", symbol2 );
				}
				break;
			case 0xC0:
				dst += sprintf( dst, "-(r%02Xh)", ea & 0x07 ); break;
			}
			dst += sprintf( dst, ",r%02Xh", ( ea >> 3 ) & 0x07 );
			break;
		case AM_rmw:
			ea = oprom[pos++];
			dst += sprintf( dst, "r%02Xh,", ( ea >> 3 ) & 0x07 );
			switch( ea & 0xC0 ) {
			case 0x00:
				dst += sprintf( dst, "@rr%02Xh", sm8500_b2w[ea & 0x07] ); break;
			case 0x40:
				dst += sprintf( dst, "(rr%02Xh)+", sm8500_b2w[ea & 0x07] ); break;
			case 0x80:
				ea2 = oprom[pos++] << 8;
				ea2 += oprom[pos++];
				symbol2 = set_ea_info( 0, ea2, EA_UINT16, EA_VALUE );
				if ( ea & 0x07 ) {
					dst += sprintf( dst, "%s(rr%02Xh)", symbol2, sm8500_b2w[ea & 0x07] );
				} else {
					dst += sprintf( dst, "@%s", symbol2 );
				}
				break;
			case 0xC0:
				dst += sprintf( dst, "-(rr%02Xh)", sm8500_b2w[ea & 0x07] ); break;
			}
			break;
		case AM_mwr:
			ea = oprom[pos++];
			switch( ea & 0xC0 ) {
			case 0x00:
				dst += sprintf( dst, "@rr%02Xh", sm8500_b2w[ea & 0x07] ); break;
			case 0x40:
				dst += sprintf( dst, "(rr%02Xh)+", sm8500_b2w[ea & 0x07] ); break;
			case 0x80:
				ea2 = oprom[pos++] << 8;
				ea2 += oprom[pos++];
				symbol2 = set_ea_info( 0, ea2, EA_UINT16, EA_VALUE );
				if ( ea & 0x07 ) {
					dst += sprintf( dst, "%s(rr%02Xh)", symbol2, sm8500_b2w[ea & 0x07] );
				} else {
					dst += sprintf( dst, "@%s", symbol2 );
				}
				break;
			case 0xC0:
				dst += sprintf( dst, "-(rr%02Xh)", sm8500_b2w[ea & 0x07] ); break;
			}
			dst += sprintf( dst, ",r%02Xh", ( ea >> 3 ) & 0x07 );
			break;
		case AM_smw:
			ea = oprom[pos++];
			dst += sprintf( dst, "rr%02Xh,", sm8500_b2w[( ea >> 3 ) & 0x07] );
			switch( ea & 0xC0 ) {
			case 0x00:
				dst += sprintf( dst, "@rr%02Xh", sm8500_b2w[ea & 0x07] ); break;
			case 0x40:
				dst += sprintf( dst, "(rr%02Xh)+", sm8500_b2w[ea & 0x07] ); break;
			case 0x80:
				ea2 = oprom[pos++] << 8;
				ea2 += oprom[pos++];
				symbol2 = set_ea_info( 0, ea2, EA_UINT16, EA_VALUE );
				if ( ea & 0x07 ) {
					dst += sprintf( dst, "%s(rr%02Xh)", symbol2, sm8500_b2w[ea & 0x07] );
				} else {
					dst += sprintf( dst, "@%s", symbol2 );
				}
				break;
			case 0xC0:
				dst += sprintf( dst, "-(rr%02Xh)", sm8500_b2w[ea & 0x07] ); break;
			}
			break;
		case AM_mws:
			ea = oprom[pos++];
			switch( ea & 0xC0 ) {
			case 0x00:
				dst += sprintf( dst, "@rr%02Xh", sm8500_b2w[ea & 0x07] ); break;
			case 0x40:
				dst += sprintf( dst, "(rr%02Xh)+", sm8500_b2w[ea & 0x07] ); break;
			case 0x80:
				ea2 = oprom[pos++] << 8;
				ea2 += oprom[pos++];
				symbol2 = set_ea_info( 0, ea2, EA_UINT16, EA_VALUE );
				if ( ea & 0x07 ) {
					dst += sprintf( dst, "%s(rr%02Xh)", symbol2, sm8500_b2w[ea & 0x07] );
				} else {
					dst += sprintf( dst, "@%s", symbol2 );
				}
				break;
			case 0xC0:
				dst += sprintf( dst, "-(rr%02Xh)", sm8500_b2w[ea & 0x07] ); break;
			}
			dst += sprintf( dst, ",rr%02Xh", sm8500_b2w[( ea >> 3 ) & 0x07] );
			break;
		case AM_cbr:
			offset = (INT8) oprom[pos++];
			symbol = set_ea_info( 0, pc + pos, offset, instr->access );
			dst += sprintf( dst, "%s,%s", sm8500_cond[ op & 0x0F ], symbol );
			break;
		case AM_rbr:
			offset = (INT8) oprom[pos++];
			symbol = set_ea_info( 0, pc + pos, offset, instr->access );
			dst += sprintf( dst, "r%02Xh,%s", op & 0x07, symbol );
			break;
		case AM_cjp:
			ea = oprom[pos++] << 8;
			ea += oprom[pos++];
			symbol = set_ea_info( 0, ea, EA_UINT16, instr->access );
			dst += sprintf( dst, "%s,%s", sm8500_cond[ op & 0x0F], symbol );
			break;
		case AM_rr:
			ea = oprom[pos++];
			switch( ea & 0xc0 ) {
			case 0x00:
				dst += sprintf( dst, "r%02Xh,r%02Xh", (ea >> 3 ) & 0x07, ea & 0x07 );
				break;
			case 0x40:
			case 0x80:
			case 0xC0:
				dst += sprintf( dst, "undef" );
				break;
			}
			break;
		case AM_r1:
			ea = oprom[pos++];
			switch( ea & 0xC0 ) {
				dst += sprintf( dst, "@r%02Xh", (ea >> 3 ) & 0x07 );
				break;
			case 0x40:
			case 0x80:
			case 0xC0:
				dst += sprintf( dst, "undef" );
				break;
			}
			break;
		case AM_S:
			ea = oprom[pos++];
			dst += sprintf( dst, "RR%02Xh", ea );
			break;
		case AM_pi:
			ea = oprom[pos++];
			symbol = set_ea_info( 1, ea, EA_UINT8, EA_VALUE );
			set_ea_info( 0, 0x10 + (op & 0x07), EA_UINT8, instr->access );
			dst += sprintf( dst, "r%02Xh, %s", 0x10 + (op & 0x07), symbol );
			break;
		case AM_Ri:
			ea = oprom[pos++];
			ea2 = oprom[pos++];
			symbol = set_ea_info( 0, ea2, EA_UINT8, EA_VALUE );
			dst += sprintf( dst, "R%02Xh,%s", ea, symbol );
			break;
		case AM_i:
			ea = oprom[pos++];
			symbol = set_ea_info( 0, ea, EA_UINT8, EA_VALUE );
			dst += sprintf( dst, "%s", symbol );
			break;
		case AM_ii:
			ea = oprom[pos++] << 8;
			ea += oprom[pos++];
			symbol = set_ea_info( 0, ea, EA_UINT16, EA_VALUE );
			dst += sprintf( dst, "%s", symbol );
			break;
		case AM_ss:
			ea = oprom[pos++];
			switch( ea & 0xC0 ) {
			case 0x00:
				dst += sprintf( dst, "rr%02Xh,rr%02Xh", sm8500_b2w[( ea >> 3 ) & 0x07], sm8500_b2w[ea & 0x07] ); break;
			case 0x40:
				dst += sprintf( dst, "undef" ); break;
			case 0x80:
				dst += sprintf( dst, "undef" ); break;
			case 0xC0:
				dst += sprintf( dst, "undef" ); break;
			}
			break;
		case AM_RR:
			ea = oprom[pos++];
			ea2 = oprom[pos++];
			dst += sprintf( dst, "R%02Xh,R%02Xh", ea2, ea );
			break;
		case AM_2:
			ea = oprom[pos++];
			switch( ea & 0xC0 ) {
			case 0x00:
				dst += sprintf( dst, "rr%02Xh", sm8500_b2w[ea & 0x07] ); break;
			case 0x40:
				ea2 = oprom[pos++] << 8;
				ea2 += oprom[pos++];
				symbol = set_ea_info( 0, ea2, EA_UINT16, EA_VALUE );
				if ( ea & 0x38 ) {
					dst += sprintf( dst, "@%s(r%02Xh)", symbol, ( ea >> 3 ) & 0x07 );
				} else {
					dst += sprintf( dst, "@%s", symbol );
				}
				break;
			case 0x80:
				dst += sprintf( dst, "undef" ); break;
			case 0xC0:
				dst += sprintf( dst, "undef" ); break;
			}
			break;
		case AM_SS:
			ea = oprom[pos++];
			ea2 = oprom[pos++];
			dst += sprintf( dst, "RR%02Xh,RR%02Xh", ea2, ea );
			break;
		case AM_bR:
			ea = oprom[pos++];
			ea2 = oprom[pos++];
			switch( ea & 0xC0 ) {
			case 0x00:
				dst += sprintf( dst, "BF,R%02Xh,#%d", ea2, ea & 0x07 ); break;
			case 0x40:
				dst += sprintf( dst, "R%02Xh,#%d,BF", ea2, ea & 0x07 ); break;
			case 0x80:
				dst += sprintf( dst, "undef" ); break;
			case 0xC0:
				dst += sprintf( dst, "undef" ); break;
			}
			break;
		case AM_Rbr:
			ea = oprom[pos++];
			offset = (INT8) oprom[pos++];
			symbol = set_ea_info( 0, pc + pos, offset, instr->access );
			dst += sprintf( dst, "R%02Xh,#%d,%s", ea, op & 0x07, symbol );
			break;
		case AM_Rb:
			ea = oprom[pos++];
			dst += sprintf( dst, "R%02Xh,#%d", ea, op&0x07 );
			break;
		case AM_rR:
			ea = oprom[pos++];
			dst += sprintf( dst, "r%02Xh,R%02Xh", op & 0x07, ea );
			break;
		case AM_Rr:
			ea = oprom[pos++];
			dst += sprintf( dst, "R%02Xh,r%02Xh", ea, op & 0x07 );
			break;
		case AM_Rii:
			ea = oprom[pos++];
			dst += sprintf( dst, "R%02Xh,", ea );
			ea = oprom[pos++];
			symbol = set_ea_info( 0, ea, EA_UINT8, EA_VALUE );
			dst += sprintf( dst, "%s,", symbol );
			ea = oprom[pos++];
			symbol = set_ea_info( 0, ea, EA_UINT8, EA_VALUE );
			dst += sprintf( dst, "%s", symbol );
			break;
		case AM_RiR:
			ea = oprom[pos++];
			dst += sprintf( dst, "R%02Xh,", ea );
			ea = oprom[pos++];
			symbol = set_ea_info( 0, ea, EA_UINT8, EA_VALUE );
			dst += sprintf( dst, "%s,", symbol );
			ea = oprom[pos++];
			dst += sprintf( dst, "R%02Xh", ea );
			break;
		case AM_riB:
			ea = oprom[pos++];
			ea2 = oprom[pos++];
			switch( ea & 0xC0 ) {
			case 0x00:
				dst += sprintf( dst, "#%2x(r%02Xh),#%d", ea2, ea >> 3, ea & 0x07 );
				break;
			case 0x40:
				dst += sprintf( dst, "undef" ); break;
			case 0x80:
				dst += sprintf( dst, "undef" ); break;
			case 0xC0:
				dst += sprintf( dst, "undef" ); break;
			}
			break;
		case AM_CALS:
			ea = oprom[pos++];
			symbol = set_ea_info( 0, 0x1000 | ( ( op & 0x0f ) << 8 ) | ea, EA_UINT16, EA_VALUE );
			dst += sprintf( dst, "%s", symbol );
			break;
		case AM_bid:
			ea = oprom[pos++];
			ea2 = oprom[pos++];
			if ( ea & 0x38 ) {
				symbol = set_ea_info( 0, ea2, EA_UINT8, EA_VALUE );
				dst += sprintf( dst, "%s(r%02Xh)", symbol, ( ea >> 3 ) & 0x07 );
			} else {
Exemplo n.º 12
0
static void op1110(char *buffer, UINT32 pc, UINT16 opcode)
{
	const char *sym;
	sym = set_ea_info(0, (UINT32)(INT32)(INT16)(INT8)(opcode & 0xff), EA_UINT8, EA_VALUE);
	sprintf(buffer, "MOV     #%s,%s", sym, regname[Rn]);
}
Exemplo n.º 13
0
static void op0000(char *buffer, UINT32 pc, UINT16 opcode)
{
	const char *sym;

	switch(opcode & 0x3f)
	{
	case 0x02:
		sprintf(buffer,"STC     SR,%s", regname[Rn]);
		break;
	case 0x03:
		sym = set_ea_info(0, activecpu_get_reg(SH2_R0 + Rn), EA_UINT32, EA_ABS_PC);
		sprintf(buffer,"BSRF    %s", regname[Rn]);
		break;
	case 0x08:
		sprintf(buffer,"CLRT");
		break;
	case 0x09:
		sprintf(buffer,"NOP");
		break;
	case 0x0A:
		sprintf(buffer,"STS     MACH,%s", regname[Rn]);
		break;
	case 0x0B:
		sprintf(buffer,"RTS");
		break;
	case 0x12:
		sprintf(buffer,"STS     GBR,%s", regname[Rn]);
		break;
	case 0x18:
		sprintf(buffer,"SETT");
		break;
	case 0x19:
		sprintf(buffer,"DIV0U");
		break;
	case 0x1A:
		sprintf(buffer,"STS     MACL,%s", regname[Rn]);
		break;
	case 0x1B:
		sprintf(buffer,"SLEEP");
		break;
	case 0x22:
		sprintf(buffer,"STC     VBR,%s", regname[Rn]);
		break;
	case 0x23:
		sym = set_ea_info(0, activecpu_get_reg(SH2_R0 + Rn), EA_UINT32, EA_ABS_PC);
		sprintf(buffer,"BRAF    %s", regname[Rn]);
		break;
	case 0x28:
		sprintf(buffer,"CLRMAC");
		break;
	case 0x29:
		sprintf(buffer,"MOVT    %s", regname[Rn]);
		break;
	case 0x2A:
		sprintf(buffer,"STS     PR,%s", regname[Rn]);
		break;
	case 0x2B:
		sprintf(buffer,"RTE");
		break;
	default:
		switch(opcode & 15)
		{
		case  0:
			sym = set_ea_info(0, opcode, EA_UINT16, EA_VALUE);
			sprintf(buffer, "??????  %s", sym);
			break;
		case  1:
			sym = set_ea_info(0, opcode, EA_UINT16, EA_VALUE);
			sprintf(buffer, "??????  %s", sym);
			break;
		case  2:
			sym = set_ea_info(0, opcode, EA_UINT16, EA_VALUE);
			sprintf(buffer, "??????  %s", sym);
			break;
		case  3:
			sym = set_ea_info(0, opcode, EA_UINT16, EA_VALUE);
			sprintf(buffer, "??????  %s", sym);
			break;
		case  4:
			sym = set_ea_info(0, activecpu_get_reg(SH2_R0) + activecpu_get_reg(SH2_R0+Rn), EA_UINT8, EA_MEM_RD);
			sprintf(buffer, "MOV.B   %s,@(R0,%s)", regname[Rm], regname[Rn]);
			break;
		case  5:
			sym = set_ea_info(0, activecpu_get_reg(SH2_R0) + activecpu_get_reg(SH2_R0+Rn), EA_UINT16, EA_MEM_RD);
			sprintf(buffer, "MOV.W   %s,@(R0,%s)", regname[Rm], regname[Rn]);
			break;
		case  6:
			sym = set_ea_info(0, activecpu_get_reg(SH2_R0) + activecpu_get_reg(SH2_R0+Rn), EA_UINT32, EA_MEM_RD);
			sprintf(buffer, "MOV.L   %s,@(R0,%s)", regname[Rm], regname[Rn]);
			break;
		case  7:
			sprintf(buffer, "MUL.L   %s,%s\n", regname[Rm], regname[Rn]);
			break;
		case  8:
			sym = set_ea_info(0, opcode, EA_UINT16, EA_VALUE);
			sprintf(buffer, "??????  %s", sym);
			break;
		case  9:
			sym = set_ea_info(0, opcode, EA_UINT16, EA_VALUE);
			sprintf(buffer, "??????  %s", sym);
			break;
		case 10:
			sym = set_ea_info(0, opcode, EA_UINT16, EA_VALUE);
			sprintf(buffer, "??????  %s", sym);
			break;
		case 11:
			sym = set_ea_info(0, opcode, EA_UINT16, EA_VALUE);
			sprintf(buffer, "??????  %s", sym);
			break;
		case 12:
			sym = set_ea_info(0, activecpu_get_reg(SH2_R0) + activecpu_get_reg(SH2_R0+Rm), EA_UINT8, EA_MEM_WR);
			sprintf(buffer, "MOV.B   @(R0,%s),%s", regname[Rm], regname[Rn]);
			break;
		case 13:
			sym = set_ea_info(0, activecpu_get_reg(SH2_R0) + activecpu_get_reg(SH2_R0+Rm), EA_UINT16, EA_MEM_WR);
			sprintf(buffer, "MOV.W   @(R0,%s),%s", regname[Rm], regname[Rn]);
			break;
		case 14:
			sym = set_ea_info(0, activecpu_get_reg(SH2_R0) + activecpu_get_reg(SH2_R0+Rm), EA_UINT32, EA_MEM_WR);
			sprintf(buffer, "MOV.L   @(R0,%s),%s", regname[Rm], regname[Rn]);
			break;
		case 15:
			set_ea_info(0, activecpu_get_reg(SH2_R0+Rn), EA_UINT32, EA_MEM_RD);
			set_ea_info(1, activecpu_get_reg(SH2_R0+Rm), EA_UINT32, EA_MEM_RD);
			sprintf(buffer, "MAC.L   @%s+,@%s+", regname[Rn], regname[Rm]);
			break;
		}
	}
}
Exemplo n.º 14
0
/****************************************************************************
 * Disassemble opcode at PC and return number of bytes it takes
 ****************************************************************************/
unsigned z80_dasm(char *buffer, offs_t pc, UINT8 *oprom, UINT8 *opram, int bytes)
{
    const z80dasm *d;
	const char *symbol, *src;
	const char *ixy;
	char *dst;
	INT8 offset = 0;
	UINT8 op, op1;
	UINT16 ea = 0, xy = 0;
	int pos = 0;

	ixy = "oops!!";
	dst = buffer;
	symbol = NULL;

	op = oprom[pos++];
    op1 = 0; /* keep GCC happy */

    switch (op)
	{
	case 0xcb:
		op = oprom[pos++];
        d = &mnemonic_cb[op];
		break;
	case 0xed:
		op1 = oprom[pos++];
        d = &mnemonic_ed[op1];
		break;
	case 0xdd:
		ixy = "ix";
		op1 = oprom[pos++];
		if( op1 == 0xcb )
		{
			offset = (INT8) opram[pos++];
			op1 = opram[pos++]; /* fourth byte from opcode_arg_base! */
			xy = z80_get_reg( Z80_IX );
			ea = (xy + offset) & 0xffff;
			d = &mnemonic_xx_cb[op1];
		}
		else d = &mnemonic_xx[op1];
        break;
	case 0xfd:
		ixy = "iy";
		op1 = oprom[pos++];
		if( op1 == 0xcb )
		{
			offset = (INT8) opram[pos++];
			op1 = opram[pos++]; /* fourth byte from opcode_arg_base! */
			xy = z80_get_reg( Z80_IY );
			ea = (ea + offset) & 0xffff;
			d = &mnemonic_xx_cb[op1];
		}
		else d = &mnemonic_xx[op1];
        break;
	default:
		d = &mnemonic_main[op];
		break;
	}

    if( d->arguments )
	{
		dst += sprintf(dst, "%-4s ", s_mnemonic[d->mnemonic]);
		src = d->arguments;
		while( *src )
		{
			switch( *src )
			{
			case '?':   /* illegal opcode */
				dst += sprintf( dst, "$%02x,$%02x", op, op1);
				break;
			case 'A':
				ea = opram[pos+0] + ( opram[pos+1] << 8);
				pos += 2;
				symbol = set_ea_info(0, ea, EA_UINT16, d->access);
				dst += sprintf( dst, "%s", symbol );
                break;
            case 'B':   /* Byte op arg */
				ea = opram[pos++];
				symbol = set_ea_info(1, ea, EA_UINT8, EA_VALUE);
				dst += sprintf( dst, "%s", symbol );
				break;
			case '(':   /* Memory byte at (HL) */
                *dst++ = *src;
				if( !strncmp( src, "(bc)", 4) )
				{
					ea = z80_get_reg( Z80_BC );
					set_ea_info(0, ea, EA_UINT8, d->access);
				}
                else
				if( !strncmp( src, "(de)", 4) )
				{
					ea = z80_get_reg( Z80_DE );
					set_ea_info(0, ea, EA_UINT8, d->access);
                }
                else
                if( !strncmp( src, "(hl)", 4) )
				{
					ea = z80_get_reg( Z80_HL );
					if( d->access == EA_ABS_PC )
						set_ea_info(0, ea, EA_DEFAULT, EA_ABS_PC);
					else
						set_ea_info(0, ea, EA_UINT8, d->access);
                }
				else
				if( !strncmp( src, "(sp)", 4) )
				{
					ea = z80_get_reg( Z80_SP );
					set_ea_info(0, ea, EA_UINT16, d->access);
                }
				else
				if( !strncmp( src, "(P)", 3) )
				{
					ea = (z80_get_reg( Z80_AF ) & 0xff00) | opram[pos];
                    set_ea_info(0, ea, EA_UINT16, d->access);
                }
                else
                if( !strncmp( src, "(c)", 3) )
				{
					ea = z80_get_reg( Z80_BC );
					set_ea_info(0, ea, EA_UINT16, d->access);
                }
                else
				if( !strncmp( src, "(I)", 3) )
				{
					ea = xy;
					set_ea_info(0, ea, EA_DEFAULT, d->access);
                }
                break;
			case 'N':   /* Immediate 16 bit */
				ea = opram[pos+0] + ( opram[pos+1] << 8 );
				pos += 2;
				symbol = set_ea_info(1, ea, EA_UINT16, EA_VALUE );
				dst += sprintf( dst, "%s", symbol );
                break;
			case 'O':   /* Offset relative to PC */
				offset = (INT8) opram[pos++];
				symbol = set_ea_info(0, pc, offset + 2, d->access);
				dst += sprintf( dst, "%s", symbol );
				break;
			case 'P':   /* Port number */
				ea = opram[pos++];
				dst += sprintf( dst, "$%02X", ea );
                break;
            case 'V':   /* Restart vector */
				ea = op & 0x38;
				symbol = set_ea_info(0, ea, EA_UINT8, d->access);
				dst += sprintf( dst, "%s", symbol );
				break;
			case 'W':   /* Memory address word */
				ea = opram[pos+0] + ( opram[pos+1] << 8);
				pos += 2;
				symbol = set_ea_info(0, ea, EA_UINT16, d->access);
				dst += sprintf( dst, "%s", symbol );
				break;
			case 'X':
				offset = (INT8) opram[pos++];
                ea = (xy + offset) & 0xffff;
            case 'Y':
				symbol = set_ea_info(0, ea, EA_UINT8, d->access);
				dst += sprintf( dst,"(%s%c$%02x)", ixy, sign(offset), offs(offset) );
				break;
			case 'I':
				dst += sprintf( dst, "%s", ixy);
				break;
			default:
				*dst++ = *src;
			}
			src++;
		}
		*dst = '\0';
	}
	else
	{
		dst += sprintf(dst, "%s", s_mnemonic[d->mnemonic]);
    }

    return pos | s_flags[d->mnemonic] | DASMFLAG_SUPPORTED;
}
Exemplo n.º 15
0
unsigned Dasm680x (int subtype, char *buf, unsigned pc)
{
	int invalid_mask;
	int code = cpu_readop(pc);
	const char *symbol, *symbol2;
	UINT8 opcode, args, access, size, invalid;

	switch( subtype )
	{
		case 6800: case 6802: case 6808:
			invalid_mask = 1;
			break;
		case 6801: case 6803:
			invalid_mask = 2;
			break;
		default:
			invalid_mask = 4;
	}

	opcode = table[code][0];
	args = table[code][1];
	access = table[code][2];
	size = table[code][3];
	invalid = table[code][4];

	if ( invalid & invalid_mask )	/* invalid for this cpu type ? */
	{
		strcpy(buf, "illegal");
		return 1;
	}

	buf += sprintf(buf, "%-5s", op_name_str[opcode]);

	switch( args )
	{
		case rel:  /* relative */
			symbol = set_ea_info( 0, pc, (INT8)ARG1 + 2, access );
			sprintf (buf, "%s", symbol);
			return 2;
		case imm:  /* immediate (byte or word) */
			if( size == B )
			{
				symbol = set_ea_info( 0, ARG1, EA_UINT8, EA_VALUE );
				sprintf (buf, "#%s", symbol);
                return 2;
			}
			symbol = set_ea_info( 0, ARGW, EA_UINT16, EA_VALUE );
			sprintf (buf, "#%s", symbol);
			return 3;
		case idx:  /* indexed + byte offset */
			symbol = set_ea_info( 1, ARG1, EA_UINT8, EA_VALUE );
			symbol2 = set_ea_info( 0, (m6800_get_reg(M6800_X) + ARG1), size, access);
			sprintf (buf, "(x+%s)", symbol );
            return 2;
		case imx:  /* immediate, indexed + byte offset */
			symbol = set_ea_info( 1, ARG1, EA_UINT8, EA_VALUE);
			symbol2 = set_ea_info( 0, (m6800_get_reg(M6800_X) + ARG2), size, access);
			sprintf (buf, "#%s,(x+$%02x)", symbol, ARG2 );
			return 3;
		case dir:  /* direct address */
			symbol = set_ea_info( 1, ARG1, size, access);
			sprintf (buf, "%s", symbol );
			return 2;
		case imd:  /* immediate, direct address */
            symbol = set_ea_info( 1, ARG1, EA_UINT8, EA_VALUE );
			symbol2 = set_ea_info( 0, ARG2, size, access);
			sprintf (buf, "#%s,%s", symbol, symbol2);
            return 3;
		case ext:  /* extended address */
			symbol = set_ea_info( 0, ARGW, size, access);
			sprintf (buf, "%s", symbol);
			return 3;
		case sx1:  /* byte from address (s + 1) */
			symbol = set_ea_info( 0, m6800_get_reg(M6800_S) + 1, EA_UINT8, access);
            sprintf (buf, "(s+1)");
            return 1;
        default:
			return 1;
	}
}
Exemplo n.º 16
0
/****************************************************************************
 * Disassemble opcode at PC and return number of bytes it takes
 ****************************************************************************/
unsigned DasmZ80( char *buffer, unsigned pc )
{
    z80dasm *d;
	const char *symbol, *src;
	const char *ixy;
	char *dst;
	unsigned PC = pc;
	INT8 offset = 0;
	UINT8 op, op1;
	UINT16 ea = 0, xy = 0;

	ixy = "oops!!";
	dst = buffer;
	symbol = NULL;

	op = cpu_readop( pc++ );
    op1 = 0; /* keep GCC happy */

    switch (op)
	{
	case 0xcb:
		op = cpu_readop(pc++);
        d = &mnemonic_cb[op];
		break;
	case 0xed:
		op1 = cpu_readop(pc++);
        d = &mnemonic_ed[op1];
		break;
	case 0xdd:
		ixy = "ix";
		op1 = cpu_readop(pc++);
		if( op1 == 0xcb )
		{
			offset = (INT8) cpu_readop_arg(pc++);
			op1 = cpu_readop_arg(pc++); /* fourth byte from OP_RAM! */
			xy = z80_get_reg( Z80_IX );
			ea = (xy + offset) & 0xffff;
			d = &mnemonic_xx_cb[op1];
		}
		else d = &mnemonic_xx[op1];
        break;
	case 0xfd:
		ixy = "iy";
		op1 = cpu_readop(pc++);
		if( op1 == 0xcb )
		{
			offset = (INT8) cpu_readop_arg(pc++);
			op1 = cpu_readop_arg(pc++); /* fourth byte from OP_RAM! */
			xy = z80_get_reg( Z80_IY );
			ea = (ea + offset) & 0xffff;
			d = &mnemonic_xx_cb[op1];
		}
		else d = &mnemonic_xx[op1];
        break;
	default:
		d = &mnemonic_main[op];
		break;
	}

    if( d->arguments )
	{
		dst += sprintf(dst, "%-4s ", s_mnemonic[d->mnemonic]);
		src = d->arguments;
		while( *src )
		{
			switch( *src )
			{
			case '?':   /* illegal opcode */
				dst += sprintf( dst, "$%02x,$%02x", op, op1);
				break;
			case 'A':
				ea = cpu_readop_arg(pc) + ( cpu_readop_arg((pc+1)&0xffff) << 8);
				pc += 2;
				symbol = set_ea_info(0, ea, EA_UINT16, d->access);
				dst += sprintf( dst, "%s", symbol );
                break;
            case 'B':   /* Byte op arg */
				ea = cpu_readop_arg( pc++ );
				symbol = set_ea_info(1, ea, EA_UINT8, EA_VALUE);
				dst += sprintf( dst, "%s", symbol );
				break;
			case '(':   /* Memory byte at (HL) */
                *dst++ = *src;
				if( !strncmp( src, "(bc)", 4) )
				{
					ea = z80_get_reg( Z80_BC );
					set_ea_info(0, ea, EA_UINT8, d->access);
				}
                else
				if( !strncmp( src, "(de)", 4) )
				{
					ea = z80_get_reg( Z80_DE );
					set_ea_info(0, ea, EA_UINT8, d->access);
                }
                else
                if( !strncmp( src, "(hl)", 4) )
				{
					ea = z80_get_reg( Z80_HL );
					if( d->access == EA_ABS_PC )
						set_ea_info(0, ea, EA_DEFAULT, EA_ABS_PC);
					else
						set_ea_info(0, ea, EA_UINT8, d->access);
                }
				else
				if( !strncmp( src, "(sp)", 4) )
				{
					ea = z80_get_reg( Z80_SP );
					set_ea_info(0, ea, EA_UINT16, d->access);
                }
				else
				if( !strncmp( src, "(P)", 3) )
				{
					ea = (z80_get_reg( Z80_AF ) & 0xff00) | cpu_readop_arg( pc );
                    set_ea_info(0, ea, EA_UINT16, d->access);
                }
                else
                if( !strncmp( src, "(c)", 3) )
				{
					ea = z80_get_reg( Z80_BC );
					set_ea_info(0, ea, EA_UINT16, d->access);
                }
                else
				if( !strncmp( src, "(I)", 3) )
				{
					ea = xy;
					set_ea_info(0, ea, EA_DEFAULT, d->access);
                }
                break;
			case 'N':   /* Immediate 16 bit */
				ea = cpu_readop_arg(pc) + ( cpu_readop_arg((pc+1)&0xffff) << 8 );
				pc += 2;
				symbol = set_ea_info(1, ea, EA_UINT16, EA_VALUE );
				dst += sprintf( dst, "%s", symbol );
                break;
			case 'O':   /* Offset relative to PC */
				offset = (INT8) cpu_readop_arg(pc++);
				symbol = set_ea_info(0, PC, offset + 2, d->access);
				dst += sprintf( dst, "%s", symbol );
				break;
			case 'P':   /* Port number */
				ea = cpu_readop_arg( pc++ );
				dst += sprintf( dst, "$%02X", ea );
                break;
            case 'V':   /* Restart vector */
				ea = op & 0x38;
				symbol = set_ea_info(0, ea, EA_UINT8, d->access);
				dst += sprintf( dst, "%s", symbol );
				break;
			case 'W':   /* Memory address word */
				ea = cpu_readop_arg(pc) + ( cpu_readop_arg((pc+1)&0xffff) << 8);
				pc += 2;
				symbol = set_ea_info(0, ea, EA_UINT16, d->access);
				dst += sprintf( dst, "%s", symbol );
				break;
			case 'X':
				offset = (INT8) cpu_readop_arg(pc++);
                ea = (xy + offset) & 0xffff;
            case 'Y':
				symbol = set_ea_info(0, ea, EA_UINT8, d->access);
				dst += sprintf( dst,"(%s%c$%02x)", ixy, sign(offset), offs(offset) );
				break;
			case 'I':
				dst += sprintf( dst, "%s", ixy);
				break;
			default:
				*dst++ = *src;
			}
			src++;
		}
		*dst = '\0';
	}
	else
	{
		dst += sprintf(dst, "%s", s_mnemonic[d->mnemonic]);
    }

    return pc - PC;
}
Exemplo n.º 17
0
/*****************************************************************************
 * Disassemble a single opcode starting at pc
 *****************************************************************************/
static unsigned internal_m6502_dasm(const struct op6502_info *opinfo, char *buffer, offs_t pc, UINT8 *oprom, UINT8 *opram, int bytes)
{
	char *dst = buffer;
	const char *symbol;
	INT8 offset;
	INT16 offset16;
	unsigned PC = pc;
	UINT16 addr;
	UINT8 op, opc, arg, access, value;
	UINT32 flags;
	int pos = 0;

	op = oprom[pos++];
	pc++;

	opc = opinfo[op].opc;
	arg = opinfo[op].arg;
	access = opinfo[op].access;

	/* determine dasmflags */
	switch(opc)
	{
		case jsr:
		case bsr:
			flags = DASMFLAG_SUPPORTED | DASMFLAG_STEP_OVER;
			break;

		case rts:
		case rti:
		case rtn:
			flags = DASMFLAG_SUPPORTED | DASMFLAG_STEP_OUT;
			break;

		default:
			flags = DASMFLAG_SUPPORTED;
			break;
	}

	dst += sprintf(dst, "%-5s", token[opc]);
	if( opc == bbr || opc == bbs || opc == rmb || opc == smb )
		dst += sprintf(dst, "%d,", (op >> 3) & 7);

	switch(arg)
	{
	case imp:
		break;

	case acc:
		dst += sprintf(dst,"a");
		break;

	case rel:
		offset = (INT8) opram[pos++];
		pc++;
		dst += sprintf(dst, "$%04X", (pc + offset) & 0xFFFF);
		break;

	case rw2:
		offset16 = (opram[pos] | (opram[pos+1] << 8)) -1;
		pos += 2;
		pc += 2;
		dst += sprintf(dst, "$%04X", (pc + offset16) & 0xFFFF);
		break;

	case imm:
		value = opram[pos++];
		pc++;
		symbol = set_ea_info( 0, value, EA_UINT8, access );
		dst += sprintf(dst,"#%s", symbol);
		break;

	case zpg:
		addr = opram[pos++];
		pc++;
		symbol = set_ea_info( 0, addr, EA_UINT8, access );
		dst += sprintf(dst,"$%02X", addr);
		break;

	case zpx:
		addr = opram[pos++];
		pc++;
		dst += sprintf(dst,"$%02X,x", addr);
		break;

	case zpy:
		addr = opram[pos++];
		pc++;
		dst += sprintf(dst,"$%02X,y", addr);
		break;

	case idx:
		addr = opram[pos++];
		pc++;
		dst += sprintf(dst,"($%02X,x)", addr);
		break;

	case idy:
		addr = opram[pos++];
		pc++;
		dst += sprintf(dst,"($%02X),y", addr);
		break;

	case zpi:
		addr = opram[pos++];
		pc++;
		dst += sprintf(dst,"($%02X)", addr);
		break;

	case zpb:
		addr = opram[pos++];
		pc++;
		symbol = set_ea_info( 0, addr, EA_UINT8, access );
		dst += sprintf(dst,"$%02X", addr);
		offset = (INT8) opram[pos++];
		pc++;
		symbol = set_ea_info( 1, pc, offset, BRA );
		dst += sprintf(dst,",%s", symbol);
		break;

	case adr:
		addr = (opram[pos] | (opram[pos+1] << 8));
		pos += 2;
		pc += 2;
		dst += sprintf(dst, "$%04X", addr);
		break;

	case aba:
		addr = (opram[pos] | (opram[pos+1] << 8));
		pos += 2;
		pc += 2;
		dst += sprintf(dst, "$%04X", addr);
		break;

	case abx:
		addr = (opram[pos] | (opram[pos+1] << 8));
		pos += 2;
		pc += 2;
		dst += sprintf(dst,"$%04X,x", addr);
		break;

	case aby:
		addr = (opram[pos] | (opram[pos+1] << 8));
		pos += 2;
		pc += 2;
		dst += sprintf(dst,"$%04X,y", addr);
		break;

	case ind:
		addr = (opram[pos] | (opram[pos+1] << 8));
		pos += 2;
		pc += 2;
		dst += sprintf(dst,"($%04X)", addr);
		break;

	case iax:
		addr = (opram[pos] | (opram[pos+1] << 8));
		pos += 2;
		pc += 2;
		pos += 2;
		pc += 2;
		dst += sprintf(dst,"($%04X),X", addr);
		break;

	case iw2:
		addr = (opram[pos] | (opram[pos+1] << 8));
		pos += 2;
		pc += 2;
		dst += sprintf(dst,"#%04X", addr);
		break;

	case iw3:
		addr = (opram[pos] | (opram[pos+1] << 8) | (opram[pos+2] << 16));
		pos += 3;
		pc += 3;
		dst += sprintf(dst,"#%06x", addr);
		break;

	case idz:
		addr = (INT8) opram[pos++];
		pc++;
		dst += sprintf(dst,"($%02X),z", addr);
		break;

	case isy:
		op = opram[pos++];
		pc++;
		addr = op + m6502_get_reg(opinfo, M6502_S);
		pos += 2;
		pc += 2;
		dst += sprintf(dst,"(s,$%02X),y", addr);
		break;

	default:
		dst += sprintf(dst,"$%02X", op);
		break;
	}
	return (pc - PC) | flags;
}
Exemplo n.º 18
0
static void op1111(char *buffer, UINT32 pc, UINT16 opcode)
{
	const char *sym;
	sym = set_ea_info(0, opcode, EA_UINT16, EA_VALUE);
	sprintf(buffer, "unknown %s", sym);
}
Exemplo n.º 19
0
static void op0110(char *buffer, UINT32 pc, UINT16 opcode)

{
	switch(opcode & 0xF)
	{
	case 0x00:
		set_ea_info(0, activecpu_get_reg(SH2_R0+Rm), EA_UINT8, EA_MEM_RD);
		sprintf(buffer, "MOV.B   @%s,%s", regname[Rm], regname[Rn]);
		break;
	case 0x01:
		set_ea_info(0, activecpu_get_reg(SH2_R0+Rm), EA_UINT16, EA_MEM_RD);
		sprintf(buffer, "MOV.W   @%s,%s", regname[Rm], regname[Rn]);
		break;
	case 0x02:
		set_ea_info(0, activecpu_get_reg(SH2_R0+Rm), EA_UINT32, EA_MEM_RD);
		sprintf(buffer, "MOV.L   @%s,%s", regname[Rm], regname[Rn]);
		break;
	case 0x03:
		sprintf(buffer, "MOV     %s,%s", regname[Rm], regname[Rn]);
		break;
	case 0x04:
		set_ea_info(0, activecpu_get_reg(SH2_R0+Rm), EA_UINT8, EA_MEM_RD);
		sprintf(buffer, "MOV.B   @%s+,%s", regname[Rm], regname[Rn]);
		break;
	case 0x05:
		set_ea_info(0, activecpu_get_reg(SH2_R0+Rm), EA_UINT16, EA_MEM_RD);
		sprintf(buffer, "MOV.W   @%s+,%s", regname[Rm], regname[Rn]);
		break;
	case 0x06:
		set_ea_info(0, activecpu_get_reg(SH2_R0+Rm), EA_UINT32, EA_MEM_RD);
		sprintf(buffer, "MOV.L   @%s+,%s", regname[Rm], regname[Rn]);
		break;
	case 0x07:
		sprintf(buffer, "NOT     %s,%s", regname[Rm], regname[Rn]);
		break;
	case 0x08:
		sprintf(buffer, "SWAP.B  %s,%s", regname[Rm], regname[Rn]);
		break;
	case 0x09:
		sprintf(buffer, "SWAP.W  %s,%s", regname[Rm], regname[Rn]);
		break;
	case 0x0a:
		sprintf(buffer, "NEGC    %s,%s", regname[Rm], regname[Rn]);
		break;
	case 0x0b:
		sprintf(buffer, "NEG     %s,%s", regname[Rm], regname[Rn]);
		break;
	case 0x0c:
		sprintf(buffer, "EXTU.B  %s,%s", regname[Rm], regname[Rn]);
		break;
	case 0x0d:
		sprintf(buffer, "EXTU.W  %s,%s", regname[Rm], regname[Rn]);
		break;
	case 0x0e:
		sprintf(buffer, "EXTS.B  %s,%s", regname[Rm], regname[Rn]);
		break;
	case 0x0f:
		sprintf(buffer, "EXTS.W  %s,%s", regname[Rm], regname[Rn]);
		break;
	}
}
Exemplo n.º 20
0
unsigned DasmF8(char *buffer, unsigned pc)
{
	UINT8 op = cpu_readop(pc);
	UINT16 ea;
	unsigned size = 1;
	const char *sym, *sym2;

    switch( op )
	{
	/* opcode  bitmask */
	case 0x00: /* 0000 0000 */
		sym = set_ea_info( 0, 12, EA_UINT8, EA_ZPG_RD );
        sprintf(buffer, "LR   A,KU");
		break;
	case 0x01: /* 0000 0001 */
		sym = set_ea_info( 0, 13, EA_UINT8, EA_ZPG_RD );
        sprintf(buffer, "LR   A,KL");
		break;
	case 0x02: /* 0000 0010 */
		sym = set_ea_info( 0, 14, EA_UINT8, EA_ZPG_RD );
        sprintf(buffer, "LR   A,QU");
		break;
	case 0x03: /* 0000 0011 */
		sym = set_ea_info( 0, 15, EA_UINT8, EA_ZPG_RD );
        sprintf(buffer, "LR   A,QL");
		break;
	case 0x04: /* 0000 0100 */
		sym = set_ea_info( 0, 12, EA_UINT8, EA_ZPG_WR );
        sprintf(buffer, "LR   KU,A");
		break;
	case 0x05: /* 0000 0101 */
		sym = set_ea_info( 0, 13, EA_UINT8, EA_ZPG_WR );
        sprintf(buffer, "LR   KL,A");
		break;
	case 0x06: /* 0000 0110 */
		sym = set_ea_info( 0, 14, EA_UINT8, EA_ZPG_WR );
        sprintf(buffer, "LR   QU,A");
		break;
	case 0x07: /* 0000 0111 */
		sym = set_ea_info( 0, 15, EA_UINT8, EA_ZPG_WR );
        sprintf(buffer, "LR   QL,A");
		break;

    case 0x08: /* 0000 1000 */
		sym = set_ea_info( 0, 12, EA_UINT16, EA_ZPG_WR );
        sprintf(buffer, "LR   K,P");
		break;
	case 0x09: /* 0000 1001 */
		sym = set_ea_info( 0, 12, EA_UINT16, EA_ZPG_RD );
        sprintf(buffer, "LR   P,K");
		break;
	case 0x0a: /* 0000 1010 */
		sprintf(buffer, "LR   A,IS");
		break;
	case 0x0b: /* 0000 1011 */
		sprintf(buffer, "LR   IS,A");
		break;

    case 0x0c: /* 0000 1100 */
		sprintf(buffer, "PK") ;
		break;
	case 0x0d: /* 0000 1101 */
		sprintf(buffer, "LR   P0,Q");
		sym = set_ea_info( 0, 14, EA_UINT16, EA_ZPG_RD );
        break;
	case 0x0e: /* 0000 1110 */
		sym = set_ea_info( 0, 14, EA_UINT16, EA_ZPG_WR );
        sprintf(buffer, "LR   Q,DC");
		break;
	case 0x0f: /* 0000 1111 */
		sym = set_ea_info( 0, 14, EA_UINT16, EA_ZPG_RD );
        sprintf(buffer, "LR   DC,Q");
		break;
	case 0x10: /* 0001 0000 */
		sym = set_ea_info( 0, 10, EA_UINT16, EA_ZPG_RD );
		sprintf(buffer, "LR   DC,H");
		break;
	case 0x11: /* 0001 0001 */
		sym = set_ea_info( 0, 10, EA_UINT16, EA_ZPG_WR );
		sprintf(buffer, "LR   H,DC");
		break;
	case 0x12: /* 0001 0010 */
		sprintf(buffer, "SR   1");
		break;
	case 0x13: /* 0001 0011 */
		sprintf(buffer, "SL   1");
		break;
	case 0x14: /* 0001 0100 */
		sprintf(buffer, "SR   4");
		break;
	case 0x15: /* 0001 0101 */
		sprintf(buffer, "SL   4");
		break;
	case 0x16: /* 0001 0110 */
		sym = set_ea_info( 0, activecpu_get_reg(F8_DC0), EA_UINT8, EA_MEM_RD );
		sprintf(buffer, "LM") ;
		break;
	case 0x17: /* 0001 0111 */
		sym = set_ea_info( 0, activecpu_get_reg(F8_DC0), EA_UINT8, EA_MEM_WR );
		sprintf(buffer, "ST");
		break;
	case 0x18: /* 0001 1000 */
		sprintf(buffer, "COM");
		break;
	case 0x19: /* 0001 1001 */
		sprintf(buffer, "LNK");
		break;
	case 0x1a: /* 0001 1010 */
		sprintf(buffer, "DI");
		break;
	case 0x1b: /* 0001 1011 */
		sprintf(buffer, "EI");
		break;
	case 0x1c: /* 0001 1100 */
		sym = set_ea_info( 0, activecpu_get_reg(F8_PC1), EA_UINT16, EA_ABS_PC );
        sprintf(buffer, "POP");
		break;
	case 0x1d: /* 0001 1101 */
		sym = set_ea_info( 0, 9, EA_UINT8, EA_ZPG_RD );
        sprintf(buffer, "LR   W,J");
		break;
	case 0x1e: /* 0001 1110 */
		sym = set_ea_info( 0, 9, EA_UINT8, EA_ZPG_WR );
        sprintf(buffer, "LR   J,W");
		break;
	case 0x1f: /* 0001 1111 */
		sprintf(buffer, "INC");
		break;
	case 0x20: /* 0010 0000 */
		size += 1;
        sym = set_ea_info( 0, cpu_readop_arg(pc+1), EA_UINT8, EA_VALUE );
		sprintf(buffer, "LI   %s",sym);
		break;
	case 0x21: /* 0010 0001 */
		size += 1;
        sym = set_ea_info( 0, cpu_readop_arg(pc+1), EA_UINT8, EA_VALUE );
		sprintf(buffer, "NI   %s",sym);
        break;
    case 0x22: /* 0010 0010 */
		size += 1;
        sym = set_ea_info( 0, cpu_readop_arg(pc+1), EA_UINT8, EA_VALUE );
		sprintf(buffer, "OI   %s",sym);
        break;
    case 0x23: /* 0010 0011 */
		size += 1;
        sym = set_ea_info( 0, cpu_readop_arg(pc+1), EA_UINT8, EA_VALUE );
		sprintf(buffer, "XI   %s",sym);
        break;
	case 0x24: /* 0010 0100 */
		size += 1;
        sym = set_ea_info( 0, cpu_readop_arg(pc+1), EA_UINT8, EA_VALUE );
		sprintf(buffer, "AI   %s",sym);
        break;
	case 0x25: /* 0010 0101 */
		size += 1;
        sym = set_ea_info( 0, cpu_readop_arg(pc+1), EA_UINT8, EA_VALUE );
		sprintf(buffer, "CI   %s",sym);
        break;
	case 0x26: /* 0010 0110 */
		size += 1;
		sym = set_ea_info( 0, cpu_readop_arg(pc+1), EA_UINT8, EA_PORT_RD );
		sprintf(buffer, "IN   %s",sym);
        break;
	case 0x27: /* 0010 0111 */
		size += 1;
		sym = set_ea_info( 0, cpu_readop_arg(pc+1), EA_UINT8, EA_PORT_WR );
		sprintf(buffer, "OUT  %s",sym);
        break;
	case 0x28: /* 0010 1000 */
		size += 2;
        ea = cpu_readop_arg(pc+1) << 8;
        ea |= cpu_readop_arg(pc+2);
		sym = set_ea_info( 0, ea, EA_UINT16, EA_ABS_PC );
		sprintf(buffer, "PI   %s",sym);
        break;
	case 0x29: /* 0010 1001 */
		size += 2;
        ea = cpu_readop_arg(pc+1) << 8;
        ea |= cpu_readop_arg(pc+2);
		sym = set_ea_info( 0, ea, EA_UINT16, EA_ABS_PC );
		sprintf(buffer, "JMP  %s",sym);
        break;
	case 0x2a: /* 0010 1010 */
		size += 2;
        ea = cpu_readop_arg(pc+1) << 8;
        ea |= cpu_readop_arg(pc+2);
		sym = set_ea_info( 0, ea, EA_UINT16, EA_VALUE );
		sprintf(buffer, "DCI  %s",sym);
        break;
	case 0x2b: /* 0010 1011 */
		sprintf(buffer, "NOP");
		break;
	case 0x2c: /* 0010 1100 */
		sprintf(buffer, "XDC");
		break;
	case 0x2d: /* 0010 1101 */
	case 0x2e: /* 0010 1110 */
	case 0x2f: /* 0010 1111 */
		sprintf(buffer, "???  $%02X",op);
        break;

    case 0x30: /* 0011 0000 */
	case 0x31: /* 0011 0001 */
	case 0x32: /* 0011 0010 */
	case 0x33: /* 0011 0011 */
	case 0x34: /* 0011 0100 */
	case 0x35: /* 0011 0101 */
	case 0x36: /* 0011 0110 */
	case 0x37: /* 0011 0111 */
	case 0x38: /* 0011 1000 */
	case 0x39: /* 0011 1001 */
	case 0x3a: /* 0011 1010 */
	case 0x3b: /* 0011 1011 */
		sym = set_ea_info( 0, op & 15, EA_UINT8, EA_ZPG_RDWR );
        sprintf(buffer, "DS   %s",rname[op & 15]);
        break;
    case 0x3c: /* 0011 1100 */
		sym = set_ea_info( 0, activecpu_get_reg(F8_IS), EA_UINT8, EA_ZPG_RDWR );
        sprintf(buffer, "DS   (IS)");
        break;
    case 0x3d: /* 0011 1101 */
		sym = set_ea_info( 0, activecpu_get_reg(F8_IS), EA_UINT8, EA_ZPG_RDWR );
        sprintf(buffer, "DS   (IS++)");
        break;
    case 0x3e: /* 0011 1110 */
		sym = set_ea_info( 0, activecpu_get_reg(F8_IS), EA_UINT8, EA_ZPG_RDWR );
        sprintf(buffer, "DS   (IS--)");
        break;
    case 0x3f: /* 0011 1111 */
		sprintf(buffer, "???  $%02X",op);
        break;

    case 0x40: /* 0100 0000 */
    case 0x41: /* 0100 0001 */
	case 0x42: /* 0100 0010 */
	case 0x43: /* 0100 0011 */
	case 0x44: /* 0100 0100 */
	case 0x45: /* 0100 0101 */
	case 0x46: /* 0100 0110 */
	case 0x47: /* 0100 0111 */
	case 0x48: /* 0100 1000 */
	case 0x49: /* 0100 1001 */
	case 0x4a: /* 0100 1010 */
	case 0x4b: /* 0100 1011 */
		sym = set_ea_info( 0, op & 15, EA_UINT8, EA_ZPG_RD );
        sprintf(buffer, "LR   A,%s",rname[op & 15]);
        break;
    case 0x4c: /* 0100 1100 */
		sym = set_ea_info( 0, activecpu_get_reg(F8_IS), EA_UINT8, EA_ZPG_RD );
        sprintf(buffer, "LR   A,(IS)");
        break;
    case 0x4d: /* 0100 1101 */
		sym = set_ea_info( 0, activecpu_get_reg(F8_IS), EA_UINT8, EA_ZPG_RD );
        sprintf(buffer, "LR   A,(IS++)");
        break;
    case 0x4e: /* 0100 1110 */
		sym = set_ea_info( 0, activecpu_get_reg(F8_IS), EA_UINT8, EA_ZPG_RD );
        sprintf(buffer, "LR   A,(IS--)");
        break;
    case 0x4f: /* 0100 1111 */
		sprintf(buffer, "???  $%02X",op);
        break;

    case 0x50: /* 0101 0000 */
	case 0x51: /* 0101 0001 */
	case 0x52: /* 0101 0010 */
	case 0x53: /* 0101 0011 */
	case 0x54: /* 0101 0100 */
	case 0x55: /* 0101 0101 */
	case 0x56: /* 0101 0110 */
	case 0x57: /* 0101 0111 */
	case 0x58: /* 0101 1000 */
	case 0x59: /* 0101 1001 */
	case 0x5a: /* 0101 1010 */
	case 0x5b: /* 0101 1011 */
		sym = set_ea_info( 0, op & 15, EA_UINT8, EA_ZPG_WR );
        sprintf(buffer, "LR   %s,A",rname[op & 15]);
        break;
    case 0x5c: /* 0101 1100 */
		sym = set_ea_info( 0, activecpu_get_reg(F8_IS), EA_UINT8, EA_ZPG_WR );
        sprintf(buffer, "LR   (IS),A");
        break;
    case 0x5d: /* 0101 1101 */
		sym = set_ea_info( 0, activecpu_get_reg(F8_IS), EA_UINT8, EA_ZPG_WR );
        sprintf(buffer, "LR   (IS++),A");
        break;
    case 0x5e: /* 0101 1110 */
		sym = set_ea_info( 0, activecpu_get_reg(F8_IS), EA_UINT8, EA_ZPG_WR );
        sprintf(buffer, "LR   (IS--),A");
        break;
    case 0x5f: /* 0101 1111 */
		sprintf(buffer, "???  $%02X",op);
        break;

    case 0x60: /* 0110 0000 */
    case 0x61: /* 0110 0001 */
	case 0x62: /* 0110 0010 */
	case 0x63: /* 0110 0011 */
	case 0x64: /* 0110 0100 */
	case 0x65: /* 0110 0101 */
	case 0x66: /* 0110 0110 */
	case 0x67: /* 0110 0111 */
		sym = set_ea_info( 0, op & 7, EA_UINT8, EA_VALUE );
		sprintf(buffer, "LISU %s", sym);
		break;
    case 0x68: /* 0110 1000 */
	case 0x69: /* 0110 1001 */
	case 0x6a: /* 0110 1010 */
	case 0x6b: /* 0110 1011 */
	case 0x6c: /* 0110 1100 */
	case 0x6d: /* 0110 1101 */
	case 0x6e: /* 0110 1110 */
	case 0x6f: /* 0110 1111 */
		sym = set_ea_info( 0, op & 7, EA_UINT8, EA_VALUE );
		sprintf(buffer, "LISL %s", sym);
        break;

    case 0x70: /* 0111 0000 */
	case 0x71: /* 0111 0001 */
	case 0x72: /* 0111 0010 */
	case 0x73: /* 0111 0011 */
	case 0x74: /* 0111 0100 */
	case 0x75: /* 0111 0101 */
	case 0x76: /* 0111 0110 */
	case 0x77: /* 0111 0111 */
	case 0x78: /* 0111 1000 */
	case 0x79: /* 0111 1001 */
	case 0x7a: /* 0111 1010 */
	case 0x7b: /* 0111 1011 */
	case 0x7c: /* 0111 1100 */
	case 0x7d: /* 0111 1101 */
	case 0x7e: /* 0111 1110 */
	case 0x7f: /* 0111 1111 */
		sym = set_ea_info( 0, op & 15, EA_UINT8, EA_VALUE );
		sprintf(buffer, "LIS  %s", sym);
		break;

    case 0x80: /* 1000 0000 */
	case 0x81: /* 1000 0001 */
	case 0x82: /* 1000 0010 */
	case 0x83: /* 1000 0011 */
	case 0x84: /* 1000 0100 */
	case 0x85: /* 1000 0101 */
	case 0x86: /* 1000 0110 */
	case 0x87: /* 1000 0111 */
		size += 1;
		sym = set_ea_info( 0, op & 7, EA_UINT8, EA_VALUE );
		ea = pc + (INT32)(INT16)(INT8)cpu_readop_arg(pc+1) - 3;
		sym2 = set_ea_info( 1, ea, EA_UINT16, EA_REL_PC );
		sprintf(buffer, "BT   %s,%s", sym, sym2);
        break;

    case 0x88: /* 1000 1000 */
		sprintf(buffer, "AM");
		break;

    case 0x89: /* 1000 1001 */
		sprintf(buffer, "AMD");
        break;

    case 0x8a: /* 1000 1010 */
		sprintf(buffer, "NM");
		break;

    case 0x8b: /* 1000 1011 */
		sprintf(buffer, "OM");
		break;

    case 0x8c: /* 1000 1100 */
		sprintf(buffer, "XM");
		break;

    case 0x8d: /* 1000 1101 */
		sprintf(buffer, "CM");
		break;

    case 0x8e: /* 1000 1110 */
		sprintf(buffer, "ADC");
        break;

    case 0x8f: /* 1000 1111 */
		size += 1;
		ea = pc + (INT8)cpu_readop_arg(pc+1) - 3;
		sym = set_ea_info( 0, ea, EA_UINT16, EA_REL_PC );
		sprintf(buffer, "BR7  %s", sym);
        break;

    case 0x90: /* 1001 0000 */
	case 0x91: /* 1001 0001 */
	case 0x92: /* 1001 0010 */
	case 0x93: /* 1001 0011 */
	case 0x94: /* 1001 0100 */
	case 0x95: /* 1001 0101 */
	case 0x96: /* 1001 0110 */
	case 0x97: /* 1001 0111 */
	case 0x98: /* 1001 1000 */
	case 0x99: /* 1001 1001 */
	case 0x9a: /* 1001 1010 */
	case 0x9b: /* 1001 1011 */
	case 0x9c: /* 1001 1100 */
	case 0x9d: /* 1001 1101 */
	case 0x9e: /* 1001 1110 */
	case 0x9f: /* 1001 1111 */
		size += 1;
		sym = set_ea_info( 0, op & 15, EA_UINT8, EA_VALUE );
		ea = pc + (INT8)cpu_readop_arg(pc+1) - 3;
        sym2 = set_ea_info( 1, ea, EA_UINT16, EA_REL_PC );
		sprintf(buffer, "BF   %s,%s", sym, sym2);
        break;

    case 0xa0: /* 1010 0000 */
	case 0xa1: /* 1010 0001 */
		sym = set_ea_info( 0, op & 15, EA_INT8, EA_PORT_RD );
		sprintf(buffer, "INS  %s", sym);
        break;

    case 0xa2: /* 1010 0010 */
	case 0xa3: /* 1010 0011 */
		sprintf(buffer, "???  $%02X\n", op);
        break;

    case 0xa4: /* 1010 0100 */
	case 0xa5: /* 1010 0101 */
	case 0xa6: /* 1010 0110 */
	case 0xa7: /* 1010 0111 */
	case 0xa8: /* 1010 1000 */
	case 0xa9: /* 1010 1001 */
	case 0xaa: /* 1010 1010 */
	case 0xab: /* 1010 1011 */
	case 0xac: /* 1010 1100 */
	case 0xad: /* 1010 1101 */
	case 0xae: /* 1010 1110 */
	case 0xaf: /* 1010 1111 */
		sym = set_ea_info( 0, op & 15, EA_INT8, EA_PORT_RD );
		sprintf(buffer, "INS  %s", sym);
        break;

    case 0xb0: /* 1011 0000 */
	case 0xb1: /* 1011 0001 */
		sym = set_ea_info( 0, op & 15, EA_INT8, EA_PORT_WR );
		sprintf(buffer, "OUTS %s", sym);
        break;

    case 0xb2: /* 1011 0010 */
	case 0xb3: /* 1011 0011 */
		sprintf(buffer, "???  $%02X\n", op);
        break;

    case 0xb4: /* 1011 0100 */
	case 0xb5: /* 1011 0101 */
	case 0xb6: /* 1011 0110 */
	case 0xb7: /* 1011 0111 */
	case 0xb8: /* 1011 1000 */
	case 0xb9: /* 1011 1001 */
	case 0xba: /* 1011 1010 */
	case 0xbb: /* 1011 1011 */
	case 0xbc: /* 1011 1100 */
	case 0xbd: /* 1011 1101 */
	case 0xbe: /* 1011 1110 */
	case 0xbf: /* 1011 1111 */
		sym = set_ea_info( 0, op & 15, EA_INT8, EA_PORT_WR );
		sprintf(buffer, "OUTS %s", sym);
        break;

    case 0xc0: /* 1100 0000 */
	case 0xc1: /* 1100 0001 */
	case 0xc2: /* 1100 0010 */
	case 0xc3: /* 1100 0011 */
	case 0xc4: /* 1100 0100 */
	case 0xc5: /* 1100 0101 */
	case 0xc6: /* 1100 0110 */
	case 0xc7: /* 1100 0111 */
	case 0xc8: /* 1100 1000 */
	case 0xc9: /* 1100 1001 */
	case 0xca: /* 1100 1010 */
	case 0xcb: /* 1100 1011 */
		sym = set_ea_info( 0, op & 15, EA_UINT8, EA_ZPG_RD );
        sprintf(buffer, "AS   %s", rname[op & 15]);
        break;
    case 0xcc: /* 1100 1100 */
		sym = set_ea_info( 0, activecpu_get_reg(F8_IS), EA_UINT8, EA_ZPG_RD );
		sprintf(buffer, "AS   (IS)");
        break;
    case 0xcd: /* 1100 1101 */
		sym = set_ea_info( 0, activecpu_get_reg(F8_IS), EA_UINT8, EA_ZPG_RD );
		sprintf(buffer, "AS   (IS++)");
        break;
    case 0xce: /* 1100 1110 */
		sym = set_ea_info( 0, activecpu_get_reg(F8_IS), EA_UINT8, EA_ZPG_RD );
		sprintf(buffer, "AS   (IS--)");
        break;
    case 0xcf: /* 1100 1111 */
		sprintf(buffer, "???  $%02X\n", op);
		break;

    case 0xd0: /* 1101 0000 */
	case 0xd1: /* 1101 0001 */
	case 0xd2: /* 1101 0010 */
	case 0xd3: /* 1101 0011 */
	case 0xd4: /* 1101 0100 */
	case 0xd5: /* 1101 0101 */
	case 0xd6: /* 1101 0110 */
	case 0xd7: /* 1101 0111 */
	case 0xd8: /* 1101 1000 */
	case 0xd9: /* 1101 1001 */
	case 0xda: /* 1101 1010 */
	case 0xdb: /* 1101 1011 */
		sym = set_ea_info( 0, op & 15, EA_UINT8, EA_ZPG_RD );
		sprintf(buffer, "ASD  %s", rname[op & 15]);
		break;
    case 0xdc: /* 1101 1100 */
		sym = set_ea_info( 0, activecpu_get_reg(F8_IS), EA_UINT8, EA_ZPG_RD );
		sprintf(buffer, "ASD  (IS)");
		break;
    case 0xdd: /* 1101 1101 */
		sym = set_ea_info( 0, activecpu_get_reg(F8_IS), EA_UINT8, EA_ZPG_RD );
		sprintf(buffer, "ASD  (IS++)");
        break;
    case 0xde: /* 1101 1110 */
		sym = set_ea_info( 0, activecpu_get_reg(F8_IS), EA_UINT8, EA_ZPG_RD );
		sprintf(buffer, "ASD  (IS--)");
        break;
    case 0xdf: /* 1101 1111 */
		sprintf(buffer, "???  $%02X\n", op);
        break;

    case 0xe0: /* 1110 0000 */
	case 0xe1: /* 1110 0001 */
	case 0xe2: /* 1110 0010 */
	case 0xe3: /* 1110 0011 */
	case 0xe4: /* 1110 0100 */
	case 0xe5: /* 1110 0101 */
	case 0xe6: /* 1110 0110 */
	case 0xe7: /* 1110 0111 */
	case 0xe8: /* 1110 1000 */
	case 0xe9: /* 1110 1001 */
	case 0xea: /* 1110 1010 */
	case 0xeb: /* 1110 1011 */
		sym = set_ea_info( 0, op & 15, EA_UINT8, EA_ZPG_RD );
		sprintf(buffer, "XS   %s", rname[op & 15]);
        break;
    case 0xec: /* 1110 1100 */
		sym = set_ea_info( 0, activecpu_get_reg(F8_IS), EA_UINT8, EA_ZPG_RD );
		sprintf(buffer, "XS   (IS)");
        break;
    case 0xed: /* 1110 1101 */
		sym = set_ea_info( 0, activecpu_get_reg(F8_IS), EA_UINT8, EA_ZPG_RD );
		sprintf(buffer, "XS   (IS++)");
        break;
    case 0xee: /* 1110 1110 */
		sym = set_ea_info( 0, activecpu_get_reg(F8_IS), EA_UINT8, EA_ZPG_RD );
		sprintf(buffer, "XS   (IS--)");
        break;
    case 0xef: /* 1110 1111 */
		sprintf(buffer, "???  $%02X\n", op);
        break;


    case 0xf0: /* 1111 0000 */
	case 0xf1: /* 1111 0001 */
	case 0xf2: /* 1111 0010 */
	case 0xf3: /* 1111 0011 */
	case 0xf4: /* 1111 0100 */
	case 0xf5: /* 1111 0101 */
	case 0xf6: /* 1111 0110 */
	case 0xf7: /* 1111 0111 */
	case 0xf8: /* 1111 1000 */
	case 0xf9: /* 1111 1001 */
	case 0xfa: /* 1111 1010 */
	case 0xfb: /* 1111 1011 */
		sym = set_ea_info( 0, op & 15, EA_UINT8, EA_ZPG_RD );
		sprintf(buffer, "NS   %s", rname[op & 15]);
		break;
    case 0xfc: /* 1111 1100 */
		sym = set_ea_info( 0, activecpu_get_reg(F8_IS), EA_UINT8, EA_ZPG_RD );
		sprintf(buffer, "NS   (IS)");
        break;
    case 0xfd: /* 1111 1101 */
		sym = set_ea_info( 0, activecpu_get_reg(F8_IS), EA_UINT8, EA_ZPG_RD );
		sprintf(buffer, "NS   (IS++)");
        break;
    case 0xfe: /* 1111 1110 */
		sym = set_ea_info( 0, activecpu_get_reg(F8_IS), EA_UINT8, EA_ZPG_RD );
		sprintf(buffer, "NS   (IS--)");
        break;
    case 0xff: /* 1111 1111 */
		sprintf(buffer, "???  $%02X\n", op);
        break;
    }

    return size;
}
Exemplo n.º 21
0
/*****************************************************************************
 * Disassemble a single opcode starting at pc
 *****************************************************************************/
unsigned Dasm6502(char *buffer, unsigned pc)
{
	char *dst = buffer;
	const char *symbol;
	INT8 offset;
	INT16 offset16;
	unsigned PC = pc;
	UINT16 addr, ea;
	UINT8 op, opc, arg, access, value;

	op = OPCODE(pc++);

	switch ( m6502_get_reg(M6502_SUBTYPE) )
	{
#if (HAS_M65C02)
		case SUBTYPE_65C02:
			opc = op65c02[op][0];
			arg = op65c02[op][1];
			access = op65c02[op][2];
			break;
#endif
#if (HAS_M65SC02)
		case SUBTYPE_65SC02:
			opc = op65sc02[op][0];
			arg = op65sc02[op][1];
			access = op65sc02[op][2];
			break;
#endif
#if (HAS_M6510)
		case SUBTYPE_6510:
			opc = op6510[op][0];
			arg = op6510[op][1];
			access = op6510[op][2];
			break;
#endif
#if (HAS_DECO16)
		case SUBTYPE_DECO16:
			opc = opdeco16[op][0];
			arg = opdeco16[op][1];
			access = opdeco16[op][2];
			break;
#endif
		default:
			opc = op6502[op][0];
			arg = op6502[op][1];
			access = op6502[op][2];
			break;
	}
	dst += sprintf(dst, "%-5s", token[opc]);
	if( opc == bbr || opc == bbs || opc == rmb || opc == smb )
		dst += sprintf(dst, "%d,", (op >> 3) & 7);

	switch(arg)
	{
	case imp:
		break;

	case acc:
		dst += sprintf(dst,"a");
		break;

	case rel:
		offset = (INT8)ARGBYTE(pc++);
		symbol = set_ea_info( 0, pc, offset, access );
		dst += sprintf(dst,"%s", symbol);
		break;

	case rw2:
		offset16 = ARGWORD(pc)-1;
		pc += 2;
		symbol = set_ea_info( 0, pc, offset16, access );
		dst += sprintf(dst,"%s", symbol);
		break;

	case imm:
		value = ARGBYTE(pc++);
		symbol = set_ea_info( 0, value, EA_UINT8, access );
		dst += sprintf(dst,"#%s", symbol);
		break;

	case zpg:
		addr = ARGBYTE(pc++);
		symbol = set_ea_info( 0, addr, EA_UINT8, access );
		dst += sprintf(dst,"$%02X", addr);
		break;

	case zpx:
		addr = ARGBYTE(pc++);
		ea = (addr + m6502_get_reg(M6502_X)) & 0xff;
		symbol = set_ea_info( 0, ea, EA_UINT8, access );
		dst += sprintf(dst,"$%02X,x", addr);
		break;

	case zpy:
		addr = ARGBYTE(pc++);
		ea = (addr + m6502_get_reg(M6502_Y)) & 0xff;
		symbol = set_ea_info( 0, ea, EA_UINT8, access );
		dst += sprintf(dst,"$%02X,y", addr);
		break;

	case idx:
		addr = ARGBYTE(pc++);
		ea = (addr + m6502_get_reg(M6502_X)) & 0xff;
		ea = RDMEM(ea) + (RDMEM((ea+1) & 0xff) << 8);
		symbol = set_ea_info( 0, ea, EA_UINT16, access );
		dst += sprintf(dst,"($%02X,x)", addr);
		break;

	case idy:
		addr = ARGBYTE(pc++);
		ea = (RDMEM(addr) + (RDMEM((addr+1) & 0xff) << 8) + m6502_get_reg(M6502_Y)) & 0xffff;
		symbol = set_ea_info( 0, ea, EA_UINT16, access );
		dst += sprintf(dst,"($%02X),y", addr);
		break;

	case zpi:
		addr = ARGBYTE(pc++);
		ea = RDMEM(addr) + (RDMEM((addr+1) & 0xff) << 8);
		symbol = set_ea_info( 0, ea, EA_UINT16, access );
		dst += sprintf(dst,"($%02X)", addr);
		break;

	case zpb:
		addr = ARGBYTE(pc++);
		symbol = set_ea_info( 0, addr, EA_UINT8, access );
		dst += sprintf(dst,"$%02X", addr);
		offset = (INT8)ARGBYTE(pc++);
		symbol = set_ea_info( 1, pc, offset, BRA );
		dst += sprintf(dst,",%s", symbol);
		break;

	case adr:
		addr = ARGWORD(pc);
		pc += 2;
		symbol = set_ea_info( 0, addr, EA_UINT16, access );
		dst += sprintf(dst,"%s", symbol);
		break;

	case aba:
		addr = ARGWORD(pc);
		pc += 2;
		symbol = set_ea_info( 0, addr, EA_UINT16, access );
		dst += sprintf(dst,"%s", symbol);
		break;

	case abx:
		addr = ARGWORD(pc);
		pc += 2;
		ea = (addr + m6502_get_reg(M6502_X)) & 0xffff;
		symbol = set_ea_info( 0, ea, EA_UINT16, access );
		dst += sprintf(dst,"$%04X,x", addr);
		break;

	case aby:
		addr = ARGWORD(pc);
		pc += 2;
		ea = (addr + m6502_get_reg(M6502_Y)) & 0xffff;
		symbol = set_ea_info( 0, ea, EA_UINT16, access );
		dst += sprintf(dst,"$%04X,y", addr);
		break;

	case ind:
		addr = ARGWORD(pc);
		pc += 2;
		ea = ARGWORD(addr);
		symbol = set_ea_info( 0, ea, EA_UINT16, access );
		dst += sprintf(dst,"($%04X)", addr);
		break;

	case iax:
		addr = ARGWORD(pc);
		pc += 2;
		ea = (ARGWORD(addr) + m6502_get_reg(M6502_X)) & 0xffff;
		symbol = set_ea_info( 0, ea, EA_UINT16, access );
		dst += sprintf(dst,"($%04X),X", addr);
		break;

	default:
		dst += sprintf(dst,"$%02X", op);
	}
	return pc - PC;
}