Faster imm opcodes

This commit is contained in:
Devine Lu Linvega 2024-06-30 17:45:25 -08:00
parent 9d0803e99f
commit e379cfa2ad
3 changed files with 15 additions and 8 deletions

View File

@ -47,12 +47,19 @@ uxn_eval(Uint16 pc)
/* IMM */
case 0x00: case 0x20:
switch(ins) {
case 0x00: /* BRK */ return 1;
case 0x20: /* JCI */ t=T; SHIFT(-1) if(!t) { pc += 2; break; } /* fall-through */
case 0x40: /* JMI */ rr = uxn.ram + pc; pc += 2 + PEEK2(rr); break;
case 0x60: /* JSI */ SHIFT( 2) rr = uxn.ram + pc; pc += 2; T2_(pc); pc += PEEK2(rr); break;
case 0x80: /* LIT */ case 0xc0: SHIFT( 1) T = uxn.ram[pc++]; break;
case 0xa0: /* LIT2 */ case 0xe0: SHIFT( 2) N = uxn.ram[pc++]; T = uxn.ram[pc++]; break;
case 0x00: /* BRK */ return 1;
case 0x20: /* JCI */ if(!uxn.wst.dat[uxn.wst.ptr--]) { pc += 2; break; } /* fall-through */
case 0x40: /* JMI */ rr = uxn.ram + pc; pc += 2 + PEEK2(rr); break;
case 0x60: /* JSI */ uxn.rst.ptr += 2;
rr = uxn.ram + pc;
pc += 2; r = pc;
uxn.rst.dat[uxn.rst.ptr] = pc;
uxn.rst.dat[(Uint8)(uxn.rst.ptr - 1)] = pc >> 8;
pc += PEEK2(rr); break;
case 0xa0: /* LIT2 */ uxn.wst.dat[++uxn.wst.ptr] = uxn.ram[pc++]; /* fall-through */
case 0x80: /* LIT */ uxn.wst.dat[++uxn.wst.ptr] = uxn.ram[pc++]; break;
case 0xe0: /* LIT2r */ uxn.rst.dat[++uxn.rst.ptr] = uxn.ram[pc++]; /* fall-through */
case 0xc0: /* LITr */ uxn.rst.dat[++uxn.rst.ptr] = uxn.ram[pc++]; break;
} break;
/* ALU */
case 0x01: /* INC */ t=T; SET(1, 0) T = t + 1; break;

View File

@ -272,7 +272,7 @@ main(int argc, char **argv)
int i = 1;
char *rom;
if(i != argc && argv[i][0] == '-' && argv[i][1] == 'v') {
fprintf(stdout, "Uxn11 - Varvara Emulator, 29 Jun 2024.\n");
fprintf(stdout, "Uxn11 - Varvara Emulator, 30 Jun 2024.\n");
i++;
}
rom = i == argc ? "boot.rom" : argv[i++];

View File

@ -72,7 +72,7 @@ main(int argc, char **argv)
return system_error("usage", "uxncli [-v] file.rom [args..]");
/* Read flags */
if(argv[i][0] == '-' && argv[i][1] == 'v')
return !printf("Uxncli - Console Varvara Emulator, 29 Jun 2024\n");
return !printf("Uxncli - Console Varvara Emulator, 30 Jun 2024\n");
if(!system_boot((Uint8 *)calloc(0x10000 * RAM_PAGES, sizeof(Uint8)), argv[i++]))
return system_error("Init", "Failed to initialize uxn.");
/* Game Loop */