From ef9e77447da6211902ca0daeb1f06c0ef07f07ce Mon Sep 17 00:00:00 2001 From: Adrian Siekierka Date: Sat, 29 May 2021 10:02:41 +0200 Subject: [PATCH] uxn core: this way of handling u->ram.ptr saves a few cycles (~0.1%) --- arm9/source/uxn.c | 10 ++++++---- include/uxn.h | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/arm9/source/uxn.c b/arm9/source/uxn.c index 6858cbc..e7d9a87 100644 --- a/arm9/source/uxn.c +++ b/arm9/source/uxn.c @@ -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; @@ -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; diff --git a/include/uxn.h b/include/uxn.h index 98692b5..fdf9e67 100644 --- a/include/uxn.h +++ b/include/uxn.h @@ -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;