[BACK]Return to db_disasm.c CVS log [TXT][DIR] Up to [local] / sys / arch / sh / sh

Annotation of sys/arch/sh/sh/db_disasm.c, Revision 1.1.1.1

1.1       nbrk        1: /*     $OpenBSD: db_disasm.c,v 1.3 2007/02/26 19:33:41 miod Exp $      */
                      2: /*     $NetBSD: db_disasm.c,v 1.13 2006/01/21 02:09:06 uwe Exp $       */
                      3:
                      4: /*
                      5:  * Copyright (c) 1998-2000 Internet Initiative Japan Inc.
                      6:  * All rights reserved.
                      7:  *
                      8:  * Author: Akinori Koketsu
                      9:  *
                     10:  * Redistribution and use in source and binary forms, with or without
                     11:  * modification, are permitted provided that the following conditions
                     12:  * are met:
                     13:  * 1. Redistributions of source code must retain the above copyright
                     14:  *    notice, this list of conditions and the following disclaimer.
                     15:  * 2. Redistribution with functional modification must include
                     16:  *    prominent notice stating how and when and by whom it is
                     17:  *    modified.
                     18:  * 3. Redistributions in binary form have to be along with the source
                     19:  *    code or documentation which include above copyright notice, this
                     20:  *    list of conditions and the following disclaimer.
                     21:  * 4. All commercial advertising materials mentioning features or use
                     22:  *    of this software must display the following acknowledgement:
                     23:  *      This product includes software developed by Internet
                     24:  *      Initiative Japan Inc.
                     25:  *
                     26:  * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY EXPRESS OR IMPLIED
                     27:  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
                     28:  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
                     29:  * DISCLAIMED.
                     30:  */
                     31:
                     32: #include <sys/param.h>
                     33: #include <sys/systm.h>
                     34:
                     35: #include <machine/db_machdep.h>
                     36:
                     37: #include <ddb/db_interface.h>
                     38: #include <ddb/db_output.h>
                     39: #include <ddb/db_sym.h>
                     40:
                     41: static void    disasm_branch(char *, size_t, const char *, db_addr_t);
                     42: static void    get_ascii(unsigned char *, char *);
                     43: static void    get_opcode(db_addr_t, char *, size_t);
                     44: static void    f_02(db_addr_t, u_int, char *, size_t);
                     45: static void    f_03(db_addr_t, u_int, char *, size_t);
                     46: static void    f_04(db_addr_t, u_int, char *, size_t);
                     47: static void    f_08(db_addr_t, u_int, char *, size_t);
                     48: static void    f_09(db_addr_t, u_int, char *, size_t);
                     49: static void    f_0a(db_addr_t, u_int, char *, size_t);
                     50: static void    f_0b(db_addr_t, u_int, char *, size_t);
                     51: static void    f_0c(db_addr_t, u_int, char *, size_t);
                     52: static void    f_10(db_addr_t, u_int, char *, size_t);
                     53: static void    f_20(db_addr_t, u_int, char *, size_t);
                     54: static void    f_24(db_addr_t, u_int, char *, size_t);
                     55: static void    f_28(db_addr_t, u_int, char *, size_t);
                     56: static void    f_2c(db_addr_t, u_int, char *, size_t);
                     57: static void    f_30(db_addr_t, u_int, char *, size_t);
                     58: static void    f_34(db_addr_t, u_int, char *, size_t);
                     59: static void    f_38(db_addr_t, u_int, char *, size_t);
                     60: static void    f_3c(db_addr_t, u_int, char *, size_t);
                     61: static void    f_40(db_addr_t, u_int, char *, size_t);
                     62: static void    f_41(db_addr_t, u_int, char *, size_t);
                     63: static void    f_42(db_addr_t, u_int, char *, size_t);
                     64: static void    f_43(db_addr_t, u_int, char *, size_t);
                     65: static void    f_44(db_addr_t, u_int, char *, size_t);
                     66: static void    f_45(db_addr_t, u_int, char *, size_t);
                     67: static void    f_46(db_addr_t, u_int, char *, size_t);
                     68: static void    f_47(db_addr_t, u_int, char *, size_t);
                     69: static void    f_48(db_addr_t, u_int, char *, size_t);
                     70: static void    f_49(db_addr_t, u_int, char *, size_t);
                     71: static void    f_4a(db_addr_t, u_int, char *, size_t);
                     72: static void    f_4b(db_addr_t, u_int, char *, size_t);
                     73: static void    f_4c(db_addr_t, u_int, char *, size_t);
                     74: static void    f_4d(db_addr_t, u_int, char *, size_t);
                     75: static void    f_4e(db_addr_t, u_int, char *, size_t);
                     76: static void    f_4f(db_addr_t, u_int, char *, size_t);
                     77: static void    f_50(db_addr_t, u_int, char *, size_t);
                     78: static void    f_60(db_addr_t, u_int, char *, size_t);
                     79: static void    f_64(db_addr_t, u_int, char *, size_t);
                     80: static void    f_68(db_addr_t, u_int, char *, size_t);
                     81: static void    f_6c(db_addr_t, u_int, char *, size_t);
                     82: static void    f_70(db_addr_t, u_int, char *, size_t);
                     83: static void    f_80(db_addr_t, u_int, char *, size_t);
                     84: static void    f_90(db_addr_t, u_int, char *, size_t);
                     85: static void    f_a0(db_addr_t, u_int, char *, size_t);
                     86: static void    f_b0(db_addr_t, u_int, char *, size_t);
                     87: static void    f_c0(db_addr_t, u_int, char *, size_t);
                     88: static void    f_d0(db_addr_t, u_int, char *, size_t);
                     89: static void    f_e0(db_addr_t, u_int, char *, size_t);
                     90: static void    f_f0(db_addr_t, u_int, char *, size_t);
                     91: static void    f_f4(db_addr_t, u_int, char *, size_t);
                     92: static void    f_f8(db_addr_t, u_int, char *, size_t);
                     93: static void    f_fc(db_addr_t, u_int, char *, size_t);
                     94: static void    f_fd(db_addr_t, u_int, char *, size_t);
                     95: static void    f_fe(db_addr_t, u_int, char *, size_t);
                     96:
                     97: typedef        void (*rasm_t)(db_addr_t, u_int, char *, size_t);
                     98: static const rasm_t f[16][16] = {
                     99:        { /* [0][0-7] */        NULL, NULL, f_02, f_03, f_04, f_04, f_04, f_04,
                    100:          /* [0][8-f] */        f_08, f_09, f_0a, f_0b, f_0c, f_0c, f_0c, f_0c },
                    101:        { /* [1][0-7] */        f_10, f_10, f_10, f_10, f_10, f_10, f_10, f_10,
                    102:          /* [1][8-f] */        f_10, f_10, f_10, f_10, f_10, f_10, f_10, f_10 },
                    103:        { /* [2][0-7] */        f_20, f_20, f_20, f_20, f_24, f_24, f_24, f_24,
                    104:          /* [2][8-f] */        f_28, f_28, f_28, f_28, f_2c, f_2c, f_2c, f_2c },
                    105:        { /* [3][0-7] */        f_30, f_30, f_30, f_30, f_34, f_34, f_34, f_34,
                    106:          /* [3][8-f] */        f_38, f_38, f_38, f_38, f_3c, f_3c, f_3c, f_3c },
                    107:        { /* [4][0-7] */        f_40, f_41, f_42, f_43, f_44, f_45, f_46, f_47,
                    108:          /* [4][8-f] */        f_48, f_49, f_4a, f_4b, f_4c, f_4d, f_4e, f_4f },
                    109:        { /* [5][0-7] */        f_50, f_50, f_50, f_50, f_50, f_50, f_50, f_50,
                    110:          /* [5][8-f] */        f_50, f_50, f_50, f_50, f_50, f_50, f_50, f_50 },
                    111:        { /* [6][0-7] */        f_60, f_60, f_60, f_60, f_64, f_64, f_64, f_64,
                    112:          /* [6][8-f] */        f_68, f_68, f_68, f_68, f_6c, f_6c, f_6c, f_6c },
                    113:        { /* [7][0-7] */        f_70, f_70, f_70, f_70, f_70, f_70, f_70, f_70,
                    114:          /* [7][8-f] */        f_70, f_70, f_70, f_70, f_70, f_70, f_70, f_70 },
                    115:        { /* [8][0-7] */        f_80, f_80, f_80, f_80, f_80, f_80, f_80, f_80,
                    116:          /* [8][8-f] */        f_80, f_80, f_80, f_80, f_80, f_80, f_80, f_80 },
                    117:        { /* [9][0-7] */        f_90, f_90, f_90, f_90, f_90, f_90, f_90, f_90,
                    118:          /* [9][8-f] */        f_90, f_90, f_90, f_90, f_90, f_90, f_90, f_90 },
                    119:        { /* [a][0-7] */        f_a0, f_a0, f_a0, f_a0, f_a0, f_a0, f_a0, f_a0,
                    120:          /* [a][8-f] */        f_a0, f_a0, f_a0, f_a0, f_a0, f_a0, f_a0, f_a0 },
                    121:        { /* [b][0-7] */        f_b0, f_b0, f_b0, f_b0, f_b0, f_b0, f_b0, f_b0,
                    122:          /* [b][8-f] */        f_b0, f_b0, f_b0, f_b0, f_b0, f_b0, f_b0, f_b0 },
                    123:        { /* [c][0-7] */        f_c0, f_c0, f_c0, f_c0, f_c0, f_c0, f_c0, f_c0,
                    124:          /* [c][8-f] */        f_c0, f_c0, f_c0, f_c0, f_c0, f_c0, f_c0, f_c0 },
                    125:        { /* [d][0-7] */        f_d0, f_d0, f_d0, f_d0, f_d0, f_d0, f_d0, f_d0,
                    126:          /* [d][8-f] */        f_d0, f_d0, f_d0, f_d0, f_d0, f_d0, f_d0, f_d0 },
                    127:        { /* [e][0-7] */        f_e0, f_e0, f_e0, f_e0, f_e0, f_e0, f_e0, f_e0,
                    128:          /* [e][8-f] */        f_e0, f_e0, f_e0, f_e0, f_e0, f_e0, f_e0, f_e0 },
                    129:        { /* [f][0-7] */        f_f0, f_f0, f_f0, f_f0, f_f4, f_f4, f_f4, f_f4,
                    130:          /* [f][8-f] */        f_f8, f_f8, f_f8, f_f8, f_fc, f_fd, f_fe, NULL }
                    131: };
                    132:
                    133: db_addr_t
                    134: db_disasm(db_addr_t loc, boolean_t altfmt)
                    135: {
                    136:        char line[40], ascii[4];
                    137:        void *pc = (void *)loc;
                    138:
                    139:        get_opcode(loc, line, sizeof line);
                    140:        if (altfmt) {
                    141:                get_ascii(pc, ascii);
                    142:                db_printf("%-32s ! %s\n", line, ascii);
                    143:        } else
                    144:                db_printf("%s\n", line);
                    145:
                    146:        return (loc + 2);
                    147: }
                    148:
                    149: static void
                    150: disasm_branch(char *buf, size_t bufsiz, const char *opstr, db_addr_t addr)
                    151: {
                    152:        size_t len;
                    153:        db_expr_t d, value;
                    154:        char *name;
                    155:        db_sym_t cursym;
                    156:        extern unsigned long db_lastsym;
                    157:        extern unsigned int db_maxoff;
                    158:
                    159:        snprintf(buf, bufsiz, "%-8s", opstr);
                    160:        len = strlen(buf);
                    161:        buf += len;
                    162:        bufsiz -= len;
                    163:
                    164:        if (addr <= db_lastsym) {
                    165:                cursym = db_search_symbol(addr, DB_STGY_PROC, &d);
                    166:                db_symbol_values(cursym, &name, &value);
                    167:                if (name && d < db_maxoff && value) {
                    168:                        if (d == 0)
                    169:                                snprintf(buf, bufsiz, "%s", name);
                    170:                        else {
                    171:                                snprintf(buf, bufsiz, "%s+", name);
                    172:                                len = strlen(buf);
                    173:                                buf += len;
                    174:                                bufsiz -= len;
                    175:                                db_format(buf, bufsiz, d, DB_FORMAT_R, 1, 0);
                    176:                        }
                    177:                        return;
                    178:                }
                    179:        }
                    180:
                    181:        db_format(buf, bufsiz, addr, DB_FORMAT_N, 1, 0);
                    182: }
                    183:
                    184: static void
                    185: get_ascii(unsigned char *cp, char *str)
                    186: {
                    187:        *str++ = (0x20 <= *cp && *cp < 0x7f) ? *cp : '.';
                    188:        cp++;
                    189:        *str++ = (0x20 <= *cp && *cp < 0x7f) ? *cp : '.';
                    190:        *str = '\0';
                    191: }
                    192:
                    193: static void
                    194: get_opcode(db_addr_t loc, char *buf, size_t bufsiz)
                    195: {
                    196:        int n0, n3;
                    197:        u_int insn = *(u_int16_t *)loc;
                    198:
                    199:        snprintf(buf, bufsiz, ".word 0x%x", insn);
                    200:
                    201:        n0 = (insn & 0xf000) >> 12;
                    202:        n3 = (insn & 0x000f);
                    203:
                    204:        if (f[n0][n3] != NULL)
                    205:                (*f[n0][n3])(loc, insn, buf, bufsiz);
                    206: }
                    207:
                    208: static void
                    209: f_02(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                    210: {
                    211:        int     rn, type, md;
                    212:
                    213:        rn   = (insn & 0x0f00) >> 8;
                    214:        type = (insn & 0x00c0) >> 6;
                    215:        md   = (insn & 0x0030) >> 4;
                    216:
                    217:        switch (type) {
                    218:        case 0:
                    219:                switch (md) {
                    220:                case 0:
                    221:                        snprintf(buf, bufsiz, "stc     sr, r%d", rn);
                    222:                        break;
                    223:                case 1:
                    224:                        snprintf(buf, bufsiz, "stc     gbr, r%d", rn);
                    225:                        break;
                    226:                case 2:
                    227:                        snprintf(buf, bufsiz, "stc     vbr, r%d", rn);
                    228:                        break;
                    229:                case 3:
                    230:                        snprintf(buf, bufsiz, "stc     ssr, r%d", rn);
                    231:                        break;
                    232:                }
                    233:                break;
                    234:        case 1:
                    235:                switch (md) {
                    236:                case 0:
                    237:                        snprintf(buf, bufsiz, "stc     spc, r%d", rn);
                    238:                        break;
                    239:                }
                    240:                break;
                    241:        case 2:
                    242:                snprintf(buf, bufsiz, "stc     r%d_bank, r%d", md, rn);
                    243:                break;
                    244:        case 3:
                    245:                snprintf(buf, bufsiz, "stc     r%d_bank, r%d", md + 4, rn);
                    246:                break;
                    247:        } /* end of switch (type) */
                    248: }
                    249:
                    250: static void
                    251: f_03(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                    252: {
                    253:        int     rn, type, md;
                    254:
                    255:        rn   = (insn & 0x0f00) >> 8;
                    256:        type = (insn & 0x00c0) >> 6;
                    257:        md   = (insn & 0x0030) >> 4;
                    258:
                    259:        switch (type) {
                    260:        case 0:
                    261:                switch (md) {
                    262:                case 0:
                    263:                        snprintf(buf, bufsiz, "bsrf    r%d", rn);
                    264:                        break;
                    265:                case 2:
                    266:                        snprintf(buf, bufsiz, "braf    r%d", rn);
                    267:                        break;
                    268:                }
                    269:                break;
                    270:        case 2:
                    271:                switch (md) {
                    272:                case 0:
                    273:                        snprintf(buf, bufsiz, "pref    @r%d", rn);
                    274:                        break;
                    275:                }
                    276:                break;
                    277:        } /* end of switch (type) */
                    278: }
                    279:
                    280: static void
                    281: f_04(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                    282: {
                    283:        int     rn, rm, md;
                    284:
                    285:        rn   = (insn & 0x0f00) >> 8;
                    286:        rm   = (insn & 0x00f0) >> 4;
                    287:        md   = (insn & 0x0003);
                    288:
                    289:        switch (md) {
                    290:        case 0:
                    291:                snprintf(buf, bufsiz, "mov.b   r%d, @(r0, r%d)", rm, rn);
                    292:                break;
                    293:        case 1:
                    294:                snprintf(buf, bufsiz, "mov.w   r%d, @(r0, r%d)", rm, rn);
                    295:                break;
                    296:        case 2:
                    297:                snprintf(buf, bufsiz, "mov.l   r%d, @(r0, r%d)", rm, rn);
                    298:                break;
                    299:        case 3:
                    300:                snprintf(buf, bufsiz, "mul.l   r%d, r%d", rm, rn);
                    301:                break;
                    302:        } /* end of switch (md) */
                    303: }
                    304:
                    305: static void
                    306: f_08(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                    307: {
                    308:        int     n1, type, md;
                    309:
                    310:        n1   = (insn & 0x0f00) >> 8;
                    311:        type = (insn & 0x00c0) >> 6;
                    312:        md   = (insn & 0x0030) >> 4;
                    313:
                    314:        if (n1 != 0)
                    315:                return;
                    316:
                    317:        switch (type) {
                    318:        case 0:
                    319:                switch (md) {
                    320:                case 0:
                    321:                        strlcpy(buf, "clrt", bufsiz);
                    322:                        break;
                    323:                case 1:
                    324:                        strlcpy(buf, "sett", bufsiz);
                    325:                        break;
                    326:                case 2:
                    327:                        strlcpy(buf, "clrmac", bufsiz);
                    328:                        break;
                    329:                case 3:
                    330:                        strlcpy(buf, "ldtlb", bufsiz);
                    331:                        break;
                    332:                }
                    333:                break;
                    334:        case 1:
                    335:                switch (md) {
                    336:                case 0:
                    337:                        strlcpy(buf, "clrs", bufsiz);
                    338:                        break;
                    339:                case 1:
                    340:                        strlcpy(buf, "sets", bufsiz);
                    341:                        break;
                    342:                }
                    343:                break;
                    344:        } /* end of switch (type) */
                    345: }
                    346:
                    347: static void
                    348: f_09(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                    349: {
                    350:        int     rn, fx;
                    351:
                    352:        rn = (insn & 0x0f00) >> 8;
                    353:        fx = (insn & 0x00f0) >> 4;
                    354:
                    355:        switch (fx) {
                    356:        case 0:
                    357:                if (rn != 0)
                    358:                        return;
                    359:                strlcpy(buf, "nop", bufsiz);
                    360:                break;
                    361:        case 1:
                    362:                if (rn != 0)
                    363:                        return;
                    364:                strlcpy(buf, "div0u", bufsiz);
                    365:                break;
                    366:        case 2:
                    367:                snprintf(buf, bufsiz, "movt    r%d", rn);
                    368:                break;
                    369:        } /* end of switch (fx) */
                    370: }
                    371:
                    372: static void
                    373: f_0a(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                    374: {
                    375:        int     rn, type, md;
                    376:
                    377:        rn   = (insn & 0x0f00) >> 8;
                    378:        type = (insn & 0x00c0) >> 6;
                    379:        md   = (insn & 0x0030) >> 4;
                    380:
                    381:        switch (type) {
                    382:        case 0:
                    383:                switch (md) {
                    384:                case 0:
                    385:                        snprintf(buf, bufsiz, "sts     mach, r%d", rn);
                    386:                        break;
                    387:                case 1:
                    388:                        snprintf(buf, bufsiz, "sts     macl, r%d", rn);
                    389:                        break;
                    390:                case 2:
                    391:                        snprintf(buf, bufsiz, "sts     pr, r%d", rn);
                    392:                        break;
                    393:                }
                    394:                break;
                    395:        case 1:
                    396:                switch (md) {
                    397:                case 1:
                    398:                        snprintf(buf, bufsiz, "sts     fpul, r%d", rn);
                    399:                        break;
                    400:                case 2:
                    401:                        snprintf(buf, bufsiz, "sts     fpscr, r%d", rn);
                    402:                        break;
                    403:                }
                    404:                break;
                    405:        } /* end of switch (type) */
                    406: }
                    407:
                    408: static void
                    409: f_0b(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                    410: {
                    411:        int     n1, fx;
                    412:
                    413:        n1 = (insn & 0x0f00) >> 8;
                    414:        if (n1 != 0)
                    415:                return;
                    416:
                    417:        fx = (insn & 0x00f0) >> 4;
                    418:        switch (fx) {
                    419:        case 0:
                    420:                strlcpy(buf, "rts", bufsiz);
                    421:                break;
                    422:        case 1:
                    423:                strlcpy(buf, "sleep", bufsiz);
                    424:                break;
                    425:        case 2:
                    426:                strlcpy(buf, "rte", bufsiz);
                    427:                break;
                    428:        } /* end of switch (fx) */
                    429: }
                    430:
                    431: static void
                    432: f_0c(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                    433: {
                    434:        int     rn, rm, md;
                    435:
                    436:        rn   = (insn & 0x0f00) >> 8;
                    437:        rm   = (insn & 0x00f0) >> 4;
                    438:        md   = (insn & 0x0003);
                    439:
                    440:        switch (md) {
                    441:        case 0:
                    442:                snprintf(buf, bufsiz, "mov.b   @(r0, r%d), r%d", rm, rn);
                    443:                break;
                    444:        case 1:
                    445:                snprintf(buf, bufsiz, "mov.w   @(r0, r%d), r%d", rm, rn);
                    446:                break;
                    447:        case 2:
                    448:                snprintf(buf, bufsiz, "mov.l   @(r0, r%d), r%d", rm, rn);
                    449:                break;
                    450:        case 3:
                    451:                snprintf(buf, bufsiz, "mac.l   @r%d+, r%d+", rm, rn);
                    452:                break;
                    453:        } /* end of switch (md) */
                    454: }
                    455:
                    456: static void
                    457: f_10(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                    458: {
                    459:        int     rn, rm, disp;
                    460:
                    461:        rn   = (insn & 0x0f00) >> 8;
                    462:        rm   = (insn & 0x00f0) >> 4;
                    463:        disp = (insn & 0x000f);
                    464:        disp *= 4;
                    465:
                    466:        snprintf(buf, bufsiz, "mov.l   r%d, @(%d, r%d)", rm, disp, rn);
                    467: }
                    468:
                    469: static void
                    470: f_20(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                    471: {
                    472:        int     rn, rm, md;
                    473:
                    474:        rn   = (insn & 0x0f00) >> 8;
                    475:        rm   = (insn & 0x00f0) >> 4;
                    476:        md   = (insn & 0x0003);
                    477:
                    478:        switch (md) {
                    479:        case 0:
                    480:                snprintf(buf, bufsiz, "mov.b   r%d, @r%d", rm, rn);
                    481:                break;
                    482:        case 1:
                    483:                snprintf(buf, bufsiz, "mov.w   r%d, @r%d", rm, rn);
                    484:                break;
                    485:        case 2:
                    486:                snprintf(buf, bufsiz, "mov.l   r%d, @r%d", rm, rn);
                    487:                break;
                    488:        } /* end of switch (md) */
                    489: }
                    490:
                    491: static void
                    492: f_24(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                    493: {
                    494:        int     rn, rm, md;
                    495:
                    496:        rn   = (insn & 0x0f00) >> 8;
                    497:        rm   = (insn & 0x00f0) >> 4;
                    498:        md   = (insn & 0x0003);
                    499:
                    500:        switch (md) {
                    501:        case 0:
                    502:                snprintf(buf, bufsiz, "mov.b   r%d, @-r%d", rm, rn);
                    503:                break;
                    504:        case 1:
                    505:                snprintf(buf, bufsiz, "mov.w   r%d, @-r%d", rm, rn);
                    506:                break;
                    507:        case 2:
                    508:                snprintf(buf, bufsiz, "mov.l   r%d, @-r%d", rm, rn);
                    509:                break;
                    510:        case 3:
                    511:                snprintf(buf, bufsiz, "div0s   r%d, r%d", rm, rn);
                    512:                break;
                    513:        } /* end of switch (md) */
                    514: }
                    515:
                    516: static void
                    517: f_28(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                    518: {
                    519:        int     rn, rm, md;
                    520:
                    521:        rn   = (insn & 0x0f00) >> 8;
                    522:        rm   = (insn & 0x00f0) >> 4;
                    523:        md   = (insn & 0x0003);
                    524:
                    525:        switch (md) {
                    526:        case 0:
                    527:                snprintf(buf, bufsiz, "tst     r%d, r%d", rm, rn);
                    528:                break;
                    529:        case 1:
                    530:                snprintf(buf, bufsiz, "and     r%d, r%d", rm, rn);
                    531:                break;
                    532:        case 2:
                    533:                snprintf(buf, bufsiz, "xor     r%d, r%d", rm, rn);
                    534:                break;
                    535:        case 3:
                    536:                snprintf(buf, bufsiz, "or      r%d, r%d", rm, rn);
                    537:                break;
                    538:        } /* end of switch (md) */
                    539: }
                    540:
                    541: static void
                    542: f_2c(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                    543: {
                    544:        int     rn, rm, md;
                    545:
                    546:        rn   = (insn & 0x0f00) >> 8;
                    547:        rm   = (insn & 0x00f0) >> 4;
                    548:        md   = (insn & 0x0003);
                    549:
                    550:        switch (md) {
                    551:        case 0:
                    552:                snprintf(buf, bufsiz, "cmp/str r%d, r%d", rm, rn);
                    553:                break;
                    554:        case 1:
                    555:                snprintf(buf, bufsiz, "xtrct   r%d, r%d", rm, rn);
                    556:                break;
                    557:        case 2:
                    558:                snprintf(buf, bufsiz, "mulu.w  r%d, r%d", rm, rn);
                    559:                break;
                    560:        case 3:
                    561:                snprintf(buf, bufsiz, "muls.w  r%d, r%d", rm, rn);
                    562:                break;
                    563:        } /* end of switch (md) */
                    564: }
                    565:
                    566: static void
                    567: f_30(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                    568: {
                    569:        int     rn, rm, md;
                    570:
                    571:        rn   = (insn & 0x0f00) >> 8;
                    572:        rm   = (insn & 0x00f0) >> 4;
                    573:        md   = (insn & 0x0003);
                    574:
                    575:        switch (md) {
                    576:        case 0:
                    577:                snprintf(buf, bufsiz, "cmp/eq  r%d, r%d", rm, rn);
                    578:                break;
                    579:        case 2:
                    580:                snprintf(buf, bufsiz, "cmp/hs  r%d, r%d", rm, rn);
                    581:                break;
                    582:        case 3:
                    583:                snprintf(buf, bufsiz, "cmp/ge  r%d, r%d", rm, rn);
                    584:                break;
                    585:        } /* end of switch (md) */
                    586: }
                    587:
                    588: static void
                    589: f_34(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                    590: {
                    591:        int     rn, rm, md;
                    592:
                    593:        rn   = (insn & 0x0f00) >> 8;
                    594:        rm   = (insn & 0x00f0) >> 4;
                    595:        md   = (insn & 0x0003);
                    596:
                    597:        switch (md) {
                    598:        case 0:
                    599:                snprintf(buf, bufsiz, "div1    r%d, r%d", rm, rn);
                    600:                break;
                    601:        case 1:
                    602:                snprintf(buf, bufsiz, "dmulu.l r%d, r%d", rm, rn);
                    603:                break;
                    604:        case 2:
                    605:                snprintf(buf, bufsiz, "cmp/hi  r%d, r%d", rm, rn);
                    606:                break;
                    607:        case 3:
                    608:                snprintf(buf, bufsiz, "cmp/gt  r%d, r%d", rm, rn);
                    609:                break;
                    610:        } /* end of switch (md) */
                    611: }
                    612:
                    613: static void
                    614: f_38(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                    615: {
                    616:        int     rn, rm, md;
                    617:
                    618:        rn   = (insn & 0x0f00) >> 8;
                    619:        rm   = (insn & 0x00f0) >> 4;
                    620:        md   = (insn & 0x0003);
                    621:
                    622:        switch (md) {
                    623:        case 0:
                    624:                snprintf(buf, bufsiz, "sub     r%d, r%d", rm, rn);
                    625:                break;
                    626:        case 2:
                    627:                snprintf(buf, bufsiz, "subc    r%d, r%d", rm, rn);
                    628:                break;
                    629:        case 3:
                    630:                snprintf(buf, bufsiz, "subv    r%d, r%d", rm, rn);
                    631:                break;
                    632:        } /* end of switch (md) */
                    633: }
                    634:
                    635: static void
                    636: f_3c(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                    637: {
                    638:        int     rn, rm, md;
                    639:
                    640:        rn   = (insn & 0x0f00) >> 8;
                    641:        rm   = (insn & 0x00f0) >> 4;
                    642:        md   = (insn & 0x0003);
                    643:
                    644:        switch (md) {
                    645:        case 0:
                    646:                snprintf(buf, bufsiz, "add     r%d, r%d", rm, rn);
                    647:                break;
                    648:        case 1:
                    649:                snprintf(buf, bufsiz, "dmulu.l r%d, r%d", rm, rn);
                    650:                break;
                    651:        case 2:
                    652:                snprintf(buf, bufsiz, "addc    r%d, r%d", rm, rn);
                    653:                break;
                    654:        case 3:
                    655:                snprintf(buf, bufsiz, "addv    r%d, r%d", rm, rn);
                    656:                break;
                    657:        } /* end of switch (md) */
                    658: }
                    659:
                    660: static void
                    661: f_40(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                    662: {
                    663:        int     rn, fx;
                    664:
                    665:        rn   = (insn & 0x0f00) >> 8;
                    666:        fx   = (insn & 0x00f0) >> 4;
                    667:
                    668:        switch (fx) {
                    669:        case 0:
                    670:                snprintf(buf, bufsiz, "shll    r%d", rn);
                    671:                break;
                    672:        case 1:
                    673:                snprintf(buf, bufsiz, "dt      r%d", rn);
                    674:                break;
                    675:        case 2:
                    676:                snprintf(buf, bufsiz, "shal    r%d", rn);
                    677:                break;
                    678:        } /* end of switch (fx) */
                    679: }
                    680:
                    681: static void
                    682: f_41(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                    683: {
                    684:        int     rn, fx;
                    685:
                    686:        rn   = (insn & 0x0f00) >> 8;
                    687:        fx   = (insn & 0x00f0) >> 4;
                    688:
                    689:        switch (fx) {
                    690:        case 0:
                    691:                snprintf(buf, bufsiz, "shlr    r%d", rn);
                    692:                break;
                    693:        case 1:
                    694:                snprintf(buf, bufsiz, "cmp/pz  r%d", rn);
                    695:                break;
                    696:        case 2:
                    697:                snprintf(buf, bufsiz, "shar    r%d", rn);
                    698:                break;
                    699:        } /* end of switch (fx) */
                    700: }
                    701:
                    702: static void
                    703: f_42(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                    704: {
                    705:        int     rn, type, md;
                    706:
                    707:        rn   = (insn & 0x0f00) >> 8;
                    708:        type = (insn & 0x00c0) >> 6;
                    709:        md   = (insn & 0x0030) >> 4;
                    710:
                    711:        switch (type) {
                    712:        case 0:
                    713:                switch (md) {
                    714:                case 0:
                    715:                        snprintf(buf, bufsiz, "sts.l   mach, @-r%d", rn);
                    716:                        break;
                    717:                case 1:
                    718:                        snprintf(buf, bufsiz, "sts.l   macl, @-r%d", rn);
                    719:                        break;
                    720:                case 2:
                    721:                        snprintf(buf, bufsiz, "sts.l   pr, @-r%d", rn);
                    722:                        break;
                    723:                }
                    724:                break;
                    725:        case 1:
                    726:                switch (md) {
                    727:                case 1:
                    728:                        snprintf(buf, bufsiz, "sts.l   fpul, @-r%d", rn);
                    729:                        break;
                    730:                case 2:
                    731:                        snprintf(buf, bufsiz, "sts.l   fpscr, @-r%d", rn);
                    732:                        break;
                    733:                }
                    734:                break;
                    735:        } /* end of switch (type) */
                    736: }
                    737:
                    738: static void
                    739: f_43(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                    740: {
                    741:        int     rn, type, md;
                    742:
                    743:        rn   = (insn & 0x0f00) >> 8;
                    744:        type = (insn & 0x00c0) >> 6;
                    745:        md   = (insn & 0x0030) >> 4;
                    746:
                    747:        switch (type) {
                    748:        case 0:
                    749:                switch (md) {
                    750:                case 0:
                    751:                        snprintf(buf, bufsiz, "stc.l   sr, @-r%d", rn);
                    752:                        break;
                    753:                case 1:
                    754:                        snprintf(buf, bufsiz, "stc.l   gbr, @-r%d", rn);
                    755:                        break;
                    756:                case 2:
                    757:                        snprintf(buf, bufsiz, "stc.l   vbr, @-r%d", rn);
                    758:                        break;
                    759:                case 3:
                    760:                        snprintf(buf, bufsiz, "stc.l   ssr, @-r%d", rn);
                    761:                        break;
                    762:                }
                    763:                break;
                    764:        case 1:
                    765:                switch (md) {
                    766:                case 0:
                    767:                        snprintf(buf, bufsiz, "stc.l   spc, @-r%d", rn);
                    768:                        break;
                    769:                }
                    770:                break;
                    771:        case 2:
                    772:                snprintf(buf, bufsiz, "stc.l   r%d_bank, @-r%d", md, rn);
                    773:                break;
                    774:        case 3:
                    775:                snprintf(buf, bufsiz, "stc.l   r%d_bank, @-r%d", md + 4, rn);
                    776:                break;
                    777:        } /* end of switch (type) */
                    778: }
                    779:
                    780: static void
                    781: f_44(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                    782: {
                    783:        int     rn, fx;
                    784:
                    785:        rn   = (insn & 0x0f00) >> 8;
                    786:        fx   = (insn & 0x00f0) >> 4;
                    787:
                    788:        switch (fx) {
                    789:        case 0:
                    790:                snprintf(buf, bufsiz, "rotl    r%d", rn);
                    791:                break;
                    792:        case 2:
                    793:                snprintf(buf, bufsiz, "rotcl   r%d", rn);
                    794:                break;
                    795:        } /* end of switch (fx) */
                    796: }
                    797:
                    798: static void
                    799: f_45(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                    800: {
                    801:        int     rn, fx;
                    802:
                    803:        rn   = (insn & 0x0f00) >> 8;
                    804:        fx   = (insn & 0x00f0) >> 4;
                    805:
                    806:        switch (fx) {
                    807:        case 0:
                    808:                snprintf(buf, bufsiz, "rotr    r%d", rn);
                    809:                break;
                    810:        case 1:
                    811:                snprintf(buf, bufsiz, "cmp/pl  r%d", rn);
                    812:                break;
                    813:        case 2:
                    814:                snprintf(buf, bufsiz, "rotcr   r%d", rn);
                    815:                break;
                    816:        } /* end of switch (fx) */
                    817: }
                    818:
                    819: static void
                    820: f_46(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                    821: {
                    822:        int     rm, type, md;
                    823:
                    824:        rm   = (insn & 0x0f00) >> 8;
                    825:        type = (insn & 0x00c0) >> 6;
                    826:        md   = (insn & 0x0030) >> 4;
                    827:
                    828:        switch (type) {
                    829:        case 0:
                    830:                switch (md) {
                    831:                case 0:
                    832:                        snprintf(buf, bufsiz, "lds.l   @r%d+, mach", rm);
                    833:                        break;
                    834:                case 1:
                    835:                        snprintf(buf, bufsiz, "lds.l   @r%d+, macl", rm);
                    836:                        break;
                    837:                case 2:
                    838:                        snprintf(buf, bufsiz, "lds.l   @r%d+, pr", rm);
                    839:                        break;
                    840:                }
                    841:                break;
                    842:        case 1:
                    843:                switch (md) {
                    844:                case 1:
                    845:                        snprintf(buf, bufsiz, "lds.l   @r%d+, fpul", rm);
                    846:                        break;
                    847:                case 2:
                    848:                        snprintf(buf, bufsiz, "lds.l   @r%d+, fpscr", rm);
                    849:                        break;
                    850:                }
                    851:                break;
                    852:        } /* end of switch (type) */
                    853: }
                    854:
                    855: static void
                    856: f_47(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                    857: {
                    858:        int     rm, type, md;
                    859:
                    860:        rm   = (insn & 0x0f00) >> 8;
                    861:        type = (insn & 0x00c0) >> 6;
                    862:        md   = (insn & 0x0030) >> 4;
                    863:
                    864:        switch (type) {
                    865:        case 0:
                    866:                switch (md) {
                    867:                case 0:
                    868:                        snprintf(buf, bufsiz, "ldc.l   @r%d+, sr", rm);
                    869:                        break;
                    870:                case 1:
                    871:                        snprintf(buf, bufsiz, "ldc.l   @r%d+, gbr", rm);
                    872:                        break;
                    873:                case 2:
                    874:                        snprintf(buf, bufsiz, "ldc.l   @r%d+, vbr", rm);
                    875:                        break;
                    876:                case 3:
                    877:                        snprintf(buf, bufsiz, "ldc.l   @r%d+, ssr", rm);
                    878:                        break;
                    879:                }
                    880:                break;
                    881:        case 1:
                    882:                switch (md) {
                    883:                case 0:
                    884:                        snprintf(buf, bufsiz, "ldc.l   @r%d+, spc", rm);
                    885:                        break;
                    886:                }
                    887:                break;
                    888:        case 2:
                    889:                snprintf(buf, bufsiz, "ldc.l   @r%d+, r%d_bank", rm, md);
                    890:                break;
                    891:        case 3:
                    892:                snprintf(buf, bufsiz, "ldc.l   @r%d+, r%d_bank", rm, md + 4);
                    893:                break;
                    894:        } /* end of switch (type) */
                    895: }
                    896:
                    897: static void
                    898: f_48(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                    899: {
                    900:        int     rn, fx;
                    901:
                    902:        rn   = (insn & 0x0f00) >> 8;
                    903:        fx   = (insn & 0x00f0) >> 4;
                    904:
                    905:        switch (fx) {
                    906:        case 0:
                    907:                snprintf(buf, bufsiz, "shll2   r%d", rn);
                    908:                break;
                    909:        case 1:
                    910:                snprintf(buf, bufsiz, "shll8   r%d", rn);
                    911:                break;
                    912:        case 2:
                    913:                snprintf(buf, bufsiz, "shll16  r%d", rn);
                    914:                break;
                    915:        } /* end of switch (fx) */
                    916: }
                    917:
                    918: static void
                    919: f_49(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                    920: {
                    921:        int     rn, fx;
                    922:
                    923:        rn   = (insn & 0x0f00) >> 8;
                    924:        fx   = (insn & 0x00f0) >> 4;
                    925:
                    926:        switch (fx) {
                    927:        case 0:
                    928:                snprintf(buf, bufsiz, "shlr2   r%d", rn);
                    929:                break;
                    930:        case 1:
                    931:                snprintf(buf, bufsiz, "shlr8   r%d", rn);
                    932:                break;
                    933:        case 2:
                    934:                snprintf(buf, bufsiz, "shlr16  r%d", rn);
                    935:                break;
                    936:        } /* end of switch (fx) */
                    937: }
                    938:
                    939: static void
                    940: f_4a(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                    941: {
                    942:        int     rm, type, md;
                    943:
                    944:        rm   = (insn & 0x0f00) >> 8;
                    945:        type = (insn & 0x00c0) >> 6;
                    946:        md   = (insn & 0x0030) >> 4;
                    947:
                    948:        switch (type) {
                    949:        case 0:
                    950:                switch (md) {
                    951:                case 0:
                    952:                        snprintf(buf, bufsiz, "lds     r%d, mach", rm);
                    953:                        break;
                    954:                case 1:
                    955:                        snprintf(buf, bufsiz, "lds     r%d, macl", rm);
                    956:                        break;
                    957:                case 2:
                    958:                        snprintf(buf, bufsiz, "lds     r%d, pr", rm);
                    959:                        break;
                    960:                }
                    961:                break;
                    962:        case 1:
                    963:                switch (md) {
                    964:                case 1:
                    965:                        snprintf(buf, bufsiz, "lds     r%d, fpul", rm);
                    966:                        break;
                    967:                case 2:
                    968:                        snprintf(buf, bufsiz, "lds     r%d, fpscr", rm);
                    969:                        break;
                    970:                }
                    971:                break;
                    972:        } /* end of switch (type) */
                    973: }
                    974:
                    975: static void
                    976: f_4b(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                    977: {
                    978:        int     rm, fx;
                    979:
                    980:        rm   = (insn & 0x0f00) >> 8;
                    981:        fx   = (insn & 0x00f0) >> 4;
                    982:
                    983:        switch (fx) {
                    984:        case 0:
                    985:                snprintf(buf, bufsiz, "jsr     @r%d", rm);
                    986:                break;
                    987:        case 1:
                    988:                snprintf(buf, bufsiz, "tas.b   @r%d", rm);
                    989:                break;
                    990:        case 2:
                    991:                snprintf(buf, bufsiz, "jmp     @r%d", rm);
                    992:                break;
                    993:        } /* end of switch (fx) */
                    994: }
                    995:
                    996: static void
                    997: f_4c(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                    998: {
                    999:        int     rn, rm;
                   1000:
                   1001:        rn   = (insn & 0x0f00) >> 8;
                   1002:        rm   = (insn & 0x00f0) >> 4;
                   1003:        snprintf(buf, bufsiz, "shad    r%d, r%d", rm, rn);
                   1004: }
                   1005:
                   1006: static void
                   1007: f_4d(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                   1008: {
                   1009:        int     rn, rm;
                   1010:
                   1011:        rn   = (insn & 0x0f00) >> 8;
                   1012:        rm   = (insn & 0x00f0) >> 4;
                   1013:        snprintf(buf, bufsiz, "shld    r%d, r%d", rm, rn);
                   1014: }
                   1015:
                   1016: static void
                   1017: f_4e(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                   1018: {
                   1019:        int     rm, type, md;
                   1020:
                   1021:        rm   = (insn & 0x0f00) >> 8;
                   1022:        type = (insn & 0x00c0) >> 6;
                   1023:        md   = (insn & 0x0030) >> 4;
                   1024:
                   1025:        switch (type) {
                   1026:        case 0:
                   1027:                switch (md) {
                   1028:                case 0:
                   1029:                        snprintf(buf, bufsiz, "ldc     r%d, sr", rm);
                   1030:                        break;
                   1031:                case 1:
                   1032:                        snprintf(buf, bufsiz, "ldc     r%d, gbr", rm);
                   1033:                        break;
                   1034:                case 2:
                   1035:                        snprintf(buf, bufsiz, "ldc     r%d, vbr", rm);
                   1036:                        break;
                   1037:                case 3:
                   1038:                        snprintf(buf, bufsiz, "ldc     r%d, ssr", rm);
                   1039:                        break;
                   1040:                }
                   1041:                break;
                   1042:        case 1:
                   1043:                switch (md) {
                   1044:                case 0:
                   1045:                        snprintf(buf, bufsiz, "ldc     r%d, spc", rm);
                   1046:                        break;
                   1047:                }
                   1048:                break;
                   1049:        case 2:
                   1050:                snprintf(buf, bufsiz, "ldc     r%d, r%d_bank", rm, md);
                   1051:                break;
                   1052:        case 3:
                   1053:                snprintf(buf, bufsiz, "ldc     r%d, r%d_bank", rm, md + 4);
                   1054:                break;
                   1055:        } /* end of switch (type) */
                   1056: }
                   1057:
                   1058: static void
                   1059: f_4f(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                   1060: {
                   1061:        int     rn, rm;
                   1062:
                   1063:        rn   = (insn & 0x0f00) >> 8;
                   1064:        rm   = (insn & 0x00f0) >> 4;
                   1065:        snprintf(buf, bufsiz, "mac.w   @r%d+, @r%d+", rm, rn);
                   1066: }
                   1067:
                   1068: static void
                   1069: f_50(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                   1070: {
                   1071:        int     rn, rm, disp;
                   1072:
                   1073:        rn   = (insn & 0x0f00) >> 8;
                   1074:        rm   = (insn & 0x00f0) >> 4;
                   1075:        disp = (insn & 0x000f);
                   1076:        disp *= 4;
                   1077:
                   1078:        snprintf(buf, bufsiz, "mov.l   @(%d, r%d), r%d", disp, rm, rn);
                   1079: }
                   1080:
                   1081: static void
                   1082: f_60(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                   1083: {
                   1084:        int     rn, rm, md;
                   1085:
                   1086:        rn   = (insn & 0x0f00) >> 8;
                   1087:        rm   = (insn & 0x00f0) >> 4;
                   1088:        md   = (insn & 0x0003);
                   1089:
                   1090:        switch (md) {
                   1091:        case 0:
                   1092:                snprintf(buf, bufsiz, "mov.b   @r%d, r%d", rm, rn);
                   1093:                break;
                   1094:        case 1:
                   1095:                snprintf(buf, bufsiz, "mov.w   @r%d, r%d", rm, rn);
                   1096:                break;
                   1097:        case 2:
                   1098:                snprintf(buf, bufsiz, "mov.l   @r%d, r%d", rm, rn);
                   1099:                break;
                   1100:        case 3:
                   1101:                snprintf(buf, bufsiz, "mov     r%d, r%d", rm, rn);
                   1102:                break;
                   1103:        } /* end of switch (md) */
                   1104: }
                   1105:
                   1106: static void
                   1107: f_64(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                   1108: {
                   1109:        int     rn, rm, md;
                   1110:
                   1111:        rn   = (insn & 0x0f00) >> 8;
                   1112:        rm   = (insn & 0x00f0) >> 4;
                   1113:        md   = (insn & 0x0003);
                   1114:
                   1115:        switch (md) {
                   1116:        case 0:
                   1117:                snprintf(buf, bufsiz, "mov.b   @r%d+, r%d", rm, rn);
                   1118:                break;
                   1119:        case 1:
                   1120:                snprintf(buf, bufsiz, "mov.w   @r%d+, r%d", rm, rn);
                   1121:                break;
                   1122:        case 2:
                   1123:                snprintf(buf, bufsiz, "mov.l   @r%d+, r%d", rm, rn);
                   1124:                break;
                   1125:        case 3:
                   1126:                snprintf(buf, bufsiz, "not     r%d, r%d", rm, rn);
                   1127:                break;
                   1128:        } /* end of switch (md) */
                   1129: }
                   1130:
                   1131: static void
                   1132: f_68(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                   1133: {
                   1134:        int     rn, rm, md;
                   1135:
                   1136:        rn   = (insn & 0x0f00) >> 8;
                   1137:        rm   = (insn & 0x00f0) >> 4;
                   1138:        md   = (insn & 0x0003);
                   1139:
                   1140:        switch (md) {
                   1141:        case 0:
                   1142:                snprintf(buf, bufsiz, "swap.b  r%d, r%d", rm, rn);
                   1143:                break;
                   1144:        case 1:
                   1145:                snprintf(buf, bufsiz, "swap.w  r%d, r%d", rm, rn);
                   1146:                break;
                   1147:        case 2:
                   1148:                snprintf(buf, bufsiz, "negc    r%d, r%d", rm, rn);
                   1149:                break;
                   1150:        case 3:
                   1151:                snprintf(buf, bufsiz, "neg     r%d, r%d", rm, rn);
                   1152:                break;
                   1153:        } /* end of switch (md) */
                   1154: }
                   1155:
                   1156: static void
                   1157: f_6c(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                   1158: {
                   1159:        int     rn, rm, md;
                   1160:
                   1161:        rn   = (insn & 0x0f00) >> 8;
                   1162:        rm   = (insn & 0x00f0) >> 4;
                   1163:        md   = (insn & 0x0003);
                   1164:
                   1165:        switch (md) {
                   1166:        case 0:
                   1167:                snprintf(buf, bufsiz, "extu.b  r%d, r%d", rm, rn);
                   1168:                break;
                   1169:        case 1:
                   1170:                snprintf(buf, bufsiz, "extu.w  r%d, r%d", rm, rn);
                   1171:                break;
                   1172:        case 2:
                   1173:                snprintf(buf, bufsiz, "exts.b  r%d, r%d", rm, rn);
                   1174:                break;
                   1175:        case 3:
                   1176:                snprintf(buf, bufsiz, "exts.w  r%d, r%d", rm, rn);
                   1177:                break;
                   1178:        } /* end of switch (md) */
                   1179: }
                   1180:
                   1181: static void
                   1182: f_70(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                   1183: {
                   1184:        int     rn, imm;
                   1185:
                   1186:        rn   = (insn & 0x0f00) >> 8;
                   1187:        imm  = (int) ((char) (insn & 0x00ff));
                   1188:
                   1189:        snprintf(buf, bufsiz, "add     #0x%x, r%d", imm, rn);
                   1190: }
                   1191:
                   1192: static void
                   1193: f_80(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                   1194: {
                   1195:        int     type, md, rn, disp;
                   1196:
                   1197:        type = (insn & 0x0c00) >> 10;
                   1198:        md   = (insn & 0x0300) >> 8;
                   1199:
                   1200:        switch (type) {
                   1201:        case 0:
                   1202:                rn   = (insn & 0x00f0) >> 4;
                   1203:                disp = (insn & 0x000f);
                   1204:
                   1205:                switch (md) {
                   1206:                case 0:
                   1207:                        snprintf(buf, bufsiz, "mov.b   r0, @(%d, r%d)",
                   1208:                            disp, rn);
                   1209:                        break;
                   1210:                case 1:
                   1211:                        disp *= 2;
                   1212:                        snprintf(buf, bufsiz, "mov.w   r0, @(%d, r%d)",
                   1213:                            disp, rn);
                   1214:                        break;
                   1215:                }
                   1216:                break;
                   1217:        case 1:
                   1218:                rn   = (insn & 0x00f0) >> 4;
                   1219:                disp = (insn & 0x000f);
                   1220:
                   1221:                switch (md) {
                   1222:                case 0:
                   1223:                        snprintf(buf, bufsiz, "mov.b   @(%d, r%d), r0",
                   1224:                            disp, rn);
                   1225:                        break;
                   1226:                case 1:
                   1227:                        disp *= 2;
                   1228:                        snprintf(buf, bufsiz, "mov.w   @(%d, r%d), r0",
                   1229:                            disp, rn);
                   1230:                        break;
                   1231:                }
                   1232:                break;
                   1233:        case 2:
                   1234:                disp = (insn & 0x00ff);
                   1235:
                   1236:                switch (md) {
                   1237:                case 0:
                   1238:                        snprintf(buf, bufsiz, "cmp/eq  #%d, r0", disp);
                   1239:                        break;
                   1240:                case 1:
                   1241:                        disp = (int) ((char) disp);
                   1242:                        disp *= 2;
                   1243:                        disasm_branch(buf, bufsiz, "bt", loc + 4 + disp);
                   1244:                        break;
                   1245:                case 3:
                   1246:                        disp = (int) ((char) disp);
                   1247:                        disp *= 2;
                   1248:                        disasm_branch(buf, bufsiz, "bf", loc + 4 + disp);
                   1249:                        break;
                   1250:                }
                   1251:                break;
                   1252:        case 3:
                   1253:                disp = (int) ((char) (insn & 0x00ff));
                   1254:                disp *= 2;
                   1255:
                   1256:                switch (md) {
                   1257:                case 1:
                   1258:                        disasm_branch(buf, bufsiz, "bt/s", loc + 4 + disp);
                   1259:                        break;
                   1260:                case 3:
                   1261:                        disasm_branch(buf, bufsiz, "bf/s", loc + 4 + disp);
                   1262:                        break;
                   1263:                }
                   1264:                break;
                   1265:        } /* end of switch (type) */
                   1266: }
                   1267:
                   1268: static void
                   1269: f_90(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                   1270: {
                   1271:        int     rn, disp;
                   1272:
                   1273:        rn   = (insn & 0x0f00) >> 8;
                   1274:        disp = (insn & 0x00ff);
                   1275:        disp *= 2;
                   1276:
                   1277:        snprintf(buf, bufsiz, "mov.w   @(%d, pc), r%d", disp, rn);
                   1278: }
                   1279:
                   1280: static void
                   1281: f_a0(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                   1282: {
                   1283:        int     disp;
                   1284:
                   1285:        disp = (insn & 0x0fff);
                   1286:        if (disp & 0x0800)      /* negative displacement? */
                   1287:                disp |= 0xfffff000; /* sign extend */
                   1288:        disp *= 2;
                   1289:
                   1290:        disasm_branch(buf, bufsiz, "bra", loc + 4 + disp);
                   1291: }
                   1292:
                   1293: static void
                   1294: f_b0(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                   1295: {
                   1296:        int     disp;
                   1297:
                   1298:        disp = (insn & 0x0fff);
                   1299:        if (disp & 0x0800)      /* negative displacement? */
                   1300:                disp |= 0xfffff000; /* sign extend */
                   1301:        disp *= 2;
                   1302:
                   1303:        disasm_branch(buf, bufsiz, "bsr", loc + 4 + disp);
                   1304: }
                   1305:
                   1306: static void
                   1307: f_c0(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                   1308: {
                   1309:        int     type, md, imm;
                   1310:
                   1311:        type = (insn & 0x0c00) >> 10;
                   1312:        md   = (insn & 0x0300) >> 8;
                   1313:        imm  = (insn & 0x00ff);
                   1314:
                   1315:        switch (type) {
                   1316:        case 0:
                   1317:                switch (md) {
                   1318:                case 0:
                   1319:                        snprintf(buf, bufsiz, "mov.b   r0, @(%d, gbr)", imm);
                   1320:                        break;
                   1321:                case 1:
                   1322:                        imm *= 2;
                   1323:                        snprintf(buf, bufsiz, "mov.w   r0, @(%d, gbr)", imm);
                   1324:                        break;
                   1325:                case 2:
                   1326:                        imm *= 4;
                   1327:                        snprintf(buf, bufsiz, "mov.l   r0, @(%d, gbr)", imm);
                   1328:                        break;
                   1329:                case 3:
                   1330:                        snprintf(buf, bufsiz, "trapa   #%d", imm);
                   1331:                        break;
                   1332:                }
                   1333:                break;
                   1334:        case 1:
                   1335:                switch (md) {
                   1336:                case 0:
                   1337:                        snprintf(buf, bufsiz, "mov.b   @(%d, gbr), r0", imm);
                   1338:                        break;
                   1339:                case 1:
                   1340:                        imm *= 2;
                   1341:                        snprintf(buf, bufsiz, "mov.w   @(%d, gbr), r0", imm);
                   1342:                        break;
                   1343:                case 2:
                   1344:                        imm *= 4;
                   1345:                        snprintf(buf, bufsiz, "mov.l   @(%d, gbr), r0", imm);
                   1346:                        break;
                   1347:                case 3:
                   1348:                        imm *= 4;
                   1349:                        snprintf(buf, bufsiz, "mova    @(%d, pc), r0", imm);
                   1350:                        break;
                   1351:                }
                   1352:                break;
                   1353:        case 2:
                   1354:                switch (md) {
                   1355:                case 0:
                   1356:                        snprintf(buf, bufsiz, "tst     #%d, r0", imm);
                   1357:                        break;
                   1358:                case 1:
                   1359:                        snprintf(buf, bufsiz, "and     #%d, r0", imm);
                   1360:                        break;
                   1361:                case 2:
                   1362:                        snprintf(buf, bufsiz, "xor     #%d, r0", imm);
                   1363:                        break;
                   1364:                case 3:
                   1365:                        snprintf(buf, bufsiz, "or      #%d, r0", imm);
                   1366:                        break;
                   1367:                }
                   1368:                break;
                   1369:        case 3:
                   1370:                switch (md) {
                   1371:                case 0:
                   1372:                        snprintf(buf, bufsiz, "tst.b   #%d, @(r0, gbr)", imm);
                   1373:                        break;
                   1374:                case 1:
                   1375:                        snprintf(buf, bufsiz, "and.b   #%d, @(r0, gbr)", imm);
                   1376:                        break;
                   1377:                case 2:
                   1378:                        snprintf(buf, bufsiz, "xor.b   #%d, @(r0, gbr)", imm);
                   1379:                        break;
                   1380:                case 3:
                   1381:                        snprintf(buf, bufsiz, "or.b    #%d, @(r0, gbr)", imm);
                   1382:                        break;
                   1383:                }
                   1384:                break;
                   1385:        } /* end of switch (type) */
                   1386: }
                   1387:
                   1388: static void
                   1389: f_d0(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                   1390: {
                   1391:        int     rn, disp;
                   1392:
                   1393:        rn   = (insn & 0x0f00) >> 8;
                   1394:        disp = (insn & 0x00ff);
                   1395:        disp *= 4;
                   1396:
                   1397:        snprintf(buf, bufsiz, "mov.l   @(%d, pc), r%d", disp, rn);
                   1398: }
                   1399:
                   1400: static void
                   1401: f_e0(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                   1402: {
                   1403:        int     rn, imm;
                   1404:
                   1405:        rn   = (insn & 0x0f00) >> 8;
                   1406:        imm  = (int) ((char) (insn & 0x00ff));
                   1407:
                   1408:        snprintf(buf, bufsiz, "mov     #0x%x, r%d", imm, rn);
                   1409: }
                   1410:
                   1411: static void
                   1412: f_f0(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                   1413: {
                   1414:        int     rn, rm, md;
                   1415:
                   1416:        rn   = (insn & 0x0f00) >> 8;
                   1417:        rm   = (insn & 0x00f0) >> 4;
                   1418:        md   = (insn & 0x0003);
                   1419:
                   1420:        switch (md) {
                   1421:        case 0:
                   1422:                snprintf(buf, bufsiz, "fadd    fr%d, fr%d", rm, rn);
                   1423:                break;
                   1424:        case 1:
                   1425:                snprintf(buf, bufsiz, "fsub    fr%d, fr%d", rm, rn);
                   1426:                break;
                   1427:        case 2:
                   1428:                snprintf(buf, bufsiz, "fmul    fr%d, fr%d", rm, rn);
                   1429:                break;
                   1430:        case 3:
                   1431:                snprintf(buf, bufsiz, "fdiv    fr%d, fr%d", rm, rn);
                   1432:                break;
                   1433:        } /* end of switch (md) */
                   1434: }
                   1435:
                   1436: static void
                   1437: f_f4(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                   1438: {
                   1439:        int     rn, rm, md;
                   1440:
                   1441:        rn   = (insn & 0x0f00) >> 8;
                   1442:        rm   = (insn & 0x00f0) >> 4;
                   1443:        md   = (insn & 0x0003);
                   1444:
                   1445:        switch (md) {
                   1446:        case 0:
                   1447:                snprintf(buf, bufsiz, "fcmp/eq fr%d, fr%d", rm, rn);
                   1448:                break;
                   1449:        case 1:
                   1450:                snprintf(buf, bufsiz, "fcmp/gt fr%d, fr%d", rm, rn);
                   1451:                break;
                   1452:        case 2:
                   1453:                snprintf(buf, bufsiz, "fmov.s  @(r0, r%d), fr%d", rm, rn);
                   1454:                break;
                   1455:        case 3:
                   1456:                snprintf(buf, bufsiz, "fmov.s  fr%d, @(r0, r%d)", rm, rn);
                   1457:                break;
                   1458:        } /* end of switch (md) */
                   1459: }
                   1460:
                   1461: static void
                   1462: f_f8(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                   1463: {
                   1464:        int     rn, rm, md;
                   1465:
                   1466:        rn   = (insn & 0x0f00) >> 8;
                   1467:        rm   = (insn & 0x00f0) >> 4;
                   1468:        md   = (insn & 0x0003);
                   1469:
                   1470:        switch (md) {
                   1471:        case 0:
                   1472:                snprintf(buf, bufsiz, "fmov.s  @r%d, fr%d", rm, rn);
                   1473:                break;
                   1474:        case 1:
                   1475:                snprintf(buf, bufsiz, "fmov.s  @r%d+, fr%d", rm, rn);
                   1476:                break;
                   1477:        case 2:
                   1478:                snprintf(buf, bufsiz, "fmov.s  fr%d, @r%d", rm, rn);
                   1479:                break;
                   1480:        case 3:
                   1481:                snprintf(buf, bufsiz, "fmov.s  fr%d, @-r%d", rm, rn);
                   1482:                break;
                   1483:        } /* end of switch (md) */
                   1484: }
                   1485:
                   1486: static void
                   1487: f_fc(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                   1488: {
                   1489:        int     rn, rm;
                   1490:
                   1491:        rn   = (insn & 0x0f00) >> 8;
                   1492:        rm   = (insn & 0x00f0) >> 4;
                   1493:
                   1494:        snprintf(buf, bufsiz, "fmov    fr%d, fr%d", rm, rn);
                   1495: }
                   1496:
                   1497: static void
                   1498: f_fd(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                   1499: {
                   1500:        int     rn, type, md;
                   1501:
                   1502:        rn   = (insn & 0x0f00) >> 8;
                   1503:        type = (insn & 0x00c0) >> 6;
                   1504:        md   = (insn & 0x0030) >> 4;
                   1505:
                   1506:        switch (type) {
                   1507:        case 0:
                   1508:                switch (md) {
                   1509:                case 0:
                   1510:                        snprintf(buf, bufsiz, "fsts    fpul, fr%d", rn);
                   1511:                        break;
                   1512:                case 1:
                   1513:                        snprintf(buf, bufsiz, "flds    fr%d, fpul", rn);
                   1514:                        break;
                   1515:                case 2:
                   1516:                        snprintf(buf, bufsiz, "float   fpul, fr%d", rn);
                   1517:                        break;
                   1518:                case 3:
                   1519:                        snprintf(buf, bufsiz, "ftrc    fr%d, fpul", rn);
                   1520:                        break;
                   1521:                }
                   1522:                break;
                   1523:        case 1:
                   1524:                switch (md) {
                   1525:                case 0:
                   1526:                        snprintf(buf, bufsiz, "fneg    fr%d", rn);
                   1527:                        break;
                   1528:                case 1:
                   1529:                        snprintf(buf, bufsiz, "fabs    fr%d", rn);
                   1530:                        break;
                   1531:                case 2:
                   1532:                        snprintf(buf, bufsiz, "fsqrt   fr%d", rn);
                   1533:                        break;
                   1534:                }
                   1535:                break;
                   1536:        case 2:
                   1537:                switch (md) {
                   1538:                case 0:
                   1539:                case 1:
                   1540:                        snprintf(buf, bufsiz, "fldi%d   fr%d", md, rn);
                   1541:                        break;
                   1542:                }
                   1543:                break;
                   1544:        } /* end of switch (type) */
                   1545: }
                   1546:
                   1547: static void
                   1548: f_fe(db_addr_t loc, u_int insn, char *buf, size_t bufsiz)
                   1549: {
                   1550:        int     rn, rm;
                   1551:
                   1552:        rn   = (insn & 0x0f00) >> 8;
                   1553:        rm   = (insn & 0x00f0) >> 4;
                   1554:
                   1555:        snprintf(buf, bufsiz, "fmac    fr0, fr%d, fr%d", rm, rn);
                   1556: }

CVSweb