Optimized core

This commit is contained in:
neauoire 2023-11-09 13:46:10 -08:00
parent fa6d62c70a
commit 6bdb6ca168
3 changed files with 78 additions and 74 deletions

View File

@ -106,6 +106,6 @@ if [ $norun = 1 ]; then exit; fi
./bin/uxncli -v
./bin/uxnemu -v
./bin/uxnasm projects/examples/devices/audio-tests.tal bin/audio-tests.rom
./bin/uxnasm projects/examples/devices/mouse.tal bin/mouse.rom
./bin/uxnemu -2x bin/audio-tests.rom
./bin/uxnemu -2x bin/mouse.rom

View File

@ -43,14 +43,18 @@ uxn_eval(Uxn *u, Uint16 pc)
for(;;) {
Uint8 ins = ram[pc++];
Stack *s = ins & 0x40 ? &u->rst : &u->wst;
switch(ins & 0x1f ? ins & 0x3f : ins) {
switch(ins & 0x3f) {
/* IMM */
case 0x00: case 0x20:
switch(ins) {
case 0x00: /* BRK */ return 1;
case 0x20: /* JCI */ t=T; SHIFT(-1) if(!t) { pc += 2; break; }
case 0x40: /* JMI */ rr = ram + pc; pc += 2 + PEEK2(rr); break;
case 0x60: /* JSI */ SHIFT( 2) rr = ram + pc; pc += 2; T2_(pc); pc += PEEK2(rr); break;
case 0x80: /* LIT */ case 0xc0: SHIFT( 1) T = ram[pc++]; break;
case 0xa0: /* LIT2 */ case 0xe0: SHIFT( 2) N = ram[pc++]; T = ram[pc++]; break;
}
break;
/* ALU */
case 0x01: /* INC */ t=T; SET(1, 0) T = t + 1; break;
case 0x21: /* INC2 */ t=T2; SET(2, 0) T2_(t + 1) break;

View File

@ -500,7 +500,7 @@ main(int argc, char *argv[])
FILE *src, *dst;
if(argc == 2 && argv[1][0] == '-' && argv[1][1] == 'v')
return !fprintf(stdout, "Uxnasm - Uxntal Assembler, 27 Oct 2023.\n");
if (argc != 3)
if(argc != 3)
return error("usage", "uxnasm [-v] input.tal output.rom");
if(!(src = fopen(argv[1], "r")))
return !error("Invalid input", argv[1]);