diff options
Diffstat (limited to 'sux.c')
-rw-r--r-- | sux.c | 44 |
1 files changed, 33 insertions, 11 deletions
@@ -97,7 +97,9 @@ uint8_t is_extop(uint8_t opcode, uint8_t dbg) { case STY_E: case STA_E: case STB_E: - case STX_E: return 0; + case STX_E: + case JMP_E: + case JSR_E: return 0; } return 1; } @@ -109,6 +111,7 @@ void *run(void *args) { uint8_t prefix = 0; uint8_t ext_prefix = 0; uint8_t prefix2 = 0; + uint8_t op_id = 0; uint8_t opcode = 0; union reg address; union reg value; @@ -175,19 +178,25 @@ void *run(void *args) { pthread_mutex_unlock(&mutex); #endif #endif - uint32_t instr = read_value(cpu, 0, cpu->pc, 3, 1, 0); + uint32_t instr = read_value(cpu, 0, cpu->pc, 4, 1, 0); uint8_t *tmp_inst = (uint8_t *)&instr; - prefix = ((instr & 3) == 3) ? *tmp_inst++ : 0; - ext_prefix = ((*tmp_inst & 0xD) == 0xD) ? *tmp_inst++ : 0; - opcode = *tmp_inst; - cpu->pc += ((instr & 3) == 3)+((ext_prefix & 0xD) == 0xD)+1; + uint8_t 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; + + cpu->pc += inst_len; address.u64 = cpu->pc; + uint8_t operand_type[2]; uint8_t am; + uint8_t ortho_id[2]; uint8_t ext_id = 0; uint8_t tmp_opcode = opcode; uint8_t tmp_ext_prefix = ext_prefix; + int is_ortho = 0; if (ext_prefix) { - ext_id = ((ext_prefix >> 4) & 0xF); + ext_id = (ext_prefix >> 4); switch (ext_id) { case 0x0: am = ext_optype[opcode]; @@ -220,9 +229,19 @@ void *run(void *args) { case STA_E: tmp_opcode = STA_Z; break; case STB_E: tmp_opcode = STB_Z; break; case STX_E: tmp_opcode = STX_Z; break; + case JMP_E: tmp_opcode = JMP_Z; break; + case JSR_E: tmp_opcode = JSR_Z; break; } } break; + case 0x1: + operand_type[0] = ((opcode & 0x10) >> 4); + operand_type[1] = ((opcode & 0x08) >> 3); + ortho_id[0] = op_id >> 4; + ortho_id[1] = op_id & 0x0F; + am = IMPL; + is_ortho = 1; + break; } } else { am = optype[opcode]; @@ -234,7 +253,7 @@ void *run(void *args) { #if keypoll pthread_mutex_lock(&mutex); #endif - disasm(cpu, lines, opcode, prefix, ext_prefix, prefix2, thread); + disasm(cpu, lines, opcode, prefix, ext_prefix, prefix2, operand_type, ortho_id, thread); lines+=1; #if keypoll pthread_mutex_unlock(&mutex); @@ -246,7 +265,7 @@ void *run(void *args) { addr[STEP_ADDR] = 1; step = 1; }*/ - if (isrw(opcode) && am != REL && isread(opcode)) { + if (isrw(opcode, ext_prefix) && am != REL && isread(opcode, ext_prefix)) { value.u64 = read_value(cpu, 0, address.u64, size, 1, check_io); } } @@ -254,12 +273,15 @@ void *run(void *args) { ext_prefix = tmp_ext_prefix; opcode = tmp_opcode; if (ext_prefix) { + uint8_t tmp = 0; switch (ext_id) { - case 0x0: exec_ext_inst(cpu, opcode, prefix, value, address, size, thread); break; + case 0x0: exec_ext_inst(cpu, opcode, prefix, value.u64, address.u64, size, thread); break; + case 0x1: exec_ortho_inst(cpu, opcode, prefix, size, operand_type, ortho_id, thread); break; } } else { - exec_base_inst(cpu, opcode, prefix, value, address, size, thread); + exec_base_inst(cpu, opcode, prefix, value.u64, address.u64, size, thread); } + //usleep(1); #if !IO ins++; #endif |