Пример #1
0
unsigned Dasm32010(char *str, unsigned pc)
{
	int a, b, d, k, m, n, p, r, s, w;	/* these can all be filled in by parsing an instruction */
	int i;
	int op;
	int cnt = 1;
	int code;
	int bit;
	char *strtmp;
	char *cp;				/* character pointer in OpFormats */

	if (!OpInizialized) InitDasm32010();

	op = -1;				/* no matching opcode */
	code = READOP16(2*pc);
	for ( i = 0; i < MAX_OPS; i++)
	{
		if ((code & Op[i].mask) == Op[i].bits)
		{
			if (op != -1)
			{
				printf("Error: opcode %04Xh matches %d (%s) and %d (%s)\n",
					code,i,Op[i].fmt,op,Op[op].fmt);
			}
			op = i;
		}
	}
	if (op == -1)
	{
		sprintf(str,"???? dw %04Xh",code);
		return cnt;
	}
	strtmp = str;
	if (Op[op].extcode)
	{
		bit = 31;
		code <<= 16;
		code |= READARG16(2*(pc+cnt));
		cnt++;
	}
	else
	{
		bit = 15;
	}

	/* shift out operands */
	cp = Op[op].parse;
	a = b = d = k = m = n = p = r = s = w = 0;

	while (bit >= 0)
	{
		/* printf("{%c/%d}",*cp,bit); */
		switch(*cp)
		{
			case 'a': a <<=1; a |= ((code & (1<<bit)) ? 1 : 0); bit--; break;
			case 'b': b <<=1; b |= ((code & (1<<bit)) ? 1 : 0); bit--; break;
			case 'd': d <<=1; d |= ((code & (1<<bit)) ? 1 : 0); bit--; break;
			case 'k': k <<=1; k |= ((code & (1<<bit)) ? 1 : 0); bit--; break;
			case 'm': m <<=1; m |= ((code & (1<<bit)) ? 1 : 0); bit--; break;
			case 'n': n <<=1; n |= ((code & (1<<bit)) ? 1 : 0); bit--; break;
			case 'p': p <<=1; p |= ((code & (1<<bit)) ? 1 : 0); bit--; break;
			case 'r': r <<=1; r |= ((code & (1<<bit)) ? 1 : 0); bit--; break;
			case 's': s <<=1; s |= ((code & (1<<bit)) ? 1 : 0); bit--; break;
			case 'w': w <<=1; w |= ((code & (1<<bit)) ? 1 : 0); bit--; break;
			case ' ': break;
			case '1': case '0':  bit--; break;
			case '\0': printf("premature end of parse string, opcode %x, bit = %d\n",code,bit); exit(1);
		}
		cp++;
	}

	/* now traverse format string */
	cp = Op[op].fmt;
	while (*cp)
	{
		if (*cp == '%')
		{
			char num[15], *q;
			cp++;
			switch (*cp++)
			{
				case 'A': sprintf(num,"$%02X",a); break;
				case 'B': sprintf(num,"$%04X",b); break;
				case 'D': sprintf(num,"%02Xh",d); break;
				case 'K': sprintf(num,"%d",k); break;
				case 'N': sprintf(num,"%s",nextar[n]); break;
				case 'M': sprintf(num,"%s",arith[m]); break;
				case 'P': sprintf(num,"PA%d",p); break;
				case 'R': sprintf(num,"AR%d",r); break;
				case 'S': sprintf(num,",%d",s); break;
				case 'W': sprintf(num,"%04Xh",w); break;
				default:
					printf("illegal escape character in format '%s'\n",Op[op].fmt);
					exit(1);
			}
			q = num; while (*q) *str++ = *q++;
			*str = '\0';
		}
		else
		{
			*str++ = *cp++;
			*str = '\0';
		}
	}
	return cnt;
}
Пример #2
0
offs_t pic16C5x_dasm(char *str, offs_t pc, const UINT8 *oprom, const UINT8 *opram)
{
	int a, b, d, f, k;	/* these can all be filled in by parsing an instruction */
	int i;
	int op;
	int cnt = 1;
	int code;
	int bit;
	char *strtmp;
	const char *cp;				/* character pointer in OpFormats */
	UINT32 flags = 0;

	rombase = oprom;
	rambase = opram;
	pcbase = 2*pc;

	if (!OpInizialized) InitDasm16C5x();

	op = -1;				/* no matching opcode */
	code = READOP16(2*pc);
	for ( i = 0; i < MAX_OPS; i++)
	{
		if ((code & Op[i].mask) == Op[i].bits)
		{
			if (op != -1)
			{
				mame_printf_debug("Error: opcode %04Xh matches %d (%s) and %d (%s)\n",
					code,i,Op[i].fmt,op,Op[op].fmt);
			}
			op = i;
		}
	}
	if (op == -1)
	{
		sprintf(str,"???? dw %04Xh",code);
		return cnt;
	}
	strtmp = str;
	if (Op[op].extcode)		/* Actually, theres no double length opcodes */
	{
		bit = 27;
		code <<= 16;
		code |= READARG16(2*(pc+cnt));
		cnt++;
	}
	else
	{
		bit = 11;
	}

	/* shift out operands */
	cp = Op[op].parse;
	a = b = d = f = k = 0;

	while (bit >= 0)
	{
		/* mame_printf_debug("{%c/%d}",*cp,bit); */
		switch(*cp)
		{
			case 'a': a <<=1; a |= ((code & (1<<bit)) ? 1 : 0); bit--; break;
			case 'b': b <<=1; b |= ((code & (1<<bit)) ? 1 : 0); bit--; break;
			case 'd': d <<=1; d |= ((code & (1<<bit)) ? 1 : 0); bit--; break;
			case 'f': f <<=1; f |= ((code & (1<<bit)) ? 1 : 0); bit--; break;
			case 'k': k <<=1; k |= ((code & (1<<bit)) ? 1 : 0); bit--; break;
			case ' ': break;
			case '1': case '0':  bit--; break;
			case '\0': fatalerror("premature end of parse string, opcode %x, bit = %d",code,bit);
		}
		cp++;
	}

	/* now traverse format string */
	cp = Op[op].fmt;
	if (!strncmp(cp, "call", 4))
		flags = DASMFLAG_STEP_OVER;
	else if (!strncmp(cp, "ret", 3))
		flags = DASMFLAG_STEP_OUT;

	while (*cp)
	{
		if (*cp == '%')
		{
			char num[30], *q;
			cp++;
			switch (*cp++)
			{
				case 'A': sprintf(num,"$%03X",a); break;
				case 'B': sprintf(num,"%d",b); break;
				case 'D': sprintf(num,"%s",dest[d]); break;
				case 'F': sprintf(num,"%s",regfile[f]); break;
				case 'K': sprintf(num,"%02Xh",k); break;
				default:
					fatalerror("illegal escape character in format '%s'",Op[op].fmt);
			}
			q = num; while (*q) *str++ = *q++;
			*str = '\0';
		}
		else
		{
			*str++ = *cp++;
			*str = '\0';
		}
	}
	return cnt | flags | DASMFLAG_SUPPORTED;
}
Пример #3
0
unsigned Dasm16C5x(char *str, unsigned pc)
{
    int a, b, d, f, k;	/* these can all be filled in by parsing an instruction */
    int i;
    int op;
    int cnt = 1;
    int code;
    int bit;
    char *strtmp;
    const char *cp;				/* character pointer in OpFormats */

    if (!OpInizialized) InitDasm16C5x();

    op = -1;				/* no matching opcode */
    code = READOP16(2*pc);
    for ( i = 0; i < MAX_OPS; i++)
    {
        if ((code & Op[i].mask) == Op[i].bits)
        {
            if (op != -1)
            {
                printf("Error: opcode %04Xh matches %d (%s) and %d (%s)\n",
                       code,i,Op[i].fmt,op,Op[op].fmt);
            }
            op = i;
        }
    }
    if (op == -1)
    {
        sprintf(str,"???? dw %04Xh",code);
        return cnt;
    }
    strtmp = str;
    if (Op[op].extcode)		/* Actually, theres no double length opcodes */
    {
        bit = 27;
        code <<= 16;
        code |= READARG16(2*(pc+cnt));
        cnt++;
    }
    else
    {
        bit = 11;
    }

    /* shift out operands */
    cp = Op[op].parse;
    a = b = d = f = k = 0;

    while (bit >= 0)
    {
        /* printf("{%c/%d}",*cp,bit); */
        switch(*cp)
        {
        case 'a':
            a <<=1;
            a |= ((code & (1<<bit)) ? 1 : 0);
            bit--;
            break;
        case 'b':
            b <<=1;
            b |= ((code & (1<<bit)) ? 1 : 0);
            bit--;
            break;
        case 'd':
            d <<=1;
            d |= ((code & (1<<bit)) ? 1 : 0);
            bit--;
            break;
        case 'f':
            f <<=1;
            f |= ((code & (1<<bit)) ? 1 : 0);
            bit--;
            break;
        case 'k':
            k <<=1;
            k |= ((code & (1<<bit)) ? 1 : 0);
            bit--;
            break;
        case ' ':
            break;
        case '1':
        case '0':
            bit--;
            break;
        case '\0':
            printf("premature end of parse string, opcode %x, bit = %d\n",code,bit);
            exit(1);
        }
        cp++;
    }

    /* now traverse format string */
    cp = Op[op].fmt;
    while (*cp)
    {
        if (*cp == '%')
        {
            char num[30], *q;
            cp++;
            switch (*cp++)
            {
            case 'A':
                sprintf(num,"$%03X",a);
                break;
            case 'B':
                sprintf(num,"%d",b);
                break;
            case 'D':
                sprintf(num,"%s",dest[d]);
                break;
            case 'F':
                sprintf(num,"%s",regfile[f]);
                break;
            case 'K':
                sprintf(num,"%02Xh",k);
                break;
            default:
                printf("illegal escape character in format '%s'\n",Op[op].fmt);
                exit(1);
            }
            q = num;
            while (*q) *str++ = *q++;
            *str = '\0';
        }
        else
        {
            *str++ = *cp++;
            *str = '\0';
        }
    }
    return cnt;
}