summaryrefslogtreecommitdiff
path: root/sux.c
diff options
context:
space:
mode:
Diffstat (limited to 'sux.c')
-rw-r--r--sux.c40
1 files changed, 28 insertions, 12 deletions
diff --git a/sux.c b/sux.c
index 5df1ad3..7c26e08 100644
--- a/sux.c
+++ b/sux.c
@@ -131,7 +131,7 @@ void *run(void *args) {
uint8_t ext_prefix = 0;
uint8_t prefix2 = 0;
uint8_t op_id = 0;
- uint8_t opcode = 0;
+ int opcode = 0;
union reg address;
union reg value;
cpu->clk = 0;
@@ -175,6 +175,7 @@ void *run(void *args) {
uc.clk = 0;
struct sux uc_test;*/
for (;;) {
+ uint8_t inst_len = 0;
#if !bench
if (end) {
pthread_mutex_lock(&main_mutex);
@@ -185,19 +186,29 @@ void *run(void *args) {
#endif
address.u64 = 0;
value.u64 = 0;
- 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 = ((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;
+ if (cpu->reset) {
+ opcode = 0x101;
+ cpu->reset = 0;
+ } else if (cpu->nmi) {
+ opcode = 0x100;
+ cpu->nmi = 0;
+ } else if (cpu->irq) {
+ opcode = 0x102;
+ cpu->irq = 0;
+ } else {
+ 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[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;
+ }
uint8_t operand_type[2];
uint8_t am;
uint8_t ortho_id[2];
uint8_t ext_id = 0;
- uint8_t tmp_opcode = opcode;
+ int tmp_opcode = opcode;
uint8_t tmp_ext_prefix = ext_prefix;
int is_ortho = 0;
int is_ext = 0;
@@ -251,7 +262,7 @@ void *run(void *args) {
break;
}
} else {
- am = optype[opcode];
+ am = (opcode < 0x100) ? optype[opcode] : IMPL;
}
uint8_t rs = (prefix >> 4) & 3;
uint8_t size = (/***/1 << rs) - 1;
@@ -316,7 +327,9 @@ void *run(void *args) {
}
/*usleep(1);*/
#if !IO
- ins++;
+ if (opcode < 0x100) {
+ ins++;
+ }
#endif
#if !bench
if (step) {
@@ -500,7 +513,10 @@ int main(int argc, char **argv) {
thr[i].sx.r11 = 0, thr[i].sx.r12 = 0;
thr[i].sx.r12 = 0, thr[i].sx.r13 = 0;
thr[i].sx.r14 = 0, thr[i].sx.r15 = 0;
- thr[i].sx.pc = read_value(&thr[i].sx, 0, vec+offset, 7, 0, 0);
+ thr[i].sx.pc = 0;
+ thr[i].sx.nmi = 0;
+ thr[i].sx.reset = 1;
+ thr[i].sx.irq = 0;
thr[i].th = i;
#if !IO
inst[i] = 0;