Annotation of hatari/src/falcon/dsp_disasm.c, revision 1.1.1.4

1.1       root        1: /*
1.1.1.2   root        2:        DSP M56001 emulation
                      3:        Disassembler
                      4: 
                      5:        (C) 2003-2008 ARAnyM developer team
                      6: 
                      7:        This program is free software; you can redistribute it and/or modify
                      8:        it under the terms of the GNU General Public License as published by
                      9:        the Free Software Foundation; either version 2 of the License, or
                     10:        (at your option) any later version.
                     11: 
                     12:        This program is distributed in the hope that it will be useful,
                     13:        but WITHOUT ANY WARRANTY; without even the implied warranty of
                     14:        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     15:        GNU General Public License for more details.
                     16: 
                     17:        You should have received a copy of the GNU General Public License
                     18:        along with this program; if not, write to the Free Software
                     19:        Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
                     20: */
                     21: 
                     22: #ifdef HAVE_CONFIG_H
                     23: #include "config.h"
                     24: #endif
                     25: 
                     26: #include <string.h>
                     27: 
                     28: #include "dsp_core.h"
1.1       root       29: #include "dsp_cpu.h"
                     30: #include "dsp_disasm.h"
                     31: 
1.1.1.2   root       32: #define DEBUG 0
1.1       root       33: 
                     34: /* More disasm infos, if wanted */
                     35: #define DSP_DISASM_REG_PC 0
                     36: 
                     37: /**********************************
                     38:  *     Defines
                     39:  **********************************/
                     40: 
                     41: #define BITMASK(x)     ((1<<(x))-1)
                     42: 
                     43: /**********************************
                     44:  *     Variables
                     45:  **********************************/
                     46: 
                     47: /* Current instruction */
1.1.1.2   root       48: static Uint32 cur_inst;
1.1.1.3   root       49: static Uint32 disasm_cur_inst_len;
1.1.1.4 ! root       50: static char str_instr[50];
        !            51: static char str_instr2[100];
        !            52: static char parallelmove_name[64];
1.1.1.3   root       53: 
                     54: /* Previous instruction */
                     55: static Uint32 prev_inst_pc = 0x10000;  /* Init to an invalid value */
1.1.1.4 ! root       56: static Uint16 isLooping = 0;
1.1.1.2   root       57: 
                     58: static dsp_core_t *dsp_core;
                     59: 
                     60: void dsp56k_disasm_init(dsp_core_t *my_dsp_core)
                     61: {
                     62:        dsp_core = my_dsp_core;
                     63: }
1.1       root       64: 
                     65: /**********************************
                     66:  *     Register change
                     67:  **********************************/
                     68: 
1.1.1.2   root       69: static Uint32 registers_save[64];
1.1       root       70: #if DSP_DISASM_REG_PC
1.1.1.2   root       71: static Uint32 pc_save;
1.1       root       72: #endif
                     73: 
                     74: static const char *registers_name[64]={
                     75:        "","","","",
                     76:        "x0","x1","y0","y1",
                     77:        "a0","b0","a2","b2",
                     78:        "a1","b1","a","b",
                     79:        
                     80:        "r0","r1","r2","r3",
                     81:        "r4","r5","r6","r7",
                     82:        "n0","n1","n2","n3",
                     83:        "n4","n5","n6","n7",
                     84: 
                     85:        "m0","m1","m2","m3",
                     86:        "m4","m5","m6","m7",
                     87:        "","","","",
                     88:        "","","","",
                     89: 
                     90:        "","","","",
                     91:        "","","","",
                     92:        "","sr","omr","sp",
                     93:        "ssh","ssl","la","lc"
                     94: };
                     95: 
                     96: /**********************************
                     97:  *     Opcode disassembler
                     98:  **********************************/
                     99: 
1.1.1.2   root      100: static Uint32 read_memory(Uint32 currPc);
                    101: 
1.1       root      102: typedef void (*dsp_emul_t)(void);
                    103: 
                    104: static void opcode8h_0(void);
                    105: 
1.1.1.2   root      106: static int dsp_calc_ea(Uint32 ea_mode, char *dest);
                    107: static void dsp_calc_cc(Uint32 cc_mode, char *dest);
1.1       root      108: static void dsp_undefined(void);
                    109: 
                    110: /* Instructions without parallel moves */
                    111: static void dsp_andi(void);
1.1.1.3   root      112: static void dsp_bchg_aa(void);
                    113: static void dsp_bchg_ea(void);
                    114: static void dsp_bchg_pp(void);
                    115: static void dsp_bchg_reg(void);
                    116: static void dsp_bclr_aa(void);
                    117: static void dsp_bclr_ea(void);
                    118: static void dsp_bclr_pp(void);
                    119: static void dsp_bclr_reg(void);
                    120: static void dsp_bset_aa(void);
                    121: static void dsp_bset_ea(void);
                    122: static void dsp_bset_pp(void);
                    123: static void dsp_bset_reg(void);
                    124: static void dsp_btst_aa(void);
                    125: static void dsp_btst_ea(void);
                    126: static void dsp_btst_pp(void);
                    127: static void dsp_btst_reg(void);
1.1       root      128: static void dsp_div(void);
                    129: static void dsp_enddo(void);
                    130: static void dsp_illegal(void);
1.1.1.3   root      131: static void dsp_jcc_imm(void);
                    132: static void dsp_jcc_ea(void);
                    133: static void dsp_jclr_aa(void);
                    134: static void dsp_jclr_ea(void);
                    135: static void dsp_jclr_pp(void);
                    136: static void dsp_jclr_reg(void);
                    137: static void dsp_jmp_ea(void);
                    138: static void dsp_jmp_imm(void);
                    139: static void dsp_jscc_ea(void);
                    140: static void dsp_jscc_imm(void);
                    141: static void dsp_jsclr_aa(void);
                    142: static void dsp_jsclr_ea(void);
                    143: static void dsp_jsclr_pp(void);
                    144: static void dsp_jsclr_reg(void);
                    145: static void dsp_jset_aa(void);
                    146: static void dsp_jset_ea(void);
                    147: static void dsp_jset_pp(void);
                    148: static void dsp_jset_reg(void);
                    149: static void dsp_jsr_ea(void);
                    150: static void dsp_jsr_imm(void);
                    151: static void dsp_jsset_aa(void);
                    152: static void dsp_jsset_ea(void);
                    153: static void dsp_jsset_pp(void);
                    154: static void dsp_jsset_reg(void);
1.1       root      155: static void dsp_lua(void);
1.1.1.3   root      156: static void dsp_movem_ea(void);
                    157: static void dsp_movem_aa(void);
1.1       root      158: static void dsp_nop(void);
                    159: static void dsp_norm(void);
                    160: static void dsp_ori(void);
                    161: static void dsp_reset(void);
                    162: static void dsp_rti(void);
                    163: static void dsp_rts(void);
                    164: static void dsp_stop(void);
                    165: static void dsp_swi(void);
                    166: static void dsp_tcc(void);
                    167: static void dsp_wait(void);
1.1.1.3   root      168: static void dsp_do_ea(void);
                    169: static void dsp_do_aa(void);
                    170: static void dsp_do_imm(void);
                    171: static void dsp_do_reg(void);
                    172: static void dsp_rep_aa(void);
                    173: static void dsp_rep_ea(void);
                    174: static void dsp_rep_imm(void);
                    175: static void dsp_rep_reg(void);
                    176: static void dsp_movec_aa(void);
                    177: static void dsp_movec_ea(void);
                    178: static void dsp_movec_imm(void);
                    179: static void dsp_movec_reg(void);
1.1       root      180: static void dsp_movep_0(void);
                    181: static void dsp_movep_1(void);
1.1.1.3   root      182: static void dsp_movep_23(void);
1.1       root      183: 
                    184: /* Parallel moves */
1.1.1.3   root      185: static void dsp_pm_class2(void);
1.1       root      186: static void dsp_pm(void);
                    187: static void dsp_pm_0(void);
                    188: static void dsp_pm_1(void);
                    189: static void dsp_pm_2(void);
                    190: static void dsp_pm_4(void);
                    191: static void dsp_pm_8(void);
                    192: 
                    193: /* Instructions with parallel moves */
                    194: static void dsp_abs(void);
                    195: static void dsp_adc(void);
                    196: static void dsp_add(void);
                    197: static void dsp_addl(void);
                    198: static void dsp_addr(void);
                    199: static void dsp_and(void);
                    200: static void dsp_asl(void);
                    201: static void dsp_asr(void);
                    202: static void dsp_clr(void);
                    203: static void dsp_cmp(void);
                    204: static void dsp_cmpm(void);
                    205: static void dsp_eor(void);
                    206: static void dsp_lsl(void);
                    207: static void dsp_lsr(void);
                    208: static void dsp_mac(void);
                    209: static void dsp_macr(void);
                    210: static void dsp_move(void);
                    211: static void dsp_mpy(void);
                    212: static void dsp_mpyr(void);
                    213: static void dsp_neg(void);
                    214: static void dsp_not(void);
                    215: static void dsp_or(void);
                    216: static void dsp_rnd(void);
                    217: static void dsp_rol(void);
                    218: static void dsp_ror(void);
                    219: static void dsp_sbc(void);
                    220: static void dsp_sub(void);
                    221: static void dsp_subl(void);
                    222: static void dsp_subr(void);
                    223: static void dsp_tfr(void);
                    224: static void dsp_tst(void);
                    225: 
1.1.1.3   root      226: static dsp_emul_t opcodes8h[512]={
                    227:        /* 0x00 - 0x3f */
                    228:        opcode8h_0, dsp_undefined, dsp_undefined, dsp_undefined, opcode8h_0, dsp_andi, dsp_undefined, dsp_ori,
                    229:        dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_andi, dsp_undefined, dsp_ori,
                    230:        dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_andi, dsp_undefined, dsp_ori,
                    231:        dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_andi, dsp_undefined, dsp_ori,
                    232:        dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined,
                    233:        dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined,
                    234:        dsp_undefined, dsp_undefined, dsp_div, dsp_div, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined,
                    235:        dsp_norm, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined,
                    236:        
                    237:        /* 0x40 - 0x7f */
                    238:        dsp_tcc, dsp_tcc, dsp_tcc, dsp_tcc, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined,
                    239:        dsp_tcc, dsp_tcc, dsp_tcc, dsp_tcc, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined,
                    240:        dsp_tcc, dsp_tcc, dsp_tcc, dsp_tcc, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined,
                    241:        dsp_tcc, dsp_tcc, dsp_tcc, dsp_tcc, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined,
                    242:        dsp_tcc, dsp_tcc, dsp_tcc, dsp_tcc, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined,
                    243:        dsp_tcc, dsp_tcc, dsp_tcc, dsp_tcc, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined,
                    244:        dsp_tcc, dsp_tcc, dsp_tcc, dsp_tcc, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined,
                    245:        dsp_tcc, dsp_tcc, dsp_tcc, dsp_tcc, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined,
                    246: 
                    247:        /* 0x80 - 0xbf */
                    248:        dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined,
                    249:        dsp_lua, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_movec_reg, dsp_undefined, dsp_undefined, 
                    250:        dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined,
                    251:        dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_movec_reg, dsp_undefined, dsp_undefined, 
                    252:        dsp_undefined, dsp_movec_aa, dsp_undefined, dsp_movec_aa, dsp_undefined, dsp_movec_imm, dsp_undefined, dsp_undefined,
                    253:        dsp_undefined, dsp_movec_ea, dsp_undefined, dsp_movec_ea, dsp_undefined, dsp_movec_imm, dsp_undefined, dsp_undefined,
                    254:        dsp_undefined, dsp_movec_aa, dsp_undefined, dsp_movec_aa, dsp_undefined, dsp_movec_imm, dsp_undefined, dsp_undefined,
                    255:        dsp_undefined, dsp_movec_ea, dsp_undefined, dsp_movec_ea, dsp_undefined, dsp_movec_imm, dsp_undefined, dsp_undefined,
                    256:        
                    257:        /* 0xc0 - 0xff */
                    258:        dsp_do_aa, dsp_rep_aa, dsp_do_aa, dsp_rep_aa, dsp_do_imm, dsp_rep_imm, dsp_undefined, dsp_undefined, 
                    259:        dsp_do_ea, dsp_rep_ea, dsp_do_ea, dsp_rep_ea, dsp_do_imm, dsp_rep_imm, dsp_undefined, dsp_undefined, 
                    260:        dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_do_imm, dsp_rep_imm, dsp_undefined, dsp_undefined, 
                    261:        dsp_do_reg, dsp_rep_reg, dsp_undefined, dsp_undefined, dsp_do_imm, dsp_rep_imm, dsp_undefined, dsp_undefined, 
                    262:        dsp_movem_aa, dsp_movem_aa, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, 
                    263:        dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_movem_ea, dsp_movem_ea, dsp_undefined, dsp_undefined, 
                    264:        dsp_movem_aa, dsp_movem_aa, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, 
                    265:        dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_movem_ea, dsp_movem_ea, dsp_undefined, dsp_undefined, 
                    266: 
                    267:        /* 0x100 - 0x13f */
                    268:        dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2,
                    269:        dsp_movep_0, dsp_movep_0, dsp_movep_1, dsp_movep_1, dsp_movep_23, dsp_movep_23, dsp_movep_23, dsp_movep_23,
                    270:        dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2,
                    271:        dsp_movep_0, dsp_movep_0, dsp_movep_1, dsp_movep_1, dsp_movep_23, dsp_movep_23, dsp_movep_23, dsp_movep_23,
                    272:        dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2,
                    273:        dsp_movep_0, dsp_movep_0, dsp_movep_1, dsp_movep_1, dsp_movep_23, dsp_movep_23, dsp_movep_23, dsp_movep_23,
                    274:        dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2, dsp_pm_class2,
                    275:        dsp_movep_0, dsp_movep_0, dsp_movep_1, dsp_movep_1, dsp_movep_23, dsp_movep_23, dsp_movep_23, dsp_movep_23,
                    276: 
                    277:        /* 0x140 - 0x17f */
                    278:        dsp_bclr_aa, dsp_bset_aa, dsp_bclr_aa, dsp_bset_aa, dsp_jclr_aa, dsp_jset_aa, dsp_jclr_aa, dsp_jset_aa,
                    279:        dsp_bclr_ea, dsp_bset_ea, dsp_bclr_ea, dsp_bset_ea, dsp_jclr_ea, dsp_jset_ea, dsp_jclr_ea, dsp_jset_ea,
                    280:        dsp_bclr_pp, dsp_bset_pp, dsp_bclr_pp, dsp_bset_pp, dsp_jclr_pp, dsp_jset_pp, dsp_jclr_pp, dsp_jset_pp,
                    281:        dsp_jclr_reg, dsp_jset_reg, dsp_bclr_reg, dsp_bset_reg, dsp_jmp_ea, dsp_jcc_ea, dsp_undefined, dsp_undefined,
                    282:        dsp_bchg_aa, dsp_btst_aa, dsp_bchg_aa, dsp_btst_aa, dsp_jsclr_aa, dsp_jsset_aa, dsp_jsclr_aa, dsp_jsset_aa,
                    283:        dsp_bchg_ea, dsp_btst_ea, dsp_bchg_ea, dsp_btst_ea, dsp_jsclr_ea, dsp_jsset_ea, dsp_jsclr_ea, dsp_jsset_ea,
                    284:        dsp_bchg_pp, dsp_btst_pp, dsp_bchg_pp, dsp_btst_pp, dsp_jsclr_pp, dsp_jsset_pp, dsp_jsclr_pp, dsp_jsset_pp,
                    285:        dsp_jsclr_reg, dsp_jsset_reg, dsp_bchg_reg, dsp_btst_reg, dsp_jsr_ea, dsp_jscc_ea, dsp_undefined, dsp_undefined,
                    286: 
                    287:        /* 0x180 - 0x1bf */
                    288:        dsp_jmp_imm, dsp_jmp_imm, dsp_jmp_imm, dsp_jmp_imm, dsp_jmp_imm, dsp_jmp_imm, dsp_jmp_imm, dsp_jmp_imm,
                    289:        dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, 
                    290:        dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, 
                    291:        dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, 
                    292:        dsp_jsr_imm, dsp_jsr_imm, dsp_jsr_imm, dsp_jsr_imm, dsp_jsr_imm, dsp_jsr_imm, dsp_jsr_imm, dsp_jsr_imm, 
                    293:        dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, 
                    294:        dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, 
                    295:        dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, dsp_undefined, 
                    296: 
                    297:        /* 0x1c0 - 0x1ff */
                    298:        dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, 
                    299:        dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, 
                    300:        dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, 
                    301:        dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, dsp_jcc_imm, 
                    302:        dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, 
                    303:        dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, 
                    304:        dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, 
                    305:        dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, dsp_jscc_imm, 
1.1       root      306: };
                    307: 
1.1.1.3   root      308: static dsp_emul_t opcodes_alu[256]={
                    309:        /* 0x00 - 0x3f */
                    310:        dsp_move, dsp_tfr, dsp_addr, dsp_tst, dsp_undefined, dsp_cmp, dsp_subr, dsp_cmpm,
                    311:        dsp_undefined, dsp_tfr, dsp_addr, dsp_tst, dsp_undefined, dsp_cmp, dsp_subr, dsp_cmpm,
                    312:        dsp_add, dsp_rnd, dsp_addl, dsp_clr, dsp_sub, dsp_undefined, dsp_subl, dsp_not,
                    313:        dsp_add, dsp_rnd, dsp_addl, dsp_clr, dsp_sub, dsp_undefined, dsp_subl, dsp_not,
                    314:        dsp_add, dsp_adc, dsp_asr, dsp_lsr, dsp_sub, dsp_sbc, dsp_abs, dsp_ror,
                    315:        dsp_add, dsp_adc, dsp_asr, dsp_lsr, dsp_sub, dsp_sbc, dsp_abs, dsp_ror,
                    316:        dsp_add, dsp_adc, dsp_asl, dsp_lsl, dsp_sub, dsp_sbc, dsp_neg, dsp_rol,
                    317:        dsp_add, dsp_adc, dsp_asl, dsp_lsl, dsp_sub, dsp_sbc, dsp_neg, dsp_rol,
                    318:        
                    319:        /* 0x40 - 0x7f */
                    320:        dsp_add, dsp_tfr, dsp_or, dsp_eor, dsp_sub, dsp_cmp, dsp_and, dsp_cmpm,
                    321:        dsp_add, dsp_tfr, dsp_or, dsp_eor, dsp_sub, dsp_cmp, dsp_and, dsp_cmpm,
                    322:        dsp_add, dsp_tfr, dsp_or, dsp_eor, dsp_sub, dsp_cmp, dsp_and, dsp_cmpm,
                    323:        dsp_add, dsp_tfr, dsp_or, dsp_eor, dsp_sub, dsp_cmp, dsp_and, dsp_cmpm,
                    324:        dsp_add, dsp_tfr, dsp_or, dsp_eor, dsp_sub, dsp_cmp, dsp_and, dsp_cmpm,
                    325:        dsp_add, dsp_tfr, dsp_or, dsp_eor, dsp_sub, dsp_cmp, dsp_and, dsp_cmpm,
                    326:        dsp_add, dsp_tfr, dsp_or, dsp_eor, dsp_sub, dsp_cmp, dsp_and, dsp_cmpm,
                    327:        dsp_add, dsp_tfr, dsp_or, dsp_eor, dsp_sub, dsp_cmp, dsp_and, dsp_cmpm,
                    328: 
                    329:        /* 0x80 - 0xbf */
                    330:        dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr,
                    331:        dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr,
                    332:        dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr,
                    333:        dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr,
                    334:        dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr,
                    335:        dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr,
                    336:        dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr,
                    337:        dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr,
                    338: 
                    339:        /* 0xc0 - 0xff */
                    340:        dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr,
                    341:        dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr,
                    342:        dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr,
                    343:        dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr,
                    344:        dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr,
                    345:        dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr,
                    346:        dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr,
                    347:        dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr, dsp_mpy, dsp_mpyr, dsp_mac, dsp_macr
1.1       root      348: };
                    349: 
                    350: 
                    351: static dsp_emul_t opcodes_parmove[16]={
                    352:        dsp_pm_0,
                    353:        dsp_pm_1,
                    354:        dsp_pm_2,
                    355:        dsp_pm_2,
                    356:        dsp_pm_4,
                    357:        dsp_pm_4,
                    358:        dsp_pm_4,
                    359:        dsp_pm_4,
                    360: 
                    361:        dsp_pm_8,
                    362:        dsp_pm_8,
                    363:        dsp_pm_8,
                    364:        dsp_pm_8,
                    365:        dsp_pm_8,
                    366:        dsp_pm_8,
                    367:        dsp_pm_8,
                    368:        dsp_pm_8
                    369: };
                    370: 
                    371: static int registers_tcc[16][2]={
                    372:        {DSP_REG_B,DSP_REG_A},
                    373:        {DSP_REG_A,DSP_REG_B},
                    374:        {DSP_REG_NULL,DSP_REG_NULL},
                    375:        {DSP_REG_NULL,DSP_REG_NULL},
                    376: 
                    377:        {DSP_REG_NULL,DSP_REG_NULL},
                    378:        {DSP_REG_NULL,DSP_REG_NULL},
                    379:        {DSP_REG_NULL,DSP_REG_NULL},
                    380:        {DSP_REG_NULL,DSP_REG_NULL},
                    381: 
                    382:        {DSP_REG_X0,DSP_REG_A},
                    383:        {DSP_REG_X0,DSP_REG_B},
                    384:        {DSP_REG_Y0,DSP_REG_A},
                    385:        {DSP_REG_Y0,DSP_REG_B},
1.1.1.2   root      386: 
                    387:        {DSP_REG_X1,DSP_REG_A},
                    388:        {DSP_REG_X1,DSP_REG_B},
1.1       root      389:        {DSP_REG_Y1,DSP_REG_A},
                    390:        {DSP_REG_Y1,DSP_REG_B}
                    391: };
                    392: 
                    393: static const char *registers_lmove[8]={
                    394:        "a10",
                    395:        "b10",
                    396:        "x",
                    397:        "y",
                    398:        "a",
                    399:        "b",
                    400:        "ab",
                    401:        "ba"
                    402: };
                    403: 
                    404: static const char *ea_names[9]={
                    405:        "(r%d)-n%d",    /* 000xxx */
                    406:        "(r%d)+n%d",    /* 001xxx */
                    407:        "(r%d)-",               /* 010xxx */
                    408:        "(r%d)+",               /* 011xxx */
                    409:        "(r%d)",                /* 100xxx */
                    410:        "(r%d+n%d)",    /* 101xxx */
                    411:        "0x%04x",               /* 110000 */
                    412:        "-(r%d)",               /* 111xxx */
                    413:        "0x%06x"                /* 110100 */
                    414: };
                    415: 
                    416: static const char *cc_name[16]={
                    417:        "cc",
                    418:        "ge",
                    419:        "ne",
                    420:        "pl",
                    421:        "nn",
                    422:        "ec",
                    423:        "lc",
                    424:        "gt",
                    425:        
                    426:        "cs",
                    427:        "lt",
                    428:        "eq",
                    429:        "mi",
                    430:        "nr",
                    431:        "es",
                    432:        "ls",
                    433:        "le"
                    434: };
                    435: 
1.1.1.4 ! root      436: void dsp56k_disasm_reg_save(void)
        !           437: {
        !           438:        memcpy(registers_save, dsp_core->registers , sizeof(registers_save));
        !           439: #if DSP_DISASM_REG_PC
        !           440:        pc_save = dsp_core->pc;
        !           441: #endif
        !           442: }
        !           443: 
        !           444: void dsp56k_disasm_reg_compare(void)
        !           445: {
        !           446:        int i;
        !           447:        
        !           448:        for (i=0; i<64; i++) {
        !           449:                if (registers_save[i] == dsp_core->registers[i]) {
        !           450:                        continue;
        !           451:                }
        !           452: 
        !           453:                switch(i) {
        !           454:                        case DSP_REG_X0:
        !           455:                        case DSP_REG_X1:
        !           456:                        case DSP_REG_Y0:
        !           457:                        case DSP_REG_Y1:
        !           458:                        case DSP_REG_A0:
        !           459:                        case DSP_REG_A1:
        !           460:                        case DSP_REG_B0:
        !           461:                        case DSP_REG_B1:
        !           462:                                fprintf(stderr,"\tReg: %s  0x%06x -> 0x%06x\n", registers_name[i], registers_save[i] & BITMASK(24), dsp_core->registers[i]  & BITMASK(24));
        !           463:                                break;
        !           464:                        case DSP_REG_R0:
        !           465:                        case DSP_REG_R1:
        !           466:                        case DSP_REG_R2:
        !           467:                        case DSP_REG_R3:
        !           468:                        case DSP_REG_R4:
        !           469:                        case DSP_REG_R5:
        !           470:                        case DSP_REG_R6:
        !           471:                        case DSP_REG_R7:
        !           472:                        case DSP_REG_M0:
        !           473:                        case DSP_REG_M1:
        !           474:                        case DSP_REG_M2:
        !           475:                        case DSP_REG_M3:
        !           476:                        case DSP_REG_M4:
        !           477:                        case DSP_REG_M5:
        !           478:                        case DSP_REG_M6:
        !           479:                        case DSP_REG_M7:
        !           480:                        case DSP_REG_N0:
        !           481:                        case DSP_REG_N1:
        !           482:                        case DSP_REG_N2:
        !           483:                        case DSP_REG_N3:
        !           484:                        case DSP_REG_N4:
        !           485:                        case DSP_REG_N5:
        !           486:                        case DSP_REG_N6:
        !           487:                        case DSP_REG_N7:
        !           488:                        case DSP_REG_SR:
        !           489:                        case DSP_REG_LA:
        !           490:                        case DSP_REG_LC:
        !           491:                                fprintf(stderr,"\tReg: %s  0x%04x -> 0x%04x\n", registers_name[i], registers_save[i] & BITMASK(16), dsp_core->registers[i]  & BITMASK(16));
        !           492:                                break;
        !           493:                        case DSP_REG_A2:
        !           494:                        case DSP_REG_B2:
        !           495:                        case DSP_REG_OMR:
        !           496:                        case DSP_REG_SP:
        !           497:                        case DSP_REG_SSH:
        !           498:                        case DSP_REG_SSL:
        !           499:                                fprintf(stderr,"\tReg: %s  0x%02x -> 0x%02x\n", registers_name[i], registers_save[i] & BITMASK(8), dsp_core->registers[i]  & BITMASK(8));
        !           500:                                break;
        !           501:                        case DSP_REG_A:
        !           502:                        case DSP_REG_B:
        !           503:                                {
        !           504:                                        fprintf(stderr,"\tReg: %s  0x%02x:%06x:%06x -> 0x%02x:%06x:%06x\n",
        !           505:                                                registers_name[i],
        !           506:                                                registers_save[DSP_REG_A2+(i & 1)] & BITMASK(8),
        !           507:                                                registers_save[DSP_REG_A1+(i & 1)] & BITMASK(24),
        !           508:                                                registers_save[DSP_REG_A0+(i & 1)] & BITMASK(24),
        !           509:                                                dsp_core->registers[DSP_REG_A2+(i & 1)]  & BITMASK(8),
        !           510:                                                dsp_core->registers[DSP_REG_A1+(i & 1)]  & BITMASK(24),
        !           511:                                                dsp_core->registers[DSP_REG_A0+(i & 1)]  & BITMASK(24)
        !           512:                                        );
        !           513:                                }
        !           514:                                break;
        !           515:                }
        !           516:        }
        !           517: 
        !           518: #if DSP_DISASM_REG_PC
        !           519:        if (pc_save != dsp_core->pc) {
        !           520:                fprintf(stderr,"\tReg: pc  0x%04x -> 0x%04x\n", pc_save, dsp_core->pc);
        !           521:        }
        !           522: #endif
        !           523: }
1.1       root      524: 
1.1.1.3   root      525: Uint16 dsp56k_disasm(void)
1.1       root      526: {
1.1.1.2   root      527:        Uint32 value;
1.1       root      528: 
1.1.1.3   root      529:        if (prev_inst_pc == dsp_core->pc){
1.1.1.4 ! root      530:                isLooping = 1;
1.1.1.3   root      531:                return 0;
                    532:        }
                    533:        prev_inst_pc = dsp_core->pc;
1.1.1.4 ! root      534:        isLooping = 0;
1.1.1.3   root      535: 
1.1.1.2   root      536:        cur_inst = read_memory(dsp_core->pc);
1.1.1.3   root      537:        disasm_cur_inst_len = 1;
1.1       root      538: 
                    539:        strcpy(parallelmove_name, "");
                    540: 
1.1.1.3   root      541:        if (cur_inst < 0x100000) {
                    542:                value = (cur_inst >> 11) & (BITMASK(6) << 3);
                    543:                value += (cur_inst >> 5) & BITMASK(3);
1.1       root      544:                opcodes8h[value]();
                    545:        } else {
                    546:                dsp_pm();
                    547:                value = cur_inst & BITMASK(8);
1.1.1.3   root      548:                opcodes_alu[value]();
                    549:        }
                    550:        return disasm_cur_inst_len;
1.1       root      551: }
                    552: 
1.1.1.4 ! root      553: /**
        !           554:  * dsp56k_getInstrText : return the disasembled instructions
        !           555:  */
        !           556: char* dsp56k_getInstructionText(void)
        !           557: {
        !           558:        if (isLooping) {
        !           559:                *str_instr2 = 0;
        !           560:        }
        !           561:        else if (disasm_cur_inst_len == 1) {
        !           562:                sprintf(str_instr2, "%04x:  %06x         (%02d cyc)  %s\n", prev_inst_pc, cur_inst, dsp_core->instr_cycle, str_instr);
        !           563:        } 
        !           564:        else {
        !           565:                sprintf(str_instr2, "%04x:  %06x %06x  (%02d cyc)  %s\n", prev_inst_pc, cur_inst, read_memory(prev_inst_pc + 1), dsp_core->instr_cycle, str_instr);
        !           566:        }
        !           567: 
        !           568:        return str_instr2;
        !           569: } 
        !           570: 
1.1.1.3   root      571: static void dsp_pm_class2(void) {
                    572:        Uint32 value;
                    573: 
                    574:        dsp_pm();
                    575:        value = cur_inst & BITMASK(8);
                    576:        opcodes_alu[value]();
                    577: } 
                    578: 
1.1.1.2   root      579: static Uint32 read_memory(Uint32 currPc)
                    580: {
                    581:        Uint32 value;
                    582: 
                    583:        if (currPc<0x200) {
                    584:                value = dsp_core->ramint[DSP_SPACE_P][currPc];
                    585:        } else {
1.1.1.3   root      586:                value = dsp_core->ramext[currPc & (DSP_RAMSIZE-1)];
1.1.1.2   root      587:        }
                    588: 
                    589:        return value & BITMASK(24);
                    590: }
                    591: 
1.1       root      592: /**********************************
                    593:  *     Conditions code calculation
                    594:  **********************************/
                    595: 
1.1.1.2   root      596: static void dsp_calc_cc(Uint32 cc_mode, char *dest)
1.1       root      597: {
                    598:        strcpy(dest, cc_name[cc_mode & BITMASK(4)]);
                    599: }
                    600: 
                    601: /**********************************
                    602:  *     Effective address calculation
                    603:  **********************************/
                    604: 
1.1.1.2   root      605: static int dsp_calc_ea(Uint32 ea_mode, char *dest)
1.1       root      606: {
                    607:        int value, retour, numreg;
                    608: 
                    609:        value = (ea_mode >> 3) & BITMASK(3);
                    610:        numreg = ea_mode & BITMASK(3);
                    611:        retour = 0;
                    612:        switch (value) {
                    613:                case 0:
                    614:                        /* (Rx)-Nx */
                    615:                        sprintf(dest, ea_names[value], numreg, numreg);
                    616:                        break;
                    617:                case 1:
                    618:                        /* (Rx)+Nx */
                    619:                        sprintf(dest, ea_names[value], numreg, numreg);
                    620:                        break;
                    621:                case 5:
                    622:                        /* (Rx+Nx) */
                    623:                        sprintf(dest, ea_names[value], numreg, numreg);
                    624:                        break;
                    625:                case 2:
                    626:                        /* (Rx)- */
                    627:                        sprintf(dest, ea_names[value], numreg);
                    628:                        break;
                    629:                case 3:
                    630:                        /* (Rx)+ */
                    631:                        sprintf(dest, ea_names[value], numreg);
                    632:                        break;
                    633:                case 4:
                    634:                        /* (Rx) */
                    635:                        sprintf(dest, ea_names[value], numreg);
                    636:                        break;
                    637:                case 7:
                    638:                        /* -(Rx) */
                    639:                        sprintf(dest, ea_names[value], numreg);
                    640:                        break;
                    641:                case 6:
1.1.1.3   root      642:                        disasm_cur_inst_len++;
1.1       root      643:                        switch ((ea_mode >> 2) & 1) {
                    644:                                case 0:
                    645:                                        /* Absolute address */
1.1.1.2   root      646:                                        sprintf(dest, ea_names[value], read_memory(dsp_core->pc+1));
1.1       root      647:                                        break;
                    648:                                case 1:
                    649:                                        /* Immediate value */
1.1.1.2   root      650:                                        sprintf(dest, ea_names[8], read_memory(dsp_core->pc+1));
1.1       root      651:                                        retour = 1;
                    652:                                        break;
                    653:                        }
                    654:                        break;
                    655:        }
                    656:        return retour;
                    657: }
                    658: 
                    659: static void opcode8h_0(void)
                    660: {
1.1.1.3   root      661:        switch(cur_inst) {
                    662:                case 0x000000:
                    663:                        dsp_nop();
1.1       root      664:                        break;
1.1.1.3   root      665:                case 0x000004:
                    666:                        dsp_rti();
1.1       root      667:                        break;
1.1.1.3   root      668:                case 0x000005:
                    669:                        dsp_illegal();
1.1       root      670:                        break;
1.1.1.3   root      671:                case 0x000006:
                    672:                        dsp_swi();
                    673:                        break;
                    674:                case 0x00000c:
                    675:                        dsp_rts();
                    676:                        break;
                    677:                case 0x000084:
                    678:                        dsp_reset();
                    679:                        break;
                    680:                case 0x000086:
                    681:                        dsp_wait();
                    682:                        break;
                    683:                case 0x000087:
                    684:                        dsp_stop();
                    685:                        break;
                    686:                case 0x00008c:
                    687:                        dsp_enddo();
1.1       root      688:                        break;
                    689:        }
                    690: }
                    691: 
                    692: /**********************************
                    693:  *     Non-parallel moves instructions
                    694:  **********************************/
                    695: 
                    696: static void dsp_undefined(void)
                    697: {
1.1.1.4 ! root      698:        sprintf(str_instr,"0x%06x unknown instruction", cur_inst);
1.1       root      699: }
                    700: 
                    701: static void dsp_andi(void)
                    702: {
                    703:        switch(cur_inst & BITMASK(2)) {
                    704:                case 0:
1.1.1.4 ! root      705:                        sprintf(str_instr, "andi #0x%02x,mr", (cur_inst>>8) & BITMASK(8));
1.1       root      706:                        break;
                    707:                case 1:
1.1.1.4 ! root      708:                        sprintf(str_instr, "andi #0x%02x,ccr", (cur_inst>>8) & BITMASK(8));
1.1       root      709:                        break;
                    710:                case 2:
1.1.1.4 ! root      711:                        sprintf(str_instr, "andi #0x%02x,omr", (cur_inst>>8) & BITMASK(8));
1.1       root      712:                        break;
                    713:                default:
                    714:                        break;
                    715:        }
                    716: }
                    717: 
1.1.1.3   root      718: static void dsp_bchg_aa(void)
                    719: {
                    720:        /* bchg #n,x:aa */
                    721:        /* bchg #n,y:aa */
                    722:        char name[16];
                    723:        Uint32 memspace, value, numbit;
                    724:        
                    725:        memspace = (cur_inst>>6) & 1;
                    726:        value = (cur_inst>>8) & BITMASK(6);
                    727:        numbit = cur_inst & BITMASK(5);
                    728: 
                    729:        if (memspace) {
                    730:                sprintf(name,"y:0x%04x",value);
                    731:        } else {
                    732:                sprintf(name,"x:0x%04x",value);
                    733:        }
                    734: 
1.1.1.4 ! root      735:        sprintf(str_instr,"bchg #%d,%s", numbit, name);
1.1.1.3   root      736: }
                    737: 
                    738: static void dsp_bchg_ea(void)
1.1       root      739: {
1.1.1.3   root      740:        /* bchg #n,x:ea */
                    741:        /* bchg #n,y:ea */
1.1       root      742:        char name[16], addr_name[16];
1.1.1.2   root      743:        Uint32 memspace, value, numbit;
1.1       root      744:        
                    745:        memspace = (cur_inst>>6) & 1;
                    746:        value = (cur_inst>>8) & BITMASK(6);
                    747:        numbit = cur_inst & BITMASK(5);
                    748: 
1.1.1.3   root      749:        dsp_calc_ea(value, addr_name);
                    750:        if (memspace) {
                    751:                sprintf(name,"y:%s",addr_name);
                    752:        } else {
                    753:                sprintf(name,"x:%s",addr_name);
                    754:        }
                    755: 
1.1.1.4 ! root      756:        sprintf(str_instr,"bchg #%d,%s", numbit, name);
1.1.1.3   root      757: }
                    758: 
                    759: static void dsp_bchg_pp(void)
                    760: {
                    761:        /* bchg #n,x:pp */
                    762:        /* bchg #n,y:pp */
                    763:        char name[16];
                    764:        Uint32 memspace, value, numbit;
                    765:        
                    766:        memspace = (cur_inst>>6) & 1;
                    767:        value = (cur_inst>>8) & BITMASK(6);
                    768:        numbit = cur_inst & BITMASK(5);
                    769: 
                    770:        if (memspace) {
                    771:                sprintf(name,"y:0x%04x",value+0xffc0);
                    772:        } else {
                    773:                sprintf(name,"x:0x%04x",value+0xffc0);
1.1       root      774:        }
1.1.1.3   root      775: 
1.1.1.4 ! root      776:        sprintf(str_instr,"bchg #%d,%s", numbit, name);
1.1.1.3   root      777: }
                    778: 
                    779: static void dsp_bchg_reg(void)
                    780: {
                    781:        /* bchg #n,R */
1.1.1.4 ! root      782:        Uint32 value, numbit;
1.1.1.3   root      783:        
                    784:        value = (cur_inst>>8) & BITMASK(6);
                    785:        numbit = cur_inst & BITMASK(5);
1.1       root      786: 
1.1.1.4 ! root      787:        sprintf(str_instr,"bchg #%d,%s", numbit, registers_name[value]);
1.1       root      788: }
                    789: 
1.1.1.3   root      790: static void dsp_bclr_aa(void)
1.1       root      791: {
1.1.1.3   root      792:        /* bclr #n,x:aa */
                    793:        /* bclr #n,y:aa */
                    794:        char name[16];
1.1.1.2   root      795:        Uint32 memspace, value, numbit;
1.1       root      796:        
                    797:        memspace = (cur_inst>>6) & 1;
                    798:        value = (cur_inst>>8) & BITMASK(6);
                    799:        numbit = cur_inst & BITMASK(5);
                    800: 
1.1.1.3   root      801:        if (memspace) {
                    802:                sprintf(name,"y:0x%04x",value);
                    803:        } else {
                    804:                sprintf(name,"x:0x%04x",value);
1.1       root      805:        }
                    806: 
1.1.1.4 ! root      807:        sprintf(str_instr,"bclr #%d,%s", numbit, name);
1.1       root      808: }
                    809: 
1.1.1.3   root      810: static void dsp_bclr_ea(void)
1.1       root      811: {
1.1.1.3   root      812:        /* bclr #n,x:ea */
                    813:        /* bclr #n,y:ea */
1.1       root      814:        char name[16], addr_name[16];
1.1.1.2   root      815:        Uint32 memspace, value, numbit;
1.1       root      816:        
                    817:        memspace = (cur_inst>>6) & 1;
                    818:        value = (cur_inst>>8) & BITMASK(6);
                    819:        numbit = cur_inst & BITMASK(5);
                    820: 
1.1.1.3   root      821:        dsp_calc_ea(value, addr_name);
                    822:        if (memspace) {
                    823:                sprintf(name,"y:%s",addr_name);
                    824:        } else {
                    825:                sprintf(name,"x:%s",addr_name);
1.1       root      826:        }
                    827: 
1.1.1.4 ! root      828:        sprintf(str_instr,"bclr #%d,%s", numbit, name);
1.1       root      829: }
                    830: 
1.1.1.3   root      831: static void dsp_bclr_pp(void)
1.1       root      832: {
1.1.1.3   root      833:        /* bclr #n,x:pp */
                    834:        /* bclr #n,y:pp */
                    835:        char name[16];
1.1.1.2   root      836:        Uint32 memspace, value, numbit;
1.1       root      837:        
                    838:        memspace = (cur_inst>>6) & 1;
                    839:        value = (cur_inst>>8) & BITMASK(6);
                    840:        numbit = cur_inst & BITMASK(5);
                    841: 
1.1.1.3   root      842:        if (memspace) {
                    843:                sprintf(name,"y:0x%04x",value+0xffc0);
                    844:        } else {
                    845:                sprintf(name,"x:0x%04x",value+0xffc0);
1.1       root      846:        }
                    847: 
1.1.1.4 ! root      848:        sprintf(str_instr,"bclr #%d,%s", numbit, name);
1.1       root      849: }
                    850: 
1.1.1.3   root      851: static void dsp_bclr_reg(void)
1.1       root      852: {
1.1.1.3   root      853:        /* bclr #n,R */
1.1.1.4 ! root      854:        Uint32 value, numbit;
1.1       root      855:        
1.1.1.3   root      856:        value = (cur_inst>>8) & BITMASK(6);
                    857:        numbit = cur_inst & BITMASK(5);
                    858: 
1.1.1.4 ! root      859:        sprintf(str_instr,"bclr #%d,%s", numbit, registers_name[value]);
1.1.1.3   root      860: }
                    861: 
                    862: static void dsp_bset_aa(void)
                    863: {
                    864:        /* bset #n,x:aa */
                    865:        /* bset #n,y:aa */
                    866:        char name[16];
                    867:        Uint32 memspace, value, numbit;
                    868:        
                    869:        memspace = (cur_inst>>6) & 1;
                    870:        value = (cur_inst>>8) & BITMASK(6);
                    871:        numbit = cur_inst & BITMASK(5);
                    872: 
                    873:        if (memspace) {
                    874:                sprintf(name,"y:0x%04x",value);
                    875:        } else {
                    876:                sprintf(name,"x:0x%04x",value);
1.1       root      877:        }
1.1.1.3   root      878: 
1.1.1.4 ! root      879:        sprintf(str_instr,"bset #%d,%s", numbit, name);
1.1.1.3   root      880: }
                    881: 
                    882: static void dsp_bset_ea(void)
                    883: {
                    884:        /* bset #n,x:ea */
                    885:        /* bset #n,y:ea */
                    886:        char name[16], addr_name[16];
                    887:        Uint32 memspace, value, numbit;
                    888:        
                    889:        memspace = (cur_inst>>6) & 1;
                    890:        value = (cur_inst>>8) & BITMASK(6);
                    891:        numbit = cur_inst & BITMASK(5);
                    892: 
                    893:        dsp_calc_ea(value, addr_name);
                    894:        if (memspace) {
                    895:                sprintf(name,"y:%s",addr_name);
                    896:        } else {
                    897:                sprintf(name,"x:%s",addr_name);
                    898:        }
                    899: 
1.1.1.4 ! root      900:        sprintf(str_instr,"bset #%d,%s", numbit, name);
1.1.1.3   root      901: }
                    902: 
                    903: static void dsp_bset_pp(void)
                    904: {
                    905:        /* bset #n,x:pp */
                    906:        /* bset #n,y:pp */
                    907:        char name[16];
                    908:        Uint32 memspace, value, numbit;
                    909:        
                    910:        memspace = (cur_inst>>6) & 1;
                    911:        value = (cur_inst>>8) & BITMASK(6);
                    912:        numbit = cur_inst & BITMASK(5);
                    913: 
                    914:        if (memspace) {
                    915:                sprintf(name,"y:0x%04x",value+0xffc0);
                    916:        } else {
                    917:                sprintf(name,"x:0x%04x",value+0xffc0);
                    918:        }
                    919: 
1.1.1.4 ! root      920:        sprintf(str_instr,"bset #%d,%s", numbit, name);
1.1.1.3   root      921: }
                    922: 
                    923: static void dsp_bset_reg(void)
                    924: {
                    925:        /* bset #n,R */
1.1.1.4 ! root      926:        Uint32 value, numbit;
1.1.1.3   root      927:        
                    928:        value = (cur_inst>>8) & BITMASK(6);
                    929:        numbit = cur_inst & BITMASK(5);
                    930: 
1.1.1.4 ! root      931:        sprintf(str_instr,"bset #%d,%s", numbit, registers_name[value]);
1.1.1.3   root      932: }
                    933: 
                    934: static void dsp_btst_aa(void)
                    935: {
                    936:        /* btst #n,x:aa */
                    937:        /* btst #n,y:aa */
                    938:        char name[16];
                    939:        Uint32 memspace, value, numbit;
                    940:        
                    941:        memspace = (cur_inst>>6) & 1;
                    942:        value = (cur_inst>>8) & BITMASK(6);
                    943:        numbit = cur_inst & BITMASK(5);
                    944: 
                    945:        if (memspace) {
                    946:                sprintf(name,"y:0x%04x",value);
                    947:        } else {
                    948:                sprintf(name,"x:0x%04x",value);
                    949:        }
                    950: 
1.1.1.4 ! root      951:        sprintf(str_instr,"btst #%d,%s", numbit, name);
1.1.1.3   root      952: }
                    953: 
                    954: static void dsp_btst_ea(void)
                    955: {
                    956:        /* btst #n,x:ea */
                    957:        /* btst #n,y:ea */
                    958:        char name[16], addr_name[16];
                    959:        Uint32 memspace, value, numbit;
                    960:        
                    961:        memspace = (cur_inst>>6) & 1;
                    962:        value = (cur_inst>>8) & BITMASK(6);
                    963:        numbit = cur_inst & BITMASK(5);
                    964: 
                    965:        dsp_calc_ea(value, addr_name);
                    966:        if (memspace) {
                    967:                sprintf(name,"y:%s",addr_name);
                    968:        } else {
                    969:                sprintf(name,"x:%s",addr_name);
                    970:        }
                    971: 
1.1.1.4 ! root      972:        sprintf(str_instr,"btst #%d,%s", numbit, name);
1.1.1.3   root      973: }
                    974: 
                    975: static void dsp_btst_pp(void)
                    976: {
                    977:        /* btst #n,x:pp */
                    978:        /* btst #n,y:pp */
                    979:        char name[16];
                    980:        Uint32 memspace, value, numbit;
                    981:        
                    982:        memspace = (cur_inst>>6) & 1;
                    983:        value = (cur_inst>>8) & BITMASK(6);
                    984:        numbit = cur_inst & BITMASK(5);
                    985: 
                    986:        if (memspace) {
                    987:                sprintf(name,"y:0x%04x",value+0xffc0);
                    988:        } else {
                    989:                sprintf(name,"x:0x%04x",value+0xffc0);
                    990:        }
                    991: 
1.1.1.4 ! root      992:        sprintf(str_instr,"btst #%d,%s", numbit, name);
1.1.1.3   root      993: }
                    994: 
                    995: static void dsp_btst_reg(void)
                    996: {
                    997:        /* btst #n,R */
1.1.1.4 ! root      998:        Uint32 value, numbit;
1.1.1.3   root      999:        
                   1000:        value = (cur_inst>>8) & BITMASK(6);
                   1001:        numbit = cur_inst & BITMASK(5);
                   1002: 
1.1.1.4 ! root     1003:        sprintf(str_instr,"btst #%d,%s", numbit, registers_name[value]);
1.1.1.3   root     1004: }
                   1005: 
                   1006: static void dsp_div(void)
                   1007: {
                   1008:        Uint32 srcreg=DSP_REG_NULL, destreg;
                   1009:        
                   1010:        switch((cur_inst>>4) & BITMASK(2)) {
                   1011:                case 0:
                   1012:                        srcreg = DSP_REG_X0;
                   1013:                                break;
                   1014:                case 1:
                   1015:                        srcreg = DSP_REG_Y0;
                   1016:                                break;
                   1017:                case 2:
                   1018:                        srcreg = DSP_REG_X1;
                   1019:                                break;
                   1020:                case 3:
                   1021:                        srcreg = DSP_REG_Y1;
                   1022:                                break;
                   1023:        }
                   1024:        destreg = DSP_REG_A+((cur_inst>>3) & 1);
                   1025: 
1.1.1.4 ! root     1026:        sprintf(str_instr,"div %s,%s", registers_name[srcreg],registers_name[destreg]);
1.1.1.3   root     1027: }
                   1028: 
                   1029: static void dsp_do_aa(void)
                   1030: {
                   1031:        char name[16];
                   1032: 
                   1033:        disasm_cur_inst_len++;
                   1034: 
                   1035:        if (cur_inst & (1<<6)) {
                   1036:                sprintf(name, "y:0x%04x", (cur_inst>>8) & BITMASK(6));
                   1037:        } else {
                   1038:                sprintf(name, "x:0x%04x", (cur_inst>>8) & BITMASK(6));
                   1039:        }
                   1040: 
1.1.1.4 ! root     1041:        sprintf(str_instr,"do %s,p:0x%04x",
1.1.1.3   root     1042:                name,
                   1043:                read_memory(dsp_core->pc+1)
                   1044:        );
1.1.1.4 ! root     1045: }
1.1.1.3   root     1046: 
                   1047: static void dsp_do_imm(void)
                   1048: {
                   1049:        disasm_cur_inst_len++;
                   1050: 
1.1.1.4 ! root     1051:        sprintf(str_instr,"do #0x%04x,p:0x%04x",
1.1.1.3   root     1052:                ((cur_inst>>8) & BITMASK(8))|((cur_inst & BITMASK(4))<<8),
                   1053:                read_memory(dsp_core->pc+1)
                   1054:        );
1.1.1.4 ! root     1055: }
1.1.1.3   root     1056: 
                   1057: static void dsp_do_ea(void)
                   1058: {
                   1059:        char addr_name[16], name[16];
                   1060:        Uint32 ea_mode;
                   1061:        
                   1062:        disasm_cur_inst_len++;
                   1063: 
                   1064:        ea_mode = (cur_inst>>8) & BITMASK(6);
                   1065:        dsp_calc_ea(ea_mode, addr_name);
                   1066: 
                   1067:        if (cur_inst & (1<<6)) {
                   1068:                sprintf(name, "y:%s", addr_name);
                   1069:        } else {
                   1070:                sprintf(name, "x:%s", addr_name);
                   1071:        }
                   1072: 
1.1.1.4 ! root     1073:        sprintf(str_instr,"do %s,p:0x%04x", 
1.1.1.3   root     1074:                name,
                   1075:                read_memory(dsp_core->pc+1)
                   1076:        );
1.1.1.4 ! root     1077: }
1.1.1.3   root     1078: 
                   1079: static void dsp_do_reg(void)
                   1080: {
                   1081:        disasm_cur_inst_len++;
                   1082: 
1.1.1.4 ! root     1083:        sprintf(str_instr,"do %s,p:0x%04x",
1.1.1.3   root     1084:                registers_name[(cur_inst>>8) & BITMASK(6)],
                   1085:                read_memory(dsp_core->pc+1)
                   1086:        );
1.1.1.4 ! root     1087: }
1.1.1.3   root     1088: 
                   1089: static void dsp_enddo(void)
                   1090: {
1.1.1.4 ! root     1091:        sprintf(str_instr,"enddo");
1.1.1.3   root     1092: }
                   1093: 
                   1094: static void dsp_illegal(void)
                   1095: {
1.1.1.4 ! root     1096:        sprintf(str_instr,"illegal");
1.1.1.3   root     1097: }
                   1098: 
                   1099: static void dsp_jcc_ea(void)
                   1100: {
                   1101:        char cond_name[16], addr_name[16];
                   1102:        Uint32 cc_code=0;
                   1103:        
                   1104:        dsp_calc_ea((cur_inst >>8) & BITMASK(6), addr_name);
                   1105:        cc_code=cur_inst & BITMASK(4);
                   1106:        dsp_calc_cc(cc_code, cond_name);        
                   1107: 
1.1.1.4 ! root     1108:        sprintf(str_instr,"j%s p:%s", cond_name, addr_name);
1.1.1.3   root     1109: }
                   1110: 
                   1111: static void dsp_jcc_imm(void)
                   1112: {
                   1113:        char cond_name[16], addr_name[16];
                   1114:        Uint32 cc_code=0;
                   1115:        
                   1116:        sprintf(addr_name, "0x%04x", cur_inst & BITMASK(12));
                   1117:        cc_code=(cur_inst>>12) & BITMASK(4);
                   1118:        dsp_calc_cc(cc_code, cond_name);        
                   1119: 
1.1.1.4 ! root     1120:        sprintf(str_instr,"j%s p:%s", cond_name, addr_name);
1.1.1.3   root     1121: }
                   1122: 
                   1123: static void dsp_jclr_aa(void)
                   1124: {
                   1125:        /* jclr #n,x:aa,p:xx */
                   1126:        /* jclr #n,y:aa,p:xx */
                   1127:        char srcname[16];
                   1128:        Uint32 memspace, value, numbit;
                   1129:        
                   1130:        disasm_cur_inst_len++;
                   1131: 
                   1132:        memspace = (cur_inst>>6) & 1;
                   1133:        value = (cur_inst>>8) & BITMASK(6);
                   1134:        numbit = cur_inst & BITMASK(5);
                   1135: 
                   1136:        if (memspace) {
                   1137:                sprintf(srcname, "y:0x%04x", value);
                   1138:        } else {
                   1139:                sprintf(srcname, "x:0x%04x", value);
                   1140:        }
                   1141: 
1.1.1.4 ! root     1142:        sprintf(str_instr,"jclr #%d,%s,p:0x%04x",
1.1.1.3   root     1143:                numbit,
                   1144:                srcname,
                   1145:                read_memory(dsp_core->pc+1)
                   1146:        );
                   1147: }
                   1148: 
                   1149: static void dsp_jclr_ea(void)
                   1150: {
                   1151:        /* jclr #n,x:ea,p:xx */
                   1152:        /* jclr #n,y:ea,p:xx */
                   1153:        char srcname[16], addr_name[16];
                   1154:        Uint32 memspace, value, numbit;
                   1155:        
                   1156:        disasm_cur_inst_len++;
                   1157: 
                   1158:        memspace = (cur_inst>>6) & 1;
                   1159:        value = (cur_inst>>8) & BITMASK(6);
                   1160:        numbit = cur_inst & BITMASK(5);
                   1161: 
                   1162:        dsp_calc_ea(value, addr_name);
                   1163:        if (memspace) {
                   1164:                sprintf(srcname, "y:%s", addr_name);
                   1165:        } else {
                   1166:                sprintf(srcname, "x:%s", addr_name);
                   1167:        }
                   1168: 
1.1.1.4 ! root     1169:        sprintf(str_instr,"jclr #%d,%s,p:0x%04x",
1.1.1.3   root     1170:                numbit,
                   1171:                srcname,
                   1172:                read_memory(dsp_core->pc+1)
                   1173:        );
                   1174: }
                   1175: 
                   1176: static void dsp_jclr_pp(void)
                   1177: {
                   1178:        /* jclr #n,x:pp,p:xx */
                   1179:        /* jclr #n,y:pp,p:xx */
                   1180:        char srcname[16];
                   1181:        Uint32 memspace, value, numbit;
                   1182:        
                   1183:        disasm_cur_inst_len++;
                   1184: 
                   1185:        memspace = (cur_inst>>6) & 1;
                   1186:        value = (cur_inst>>8) & BITMASK(6);
                   1187:        numbit = cur_inst & BITMASK(5);
                   1188: 
                   1189:        value += 0xffc0;
                   1190:        if (memspace) {
                   1191:                sprintf(srcname, "y:0x%04x", value);
                   1192:        } else {
                   1193:                sprintf(srcname, "x:0x%04x", value);
                   1194:        }
                   1195: 
1.1.1.4 ! root     1196:        sprintf(str_instr,"jclr #%d,%s,p:0x%04x",
1.1.1.3   root     1197:                numbit,
                   1198:                srcname,
                   1199:                read_memory(dsp_core->pc+1)
                   1200:        );
                   1201: }
                   1202: 
                   1203: static void dsp_jclr_reg(void)
                   1204: {
                   1205:        /* jclr #n,R,p:xx */
1.1.1.4 ! root     1206:        Uint32 value, numbit;
1.1.1.3   root     1207:        
                   1208:        disasm_cur_inst_len++;
                   1209: 
                   1210:        value = (cur_inst>>8) & BITMASK(6);
                   1211:        numbit = cur_inst & BITMASK(5);
                   1212: 
1.1.1.4 ! root     1213:        sprintf(str_instr,"jclr #%d,%s,p:0x%04x",
1.1.1.3   root     1214:                numbit,
1.1.1.4 ! root     1215:                registers_name[value],
1.1.1.3   root     1216:                read_memory(dsp_core->pc+1)
                   1217:        );
                   1218: }
                   1219: 
                   1220: static void dsp_jmp_imm(void)
                   1221: {
1.1.1.4 ! root     1222:        sprintf(str_instr,"jmp p:0x%04x", cur_inst & BITMASK(12));
1.1.1.3   root     1223: }
                   1224: 
                   1225: static void dsp_jmp_ea(void)
                   1226: {
                   1227:        char dstname[16];
                   1228: 
                   1229:        dsp_calc_ea((cur_inst >>8) & BITMASK(6), dstname);
                   1230: 
1.1.1.4 ! root     1231:        sprintf(str_instr,"jmp p:%s", dstname);
1.1.1.3   root     1232: }
                   1233: 
                   1234: static void dsp_jscc_ea(void)
                   1235: {
                   1236:        char cond_name[16], addr_name[16];
                   1237:        Uint32 cc_code=0;
                   1238:        
                   1239:        dsp_calc_ea((cur_inst>>8) & BITMASK(6), addr_name);
                   1240:        cc_code=cur_inst & BITMASK(4);
                   1241:        dsp_calc_cc(cc_code, cond_name);        
                   1242: 
1.1.1.4 ! root     1243:        sprintf(str_instr,"js%s p:%s", cond_name, addr_name);
1.1.1.3   root     1244: }
                   1245:        
                   1246: static void dsp_jscc_imm(void)
                   1247: {
                   1248:        char cond_name[16], addr_name[16];
                   1249:        Uint32 cc_code=0;
                   1250:        
                   1251:        sprintf(addr_name, "0x%04x", cur_inst & BITMASK(12));
                   1252:        cc_code=(cur_inst>>12) & BITMASK(4);
                   1253:        dsp_calc_cc(cc_code, cond_name);        
                   1254: 
1.1.1.4 ! root     1255:        sprintf(str_instr,"js%s p:%s", cond_name, addr_name);
1.1.1.3   root     1256: }
                   1257: 
                   1258: static void dsp_jsclr_aa(void)
                   1259: {
                   1260:        /* jsclr #n,x:aa,p:xx */
                   1261:        /* jsclr #n,y:aa,p:xx */
                   1262:        char srcname[16];
                   1263:        Uint32 memspace, value, numbit;
                   1264:        
                   1265:        disasm_cur_inst_len++;
                   1266: 
                   1267:        memspace = (cur_inst>>6) & 1;
                   1268:        value = (cur_inst>>8) & BITMASK(6);
                   1269:        numbit = cur_inst & BITMASK(5);
                   1270: 
                   1271:        if (memspace) {
                   1272:                sprintf(srcname, "y:0x%04x", value);
                   1273:        } else {
                   1274:                sprintf(srcname, "x:0x%04x", value);
                   1275:        }
                   1276: 
1.1.1.4 ! root     1277:        sprintf(str_instr,"jsclr #%d,%s,p:0x%04x",
1.1.1.3   root     1278:                numbit,
                   1279:                srcname,
                   1280:                read_memory(dsp_core->pc+1)
                   1281:        );
                   1282: }
                   1283: 
                   1284: static void dsp_jsclr_ea(void)
                   1285: {
                   1286:        /* jsclr #n,x:ea,p:xx */
                   1287:        /* jsclr #n,y:ea,p:xx */
                   1288:        char srcname[16], addr_name[16];
                   1289:        Uint32 memspace, value, numbit;
                   1290:        
                   1291:        disasm_cur_inst_len++;
                   1292: 
                   1293:        memspace = (cur_inst>>6) & 1;
                   1294:        value = (cur_inst>>8) & BITMASK(6);
                   1295:        numbit = cur_inst & BITMASK(5);
                   1296: 
                   1297:        dsp_calc_ea(value, addr_name);
                   1298:        if (memspace) {
                   1299:                sprintf(srcname, "y:%s", addr_name);
                   1300:        } else {
                   1301:                sprintf(srcname, "x:%s", addr_name);
                   1302:        }
                   1303: 
1.1.1.4 ! root     1304:        sprintf(str_instr,"jsclr #%d,%s,p:0x%04x",
1.1.1.3   root     1305:                numbit,
                   1306:                srcname,
                   1307:                read_memory(dsp_core->pc+1)
                   1308:        );
1.1       root     1309: }
                   1310: 
1.1.1.3   root     1311: static void dsp_jsclr_pp(void)
1.1       root     1312: {
1.1.1.3   root     1313:        /* jsclr #n,x:pp,p:xx */
                   1314:        /* jsclr #n,y:pp,p:xx */
                   1315:        char srcname[16];
                   1316:        Uint32 memspace, value, numbit;
1.1       root     1317:        
1.1.1.3   root     1318:        disasm_cur_inst_len++;
1.1       root     1319: 
1.1.1.3   root     1320:        memspace = (cur_inst>>6) & 1;
                   1321:        value = (cur_inst>>8) & BITMASK(6);
                   1322:        numbit = cur_inst & BITMASK(5);
1.1       root     1323: 
1.1.1.3   root     1324:        value += 0xffc0;
                   1325:        if (memspace) {
                   1326:                sprintf(srcname, "y:0x%04x", value);
1.1       root     1327:        } else {
1.1.1.3   root     1328:                sprintf(srcname, "x:0x%04x", value);
1.1       root     1329:        }
                   1330: 
1.1.1.4 ! root     1331:        sprintf(str_instr,"jsclr #%d,%s,p:0x%04x",
1.1.1.3   root     1332:                numbit,
                   1333:                srcname,
1.1.1.2   root     1334:                read_memory(dsp_core->pc+1)
1.1       root     1335:        );
                   1336: }
                   1337: 
1.1.1.3   root     1338: static void dsp_jsclr_reg(void)
1.1       root     1339: {
1.1.1.3   root     1340:        /* jsclr #n,R,p:xx */
1.1.1.4 ! root     1341:        Uint32 value, numbit;
1.1.1.3   root     1342:        
                   1343:        disasm_cur_inst_len++;
                   1344: 
                   1345:        value = (cur_inst>>8) & BITMASK(6);
                   1346:        numbit = cur_inst & BITMASK(5);
                   1347: 
1.1.1.4 ! root     1348:        sprintf(str_instr,"jsclr #%d,%s,p:0x%04x",
1.1.1.3   root     1349:                numbit,
1.1.1.4 ! root     1350:                registers_name[value],
1.1.1.2   root     1351:                read_memory(dsp_core->pc+1)
1.1       root     1352:        );
                   1353: }
                   1354: 
1.1.1.3   root     1355: static void dsp_jset_aa(void)
1.1       root     1356: {
1.1.1.3   root     1357:        /* jset #n,x:aa,p:xx */
                   1358:        /* jset #n,y:aa,p:xx */
                   1359:        char srcname[16];
                   1360:        Uint32 memspace, value, numbit;
1.1       root     1361:        
1.1.1.3   root     1362:        disasm_cur_inst_len++;
1.1       root     1363: 
1.1.1.3   root     1364:        memspace = (cur_inst>>6) & 1;
                   1365:        value = (cur_inst>>8) & BITMASK(6);
                   1366:        numbit = cur_inst & BITMASK(5);
                   1367: 
                   1368:        if (memspace) {
                   1369:                sprintf(srcname, "y:0x%04x", value);
1.1       root     1370:        } else {
1.1.1.3   root     1371:                sprintf(srcname, "x:0x%04x", value);
1.1       root     1372:        }
                   1373: 
1.1.1.4 ! root     1374:        sprintf(str_instr,"jset #%d,%s,p:0x%04x",
1.1.1.3   root     1375:                numbit,
                   1376:                srcname,
1.1.1.2   root     1377:                read_memory(dsp_core->pc+1)
1.1       root     1378:        );
                   1379: }
                   1380: 
1.1.1.3   root     1381: static void dsp_jset_ea(void)
1.1       root     1382: {
1.1.1.3   root     1383:        /* jset #n,x:ea,p:xx */
                   1384:        /* jset #n,y:ea,p:xx */
                   1385:        char srcname[16], addr_name[16];
                   1386:        Uint32 memspace, value, numbit;
                   1387:        
                   1388:        disasm_cur_inst_len++;
                   1389: 
                   1390:        memspace = (cur_inst>>6) & 1;
                   1391:        value = (cur_inst>>8) & BITMASK(6);
                   1392:        numbit = cur_inst & BITMASK(5);
                   1393: 
                   1394:        dsp_calc_ea(value, addr_name);
                   1395:        if (memspace) {
                   1396:                sprintf(srcname, "y:%s", addr_name);
                   1397:        } else {
                   1398:                sprintf(srcname, "x:%s", addr_name);
                   1399:        }
                   1400: 
1.1.1.4 ! root     1401:        sprintf(str_instr,"jset #%d,%s,p:0x%04x",
1.1.1.3   root     1402:                numbit,
                   1403:                srcname,
1.1.1.2   root     1404:                read_memory(dsp_core->pc+1)
1.1       root     1405:        );
                   1406: }
                   1407: 
1.1.1.3   root     1408: static void dsp_jset_pp(void)
1.1       root     1409: {
1.1.1.3   root     1410:        /* jset #n,x:pp,p:xx */
                   1411:        /* jset #n,y:pp,p:xx */
                   1412:        char srcname[16];
                   1413:        Uint32 memspace, value, numbit;
                   1414:        
                   1415:        disasm_cur_inst_len++;
1.1       root     1416: 
1.1.1.3   root     1417:        memspace = (cur_inst>>6) & 1;
                   1418:        value = (cur_inst>>8) & BITMASK(6);
                   1419:        numbit = cur_inst & BITMASK(5);
1.1       root     1420: 
1.1.1.3   root     1421:        value += 0xffc0;
                   1422:        if (memspace) {
                   1423:                sprintf(srcname, "y:0x%04x", value);
                   1424:        } else {
                   1425:                sprintf(srcname, "x:0x%04x", value);
1.1       root     1426:        }
                   1427: 
1.1.1.4 ! root     1428:        sprintf(str_instr,"jset #%d,%s,p:0x%04x",
1.1.1.3   root     1429:                numbit,
                   1430:                srcname,
                   1431:                read_memory(dsp_core->pc+1)
                   1432:        );
1.1       root     1433: }
                   1434: 
1.1.1.3   root     1435: static void dsp_jset_reg(void)
1.1       root     1436: {
1.1.1.3   root     1437:        /* jset #n,R,p:xx */
1.1.1.4 ! root     1438:        Uint32 value, numbit;
1.1       root     1439:        
1.1.1.3   root     1440:        disasm_cur_inst_len++;
                   1441: 
1.1       root     1442:        value = (cur_inst>>8) & BITMASK(6);
                   1443:        numbit = cur_inst & BITMASK(5);
                   1444: 
1.1.1.4 ! root     1445:        sprintf(str_instr,"jset #%d,%s,p:0x%04x",
1.1       root     1446:                numbit,
1.1.1.4 ! root     1447:                registers_name[value],
1.1.1.2   root     1448:                read_memory(dsp_core->pc+1)
1.1       root     1449:        );
                   1450: }
                   1451: 
1.1.1.3   root     1452: static void dsp_jsr_imm(void)
1.1       root     1453: {
1.1.1.4 ! root     1454:        sprintf(str_instr,"jsr p:0x%04x", cur_inst & BITMASK(12));
1.1       root     1455: }
                   1456: 
1.1.1.3   root     1457: static void dsp_jsr_ea(void)
1.1       root     1458: {
1.1.1.3   root     1459:        char dstname[16];
1.1       root     1460: 
1.1.1.3   root     1461:        dsp_calc_ea((cur_inst>>8) & BITMASK(6),dstname);
                   1462: 
1.1.1.4 ! root     1463:        sprintf(str_instr,"jsr p:%s", dstname);
1.1       root     1464: }
1.1.1.3   root     1465: 
                   1466: static void dsp_jsset_aa(void)
1.1       root     1467: {
1.1.1.3   root     1468:        /* jsset #n,x:aa,p:xx */
                   1469:        /* jsset #n,y:aa,p:xx */
                   1470:        char srcname[16];
1.1.1.2   root     1471:        Uint32 memspace, value, numbit;
1.1       root     1472:        
1.1.1.3   root     1473:        disasm_cur_inst_len++;
                   1474: 
1.1       root     1475:        memspace = (cur_inst>>6) & 1;
                   1476:        value = (cur_inst>>8) & BITMASK(6);
                   1477:        numbit = cur_inst & BITMASK(5);
                   1478: 
1.1.1.3   root     1479:        if (memspace) {
                   1480:                sprintf(srcname, "y:0x%04x", value);
                   1481:        } else {
                   1482:                sprintf(srcname, "x:0x%04x", value);
1.1       root     1483:        }
                   1484: 
1.1.1.4 ! root     1485:        sprintf(str_instr,"jsset #%d,%s,p:0x%04x",
1.1       root     1486:                numbit,
                   1487:                srcname,
1.1.1.2   root     1488:                read_memory(dsp_core->pc+1)
1.1       root     1489:        );
                   1490: }
                   1491: 
1.1.1.3   root     1492: static void dsp_jsset_ea(void)
1.1       root     1493: {
1.1.1.3   root     1494:        /* jsset #n,x:ea,p:xx */
                   1495:        /* jsset #n,y:ea,p:xx */
1.1       root     1496:        char srcname[16], addr_name[16];
1.1.1.2   root     1497:        Uint32 memspace, value, numbit;
1.1       root     1498:        
1.1.1.3   root     1499:        disasm_cur_inst_len++;
                   1500: 
1.1       root     1501:        memspace = (cur_inst>>6) & 1;
                   1502:        value = (cur_inst>>8) & BITMASK(6);
                   1503:        numbit = cur_inst & BITMASK(5);
                   1504: 
1.1.1.3   root     1505:        dsp_calc_ea(value, addr_name);
                   1506:        if (memspace) {
                   1507:                sprintf(srcname, "y:%s", addr_name);
                   1508:        } else {
                   1509:                sprintf(srcname, "x:%s", addr_name);
1.1       root     1510:        }
                   1511: 
1.1.1.4 ! root     1512:        sprintf(str_instr,"jsset #%d,%s,p:0x%04x",
1.1       root     1513:                numbit,
                   1514:                srcname,
1.1.1.2   root     1515:                read_memory(dsp_core->pc+1)
1.1       root     1516:        );
                   1517: }
                   1518: 
1.1.1.3   root     1519: static void dsp_jsset_pp(void)
1.1       root     1520: {
1.1.1.3   root     1521:        /* jsset #n,x:pp,p:xx */
                   1522:        /* jsset #n,y:pp,p:xx */
                   1523:        char srcname[16];
                   1524:        Uint32 memspace, value, numbit;
                   1525:        
                   1526:        disasm_cur_inst_len++;
                   1527: 
                   1528:        memspace = (cur_inst>>6) & 1;
                   1529:        value = (cur_inst>>8) & BITMASK(6);
                   1530:        numbit = cur_inst & BITMASK(5);
1.1       root     1531: 
1.1.1.3   root     1532:        value += 0xffc0;
                   1533:        if (memspace) {
                   1534:                sprintf(srcname, "y:0x%04x", value);
1.1       root     1535:        } else {
1.1.1.3   root     1536:                sprintf(srcname, "x:0x%04x", value);
1.1       root     1537:        }
                   1538: 
1.1.1.4 ! root     1539:        sprintf(str_instr,"jsset #%d,%s,p:0x%04x",
1.1.1.3   root     1540:                numbit,
                   1541:                srcname,
                   1542:                read_memory(dsp_core->pc+1)
                   1543:        );
1.1       root     1544: }
                   1545: 
1.1.1.3   root     1546: static void dsp_jsset_reg(void)
1.1       root     1547: {
1.1.1.3   root     1548:        /* jsset #n,r,p:xx */
1.1.1.4 ! root     1549:        Uint32 value, numbit;
1.1       root     1550:        
1.1.1.3   root     1551:        disasm_cur_inst_len++;
                   1552: 
1.1       root     1553:        value = (cur_inst>>8) & BITMASK(6);
                   1554:        numbit = cur_inst & BITMASK(5);
                   1555: 
1.1.1.4 ! root     1556:        sprintf(str_instr,"jsset #%d,%s,p:0x%04x",
1.1       root     1557:                numbit,
1.1.1.4 ! root     1558:                registers_name[value],
1.1.1.2   root     1559:                read_memory(dsp_core->pc+1)
1.1       root     1560:        );
                   1561: }
                   1562: 
                   1563: static void dsp_lua(void)
                   1564: {
                   1565:        char addr_name[16], numreg;
                   1566: 
                   1567:        dsp_calc_ea((cur_inst>>8) & BITMASK(5), addr_name);
                   1568:        numreg = cur_inst & BITMASK(3);
                   1569:        
1.1.1.4 ! root     1570:        sprintf(str_instr,"lua %s,r%d", addr_name, numreg);
1.1       root     1571: }
                   1572: 
1.1.1.3   root     1573: static void dsp_movec_reg(void)
1.1       root     1574: {
1.1.1.2   root     1575:        Uint32 numreg1, numreg2;
1.1       root     1576: 
                   1577:        /* S1,D2 */
                   1578:        /* S2,D1 */
                   1579: 
                   1580:        numreg2 = (cur_inst>>8) & BITMASK(6);
1.1.1.3   root     1581:        numreg1 = cur_inst & BITMASK(6);
1.1       root     1582: 
                   1583:        if (cur_inst & (1<<15)) {
                   1584:                /* Write D1 */
1.1.1.4 ! root     1585:                sprintf(str_instr,"movec %s,%s", registers_name[numreg2], registers_name[numreg1]);
1.1       root     1586:        } else {
                   1587:                /* Read S1 */
1.1.1.4 ! root     1588:                sprintf(str_instr,"movec %s,%s", registers_name[numreg1], registers_name[numreg2]);
1.1       root     1589:        }
                   1590: }
                   1591: 
1.1.1.3   root     1592: static void dsp_movec_aa(void)
1.1       root     1593: {
                   1594:        const char *spacename;
                   1595:        char srcname[16],dstname[16];
1.1.1.2   root     1596:        Uint32 numreg, addr;
1.1       root     1597: 
                   1598:        /* x:aa,D1 */
                   1599:        /* S1,x:aa */
                   1600:        /* y:aa,D1 */
                   1601:        /* S1,y:aa */
                   1602: 
1.1.1.3   root     1603:        numreg = cur_inst & BITMASK(6);
1.1       root     1604:        addr = (cur_inst>>8) & BITMASK(6);
                   1605: 
                   1606:        if (cur_inst & (1<<6)) {
                   1607:                spacename="y";
                   1608:        } else {
                   1609:                spacename="x";
                   1610:        }
                   1611: 
                   1612:        if (cur_inst & (1<<15)) {
                   1613:                /* Write D1 */
                   1614:                sprintf(srcname, "%s:0x%04x", spacename, addr);
                   1615:                strcpy(dstname, registers_name[numreg]);
                   1616:        } else {
                   1617:                /* Read S1 */
                   1618:                strcpy(srcname, registers_name[numreg]);
                   1619:                sprintf(dstname, "%s:0x%04x", spacename, addr);
                   1620:        }
                   1621: 
1.1.1.4 ! root     1622:        sprintf(str_instr,"movec %s,%s", srcname, dstname);
1.1       root     1623: }
                   1624: 
1.1.1.3   root     1625: static void dsp_movec_imm(void)
1.1       root     1626: {
1.1.1.2   root     1627:        Uint32 numreg;
1.1       root     1628: 
                   1629:        /* #xx,D1 */
                   1630: 
1.1.1.3   root     1631:        numreg = cur_inst & BITMASK(6);
1.1       root     1632: 
1.1.1.4 ! root     1633:        sprintf(str_instr,"movec #0x%02x,%s", (cur_inst>>8) & BITMASK(8), registers_name[numreg]);
1.1       root     1634: }
                   1635: 
1.1.1.3   root     1636: static void dsp_movec_ea(void)
1.1       root     1637: {
                   1638:        const char *spacename;
                   1639:        char srcname[16], dstname[16], addr_name[16];
1.1.1.2   root     1640:        Uint32 numreg, ea_mode;
1.1       root     1641:        int retour;
                   1642: 
                   1643:        /* x:ea,D1 */
                   1644:        /* S1,x:ea */
                   1645:        /* y:ea,D1 */
                   1646:        /* S1,y:ea */
                   1647:        /* #xxxx,D1 */
                   1648: 
1.1.1.3   root     1649:        numreg = cur_inst & BITMASK(6);
1.1       root     1650:        ea_mode = (cur_inst>>8) & BITMASK(6);
                   1651:        retour = dsp_calc_ea(ea_mode, addr_name);
                   1652: 
                   1653:        if (cur_inst & (1<<6)) {
                   1654:                spacename="y";
                   1655:        } else {
                   1656:                spacename="x";
                   1657:        }
                   1658: 
                   1659:        if (cur_inst & (1<<15)) {
                   1660:                /* Write D1 */
                   1661:                if (retour) {
                   1662:                        sprintf(srcname, "#%s", addr_name);
                   1663:                } else {
                   1664:                        sprintf(srcname, "%s:%s", spacename, addr_name);
                   1665:                }
                   1666:                strcpy(dstname, registers_name[numreg]);
                   1667:        } else {
                   1668:                /* Read S1 */
                   1669:                strcpy(srcname, registers_name[numreg]);
                   1670:                sprintf(dstname, "%s:%s", spacename, addr_name);
                   1671:        }
                   1672: 
1.1.1.4 ! root     1673:        sprintf(str_instr,"movec %s,%s", srcname, dstname);
1.1       root     1674: }
                   1675: 
1.1.1.3   root     1676: static void dsp_movem_aa(void)
1.1       root     1677: {
1.1.1.3   root     1678:        /* S,p:aa */
                   1679:        /* p:aa,D */
1.1       root     1680:        char addr_name[16], srcname[16], dstname[16];
1.1.1.3   root     1681:        Uint32 numreg;
1.1       root     1682: 
1.1.1.3   root     1683:        sprintf(addr_name, "0x%04x",(cur_inst>>8) & BITMASK(6));
1.1       root     1684:        numreg = cur_inst & BITMASK(6);
                   1685:        if  (cur_inst & (1<<15)) {
                   1686:                /* Write D */
                   1687:                sprintf(srcname, "p:%s", addr_name);
                   1688:                strcpy(dstname, registers_name[numreg]);
                   1689:        } else {
                   1690:                /* Read S */
                   1691:                strcpy(srcname, registers_name[numreg]);
                   1692:                sprintf(dstname, "p:%s", addr_name);
                   1693:        }
1.1.1.2   root     1694: 
1.1.1.4 ! root     1695:        sprintf(str_instr,"movem %s,%s", srcname, dstname);
1.1       root     1696: }
                   1697: 
1.1.1.3   root     1698: static void dsp_movem_ea(void)
1.1       root     1699: {
1.1.1.3   root     1700:        /* S,p:ea */
                   1701:        /* p:ea,D */
                   1702:        char addr_name[16], srcname[16], dstname[16];
                   1703:        Uint32 ea_mode, numreg;
1.1       root     1704: 
1.1.1.3   root     1705:        ea_mode = (cur_inst>>8) & BITMASK(6);
                   1706:        dsp_calc_ea(ea_mode, addr_name);
                   1707:        numreg = cur_inst & BITMASK(6);
                   1708:        if  (cur_inst & (1<<15)) {
                   1709:                /* Write D */
                   1710:                sprintf(srcname, "p:%s", addr_name);
                   1711:                strcpy(dstname, registers_name[numreg]);
                   1712:        } else {
                   1713:                /* Read S */
                   1714:                strcpy(srcname, registers_name[numreg]);
                   1715:                sprintf(dstname, "p:%s", addr_name);
                   1716:        }
                   1717: 
1.1.1.4 ! root     1718:        sprintf(str_instr,"movem %s,%s", srcname, dstname);
1.1       root     1719: }
                   1720: 
                   1721: static void dsp_movep_0(void)
                   1722: {
                   1723:        char srcname[16]="",dstname[16]="";
1.1.1.2   root     1724:        Uint32 addr, memspace, numreg;
1.1       root     1725: 
                   1726:        /* S,x:pp */
                   1727:        /* x:pp,D */
                   1728:        /* S,y:pp */
                   1729:        /* y:pp,D */
                   1730: 
                   1731:        addr = 0xffc0 + (cur_inst & BITMASK(6));
                   1732:        memspace = (cur_inst>>16) & 1;
                   1733:        numreg = (cur_inst>>8) & BITMASK(6);
                   1734: 
                   1735:        if (cur_inst & (1<<15)) {
                   1736:                /* Write pp */
                   1737: 
                   1738:                strcpy(srcname, registers_name[numreg]);
                   1739: 
                   1740:                if (memspace) {
                   1741:                        sprintf(dstname, "y:0x%04x", addr);
                   1742:                } else {
                   1743:                        sprintf(dstname, "x:0x%04x", addr);
                   1744:                }
                   1745:        } else {
                   1746:                /* Read pp */
                   1747: 
                   1748:                if (memspace) {
                   1749:                        sprintf(srcname, "y:0x%04x", addr);
                   1750:                } else {
                   1751:                        sprintf(srcname, "x:0x%04x", addr);
                   1752:                }
                   1753: 
                   1754:                strcpy(dstname, registers_name[numreg]);
                   1755:        }
                   1756: 
1.1.1.4 ! root     1757:        sprintf(str_instr,"movep %s,%s", srcname, dstname);
1.1       root     1758: }
                   1759: 
                   1760: static void dsp_movep_1(void)
                   1761: {
                   1762:        char srcname[16]="",dstname[16]="",name[16]="";
1.1.1.2   root     1763:        Uint32 addr, memspace; 
1.1       root     1764: 
                   1765:        /* p:ea,x:pp */
                   1766:        /* x:pp,p:ea */
                   1767:        /* p:ea,y:pp */
                   1768:        /* y:pp,p:ea */
                   1769: 
                   1770:        addr = 0xffc0 + (cur_inst & BITMASK(6));
                   1771:        dsp_calc_ea((cur_inst>>8) & BITMASK(6), name);
                   1772:        memspace = (cur_inst>>16) & 1;
                   1773: 
                   1774:        if (cur_inst & (1<<15)) {
                   1775:                /* Write pp */
                   1776: 
                   1777:                sprintf(srcname, "p:%s", name);
                   1778: 
                   1779:                if (memspace) {
                   1780:                        sprintf(dstname, "y:0x%04x", addr);
                   1781:                } else {
                   1782:                        sprintf(dstname, "x:0x%04x", addr);
                   1783:                }
                   1784:        } else {
                   1785:                /* Read pp */
                   1786: 
                   1787:                if (memspace) {
                   1788:                        sprintf(srcname, "y:0x%04x", addr);
                   1789:                } else {
                   1790:                        sprintf(srcname, "x:0x%04x", addr);
                   1791:                }
                   1792: 
                   1793:                sprintf(dstname, "p:%s", name);
                   1794:        }
                   1795: 
1.1.1.4 ! root     1796:        sprintf(str_instr,"movep %s,%s", srcname, dstname);
1.1       root     1797: }
                   1798: 
1.1.1.3   root     1799: static void dsp_movep_23(void)
1.1       root     1800: {
                   1801:        char srcname[16]="",dstname[16]="",name[16]="";
1.1.1.2   root     1802:        Uint32 addr, memspace, easpace, retour; 
1.1       root     1803: 
                   1804:        /* x:ea,x:pp */
                   1805:        /* y:ea,x:pp */
                   1806:        /* #xxxxxx,x:pp */
                   1807:        /* x:pp,x:ea */
                   1808:        /* x:pp,y:ea */
                   1809: 
                   1810:        /* x:ea,y:pp */
                   1811:        /* y:ea,y:pp */
                   1812:        /* #xxxxxx,y:pp */
                   1813:        /* y:pp,y:ea */
                   1814:        /* y:pp,x:ea */
                   1815: 
                   1816:        addr = 0xffc0 + (cur_inst & BITMASK(6));
                   1817:        retour = dsp_calc_ea((cur_inst>>8) & BITMASK(6), name);
                   1818:        memspace = (cur_inst>>16) & 1;
                   1819:        easpace = (cur_inst>>6) & 1;
                   1820: 
                   1821:        if (cur_inst & (1<<15)) {
                   1822:                /* Write pp */
                   1823: 
                   1824:                if (retour) {
                   1825:                        sprintf(srcname, "#%s", name);
                   1826:                } else {
                   1827:                        if (easpace) {
                   1828:                                sprintf(srcname, "y:%s", name);
                   1829:                        } else {
                   1830:                                sprintf(srcname, "x:%s", name);
                   1831:                        }
                   1832:                }
                   1833: 
                   1834:                if (memspace) {
                   1835:                        sprintf(dstname, "y:0x%04x", addr);
                   1836:                } else {
                   1837:                        sprintf(dstname, "x:0x%04x", addr);
                   1838:                }
                   1839:        } else {
                   1840:                /* Read pp */
                   1841: 
                   1842:                if (memspace) {
                   1843:                        sprintf(srcname, "y:0x%04x", addr);
                   1844:                } else {
                   1845:                        sprintf(srcname, "x:0x%04x", addr);
                   1846:                }
                   1847: 
                   1848:                if (easpace) {
                   1849:                        sprintf(dstname, "y:%s", name);
                   1850:                } else {
                   1851:                        sprintf(dstname, "x:%s", name);
                   1852:                }
                   1853:        }
                   1854: 
1.1.1.4 ! root     1855:        sprintf(str_instr,"movep %s,%s", srcname, dstname);
1.1       root     1856: }
                   1857: 
                   1858: static void dsp_nop(void)
                   1859: {
1.1.1.4 ! root     1860:        sprintf(str_instr,"nop");
1.1       root     1861: }
                   1862: 
                   1863: static void dsp_norm(void)
                   1864: {
1.1.1.2   root     1865:        Uint32 srcreg, destreg;
1.1       root     1866: 
                   1867:        srcreg = DSP_REG_R0+((cur_inst>>8) & BITMASK(3));
                   1868:        destreg = DSP_REG_A+((cur_inst>>3) & 1);
                   1869: 
1.1.1.4 ! root     1870:        sprintf(str_instr,"norm %s,%s", registers_name[srcreg], registers_name[destreg]);
1.1       root     1871: }
                   1872: 
                   1873: static void dsp_ori(void)
                   1874: {
                   1875:        switch(cur_inst & BITMASK(2)) {
                   1876:                case 0:
1.1.1.4 ! root     1877:                        sprintf(str_instr,"ori #0x%02x,mr", (cur_inst>>8) & BITMASK(8));
1.1       root     1878:                        break;
                   1879:                case 1:
1.1.1.4 ! root     1880:                        sprintf(str_instr,"ori #0x%02x,ccr", (cur_inst>>8) & BITMASK(8));
1.1       root     1881:                        break;
                   1882:                case 2:
1.1.1.4 ! root     1883:                        sprintf(str_instr,"ori #0x%02x,omr", (cur_inst>>8) & BITMASK(8));
1.1       root     1884:                        break;
                   1885:                default:
                   1886:                        break;
                   1887:        }
                   1888: 
                   1889: }
                   1890: 
1.1.1.3   root     1891: static void dsp_rep_aa(void)
1.1       root     1892: {
                   1893:        char name[16];
                   1894: 
                   1895:        /* x:aa */
                   1896:        /* y:aa */
                   1897: 
                   1898:        if (cur_inst & (1<<6)) {
                   1899:                sprintf(name, "y:0x%04x",(cur_inst>>8) & BITMASK(6));
                   1900:        } else {
                   1901:                sprintf(name, "x:0x%04x",(cur_inst>>8) & BITMASK(6));
                   1902:        }
                   1903: 
1.1.1.4 ! root     1904:        sprintf(str_instr,"rep %s", name);
1.1       root     1905: }
                   1906: 
1.1.1.3   root     1907: static void dsp_rep_imm(void)
1.1       root     1908: {
                   1909:        /* #xxx */
1.1.1.4 ! root     1910:        sprintf(str_instr,"rep #0x%02x", ((cur_inst>>8) & BITMASK(8))
1.1.1.3   root     1911:                + ((cur_inst & BITMASK(4))<<8));
1.1       root     1912: }
                   1913: 
1.1.1.3   root     1914: static void dsp_rep_ea(void)
1.1       root     1915: {
                   1916:        char name[16],addr_name[16];
                   1917: 
                   1918:        /* x:ea */
                   1919:        /* y:ea */
                   1920: 
                   1921:        dsp_calc_ea((cur_inst>>8) & BITMASK(6), addr_name);
                   1922:        if (cur_inst & (1<<6)) {
                   1923:                sprintf(name, "y:%s",addr_name);
                   1924:        } else {
                   1925:                sprintf(name, "x:%s",addr_name);
                   1926:        }
                   1927: 
1.1.1.4 ! root     1928:        sprintf(str_instr,"rep %s", name);
1.1       root     1929: }
                   1930: 
1.1.1.3   root     1931: static void dsp_rep_reg(void)
1.1       root     1932: {
                   1933:        /* R */
                   1934: 
1.1.1.4 ! root     1935:        sprintf(str_instr,"rep %s", registers_name[(cur_inst>>8) & BITMASK(6)]);
1.1       root     1936: }
                   1937: 
                   1938: static void dsp_reset(void)
                   1939: {
1.1.1.4 ! root     1940:        sprintf(str_instr,"reset");
1.1       root     1941: }
                   1942: 
                   1943: static void dsp_rti(void)
                   1944: {
1.1.1.4 ! root     1945:        sprintf(str_instr,"rti");
1.1       root     1946: }
                   1947: 
                   1948: static void dsp_rts(void)
                   1949: {
1.1.1.4 ! root     1950:        sprintf(str_instr,"rts");
1.1       root     1951: }
                   1952: 
                   1953: static void dsp_stop(void)
                   1954: {
1.1.1.4 ! root     1955:        sprintf(str_instr,"stop");
1.1       root     1956: }
                   1957:        
                   1958: static void dsp_swi(void)
                   1959: {
1.1.1.4 ! root     1960:        sprintf(str_instr,"swi");
1.1       root     1961: }
                   1962: 
                   1963: static void dsp_tcc(void)
                   1964: {
                   1965:        char ccname[16];
1.1.1.2   root     1966:        Uint32 src1reg, dst1reg, src2reg, dst2reg;
1.1       root     1967: 
                   1968:        dsp_calc_cc((cur_inst>>12) & BITMASK(4), ccname);
                   1969:        src1reg = registers_tcc[(cur_inst>>3) & BITMASK(4)][0];
1.1.1.2   root     1970:        dst1reg = registers_tcc[(cur_inst>>3) & BITMASK(4)][1];
1.1       root     1971: 
                   1972:        if (cur_inst & (1<<16)) {
                   1973:                src2reg = DSP_REG_R0+(cur_inst & BITMASK(3));
                   1974:                dst2reg = DSP_REG_R0+((cur_inst>>8) & BITMASK(3));
                   1975: 
1.1.1.4 ! root     1976:                sprintf(str_instr,"t%s %s,%s %s,%s",
1.1       root     1977:                        ccname,
                   1978:                        registers_name[src1reg],
                   1979:                        registers_name[dst1reg],
                   1980:                        registers_name[src2reg],
                   1981:                        registers_name[dst2reg]
                   1982:                );
                   1983:        } else {
1.1.1.4 ! root     1984:                sprintf(str_instr,"t%s %s,%s",
1.1       root     1985:                        ccname,
                   1986:                        registers_name[src1reg],
                   1987:                        registers_name[dst1reg]
                   1988:                );
                   1989:        }
                   1990: }
                   1991: 
                   1992: static void dsp_wait(void)
                   1993: {
1.1.1.4 ! root     1994:        sprintf(str_instr,"wait");
1.1       root     1995: }
                   1996: 
                   1997: /**********************************
                   1998:  *     Parallel moves
                   1999:  **********************************/
                   2000: 
                   2001: static void dsp_pm(void)
                   2002: {
1.1.1.2   root     2003:        Uint32 value;
1.1       root     2004: 
                   2005:        value = (cur_inst >> 20) & BITMASK(4);
                   2006:        opcodes_parmove[value]();
                   2007: }
                   2008: 
                   2009: static void dsp_pm_0(void)
                   2010: {
                   2011:        char space_name[16], addr_name[16];
1.1.1.2   root     2012:        Uint32 memspace, numreg1, numreg2;
1.1       root     2013: /*
                   2014:        0000 100d 00mm mrrr S,x:ea      x0,D
                   2015:        0000 100d 10mm mrrr S,y:ea      y0,D
                   2016: */
                   2017:        memspace = (cur_inst>>15) & 1;
                   2018:        numreg1 = DSP_REG_A+((cur_inst>>16) & 1);
                   2019:        dsp_calc_ea((cur_inst>>8) & BITMASK(6), addr_name);
                   2020: 
                   2021:        if (memspace) {
                   2022:                strcpy(space_name,"y");
                   2023:                numreg2 = DSP_REG_Y0;
                   2024:        } else {
                   2025:                strcpy(space_name,"x");
                   2026:                numreg2 = DSP_REG_X0;
                   2027:        }
                   2028: 
                   2029:        sprintf(parallelmove_name,
                   2030:                "%s,%s:%s %s,%s",
                   2031:                registers_name[numreg1],
                   2032:                space_name,
                   2033:                addr_name,
                   2034:                registers_name[numreg2],
                   2035:                registers_name[numreg1]
                   2036:        );
                   2037: }
                   2038: 
                   2039: static void dsp_pm_1(void)
                   2040: {
                   2041: /*
                   2042:        0001 ffdf w0mm mrrr x:ea,D1             S2,D2
                   2043:                                                S1,x:ea         S2,D2
                   2044:                                                #xxxxxx,D1      S2,D2
                   2045:        0001 deff w1mm mrrr S1,D1               y:ea,D2
                   2046:                                                S1,D1           S2,y:ea
                   2047:                                                S1,D1           #xxxxxx,D2
                   2048: */
                   2049: 
                   2050:        char addr_name[16];
1.1.1.2   root     2051:        Uint32 memspace, write_flag, retour, s1reg, s2reg, d1reg, d2reg;
1.1       root     2052: 
                   2053:        memspace = (cur_inst>>14) & 1;
                   2054:        write_flag = (cur_inst>>15) & 1;
                   2055:        retour = dsp_calc_ea((cur_inst>>8) & BITMASK(6), addr_name);
                   2056: 
                   2057:        if (memspace==DSP_SPACE_Y) {
                   2058:                s2reg = d2reg = DSP_REG_Y0;
                   2059:                switch((cur_inst>>16) & BITMASK(2)) {
                   2060:                        case 0: s2reg = d2reg = DSP_REG_Y0;     break;
                   2061:                        case 1: s2reg = d2reg = DSP_REG_Y1;     break;
                   2062:                        case 2: s2reg = d2reg = DSP_REG_A;      break;
                   2063:                        case 3: s2reg = d2reg = DSP_REG_B;      break;
                   2064:                }
                   2065: 
                   2066:                s1reg = DSP_REG_A+((cur_inst>>19) & 1);
                   2067:                d1reg = DSP_REG_X0+((cur_inst>>18) & 1);
                   2068: 
                   2069:                if (write_flag) {
                   2070:                        /* Write D2 */
                   2071: 
                   2072:                        if (retour) {
                   2073:                                sprintf(parallelmove_name,"%s,%s #%s,%s",
                   2074:                                        registers_name[s1reg],
                   2075:                                        registers_name[d1reg],
                   2076:                                        addr_name,
                   2077:                                        registers_name[d2reg]
                   2078:                                );
                   2079:                        } else {
                   2080:                                sprintf(parallelmove_name,"%s,%s y:%s,%s",
                   2081:                                        registers_name[s1reg],
                   2082:                                        registers_name[d1reg],
                   2083:                                        addr_name,
                   2084:                                        registers_name[d2reg]
                   2085:                                );
                   2086:                        }
                   2087:                } else {
                   2088:                        /* Read S2 */
                   2089:                        sprintf(parallelmove_name,"%s,%s %s,y:%s",
                   2090:                                registers_name[s1reg],
                   2091:                                registers_name[d1reg],
                   2092:                                registers_name[s2reg],
                   2093:                                addr_name
                   2094:                        );
                   2095:                }               
                   2096: 
                   2097:        } else {
                   2098:                s1reg = d1reg = DSP_REG_X0;
                   2099:                switch((cur_inst>>18) & BITMASK(2)) {
                   2100:                        case 0: s1reg = d1reg = DSP_REG_X0;     break;
                   2101:                        case 1: s1reg = d1reg = DSP_REG_X1;     break;
                   2102:                        case 2: s1reg = d1reg = DSP_REG_A;      break;
                   2103:                        case 3: s1reg = d1reg = DSP_REG_B;      break;
                   2104:                }
                   2105: 
                   2106:                s2reg = DSP_REG_A+((cur_inst>>17) & 1);
                   2107:                d2reg = DSP_REG_Y0+((cur_inst>>16) & 1);
                   2108: 
                   2109:                if (write_flag) {
                   2110:                        /* Write D1 */
                   2111: 
                   2112:                        if (retour) {
                   2113:                                sprintf(parallelmove_name,"#%s,%s %s,%s",
                   2114:                                        addr_name,
                   2115:                                        registers_name[d1reg],
                   2116:                                        registers_name[s2reg],
                   2117:                                        registers_name[d2reg]
                   2118:                                );
                   2119:                        } else {
                   2120:                                sprintf(parallelmove_name,"x:%s,%s %s,%s",
                   2121:                                        addr_name,
                   2122:                                        registers_name[d1reg],
                   2123:                                        registers_name[s2reg],
                   2124:                                        registers_name[d2reg]
                   2125:                                );
                   2126:                        }
                   2127:                } else {
                   2128:                        /* Read S1 */
                   2129:                        sprintf(parallelmove_name,"%s,x:%s %s,%s",
                   2130:                                registers_name[s1reg],
                   2131:                                addr_name,
                   2132:                                registers_name[s2reg],
                   2133:                                registers_name[d2reg]
                   2134:                        );
                   2135:                }               
                   2136:        
                   2137:        }
                   2138: }
                   2139: 
                   2140: static void dsp_pm_2(void)
                   2141: {
                   2142:        char addr_name[16];
1.1.1.2   root     2143:        Uint32 numreg1, numreg2;
1.1       root     2144: /*
                   2145:        0010 0000 0000 0000 nop
                   2146:        0010 0000 010m mrrr R update
                   2147:        0010 00ee eeed dddd S,D
                   2148:        001d dddd iiii iiii #xx,D
                   2149: */
                   2150:        if (((cur_inst >> 8) & 0xffff) == 0x2000) {
                   2151:                return;
                   2152:        }
                   2153: 
                   2154:        if (((cur_inst >> 8) & 0xffe0) == 0x2040) {
                   2155:                dsp_calc_ea((cur_inst>>8) & BITMASK(5), addr_name);
                   2156:                sprintf(parallelmove_name, "%s,r%d",addr_name, (cur_inst>>8) & BITMASK(3));
                   2157:                return;
                   2158:        }
                   2159: 
                   2160:        if (((cur_inst >> 8) & 0xfc00) == 0x2000) {
                   2161:                numreg1 = (cur_inst>>13) & BITMASK(5);
                   2162:                numreg2 = (cur_inst>>8) & BITMASK(5);
                   2163:                sprintf(parallelmove_name, "%s,%s", registers_name[numreg1], registers_name[numreg2]); 
                   2164:                return;
                   2165:        }
                   2166: 
                   2167:        numreg1 = (cur_inst>>16) & BITMASK(5);
                   2168:        sprintf(parallelmove_name, "#0x%02x,%s", (cur_inst >> 8) & BITMASK(8), registers_name[numreg1]);
                   2169: }
                   2170: 
                   2171: static void dsp_pm_4(void)
                   2172: {
                   2173:        char addr_name[16];
1.1.1.2   root     2174:        Uint32 value, retour, ea_mode, memspace;
1.1       root     2175: /*
                   2176:        0100 l0ll w0aa aaaa l:aa,D
                   2177:                                                S,l:aa
                   2178:        0100 l0ll w1mm mrrr l:ea,D
                   2179:                                                S,l:ea
                   2180:        01dd 0ddd w0aa aaaa x:aa,D
                   2181:                                                S,x:aa
                   2182:        01dd 0ddd w1mm mrrr x:ea,D
                   2183:                                                S,x:ea
                   2184:                                                #xxxxxx,D
                   2185:        01dd 1ddd w0aa aaaa y:aa,D
                   2186:                                                S,y:aa
                   2187:        01dd 1ddd w1mm mrrr y:ea,D
                   2188:                                                S,y:ea
                   2189:                                                #xxxxxx,D
                   2190: */
                   2191:        value = (cur_inst>>16) & BITMASK(3);
                   2192:        value |= (cur_inst>>17) & (BITMASK(2)<<3);
                   2193: 
                   2194:        ea_mode = (cur_inst>>8) & BITMASK(6);
                   2195: 
                   2196:        if ((value>>2)==0) {
                   2197:                /* L: memory move */
                   2198:                if (cur_inst & (1<<14)) {
                   2199:                        retour = dsp_calc_ea(ea_mode, addr_name);       
                   2200:                } else {
1.1.1.2   root     2201:                        sprintf(addr_name,"0x%04x", ea_mode);
1.1       root     2202:                        retour = 0;
                   2203:                }
                   2204: 
                   2205:                value = (cur_inst>>16) & BITMASK(2);
                   2206:                value |= (cur_inst>>17) & (1<<2);
                   2207: 
                   2208:                if (cur_inst & (1<<15)) {
                   2209:                        /* Write D */
                   2210: 
                   2211:                        if (retour) {
                   2212:                                sprintf(parallelmove_name, "#%s,%s", addr_name, registers_lmove[value]);
                   2213:                        } else {
                   2214:                                sprintf(parallelmove_name, "l:%s,%s", addr_name, registers_lmove[value]);
                   2215:                        }
                   2216:                } else {
                   2217:                        /* Read S */
                   2218:                        sprintf(parallelmove_name, "%s,l:%s", registers_lmove[value], addr_name);
                   2219:                }
                   2220: 
                   2221:                return;
                   2222:        }
                   2223: 
                   2224:        memspace = (cur_inst>>19) & 1;
                   2225:        if (cur_inst & (1<<14)) {
                   2226:                retour = dsp_calc_ea(ea_mode, addr_name);       
                   2227:        } else {
                   2228:                sprintf(addr_name,"0x%04x", ea_mode);
                   2229:                retour = 0;
                   2230:        }
                   2231: 
                   2232:        if (memspace) {
                   2233:                /* Y: */
                   2234: 
                   2235:                if (cur_inst & (1<<15)) {
                   2236:                        /* Write D */
                   2237: 
                   2238:                        if (retour) {
                   2239:                                sprintf(parallelmove_name, "#%s,%s", addr_name, registers_name[value]);
                   2240:                        } else {
                   2241:                                sprintf(parallelmove_name, "y:%s,%s", addr_name, registers_name[value]);
                   2242:                        }
                   2243: 
                   2244:                } else {
                   2245:                        /* Read S */
                   2246:                        sprintf(parallelmove_name, "%s,y:%s", registers_name[value], addr_name);
                   2247:                }
                   2248:        } else {
                   2249:                /* X: */
                   2250: 
                   2251:                if (cur_inst & (1<<15)) {
                   2252:                        /* Write D */
                   2253: 
                   2254:                        if (retour) {
                   2255:                                sprintf(parallelmove_name, "#%s,%s", addr_name, registers_name[value]);
                   2256:                        } else {
                   2257:                                sprintf(parallelmove_name, "x:%s,%s", addr_name, registers_name[value]);
                   2258:                        }
                   2259:                } else {
                   2260:                        /* Read S */
                   2261:                        sprintf(parallelmove_name, "%s,x:%s", registers_name[value], addr_name);
                   2262:                }
                   2263:        }
                   2264: }
                   2265: 
                   2266: static void dsp_pm_8(void)
                   2267: {
                   2268:        char addr1_name[16], addr2_name[16];
1.1.1.2   root     2269:        Uint32 ea_mode1, ea_mode2, numreg1, numreg2;
1.1       root     2270: /*
                   2271:        1wmm eeff WrrM MRRR x:ea,D1             y:ea,D2 
                   2272:                                                x:ea,D1         S2,y:ea
                   2273:                                                S1,x:ea         y:ea,D2
                   2274:                                                S1,x:ea         S2,y:ea
                   2275: */
                   2276:        numreg1 = DSP_REG_X0;
                   2277:        switch((cur_inst>>18) & BITMASK(2)) {
                   2278:                case 0: numreg1 = DSP_REG_X0;   break;
                   2279:                case 1: numreg1 = DSP_REG_X1;   break;
                   2280:                case 2: numreg1 = DSP_REG_A;    break;
                   2281:                case 3: numreg1 = DSP_REG_B;    break;
                   2282:        }
                   2283: 
                   2284:        numreg2 = DSP_REG_Y0;
                   2285:        switch((cur_inst>>16) & BITMASK(2)) {
                   2286:                case 0: numreg2 = DSP_REG_Y0;   break;
                   2287:                case 1: numreg2 = DSP_REG_Y1;   break;
                   2288:                case 2: numreg2 = DSP_REG_A;    break;
                   2289:                case 3: numreg2 = DSP_REG_B;    break;
                   2290:        }
                   2291: 
                   2292:        ea_mode1 = (cur_inst>>8) & BITMASK(5);
                   2293:        if ((ea_mode1>>3) == 0) {
                   2294:                ea_mode1 |= (1<<5);
                   2295:        }
                   2296:        ea_mode2 = (cur_inst>>13) & BITMASK(2);
                   2297:        ea_mode2 |= ((cur_inst>>20) & BITMASK(2))<<3;
                   2298:        if ((ea_mode1 & (1<<2))==0) {
                   2299:                ea_mode2 |= 1<<2;
                   2300:        }
                   2301:        if ((ea_mode2>>3) == 0) {
                   2302:                ea_mode2 |= (1<<5);
                   2303:        }
                   2304: 
                   2305:        dsp_calc_ea(ea_mode1, addr1_name);
                   2306:        dsp_calc_ea(ea_mode2, addr2_name);
                   2307:        
                   2308:        if (cur_inst & (1<<15)) {
                   2309:                if (cur_inst & (1<<22)) {
                   2310:                        sprintf(parallelmove_name, "x:%s,%s y:%s,%s",
                   2311:                                addr1_name,
                   2312:                                registers_name[numreg1],
                   2313:                                addr2_name,
                   2314:                                registers_name[numreg2]
                   2315:                        );
                   2316:                } else {
                   2317:                        sprintf(parallelmove_name, "x:%s,%s %s,y:%s",
                   2318:                                addr1_name,
                   2319:                                registers_name[numreg1],
                   2320:                                registers_name[numreg2],
                   2321:                                addr2_name
                   2322:                        );
                   2323:                }
                   2324:        } else {
                   2325:                if (cur_inst & (1<<22)) {
                   2326:                        sprintf(parallelmove_name, "%s,x:%s y:%s,%s",
                   2327:                                registers_name[numreg1],
                   2328:                                addr1_name,
                   2329:                                addr2_name,
                   2330:                                registers_name[numreg2]
                   2331:                        );
                   2332:                } else {
                   2333:                        sprintf(parallelmove_name, "%s,x:%s %s,y:%s",
                   2334:                                registers_name[numreg1],
                   2335:                                addr1_name,
                   2336:                                registers_name[numreg2],
                   2337:                                addr2_name
                   2338:                        );
                   2339:                }
                   2340:        }       
                   2341: }
                   2342: 
                   2343: 
                   2344: /**********************************
                   2345:  *     Parallel moves ALU instructions
                   2346:  **********************************/
                   2347: 
                   2348: static void dsp_abs(void)
                   2349: {
1.1.1.2   root     2350:        Uint32 numreg;
1.1       root     2351:        
                   2352:        numreg = DSP_REG_A+((cur_inst>>3) & 1);
                   2353: 
1.1.1.4 ! root     2354:        sprintf(str_instr,"abs %s %s", registers_name[numreg], parallelmove_name);
1.1       root     2355: }
                   2356: 
                   2357: static void dsp_adc(void)
                   2358: {
                   2359:        const char *srcname;
1.1.1.2   root     2360:        Uint32 numreg;
1.1       root     2361: 
                   2362:        if (cur_inst & (1<<4)) {
                   2363:                srcname="y";
                   2364:        } else {
                   2365:                srcname="x";
                   2366:        }
                   2367: 
                   2368:        numreg=DSP_REG_A+((cur_inst>>3) & 1);
                   2369: 
1.1.1.4 ! root     2370:        sprintf(str_instr,"adc %s,%s %s",
1.1       root     2371:                srcname,
                   2372:                registers_name[numreg],
                   2373:                parallelmove_name
                   2374:        );
                   2375: }
                   2376: 
                   2377: static void dsp_add(void)
                   2378: {
                   2379:        const char *srcname;
1.1.1.2   root     2380:        Uint32 srcreg, dstreg;
1.1       root     2381:        
                   2382:        srcreg = (cur_inst>>4) & BITMASK(3);
                   2383:        dstreg = (cur_inst>>3) & 1;
                   2384: 
                   2385:        switch(srcreg) {
                   2386:                case 1:
                   2387:                        srcreg = dstreg ^ 1;
                   2388:                        srcname = registers_name[DSP_REG_A+srcreg];
                   2389:                        break;
                   2390:                case 2:
                   2391:                        srcname="x";
                   2392:                        break;
                   2393:                case 3:
                   2394:                        srcname="y";
                   2395:                        break;
1.1.1.2   root     2396:                case 4:
                   2397:                        srcname=registers_name[DSP_REG_X0];
                   2398:                        break;
                   2399:                case 5:
                   2400:                        srcname=registers_name[DSP_REG_Y0];
                   2401:                        break;
                   2402:                case 6:
                   2403:                        srcname=registers_name[DSP_REG_X1];
                   2404:                        break;
                   2405:                case 7:
                   2406:                        srcname=registers_name[DSP_REG_Y1];
1.1       root     2407:                        break;
                   2408:                default:
                   2409:                        srcname="";
                   2410:                        break;
                   2411:        }
                   2412: 
1.1.1.4 ! root     2413:        sprintf(str_instr,"add %s,%s %s",
1.1       root     2414:                srcname,
                   2415:                registers_name[DSP_REG_A+dstreg],
                   2416:                parallelmove_name
                   2417:        );
                   2418: }
                   2419: 
                   2420: static void dsp_addl(void)
                   2421: {
1.1.1.2   root     2422:        Uint32 numreg;
1.1       root     2423: 
                   2424:        numreg = (cur_inst>>3) & 1;
                   2425: 
1.1.1.4 ! root     2426:        sprintf(str_instr,"addl %s,%s %s",
1.1       root     2427:                registers_name[DSP_REG_A+(numreg ^ 1)],
                   2428:                registers_name[DSP_REG_A+numreg],
                   2429:                parallelmove_name
                   2430:        );
                   2431: }
                   2432: 
                   2433: static void dsp_addr(void)
                   2434: {
1.1.1.2   root     2435:        Uint32 numreg;
1.1       root     2436: 
                   2437:        numreg = (cur_inst>>3) & 1;
                   2438: 
1.1.1.4 ! root     2439:        sprintf(str_instr,"addr %s,%s %s",
1.1       root     2440:                registers_name[DSP_REG_A+(numreg ^ 1)],
                   2441:                registers_name[DSP_REG_A+numreg],
                   2442:                parallelmove_name
                   2443:        );
                   2444: }
                   2445: 
                   2446: static void dsp_and(void)
                   2447: {
1.1.1.2   root     2448:        Uint32 srcreg,dstreg;
1.1       root     2449: 
1.1.1.2   root     2450:        switch((cur_inst>>4) & BITMASK(2)) {
                   2451:                case 1:
                   2452:                        srcreg=DSP_REG_Y0;
                   2453:                        break;
                   2454:                case 2:
                   2455:                        srcreg=DSP_REG_X1;
                   2456:                        break;
                   2457:                case 3:
                   2458:                        srcreg=DSP_REG_Y1;
                   2459:                        break;
                   2460:                case 0:
                   2461:                default:
                   2462:                        srcreg=DSP_REG_X0;
                   2463:        }
                   2464:        dstreg = DSP_REG_A+((cur_inst>>3) & 1);
1.1       root     2465: 
1.1.1.4 ! root     2466:        sprintf(str_instr,"and %s,%s %s",
1.1.1.2   root     2467:                registers_name[srcreg],
                   2468:                registers_name[dstreg],
1.1       root     2469:                parallelmove_name
                   2470:        );
                   2471: }
                   2472: 
                   2473: static void dsp_asl(void)
                   2474: {
1.1.1.2   root     2475:        Uint32 numreg;
1.1       root     2476: 
                   2477:        numreg = DSP_REG_A+((cur_inst>>3) & 1);
                   2478: 
1.1.1.4 ! root     2479:        sprintf(str_instr,"asl %s %s",
1.1       root     2480:                registers_name[numreg],
                   2481:                parallelmove_name
                   2482:        );
                   2483: }
                   2484: 
                   2485: static void dsp_asr(void)
                   2486: {
1.1.1.2   root     2487:        Uint32 numreg;
1.1       root     2488: 
                   2489:        numreg = DSP_REG_A+((cur_inst>>3) & 1);
                   2490: 
1.1.1.4 ! root     2491:        sprintf(str_instr,"asr %s %s",
1.1       root     2492:                registers_name[numreg],
                   2493:                parallelmove_name
                   2494:        );
                   2495: }
                   2496: 
                   2497: static void dsp_clr(void)
                   2498: {
1.1.1.2   root     2499:        Uint32 numreg;
1.1       root     2500: 
                   2501:        numreg = DSP_REG_A+((cur_inst>>3) & 1);
                   2502: 
1.1.1.4 ! root     2503:        sprintf(str_instr,"clr %s %s",
1.1       root     2504:                registers_name[numreg],
                   2505:                parallelmove_name
                   2506:        );
                   2507: }
                   2508: 
                   2509: static void dsp_cmp(void)
                   2510: {
1.1.1.2   root     2511:        Uint32 srcreg, dstreg;
1.1       root     2512:        
                   2513:        srcreg = (cur_inst>>4) & BITMASK(3);
                   2514:        dstreg = (cur_inst>>3) & 1;
                   2515: 
                   2516:        switch(srcreg) {
                   2517:                case 0:
                   2518:                        srcreg = DSP_REG_A+(dstreg ^ 1);
                   2519:                        break;
                   2520:                case 4:
                   2521:                        srcreg = DSP_REG_X0;
                   2522:                        break;
                   2523:                case 5:
                   2524:                        srcreg = DSP_REG_Y0;
                   2525:                        break;
                   2526:                case 6:
                   2527:                        srcreg = DSP_REG_X1;
                   2528:                        break;
                   2529:                case 7:
                   2530:                        srcreg = DSP_REG_Y1;
                   2531:                        break;
                   2532:        }
                   2533: 
1.1.1.4 ! root     2534:        sprintf(str_instr,"cmp %s,%s %s",
1.1       root     2535:                registers_name[srcreg],
                   2536:                registers_name[DSP_REG_A+dstreg],
                   2537:                parallelmove_name
                   2538:        );
                   2539: }
                   2540: 
                   2541: static void dsp_cmpm(void)
                   2542: {
1.1.1.2   root     2543:        Uint32 srcreg, dstreg;
1.1       root     2544:        
                   2545:        srcreg = (cur_inst>>4) & BITMASK(3);
                   2546:        dstreg = (cur_inst>>3) & 1;
                   2547: 
                   2548:        switch(srcreg) {
                   2549:                case 0:
                   2550:                        srcreg = DSP_REG_A+(dstreg ^ 1);
                   2551:                        break;
                   2552:                case 4:
                   2553:                        srcreg = DSP_REG_X0;
                   2554:                        break;
                   2555:                case 5:
                   2556:                        srcreg = DSP_REG_Y0;
                   2557:                        break;
                   2558:                case 6:
                   2559:                        srcreg = DSP_REG_X1;
                   2560:                        break;
                   2561:                case 7:
                   2562:                        srcreg = DSP_REG_Y1;
                   2563:                        break;
                   2564:        }
                   2565: 
1.1.1.4 ! root     2566:        sprintf(str_instr,"cmpm %s,%s %s",
1.1       root     2567:                registers_name[srcreg],
                   2568:                registers_name[DSP_REG_A+dstreg],
                   2569:                parallelmove_name
                   2570:        );
                   2571: }
                   2572: 
                   2573: static void dsp_eor(void)
                   2574: {
1.1.1.2   root     2575:        Uint32 srcreg, dstreg;
1.1       root     2576: 
1.1.1.2   root     2577:        switch((cur_inst>>4) & BITMASK(2)) {
                   2578:                case 1:
                   2579:                        srcreg=DSP_REG_Y0;
                   2580:                        break;
                   2581:                case 2:
                   2582:                        srcreg=DSP_REG_X1;
                   2583:                        break;
                   2584:                case 3:
                   2585:                        srcreg=DSP_REG_Y1;
                   2586:                        break;
                   2587:                case 0:
                   2588:                default:
                   2589:                        srcreg=DSP_REG_X0;
                   2590:        }
                   2591:        dstreg = DSP_REG_A+((cur_inst>>3) & 1);
1.1       root     2592: 
1.1.1.4 ! root     2593:        sprintf(str_instr,"eor %s,%s %s",
1.1.1.2   root     2594:                registers_name[srcreg],
                   2595:                registers_name[dstreg],
1.1       root     2596:                parallelmove_name
                   2597:        );
                   2598: }
                   2599: 
                   2600: static void dsp_lsl(void)
                   2601: {
1.1.1.2   root     2602:        Uint32 numreg;
1.1       root     2603: 
                   2604:        numreg = DSP_REG_A+((cur_inst>>3) & 1);
                   2605: 
1.1.1.4 ! root     2606:        sprintf(str_instr,"lsl %s %s",
1.1       root     2607:                registers_name[numreg],
                   2608:                parallelmove_name
                   2609:        );
                   2610: }
                   2611: 
                   2612: static void dsp_lsr(void)
                   2613: {
1.1.1.2   root     2614:        Uint32 numreg;
1.1       root     2615: 
                   2616:        numreg = DSP_REG_A+((cur_inst>>3) & 1);
                   2617: 
1.1.1.4 ! root     2618:        sprintf(str_instr,"lsr %s %s",
1.1       root     2619:                registers_name[numreg],
                   2620:                parallelmove_name
                   2621:        );
                   2622: }
                   2623: 
                   2624: static void dsp_mac(void)
                   2625: {
                   2626:        const char *sign_name;
1.1.1.2   root     2627:        Uint32 src1reg=DSP_REG_NULL, src2reg=DSP_REG_NULL, dstreg;
1.1       root     2628: 
                   2629:        if (cur_inst & (1<<2)) {
                   2630:                sign_name="-";
                   2631:        } else {
                   2632:                sign_name="";
                   2633:        }
                   2634:        
                   2635:        switch((cur_inst>>4) & BITMASK(3)) {
                   2636:                case 0:
                   2637:                        src1reg = DSP_REG_X0;
                   2638:                        src2reg = DSP_REG_X0;
                   2639:                        break;
                   2640:                case 1:
                   2641:                        src1reg = DSP_REG_Y0;
                   2642:                        src2reg = DSP_REG_Y0;
                   2643:                        break;
                   2644:                case 2:
                   2645:                        src1reg = DSP_REG_X1;
                   2646:                        src2reg = DSP_REG_X0;
                   2647:                        break;
                   2648:                case 3:
                   2649:                        src1reg = DSP_REG_Y1;
                   2650:                        src2reg = DSP_REG_Y0;
                   2651:                        break;
                   2652:                case 4:
                   2653:                        src1reg = DSP_REG_X0;
                   2654:                        src2reg = DSP_REG_Y1;
                   2655:                        break;
                   2656:                case 5:
                   2657:                        src1reg = DSP_REG_Y0;
                   2658:                        src2reg = DSP_REG_X0;
                   2659:                        break;
                   2660:                case 6:
                   2661:                        src1reg = DSP_REG_X1;
                   2662:                        src2reg = DSP_REG_Y0;
                   2663:                        break;
                   2664:                case 7:
                   2665:                        src1reg = DSP_REG_Y1;
                   2666:                        src2reg = DSP_REG_X1;
                   2667:                        break;
                   2668:        }
                   2669:        dstreg = (cur_inst>>3) & 1;
                   2670: 
1.1.1.4 ! root     2671:        sprintf(str_instr,"mac %s%s,%s,%s %s",
1.1       root     2672:                sign_name,
                   2673:                registers_name[src1reg],
                   2674:                registers_name[src2reg],
                   2675:                registers_name[DSP_REG_A+dstreg],
                   2676:                parallelmove_name
                   2677:        );
                   2678: }
                   2679: 
                   2680: static void dsp_macr(void)
                   2681: {
                   2682:        const char *sign_name;
1.1.1.2   root     2683:        Uint32 src1reg=DSP_REG_NULL, src2reg=DSP_REG_NULL, dstreg;
1.1       root     2684: 
                   2685:        if (cur_inst & (1<<2)) {
                   2686:                sign_name="-";
                   2687:        } else {
                   2688:                sign_name="";
                   2689:        }
                   2690:        
                   2691:        switch((cur_inst>>4) & BITMASK(3)) {
                   2692:                case 0:
                   2693:                        src1reg = DSP_REG_X0;
                   2694:                        src2reg = DSP_REG_X0;
                   2695:                        break;
                   2696:                case 1:
                   2697:                        src1reg = DSP_REG_Y0;
                   2698:                        src2reg = DSP_REG_Y0;
                   2699:                        break;
                   2700:                case 2:
                   2701:                        src1reg = DSP_REG_X1;
                   2702:                        src2reg = DSP_REG_X0;
                   2703:                        break;
                   2704:                case 3:
                   2705:                        src1reg = DSP_REG_Y1;
                   2706:                        src2reg = DSP_REG_Y0;
                   2707:                        break;
                   2708:                case 4:
                   2709:                        src1reg = DSP_REG_X0;
                   2710:                        src2reg = DSP_REG_Y1;
                   2711:                        break;
                   2712:                case 5:
                   2713:                        src1reg = DSP_REG_Y0;
                   2714:                        src2reg = DSP_REG_X0;
                   2715:                        break;
                   2716:                case 6:
                   2717:                        src1reg = DSP_REG_X1;
                   2718:                        src2reg = DSP_REG_Y0;
                   2719:                        break;
                   2720:                case 7:
                   2721:                        src1reg = DSP_REG_Y1;
                   2722:                        src2reg = DSP_REG_X1;
                   2723:                        break;
                   2724:        }
                   2725:        dstreg = (cur_inst>>3) & 1;
                   2726: 
1.1.1.4 ! root     2727:        sprintf(str_instr,"macr %s%s,%s,%s %s",
1.1       root     2728:                sign_name,
                   2729:                registers_name[src1reg],
                   2730:                registers_name[src2reg],
                   2731:                registers_name[DSP_REG_A+dstreg],
                   2732:                parallelmove_name
                   2733:        );
                   2734: }
                   2735: 
                   2736: static void dsp_move(void)
                   2737: {
1.1.1.4 ! root     2738:        sprintf(str_instr,"move %s", parallelmove_name);
1.1       root     2739: }
                   2740: 
                   2741: static void dsp_mpy(void)
                   2742: {
                   2743:        const char *sign_name;
1.1.1.2   root     2744:        Uint32 src1reg=DSP_REG_NULL, src2reg=DSP_REG_NULL, dstreg;
1.1       root     2745: 
                   2746:        if (cur_inst & (1<<2)) {
                   2747:                sign_name="-";
                   2748:        } else {
                   2749:                sign_name="";
                   2750:        }
                   2751:        
                   2752:        switch((cur_inst>>4) & BITMASK(3)) {
                   2753:                case 0:
                   2754:                        src1reg = DSP_REG_X0;
                   2755:                        src2reg = DSP_REG_X0;
                   2756:                        break;
                   2757:                case 1:
                   2758:                        src1reg = DSP_REG_Y0;
                   2759:                        src2reg = DSP_REG_Y0;
                   2760:                        break;
                   2761:                case 2:
                   2762:                        src1reg = DSP_REG_X1;
                   2763:                        src2reg = DSP_REG_X0;
                   2764:                        break;
                   2765:                case 3:
                   2766:                        src1reg = DSP_REG_Y1;
                   2767:                        src2reg = DSP_REG_Y0;
                   2768:                        break;
                   2769:                case 4:
                   2770:                        src1reg = DSP_REG_X0;
                   2771:                        src2reg = DSP_REG_Y1;
                   2772:                        break;
                   2773:                case 5:
                   2774:                        src1reg = DSP_REG_Y0;
                   2775:                        src2reg = DSP_REG_X0;
                   2776:                        break;
                   2777:                case 6:
                   2778:                        src1reg = DSP_REG_X1;
                   2779:                        src2reg = DSP_REG_Y0;
                   2780:                        break;
                   2781:                case 7:
                   2782:                        src1reg = DSP_REG_Y1;
                   2783:                        src2reg = DSP_REG_X1;
                   2784:                        break;
                   2785:        }
                   2786:        dstreg = (cur_inst>>3) & 1;
                   2787: 
1.1.1.4 ! root     2788:        sprintf(str_instr,"mpy %s%s,%s,%s %s",
1.1       root     2789:                sign_name,
                   2790:                registers_name[src1reg],
                   2791:                registers_name[src2reg],
                   2792:                registers_name[DSP_REG_A+dstreg],
                   2793:                parallelmove_name
                   2794:        );
                   2795: }
                   2796: 
                   2797: static void dsp_mpyr(void)
                   2798: {
                   2799:        const char *sign_name;
1.1.1.2   root     2800:        Uint32 src1reg=DSP_REG_NULL, src2reg=DSP_REG_NULL, dstreg;
1.1       root     2801: 
                   2802:        if (cur_inst & (1<<2)) {
                   2803:                sign_name="-";
                   2804:        } else {
                   2805:                sign_name="";
                   2806:        }
                   2807:        
                   2808:        switch((cur_inst>>4) & BITMASK(3)) {
                   2809:                case 0:
                   2810:                        src1reg = DSP_REG_X0;
                   2811:                        src2reg = DSP_REG_X0;
                   2812:                        break;
                   2813:                case 1:
                   2814:                        src1reg = DSP_REG_Y0;
                   2815:                        src2reg = DSP_REG_Y0;
                   2816:                        break;
                   2817:                case 2:
                   2818:                        src1reg = DSP_REG_X1;
                   2819:                        src2reg = DSP_REG_X0;
                   2820:                        break;
                   2821:                case 3:
                   2822:                        src1reg = DSP_REG_Y1;
                   2823:                        src2reg = DSP_REG_Y0;
                   2824:                        break;
                   2825:                case 4:
                   2826:                        src1reg = DSP_REG_X0;
                   2827:                        src2reg = DSP_REG_Y1;
                   2828:                        break;
                   2829:                case 5:
                   2830:                        src1reg = DSP_REG_Y0;
                   2831:                        src2reg = DSP_REG_X0;
                   2832:                        break;
                   2833:                case 6:
                   2834:                        src1reg = DSP_REG_X1;
                   2835:                        src2reg = DSP_REG_Y0;
                   2836:                        break;
                   2837:                case 7:
                   2838:                        src1reg = DSP_REG_Y1;
                   2839:                        src2reg = DSP_REG_X1;
                   2840:                        break;
                   2841:        }
                   2842:        dstreg = (cur_inst>>3) & 1;
                   2843: 
1.1.1.4 ! root     2844:        sprintf(str_instr,"mpyr %s%s,%s,%s %s",
1.1       root     2845:                sign_name,
                   2846:                registers_name[src1reg],
                   2847:                registers_name[src2reg],
                   2848:                registers_name[DSP_REG_A+dstreg],
                   2849:                parallelmove_name
                   2850:        );
                   2851: }
                   2852: 
                   2853: static void dsp_neg(void)
                   2854: {
1.1.1.2   root     2855:        Uint32 numreg;
1.1       root     2856: 
                   2857:        numreg = DSP_REG_A+((cur_inst>>3) & 1);
                   2858: 
1.1.1.4 ! root     2859:        sprintf(str_instr,"neg %s %s",
1.1       root     2860:                registers_name[numreg],
                   2861:                parallelmove_name
                   2862:        );
                   2863: }
                   2864: 
                   2865: static void dsp_not(void)
                   2866: {
1.1.1.2   root     2867:        Uint32 numreg;
1.1       root     2868: 
                   2869:        numreg = DSP_REG_A+((cur_inst>>3) & 1);
                   2870: 
1.1.1.4 ! root     2871:        sprintf(str_instr,"not %s %s",
1.1       root     2872:                registers_name[numreg],
                   2873:                parallelmove_name
                   2874:        );
                   2875: }
                   2876: 
                   2877: static void dsp_or(void)
                   2878: {
1.1.1.2   root     2879:        Uint32 srcreg, dstreg;
1.1       root     2880: 
1.1.1.2   root     2881:        switch((cur_inst>>4) & BITMASK(2)) {
                   2882:                case 1:
                   2883:                        srcreg=DSP_REG_Y0;
                   2884:                        break;
                   2885:                case 2:
                   2886:                        srcreg=DSP_REG_X1;
                   2887:                        break;
                   2888:                case 3:
                   2889:                        srcreg=DSP_REG_Y1;
                   2890:                        break;
                   2891:                case 0:
                   2892:                default:
                   2893:                        srcreg=DSP_REG_X0;
                   2894:        }
                   2895:        dstreg = DSP_REG_A+((cur_inst>>3) & 1);
1.1       root     2896: 
1.1.1.4 ! root     2897:        sprintf(str_instr,"or %s,%s %s",
1.1.1.2   root     2898:                registers_name[srcreg],
                   2899:                registers_name[dstreg],
1.1       root     2900:                parallelmove_name
                   2901:        );
                   2902: }
                   2903: 
                   2904: static void dsp_rnd(void)
                   2905: {
1.1.1.2   root     2906:        Uint32 numreg;
1.1       root     2907: 
                   2908:        numreg = DSP_REG_A+((cur_inst>>3) & 1);
                   2909: 
1.1.1.4 ! root     2910:        sprintf(str_instr,"rnd %s %s",
1.1       root     2911:                registers_name[numreg],
                   2912:                parallelmove_name
                   2913:        );
                   2914: }
                   2915: 
                   2916: static void dsp_rol(void)
                   2917: {
1.1.1.2   root     2918:        Uint32 numreg;
1.1       root     2919: 
                   2920:        numreg = DSP_REG_A+((cur_inst>>3) & 1);
                   2921: 
1.1.1.4 ! root     2922:        sprintf(str_instr,"rol %s %s",
1.1       root     2923:                registers_name[numreg],
                   2924:                parallelmove_name
                   2925:        );
                   2926: }
                   2927: 
                   2928: static void dsp_ror(void)
                   2929: {
1.1.1.2   root     2930:        Uint32 numreg;
1.1       root     2931: 
                   2932:        numreg = DSP_REG_A+((cur_inst>>3) & 1);
                   2933: 
1.1.1.4 ! root     2934:        sprintf(str_instr,"ror %s %s",
1.1       root     2935:                registers_name[numreg],
                   2936:                parallelmove_name
                   2937:        );
                   2938: }
                   2939: 
                   2940: static void dsp_sbc(void)
                   2941: {
                   2942:        const char *srcname;
1.1.1.2   root     2943:        Uint32 numreg;
1.1       root     2944: 
                   2945:        if (cur_inst & (1<<4)) {
                   2946:                srcname="y";
                   2947:        } else {
                   2948:                srcname="x";
                   2949:        }
                   2950: 
                   2951:        numreg = DSP_REG_A+((cur_inst>>3) & 1);
                   2952: 
1.1.1.4 ! root     2953:        sprintf(str_instr,"sbc %s,%s %s",
1.1       root     2954:                srcname,
                   2955:                registers_name[numreg],
                   2956:                parallelmove_name
                   2957:        );
                   2958: }
                   2959: 
                   2960: static void dsp_sub(void)
                   2961: {
                   2962:        const char *srcname;
1.1.1.2   root     2963:        Uint32 srcreg, dstreg;
1.1       root     2964:        
                   2965:        srcreg = (cur_inst>>4) & BITMASK(3);
                   2966:        dstreg = (cur_inst>>3) & 1;
                   2967: 
                   2968:        switch(srcreg) {
                   2969:                case 1:
                   2970:                        srcreg = dstreg ^ 1;
                   2971:                        srcname = registers_name[DSP_REG_A+srcreg];
                   2972:                        break;
                   2973:                case 2:
                   2974:                        srcname="x";
                   2975:                        break;
                   2976:                case 3:
                   2977:                        srcname="y";
                   2978:                        break;
1.1.1.2   root     2979:                case 4:
                   2980:                        srcname=registers_name[DSP_REG_X0];
                   2981:                        break;
                   2982:                case 5:
                   2983:                        srcname=registers_name[DSP_REG_Y0];
                   2984:                        break;
                   2985:                case 6:
                   2986:                        srcname=registers_name[DSP_REG_X1];
                   2987:                        break;
                   2988:                case 7:
                   2989:                        srcname=registers_name[DSP_REG_Y1];
1.1       root     2990:                        break;
                   2991:                default:
                   2992:                        srcname="";
                   2993:                        break;
                   2994:        }
                   2995: 
1.1.1.4 ! root     2996:        sprintf(str_instr,"sub %s,%s %s",
1.1       root     2997:                srcname,
                   2998:                registers_name[DSP_REG_A+dstreg],
                   2999:                parallelmove_name
                   3000:        );
                   3001: }
                   3002: 
                   3003: static void dsp_subl(void)
                   3004: {
1.1.1.2   root     3005:        Uint32 numreg;
1.1       root     3006: 
                   3007:        numreg = (cur_inst>>3) & 1;
                   3008: 
1.1.1.4 ! root     3009:        sprintf(str_instr,"subl %s,%s %s",
1.1       root     3010:                registers_name[DSP_REG_A+(numreg ^ 1)],
                   3011:                registers_name[DSP_REG_A+numreg],
                   3012:                parallelmove_name
                   3013:        );
                   3014: }
                   3015: 
                   3016: static void dsp_subr(void)
                   3017: {
1.1.1.2   root     3018:        Uint32 numreg;
1.1       root     3019: 
                   3020:        numreg = (cur_inst>>3) & 1;
                   3021: 
1.1.1.4 ! root     3022:        sprintf(str_instr,"subr %s,%s %s",
1.1       root     3023:                registers_name[DSP_REG_A+(numreg ^ 1)],
                   3024:                registers_name[DSP_REG_A+numreg],
                   3025:                parallelmove_name
                   3026:        );
                   3027: }
                   3028: 
                   3029: static void dsp_tfr(void)
                   3030: {
1.1.1.2   root     3031:        Uint32 srcreg, dstreg;
1.1       root     3032:        
                   3033:        srcreg = (cur_inst>>4) & BITMASK(3);
                   3034:        dstreg = (cur_inst>>3) & 1;
                   3035: 
1.1.1.2   root     3036:        switch(srcreg) {
                   3037:                case 4:
                   3038:                        srcreg = DSP_REG_X0;
                   3039:                        break;
                   3040:                case 5:
                   3041:                        srcreg = DSP_REG_Y0;
                   3042:                        break;
                   3043:                case 6:
                   3044:                        srcreg = DSP_REG_X1;
                   3045:                        break;
                   3046:                case 7:
                   3047:                        srcreg = DSP_REG_Y1;
                   3048:                        break;
                   3049:                case 0:
                   3050:                default:
                   3051:                        srcreg = DSP_REG_A+(dstreg ^ 1);
                   3052:                        break;
1.1       root     3053:        }
                   3054: 
1.1.1.4 ! root     3055:        sprintf(str_instr,"tfr %s,%s %s",
1.1       root     3056:                registers_name[srcreg],
                   3057:                registers_name[DSP_REG_A+dstreg],
                   3058:                parallelmove_name
                   3059:        );
                   3060: }
                   3061: 
                   3062: static void dsp_tst(void)
                   3063: {
1.1.1.4 ! root     3064:        sprintf(str_instr,"tst %s %s",
1.1       root     3065:                registers_name[DSP_REG_A+((cur_inst>>3) & 1)],
                   3066:                parallelmove_name
                   3067:        );
                   3068: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.