diff options
Diffstat (limited to 'sux.c')
-rw-r--r-- | sux.c | 194 |
1 files changed, 110 insertions, 84 deletions
@@ -14,18 +14,21 @@ #endif #define THREADS 1 -#define BENCH_INST 100000000*THREADS +#define BENCH_INST 100000000 << THREADS-1 #define CTRL_ADDR 0xC000 #define TX_ADDR 0xC001 #define RX_ADDR 0xC002 #define CURSES_BACKSPACE 0x7F +#define setflag(flag, bit) (flag) ? (cpu->ps |= (bit << (thread << 3))) : (cpu->ps &= ~(bit << (thread << 3))) + uint64_t clk[THREADS]; /* Per Thread Clock cycles. */ uint64_t tclk; /* Total Clock cycles. */ uint64_t inst[THREADS]; uint64_t inss; uint8_t threads_done = 0; uint8_t kbd_rdy = 0; +uint8_t kbd_ln = 0; uint8_t wai = 0; uint8_t irq = 0; #if !bench @@ -85,7 +88,7 @@ void *run(void *args) { addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]] = (uint64_t)cpu->ps >> 8*thread; cpu->sp[thread]--; cpu->i[thread] = 1; - (cpu->i[thread]) ? (cpu->ps |= (I << 8*thread)) : (cpu->ps &= ~(I << 8*thread)); + setflag(cpu->i[thread], I); cpu->pc[thread] = (uint64_t)addr[0xFFA0] | (uint64_t)addr[0xFFA1] << 8 | (uint64_t)addr[0xFFA2] << 16 @@ -314,7 +317,15 @@ void *run(void *args) { break; } - mvwprintw(scr, 29, 0, "address: $%016llx\r", address); + mvwprintw(scr, 29, 0, "address: $%016llx, scr_row: %02u, scr_col: %02u, scr_lnst: $%04x, scr_lncnt: $%04x\r", address, addr[0], addr[1], addr[2] | (addr[3] << 8), addr[4] | (addr[5] << 8)); + mvwprintw(scr, 32, 0, "%02x %02x %02x %02x %02x %02x %02x %02x " + "%02x %02x %02x %02x %02x %02x %02x %02x\r" + , addr[0x4000], addr[0x4001], addr[0x4002], addr[0x4003], addr[0x4004], addr[0x4005], addr[0x4006], addr[0x4007] + , addr[0x4008], addr[0x4009], addr[0x400A], addr[0x400B], addr[0x400C], addr[0x400D], addr[0x400E], addr[0x400F]); + mvwprintw(scr, 33, 0, "%02x %02x %02x %02x %02x %02x %02x %02x " + "%02x %02x %02x %02x %02x %02x %02x %02x\r" + , addr[0x4010], addr[0x4011], addr[0x4012], addr[0x4013], addr[0x4014], addr[0x4015], addr[0x4016], addr[0x4017] + , addr[0x4018], addr[0x4019], addr[0x401A], addr[0x401B], addr[0x401C], addr[0x401D], addr[0x401E], addr[0x401F]); wrefresh(scr); #if keypoll pthread_mutex_unlock(&mutex); @@ -345,16 +356,17 @@ void *run(void *args) { cpu->n[thread] = (sum >> 63); cpu->v[thread] = !((cpu->a[thread]^value) & 0x8000000000000000) && ((cpu->a[thread]^sum) & 0x8000000000000000); cpu->c[thread] = (sum < value); - (cpu->z[thread]) ? (cpu->ps |= (Z << 8*thread)) : (cpu->ps &= ~(Z << 8*thread)); - (cpu->n[thread]) ? (cpu->ps |= (N << 8*thread)) : (cpu->ps &= ~(N << 8*thread)); - (cpu->v[thread]) ? (cpu->ps |= (V << 8*thread)) : (cpu->ps &= ~(V << 8*thread)); - (cpu->c[thread]) ? (cpu->ps |= (C << 8*thread)) : (cpu->ps &= ~(C << 8*thread)); + setflag(cpu->z[thread], Z); + setflag(cpu->n[thread], N); + setflag(cpu->v[thread], V); + setflag(cpu->c[thread], C); + setflag(cpu->i[thread], I); break; case PHB: /* PusH B register to stack. */ tmp = addr[cpu->pc[thread]++]; if (tmp > 7) tmp = 7; - for (int8_t i = tmp*8; i >= 0; i-=8) { + for (int8_t i = tmp<<3; i >= 0; i-=8) { if (i) addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]] = (uint64_t)cpu->b[thread] >> i; else @@ -366,7 +378,7 @@ void *run(void *args) { tmp = addr[cpu->pc[thread]++]; if (tmp > 7) tmp = 7; - for (int8_t i = tmp*8; i >= 0; i-=8) { + for (int8_t i = tmp<<3; i >= 0; i-=8) { if (i) addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]] = (uint64_t)cpu->ps >> i; else @@ -378,7 +390,7 @@ void *run(void *args) { tmp = addr[cpu->pc[thread]++]; if (tmp > 7) tmp = 7; - for (int8_t i = tmp*8; i >= 0; i-=8) { + for (int8_t i = tmp<<3; i >= 0; i-=8) { if (i) addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]] = (uint64_t)cpu->a[thread] >> i; else @@ -390,7 +402,7 @@ void *run(void *args) { tmp = addr[cpu->pc[thread]++]; if (tmp > 7) tmp = 7; - for (int8_t i = tmp*8; i >= 0; i-=8) { + for (int8_t i = tmp<<3; i >= 0; i-=8) { if (i) addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]] = (uint64_t)cpu->y[thread] >> i; else @@ -451,14 +463,14 @@ void *run(void *args) { cpu->z[thread] = (cpu->x[thread] == 0); cpu->n[thread] = (cpu->x[thread] >> 63); } - (cpu->z[thread]) ? (cpu->ps |= (Z << 8*thread)) : (cpu->ps &= ~(Z << 8*thread)); - (cpu->n[thread]) ? (cpu->ps |= (N << 8*thread)) : (cpu->ps &= ~(N << 8*thread)); + setflag(cpu->z[thread], Z); + setflag(cpu->n[thread], N); break; case PHX: /* PusH X register to stack. */ tmp = addr[cpu->pc[thread]++]; if (tmp > 7) tmp = 7; - for (int8_t i = tmp*8; i >= 0; i-=8) { + for (int8_t i = tmp<<3; i >= 0; i-=8) { if (i) addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]] = (uint64_t)cpu->x[thread] >> i; else @@ -481,17 +493,17 @@ void *run(void *args) { cpu->n[thread] = (sum >> 63); cpu->v[thread] = ((cpu->a[thread]^value) & 0x8000000000000000) && ((cpu->a[thread]^sum) & 0x8000000000000000); cpu->c[thread] = (sum > value); - (cpu->z[thread]) ? (cpu->ps |= (Z << 8*thread)) : (cpu->ps &= ~(Z << 8*thread)); - (cpu->n[thread]) ? (cpu->ps |= (N << 8*thread)) : (cpu->ps &= ~(N << 8*thread)); - (cpu->v[thread]) ? (cpu->ps |= (V << 8*thread)) : (cpu->ps &= ~(V << 8*thread)); - (cpu->c[thread]) ? (cpu->ps |= (C << 8*thread)) : (cpu->ps &= ~(C << 8*thread)); + setflag(cpu->z[thread], Z); + setflag(cpu->n[thread], N); + setflag(cpu->v[thread], V); + setflag(cpu->c[thread], C); cpu->a[thread] = sum; break; case PLB: /* PuLl B register from stack. */ tmp = addr[cpu->pc[thread]++]; if (tmp > 7) tmp = 7; - for (uint8_t i = 0; i < (tmp+1)*8; i+=8) { + for (uint8_t i = 0; i < (tmp+1)<<3; i+=8) { cpu->sp[thread]++; if (i) cpu->b[thread] += (uint64_t)addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]] << i; @@ -503,7 +515,7 @@ void *run(void *args) { tmp = addr[cpu->pc[thread]++]; if (tmp > 7) tmp = 7; - for (uint8_t i = 0; i < (tmp+1)*8; i+=8) { + for (uint8_t i = 0; i < (tmp+1)<<3; i+=8) { cpu->sp[thread]++; if (i) cpu->ps += (uint64_t)addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]] << i; @@ -515,7 +527,7 @@ void *run(void *args) { tmp = addr[cpu->pc[thread]++]; if (tmp > 7) tmp = 7; - for (uint8_t i = 0; i < (tmp+1)*8; i+=8) { + for (uint8_t i = 0; i < (tmp+1)<<3; i+=8) { cpu->sp[thread]++; if (i) cpu->a[thread] += (uint64_t)addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]] << i; @@ -527,7 +539,7 @@ void *run(void *args) { tmp = addr[cpu->pc[thread]++]; if (tmp > 7) tmp = 7; - for (uint8_t i = 0; i < (tmp+1)*8; i+=8) { + for (uint8_t i = 0; i < (tmp+1)<<3; i+=8) { cpu->sp[thread]++; if (i) cpu->y[thread] += (uint64_t)addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]] << i; @@ -539,7 +551,7 @@ void *run(void *args) { tmp = addr[cpu->pc[thread]++]; if (tmp > 7) tmp = 7; - for (uint8_t i = 0; i < (tmp+1)*8; i+=8) { + for (uint8_t i = 0; i < (tmp+1)<<3; i+=8) { cpu->sp[thread]++; if (i) cpu->x[thread] += (uint64_t)addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]] << i; @@ -555,7 +567,7 @@ void *run(void *args) { stksize = 24; else stksize = 0; - for (int8_t i = 24; i >= 0; i-=8) { + for (int8_t i = stksize; i >= 0; i-=8) { if (i) addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]] = (uint64_t)cpu->pc[thread] >> i; else @@ -574,21 +586,21 @@ void *run(void *args) { cpu->a[thread] &= value; cpu->z[thread] = (value == 0); cpu->n[thread] = (value >> 63); - (cpu->z[thread]) ? (cpu->ps |= (Z << 8*thread)) : (cpu->ps &= ~(Z << 8*thread)); - (cpu->n[thread]) ? (cpu->ps |= (N << 8*thread)) : (cpu->ps &= ~(N << 8*thread)); + setflag(cpu->z[thread], Z); + setflag(cpu->n[thread], N); break; case STT: /* STart Thread. */ cpu->crt |= value; for (uint8_t i = 0; i < 7; i++) { if ((value >> i) & 1) { - address = (uint64_t)addr[tv+(8*i)] - | (uint64_t)addr[tv+1+(8*i)] << 8 - | (uint64_t)addr[tv+2+(8*i)] << 16 - | (uint64_t)addr[tv+3+(8*i)] << 24 - | (uint64_t)addr[tv+4+(8*i)] << 32 - | (uint64_t)addr[tv+5+(8*i)] << 40 - | (uint64_t)addr[tv+6+(8*i)] << 48 - | (uint64_t)addr[tv+7+(8*i)] << 56; + address = (uint64_t)addr[tv+(i<<3)] + | (uint64_t)addr[tv+1+(i<<3)] << 8 + | (uint64_t)addr[tv+2+(i<<3)] << 16 + | (uint64_t)addr[tv+3+(i<<3)] << 24 + | (uint64_t)addr[tv+4+(i<<3)] << 32 + | (uint64_t)addr[tv+5+(i<<3)] << 40 + | (uint64_t)addr[tv+6+(i<<3)] << 48 + | (uint64_t)addr[tv+7+(i<<3)] << 56; cpu->pc[i+1] = address; } } @@ -608,12 +620,12 @@ void *run(void *args) { cpu->a[thread] |= value; cpu->z[thread] = (value == 0); cpu->n[thread] = (value >> 63); - (cpu->z[thread]) ? (cpu->ps |= (Z << 8*thread)) : (cpu->ps &= ~(Z << 8*thread)); - (cpu->n[thread]) ? (cpu->ps |= (N << 8*thread)) : (cpu->ps &= ~(N << 8*thread)); + setflag(cpu->z[thread], Z); + setflag(cpu->n[thread], N); break; case SEI: /* SEt Interrupt. */ cpu->i[thread] = 1; - (cpu->ps |= (I << 8*thread)); + setflag(cpu->i[thread], I); break; case BNG: /* BNG Absolute. */ case 0x74: /* BNG Zero Matrix. */ @@ -630,12 +642,12 @@ void *run(void *args) { cpu->a[thread] ^= value; cpu->z[thread] = (value == 0); cpu->n[thread] = (value >> 63); - (cpu->z[thread]) ? (cpu->ps |= (Z << 8*thread)) : (cpu->ps &= ~(Z << 8*thread)); - (cpu->n[thread]) ? (cpu->ps |= (N << 8*thread)) : (cpu->ps &= ~(N << 8*thread)); + setflag(cpu->z[thread], Z); + setflag(cpu->n[thread], N); break; case CLI: /* CLear Interrupt. */ cpu->i[thread] = 0; - (cpu->ps &= ~(I << 8*thread)); + setflag(cpu->i[thread], I); break; case BCS: /* BCS Absolute. */ case 0x84: /* BCS Zero Matrix. */ @@ -654,13 +666,13 @@ void *run(void *args) { cpu->n[thread] = (sum >> 63); cpu->c[thread] = cpu->a[thread] >> 64-value; cpu->a[thread] = sum; - (cpu->z[thread]) ? (cpu->ps |= (Z << 8*thread)) : (cpu->ps &= ~(Z << 8*thread)); - (cpu->n[thread]) ? (cpu->ps |= (N << 8*thread)) : (cpu->ps &= ~(N << 8*thread)); - (cpu->c[thread]) ? (cpu->ps |= (C << 8*thread)) : (cpu->ps &= ~(C << 8*thread)); + setflag(cpu->z[thread], Z); + setflag(cpu->n[thread], N); + setflag(cpu->c[thread], C); break; case SEC: /* SEt Carry flag.*/ cpu->c[thread] = 1; - (cpu->ps |= (C << 8*thread)); + setflag(cpu->c[thread], C); break; case STA: /* STA Absolute. */ case STY: /* STY Absolute. */ @@ -760,7 +772,11 @@ void *run(void *args) { break; } } else { - if (addr[address] == CURSES_BACKSPACE || addr[address] == '\b') { + if (addr[address] == 0xC) { + x=0,y=0; + wclear(scr); + wmove(scr, y, x); + } else if (addr[address] == CURSES_BACKSPACE || addr[address] == '\b') { if (x > 0) { x--; wmove(scr, y, x); @@ -820,6 +836,7 @@ void *run(void *args) { else x = ((bcd[1]*10) + bcd[0]); mvwprintw(scr, 30, 0, "x: %i, y: %i ", x, y); + mvwprintw(scr, 31, 0, "bcd[3-2]: {%u, %u}, bcd[1-0]: {%u, %u}", bcd[3], bcd[2], bcd[1], bcd[0]); wrefresh(scr); idx = 3; bcd[0] = 0; @@ -893,9 +910,9 @@ void *run(void *args) { cpu->n[thread] = (sum >> 63); cpu->c[thread] = cpu->a[thread] & 1; cpu->a[thread] = sum; - (cpu->z[thread]) ? (cpu->ps |= (Z << 8*thread)) : (cpu->ps &= ~(Z << 8*thread)); - (cpu->n[thread]) ? (cpu->ps |= (N << 8*thread)) : (cpu->ps &= ~(N << 8*thread)); - (cpu->c[thread]) ? (cpu->ps |= (C << 8*thread)) : (cpu->ps &= ~(C << 8*thread)); + setflag(cpu->z[thread], Z); + setflag(cpu->n[thread], N); + setflag(cpu->c[thread], C); break; case ASR: /* ASR Immediate. */ case ARB: /* Arithmetic shift Right accumulator by B. */ @@ -909,13 +926,13 @@ void *run(void *args) { cpu->n[thread] = (sum >> 63); cpu->c[thread] = cpu->a[thread] & 1; cpu->a[thread] = sum; - (cpu->z[thread]) ? (cpu->ps |= (Z << 8*thread)) : (cpu->ps &= ~(Z << 8*thread)); - (cpu->n[thread]) ? (cpu->ps |= (N << 8*thread)) : (cpu->ps &= ~(N << 8*thread)); - (cpu->c[thread]) ? (cpu->ps |= (C << 8*thread)) : (cpu->ps &= ~(C << 8*thread)); + setflag(cpu->z[thread], Z); + setflag(cpu->n[thread], N); + setflag(cpu->c[thread], C); break; case CLC: /* CLear Carry flag. */ cpu->c[thread] = 0; - (cpu->ps &= ~(C << 8*thread)); + setflag(cpu->c[thread], C); break; case LDB: /* LDB Immediate. */ case LDA: /* LDA Immediate. */ @@ -978,8 +995,8 @@ void *run(void *args) { cpu->x[thread] = value; cpu->z[thread] = (value == 0); cpu->n[thread] = (value >> 63); - (cpu->z[thread]) ? (cpu->ps |= (Z << 8*thread)) : (cpu->ps &= ~(Z << 8*thread)); - (cpu->n[thread]) ? (cpu->ps |= (N << 8*thread)) : (cpu->ps &= ~(N << 8*thread)); + setflag(cpu->z[thread], Z); + setflag(cpu->n[thread], N); break; case BEQ: /* BEQ Absolute. */ case 0xA4: /* BEQ Zero Matrix. */ @@ -999,13 +1016,13 @@ void *run(void *args) { cpu->n[thread] = (sum >> 63); cpu->c[thread] = cpu->a[thread] >> (uint64_t)64-value; cpu->a[thread] = sum; - (cpu->z[thread]) ? (cpu->ps |= (Z << 8*thread)) : (cpu->ps &= ~(Z << 8*thread)); - (cpu->n[thread]) ? (cpu->ps |= (N << 8*thread)) : (cpu->ps &= ~(N << 8*thread)); - (cpu->c[thread]) ? (cpu->ps |= (C << 8*thread)) : (cpu->ps &= ~(C << 8*thread)); + setflag(cpu->z[thread], Z); + setflag(cpu->n[thread], N); + setflag(cpu->c[thread], C); break; case SSP: /* Set Stack Protection flag. */ cpu->s[thread] = 1; - (cpu->ps |= (S << 8*thread)); + setflag(cpu->s[thread], S); break; case BNE: /* BNE Absolute. */ case 0xB4: /* BNE Zero Matrix. */ @@ -1025,13 +1042,13 @@ void *run(void *args) { cpu->n[thread] = (sum >> 63); cpu->c[thread] = cpu->a[thread] & 1; cpu->a[thread] = sum; - (cpu->z[thread]) ? (cpu->ps |= (Z << 8*thread)) : (cpu->ps &= ~(Z << 8*thread)); - (cpu->n[thread]) ? (cpu->ps |= (N << 8*thread)) : (cpu->ps &= ~(N << 8*thread)); - (cpu->c[thread]) ? (cpu->ps |= (C << 8*thread)) : (cpu->ps &= ~(C << 8*thread)); + setflag(cpu->z[thread], Z); + setflag(cpu->n[thread], N); + setflag(cpu->c[thread], C); break; case CSP: /* Clear Stack Protection flag. */ cpu->s[thread] = 0; - (cpu->ps &= ~(S << 8*thread)); + setflag(cpu->s[thread], S); break; case BVS: /* BVS Absolute. */ case 0xC4: /* BVS Zero Matrix. */ @@ -1051,14 +1068,14 @@ void *run(void *args) { cpu->n[thread] = (sum >> 63); cpu->v[thread] = !((cpu->a[thread]^value) & 0x8000000000000000) && ((cpu->a[thread]^sum) & 0x8000000000000000); cpu->c[thread] = (!((cpu->a[thread]^sum) && (cpu->a[thread]^value)) && (cpu->a[thread] >= ((uint64_t)1 << 32) && value >= ((uint64_t)1 << 32))); - (cpu->z[thread]) ? (cpu->ps |= (Z << 8*thread)) : (cpu->ps &= ~(Z << 8*thread)); - (cpu->n[thread]) ? (cpu->ps |= (N << 8*thread)) : (cpu->ps &= ~(N << 8*thread)); - (cpu->v[thread]) ? (cpu->ps |= (V << 8*thread)) : (cpu->ps &= ~(V << 8*thread)); - (cpu->c[thread]) ? (cpu->ps |= (C << 8*thread)) : (cpu->ps &= ~(C << 8*thread)); + setflag(cpu->z[thread], Z); + setflag(cpu->n[thread], N); + setflag(cpu->v[thread], V); + setflag(cpu->c[thread], C); break; case SEV: /* SEt oVerflow flag. */ cpu->v[thread] = 1; - (cpu->ps |= (V << 8*thread)); + setflag(cpu->v[thread], V); break; case BVC: /* BVC Absolute. */ case 0xD4: /* BVC Zero Matrix. */ @@ -1079,12 +1096,12 @@ void *run(void *args) { cpu->a[thread] = sum; cpu->z[thread] = (sum == 0); cpu->n[thread] = (sum >> 63); - (cpu->z[thread]) ? (cpu->ps |= (Z << 8*thread)) : (cpu->ps &= ~(Z << 8*thread)); - (cpu->n[thread]) ? (cpu->ps |= (N << 8*thread)) : (cpu->ps &= ~(N << 8*thread)); + setflag(cpu->z[thread], Z); + setflag(cpu->n[thread], N); break; case CLV: /* CLear oVerflow flag. */ cpu->v[thread] = 0; - (cpu->ps &= ~(V << 8*thread)); + setflag(cpu->v[thread], V); break; case RTS: /* ReTurn from Subroutine. */ if (addrsize) @@ -1138,10 +1155,10 @@ void *run(void *args) { cpu->v[thread] = ((reg^value) & 0x8000000000000000) && ((reg^sum) & 0x8000000000000000); cpu->z[thread] = (sum == 0) ? 1 : 0; cpu->c[thread] = (sum > value) ? 1 : 0; - (cpu->n[thread]) ? (cpu->ps |= (N << 8*thread)) : (cpu->ps &= ~(N << 8*thread)); - (cpu->v[thread]) ? (cpu->ps |= (V << 8*thread)) : (cpu->ps &= ~(V << 8*thread)); - (cpu->z[thread]) ? (cpu->ps |= (Z << 8*thread)) : (cpu->ps &= ~(Z << 8*thread)); - (cpu->c[thread]) ? (cpu->ps |= (C << 8*thread)) : (cpu->ps &= ~(C << 8*thread)); + setflag(cpu->n[thread], N); + setflag(cpu->v[thread], V); + setflag(cpu->z[thread], Z); + setflag(cpu->c[thread], C); break; case ENT: /* ENd Thread. */ cpu->crt &= ~value; @@ -1181,8 +1198,8 @@ void *run(void *args) { cpu->z[thread] = (cpu->x[thread] == 0); cpu->n[thread] = (cpu->x[thread] >> 63); } - (cpu->z[thread]) ? (cpu->ps |= (Z << 8*thread)) : (cpu->ps &= ~(Z << 8*thread)); - (cpu->n[thread]) ? (cpu->ps |= (N << 8*thread)) : (cpu->ps &= ~(N << 8*thread)); + setflag(cpu->z[thread], Z); + setflag(cpu->n[thread], N); break; case 0x04: /* JMP Indirect. */ case 0x14: /* JMP Indexed Indirect. */ @@ -1212,8 +1229,8 @@ void *run(void *args) { cpu->z[thread] = (cpu->x[thread] == 0); cpu->n[thread] = (cpu->x[thread] >> 63); } - (cpu->z[thread]) ? (cpu->ps |= (Z << 8*thread)) : (cpu->ps &= ~(Z << 8*thread)); - (cpu->n[thread]) ? (cpu->ps |= (N << 8*thread)) : (cpu->ps &= ~(N << 8*thread)); + setflag(cpu->z[thread], Z); + setflag(cpu->n[thread], N); break; case JSL: /* Jump to Subroutine Long. */ if (addrsize) @@ -1253,17 +1270,17 @@ void *run(void *args) { addr[address]--; break; case BRK: /* BReaK. */ - for (int8_t i = 56; i >= 0; i-=8) { + for (int8_t i = stksize; i >= 0; i-=8) { if (i) - addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]] = (uint64_t)cpu->pc[thread]-1 >> i; + addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]] = (uint64_t)cpu->pc[thread] >> i; else - addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]] = (uint64_t)cpu->pc[thread]-1 & 0xFF; + addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]] = (uint64_t)cpu->pc[thread] & 0xFF; cpu->sp[thread]--; } - addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]] = (uint64_t)cpu->ps >> 8*thread; + addr[(cpu->stk_st[thread] << 16)+cpu->sp[thread]] = (uint64_t)cpu->ps >> thread << 3; cpu->sp[thread]--; cpu->i[thread] = 1; - (cpu->i[thread]) ? (cpu->ps |= (I << 8*thread)) : (cpu->ps &= ~(I << 8*thread)); + setflag(cpu->i[thread], I); cpu->pc[thread] = (uint64_t)addr[0xFFE0] | (uint64_t)addr[0xFFE1] << 8 | (uint64_t)addr[0xFFE2] << 16 @@ -1286,6 +1303,13 @@ void *run(void *args) { break; } ins++; + /*if (!addr[CTRL_ADDR]) + kbd_ln = 0; + else + kbd_ln = 1; + if (kbd_ln) + usleep(16666); + /*usleep(500000);*/ #if debug && !bench #if keypoll pthread_mutex_lock(&mutex); @@ -1409,6 +1433,7 @@ int main(int argc, char **argv) { curs_set(1); c = 0; addr[CTRL_ADDR] = 0; + kbd_ln = 0; } #if keypoll pthread_mutex_lock(&mutex); @@ -1426,7 +1451,8 @@ int main(int argc, char **argv) { default: addr[RX_ADDR] = (uint8_t)c; addr[CTRL_ADDR] = 1; - kbd_rdy = 1; + if (c == '\n') + kbd_ln = 1; #if !keypoll pthread_mutex_lock(&mutex); pthread_cond_signal(&cond); |