From a14401b261d8f38f30676f993acbc1def7482c22 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Wed, 2 Feb 2022 15:14:31 -0400 Subject: sux.c, sux.h: Add code for using the new instruction handler. --- sux.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'sux.c') diff --git a/sux.c b/sux.c index dce4d29..5df1ad3 100644 --- a/sux.c +++ b/sux.c @@ -185,10 +185,10 @@ void *run(void *args) { #endif address.u64 = 0; value.u64 = 0; - uint32_t inst = read_value(cpu, 0, cpu->pc, 4, 1, 0); - uint8_t *tmp_inst = (uint8_t *)&inst; + uint32_t instr = read_value(cpu, 0, cpu->pc, 4, 1, 0); + uint8_t *tmp_inst = (uint8_t *)&instr; uint8_t inst_len = 0; - prefix = ((inst & 3) == 3) ? tmp_inst[inst_len++] : 0; + prefix = ((instr & 3) == 3) ? tmp_inst[inst_len++] : 0; ext_prefix = ((tmp_inst[inst_len] & 0xF) == 0xD) ? tmp_inst[inst_len++] : 0; opcode = tmp_inst[inst_len++]; op_id = (ext_prefix == 0x1D) ? tmp_inst[inst_len++] : 0; @@ -200,6 +200,7 @@ void *run(void *args) { uint8_t tmp_opcode = opcode; uint8_t tmp_ext_prefix = ext_prefix; int is_ortho = 0; + int is_ext = 0; if (ext_prefix) { ext_id = (ext_prefix >> 4); switch (ext_id) { @@ -207,6 +208,7 @@ void *run(void *args) { am = ext_optype[opcode]; if (!is_extop(opcode, 0)) { tmp_ext_prefix = 0; + is_ext = 1; switch (opcode) { case ADC_E: tmp_opcode = ADC_IMM; break; case SBC_E: tmp_opcode = SBC_IMM; break; @@ -282,14 +284,16 @@ void *run(void *args) { cpu->pc = address.u64; } #endif - if (am != IMPL && am != BREG) { - address.u64 = get_addr(cpu, opcode, prefix, ext_prefix, 1, 1, thread); - /*if (address.u64 > mem_size-1) { - addr[STEP_ADDR] = 1; - step = 1; - }*/ - if (isrw(opcode, ext_prefix) && am != REL && isread(opcode, ext_prefix)) { - value.u64 = read_value(cpu, 0, address.u64, size, 1, check_io); + if (ext_prefix && ext_id == 0) { + if (am != IMPL && am != BREG) { + address.u64 = get_addr(cpu, opcode, prefix, ext_prefix, 1, 1, thread); + /*if (address.u64 > mem_size-1) { + addr[STEP_ADDR] = 1; + step = 1; + }*/ + if (isrw(opcode, ext_prefix) && am != REL && isread(opcode, ext_prefix)) { + value.u64 = read_value(cpu, 0, address.u64, size, 1, check_io); + } } } /*decode_microinst(&uc, &uc_test, prefix, 0);*/ @@ -302,7 +306,13 @@ void *run(void *args) { case 0x1: exec_ortho_inst(cpu, opcode, prefix, size, operand_type, ortho_id, thread); break; } } else { - exec_base_inst(cpu, opcode, prefix, value.u64, address.u64, size, thread); + if (is_ext) { + exec_base_inst(cpu, opcode, prefix, value.u64, address.u64, size, thread); + } else { + const int inc_pc = 1; + const int inc_clk = getclk; + i[opcode](cpu, prefix, 7, inc_pc, inc_clk, thread); + } } /*usleep(1);*/ #if !IO @@ -316,7 +326,7 @@ void *run(void *args) { wrefresh(regs); wrefresh(inst_win); #endif - for (; step && c != 19 && !end; c = get_key(scr)); + for (; step && c != 19 && !end; c = get_key(scr, -1, cpu->clk)); #if debug wrefresh(scr); wrefresh(regs); -- cgit v1.2.3-13-gbd6f