--- hatari/src/falcon/dsp_cpu.c 2019/04/01 07:14:55 1.1.1.2 +++ hatari/src/falcon/dsp_cpu.c 2019/04/01 07:15:35 1.1.1.3 @@ -153,18 +153,18 @@ static void dsp_swi(void); static void dsp_tcc(void); static void dsp_wait(void); -static void dsp_do_0(void); -static void dsp_do_2(void); -static void dsp_do_4(void); -static void dsp_do_c(void); -static void dsp_rep_1(void); -static void dsp_rep_3(void); -static void dsp_rep_5(void); -static void dsp_rep_d(void); -static void dsp_movec_7(void); -static void dsp_movec_9(void); -static void dsp_movec_b(void); -static void dsp_movec_d(void); +static void dsp_do_ea(void); +static void dsp_do_aa(void); +static void dsp_do_imm(void); +static void dsp_do_reg(void); +static void dsp_rep_aa(void); +static void dsp_rep_ea(void); +static void dsp_rep_imm(void); +static void dsp_rep_reg(void); +static void dsp_movec_aa(void); +static void dsp_movec_ea(void); +static void dsp_movec_imm(void); +static void dsp_movec_reg(void); static void dsp_movep_0(void); static void dsp_movep_1(void); static void dsp_movep_2(void); @@ -467,70 +467,40 @@ static dsp_emul_t opcodes_alu80ff[4]={ dsp_macr }; -static dsp_emul_t opcodes_do[16]={ - dsp_do_0, - dsp_undefined, - dsp_do_2, - dsp_undefined, - - dsp_do_4, - dsp_undefined, - dsp_do_2, - dsp_undefined, +static dsp_emul_t opcodes_do[8]={ + dsp_do_aa, + dsp_do_imm, + dsp_do_ea, + dsp_do_imm, dsp_undefined, - dsp_undefined, - dsp_do_2, - dsp_undefined, - - dsp_do_c, - dsp_undefined, - dsp_do_2, - dsp_undefined + dsp_do_imm, + dsp_do_reg, + dsp_do_imm }; -static dsp_emul_t opcodes_rep[16]={ - dsp_undefined, - dsp_rep_1, - dsp_undefined, - dsp_rep_3, +static dsp_emul_t opcodes_rep[8]={ + dsp_rep_aa, + dsp_rep_imm, + dsp_rep_ea, + dsp_rep_imm, dsp_undefined, - dsp_rep_5, - dsp_undefined, - dsp_rep_3, - - dsp_undefined, - dsp_undefined, - dsp_undefined, - dsp_rep_3, - - dsp_undefined, - dsp_rep_d, - dsp_undefined, - dsp_rep_3 + dsp_rep_imm, + dsp_rep_reg, + dsp_rep_imm }; -static dsp_emul_t opcodes_movec[16]={ +static dsp_emul_t opcodes_movec[8]={ dsp_undefined, dsp_undefined, dsp_undefined, - dsp_undefined, - - dsp_undefined, - dsp_undefined, - dsp_undefined, - dsp_movec_7, + dsp_movec_reg, - dsp_undefined, - dsp_movec_9, - dsp_undefined, - dsp_movec_b, - - dsp_undefined, - dsp_movec_d, - dsp_undefined, - dsp_movec_b + dsp_movec_aa, + dsp_movec_imm, + dsp_movec_ea, + dsp_movec_imm }; static dsp_emul_t opcodes_movep[4]={ @@ -1402,11 +1372,11 @@ static void opcode8h_0(void) static void opcode8h_1(void) { - switch(cur_inst & 0xfff8c7) { - case 0x018040: + switch(cur_inst & 0xfff000) { + case 0x018000: dsp_div(); break; - case 0x01c805: + case 0x01d000: dsp_norm(); break; } @@ -1745,11 +1715,11 @@ static void dsp_div(void) destreg = DSP_REG_A+((cur_inst>>3) & 1); source[0] = 0; - source[1] = dsp_core->registers[srcreg]; - if (source[1] & (1<<23)) { - source[0] = 0xff; - } - source[2] = 0; + source[1] = dsp_core->registers[srcreg]; + if (source[1] & (1<<23)) { + source[0] = 0xff; + } + source[2] = 0; dest[0] = dsp_core->registers[DSP_REG_A2+(destreg & 1)]; dest[1] = dsp_core->registers[DSP_REG_A1+(destreg & 1)]; @@ -1777,6 +1747,15 @@ static void dsp_div(void) dsp_core->registers[DSP_REG_SR] |= newsr & (1<registers[DSP_REG_SR] |= (1<>12) & (BITMASK(2)<<2); - value |= (cur_inst>>6) & 1<<1; - value |= (cur_inst>>5) & 1; + value = ((cur_inst>>14) & BITMASK(2))<<1; + value |= (cur_inst>>7) & 1; opcodes_do[value](); } -static void dsp_do_0(void) +static void dsp_do_aa(void) { Uint32 memspace, addr; @@ -1809,14 +1787,15 @@ static void dsp_do_0(void) dsp_core->registers[DSP_REG_LC] = read_memory(memspace, addr) & BITMASK(16); } -static void dsp_do_2(void) +static void dsp_do_imm(void) { /* #xx */ - dsp_core->registers[DSP_REG_LC] = (cur_inst>>8) & BITMASK(8); - dsp_core->registers[DSP_REG_LC] |= (cur_inst & BITMASK(4))<<8; + + dsp_core->registers[DSP_REG_LC] = ((cur_inst>>8) & BITMASK(8)) + + ((cur_inst & BITMASK(4))<<8); } -static void dsp_do_4(void) +static void dsp_do_ea(void) { Uint32 memspace, ea_mode, addr; @@ -1829,7 +1808,7 @@ static void dsp_do_4(void) dsp_core->registers[DSP_REG_LC] = read_memory(memspace, addr) & BITMASK(16); } -static void dsp_do_c(void) +static void dsp_do_reg(void) { Uint32 numreg; @@ -2189,19 +2168,26 @@ static void dsp_lua(void) } } +/* + MOVEC instruction parameter encoding + + xxxxxxx0 x1xxxxxx 1xxxxxxx reg + xxxxxxx1 x0xxxxxx 0xxxxxxx aa + xxxxxxx1 x1xxxxxx 0xxxxxxx ea + xxxxxxx1 xYxxxxxx 1xxxxxxx #xx +*/ static void dsp_movec(void) { Uint32 value; - - value = (cur_inst>>13) & (1<<3); - value |= (cur_inst>>12) & (1<<2); - value |= (cur_inst>>6) & (1<<1); - value |= (cur_inst>>5) & 1; + + value = ((cur_inst>>16) & 1)<<2; + value |= ((cur_inst>>14) & 1)<<1; + value |= (cur_inst>>7) & 1; opcodes_movec[value](); } -static void dsp_movec_7(void) +static void dsp_movec_reg(void) { Uint32 numreg1, numreg2, value; @@ -2238,7 +2224,7 @@ static void dsp_movec_7(void) } } -static void dsp_movec_9(void) +static void dsp_movec_aa(void) { Uint32 numreg, addr, memspace; @@ -2263,7 +2249,7 @@ static void dsp_movec_9(void) } } -static void dsp_movec_b(void) +static void dsp_movec_imm(void) { Uint32 numreg; @@ -2273,7 +2259,7 @@ static void dsp_movec_b(void) dsp_core->registers[numreg] = (cur_inst>>8) & BITMASK(8); } -static void dsp_movec_d(void) +static void dsp_movec_ea(void) { Uint32 numreg, addr, memspace, ea_mode; int retour; @@ -2528,22 +2514,30 @@ static void dsp_ori(void) } } +/* + REP instruction parameter encoding + + xxxxxxxx 00xxxxxx 0xxxxxxx aa + xxxxxxxx 01xxxxxx 0xxxxxxx ea + xxxxxxxx YYxxxxxx 1xxxxxxx imm + xxxxxxxx 11xxxxxx 0xxxxxxx reg +*/ + static void dsp_rep(void) { Uint32 value; dsp_core->registers[DSP_REG_LCSAVE] = dsp_core->registers[DSP_REG_LC]; - value = (cur_inst>>12) & (BITMASK(2)<<2); - value |= (cur_inst>>6) & (1<<1); - value |= (cur_inst>>5) & 1; + value = ((cur_inst>>14) & BITMASK(2))<<1; + value |= (cur_inst>>7) & 1; opcodes_rep[value](); pc_on_rep = 1; /* Not decrement LC at first time */ dsp_core->loop_rep = 1; /* We are now running rep */ } -static void dsp_rep_1(void) +static void dsp_rep_aa(void) { /* x:aa */ /* y:aa */ @@ -2551,14 +2545,15 @@ static void dsp_rep_1(void) dsp_core->registers[DSP_REG_LC]=read_memory((cur_inst>>6) & 1,(cur_inst>>8) & BITMASK(6)); } -static void dsp_rep_3(void) +static void dsp_rep_imm(void) { /* #xxx */ - dsp_core->registers[DSP_REG_LC]= (cur_inst>>8) & BITMASK(8); + dsp_core->registers[DSP_REG_LC] = ((cur_inst>>8) & BITMASK(8)) + + ((cur_inst & BITMASK(4))<<8); } -static void dsp_rep_5(void) +static void dsp_rep_ea(void) { Uint32 value; @@ -2569,7 +2564,7 @@ static void dsp_rep_5(void) dsp_core->registers[DSP_REG_LC]= read_memory((cur_inst>>6) & 1, value); } -static void dsp_rep_d(void) +static void dsp_rep_reg(void) { Uint32 numreg;