Skip to content

Commit

Permalink
uxn core: this way of handling u->ram.ptr saves a few cycles (~0.1%)
Browse files Browse the repository at this point in the history
  • Loading branch information
asiekierka committed May 29, 2021
1 parent df9b036 commit ef9e774
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions arm9/source/uxn.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,14 +510,15 @@ evaluxn(Uxn *u, Uint16 vec)
case 0xa1: /* LIT2k */
__asm__( "evaluxn_21_LIT2:" );
{
u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, u->ram.ptr++);
u->wst.dat[u->wst.ptr + 1] = mempeek8(u->ram.dat, u->ram.ptr++);
u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, u->ram.ptr);
u->wst.dat[u->wst.ptr + 1] = mempeek8(u->ram.dat, u->ram.ptr + 1);
#ifndef NO_STACK_CHECKS
if(__builtin_expect(u->wst.ptr > 253, 0)) {
u->wst.error = 2;
goto error;
}
#endif
u->ram.ptr += 2;
u->wst.ptr += 2;
}
break;
Expand Down Expand Up @@ -1433,14 +1434,15 @@ evaluxn(Uxn *u, Uint16 vec)
case 0xe1: /* LIT2kr */
__asm__( "evaluxn_61_LIT2r:" );
{
u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, u->ram.ptr++);
u->rst.dat[u->rst.ptr + 1] = mempeek8(u->ram.dat, u->ram.ptr++);
u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, u->ram.ptr);
u->rst.dat[u->rst.ptr + 1] = mempeek8(u->ram.dat, u->ram.ptr + 1);
#ifndef NO_STACK_CHECKS
if(__builtin_expect(u->rst.ptr > 253, 0)) {
u->rst.error = 2;
goto error;
}
#endif
u->ram.ptr += 2;
u->rst.ptr += 2;
}
break;
Expand Down
2 changes: 1 addition & 1 deletion include/uxn.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ typedef struct Device {
} Device;

typedef struct Uxn {
Stack wst, rst, *src, *dst;
Stack wst, rst;
Memory ram;
Device dev[16];
} Uxn;
Expand Down

0 comments on commit ef9e774

Please sign in to comment.