On Friday, January 24, 2020, Richard Henderson <richard.hender...@linaro.org>
wrote:

> On 1/24/20 6:38 AM, Aleksandar Markovic wrote:
> > The basic disassembly logic was obtained by somewhat modified script
> > decodetree.py, and such output was further manually modified to
> > handle numerous details of micromips 32R6 instruction coding scheme.
>
> What modifications to the script?
> What manual modifications to the output?
>
> It's been a while since I looked at micromips, but I don't recall anything
> so
> odd that it couldn't be handled with the current output of decodetree.py.
>

I don't have dev setup at hand right now, but I can look it up in few days.
Some of the changes are purely of cosmetic nature (like outputing binary
instead of hex codes), but some are not. I can send you the whole modified
script, once I come back to my desk. There are some not-so-obvious
micromips oddities, if one delves enough into the coding scheme.

> +static void getAlias(char *buffer, int regNo)
> > +{
> > +    switch (regNo) {
> > +    case 0:
> > +        strncpy(buffer, "zero", 5);
> > +        break;
> > +    case 1:
> > +        strncpy(buffer, "at", 5);
> > +        break;
> > +    case 2:
> > +    case 3:
> > +        sprintf(buffer, "v%d", regNo - 2);
> > +        break;
> > +    case 4:
> > +    case 5:
> > +    case 6:
> > +    case 7:
> > +        sprintf(buffer, "a%d", regNo - 4);
> > +        break;
> > +    case 8:
> > +    case 9:
> > +    case 10:
> > +    case 11:
> > +    case 12:
> > +    case 13:
> > +    case 14:
> > +    case 15:
> > +        sprintf(buffer, "t%d", regNo - 8);
> > +        break;
> > +    case 16:
> > +    case 17:
> > +    case 18:
> > +    case 19:
> > +    case 20:
> > +    case 21:
> > +    case 22:
> > +    case 23:
> > +        sprintf(buffer, "s%d", regNo - 16);
> > +        break;
> > +    case 24:
> > +    case 25:
> > +        sprintf(buffer, "t%d", regNo - 16);
> > +        break;
> > +    case 28:
> > +        strncpy(buffer, "gp", 5);
> > +        break;
> > +    case 29:
> > +        strncpy(buffer, "sp", 5);
> > +        break;
> > +    case 30:
> > +        strncpy(buffer, "s8", 5);
> > +        break;
> > +    case 31:
> > +        strncpy(buffer, "ra", 5);
> > +        break;
> > +    default:
> > +        sprintf(buffer, "r%d", regNo);
> > +        break;
> > +    }
> > +}
>
> Surely this would be better as a const array of string literals.  There are
> only 32 of them after all.
>
> Then you can just return the const char *, which is much better than
> sprintf'ing into a caller-provided buffer of unknown size.
>
>
Right. Thank you. This is anyway still code-in-development, made just to do
the job, but it can be implemented better, like in the way you suggested.

Thanks again,

Aleksandar



>
> r~
>
>

Reply via email to