commit 3d3569bab7a65e581fb5d9e108be4355826daf31
parent 1afe39fba4a0fdba16b6e561b3fb4b38578ccbb1
Author: Andrew Alderwick <andrew@alderwick.co.uk>
Date:   Sun, 15 Aug 2021 20:05:19 +0100
Updated uxn-fast.c
Diffstat:
| M | src/uxn-fast.c |  |  | 138 | ++++++++++++++++++++++++++++++++++++------------------------------------------- | 
1 file changed, 62 insertions(+), 76 deletions(-)
diff --git a/src/uxn-fast.c b/src/uxn-fast.c
@@ -139,22 +139,19 @@ uxn_eval(Uxn *u, Uint16 vec)
 #endif
 			}
 			break;
-		case 0x06: /* OVR */
-			__asm__("evaluxn_06_OVR:");
+		case 0x06: /* NIP */
+			__asm__("evaluxn_06_NIP:");
 			{
-				Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
-				u->wst.dat[u->wst.ptr] = b;
+				Uint8 a;
+				u->wst.dat[u->wst.ptr - 1];
+				a = u->wst.dat[u->wst.ptr - 2];
 #ifndef NO_STACK_CHECKS
 				if(__builtin_expect(u->wst.ptr < 2, 0)) {
 					u->wst.error = 1;
 					goto error;
 				}
-				if(__builtin_expect(u->wst.ptr > 254, 0)) {
-					u->wst.error = 2;
-					goto error;
-				}
 #endif
-				u->wst.ptr += 1;
+				u->wst.ptr -= 1;
 			}
 			break;
 		case 0x07: /* ROT */
@@ -594,23 +591,21 @@ uxn_eval(Uxn *u, Uint16 vec)
 #endif
 			}
 			break;
-		case 0x26: /* OVR2 */
-			__asm__("evaluxn_26_OVR2:");
+		case 0x26: /* NIP2 */
+			__asm__("evaluxn_26_NIP2:");
 			{
-				Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4];
-				u->wst.dat[u->wst.ptr] = d;
-				u->wst.dat[u->wst.ptr + 1] = c;
+				Uint16 a;
+				(u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8));
+				a = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8));
+				u->wst.dat[u->wst.ptr - 4] = a >> 8;
+				u->wst.dat[u->wst.ptr - 3] = a & 0xff;
 #ifndef NO_STACK_CHECKS
 				if(__builtin_expect(u->wst.ptr < 4, 0)) {
 					u->wst.error = 1;
 					goto error;
 				}
-				if(__builtin_expect(u->wst.ptr > 253, 0)) {
-					u->wst.error = 2;
-					goto error;
-				}
 #endif
-				u->wst.ptr += 2;
+				u->wst.ptr -= 2;
 			}
 			break;
 		case 0x27: /* ROT2 */
@@ -1076,22 +1071,19 @@ uxn_eval(Uxn *u, Uint16 vec)
 #endif
 			}
 			break;
-		case 0x46: /* OVRr */
-			__asm__("evaluxn_46_OVRr:");
+		case 0x46: /* NIPr */
+			__asm__("evaluxn_46_NIPr:");
 			{
-				Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
-				u->rst.dat[u->rst.ptr] = b;
+				Uint8 a;
+				u->rst.dat[u->rst.ptr - 1];
+				a = u->rst.dat[u->rst.ptr - 2];
 #ifndef NO_STACK_CHECKS
 				if(__builtin_expect(u->rst.ptr < 2, 0)) {
 					u->rst.error = 1;
 					goto error;
 				}
-				if(__builtin_expect(u->rst.ptr > 254, 0)) {
-					u->rst.error = 2;
-					goto error;
-				}
 #endif
-				u->rst.ptr += 1;
+				u->rst.ptr -= 1;
 			}
 			break;
 		case 0x47: /* ROTr */
@@ -1531,23 +1523,21 @@ uxn_eval(Uxn *u, Uint16 vec)
 #endif
 			}
 			break;
-		case 0x66: /* OVR2r */
-			__asm__("evaluxn_66_OVR2r:");
+		case 0x66: /* NIP2r */
+			__asm__("evaluxn_66_NIP2r:");
 			{
-				Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3], d = u->rst.dat[u->rst.ptr - 4];
-				u->rst.dat[u->rst.ptr] = d;
-				u->rst.dat[u->rst.ptr + 1] = c;
+				Uint16 a;
+				(u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8));
+				a = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8));
+				u->rst.dat[u->rst.ptr - 4] = a >> 8;
+				u->rst.dat[u->rst.ptr - 3] = a & 0xff;
 #ifndef NO_STACK_CHECKS
 				if(__builtin_expect(u->rst.ptr < 4, 0)) {
 					u->rst.error = 1;
 					goto error;
 				}
-				if(__builtin_expect(u->rst.ptr > 253, 0)) {
-					u->rst.error = 2;
-					goto error;
-				}
 #endif
-				u->rst.ptr += 2;
+				u->rst.ptr -= 2;
 			}
 			break;
 		case 0x67: /* ROT2r */
@@ -2004,24 +1994,24 @@ uxn_eval(Uxn *u, Uint16 vec)
 				u->wst.ptr += 2;
 			}
 			break;
-		case 0x86: /* OVRk */
-			__asm__("evaluxn_86_OVRk:");
+		case 0x86: /* NIPk */
+			__asm__("evaluxn_86_NIPk:");
 			{
-				Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
-				u->wst.dat[u->wst.ptr] = b;
-				u->wst.dat[u->wst.ptr + 1] = a;
-				u->wst.dat[u->wst.ptr + 2] = b;
+				Uint8 a;
+				u->wst.dat[u->wst.ptr - 1];
+				a = u->wst.dat[u->wst.ptr - 2];
+				u->wst.dat[u->wst.ptr] = a;
 #ifndef NO_STACK_CHECKS
 				if(__builtin_expect(u->wst.ptr < 2, 0)) {
 					u->wst.error = 1;
 					goto error;
 				}
-				if(__builtin_expect(u->wst.ptr > 252, 0)) {
+				if(__builtin_expect(u->wst.ptr > 254, 0)) {
 					u->wst.error = 2;
 					goto error;
 				}
 #endif
-				u->wst.ptr += 3;
+				u->wst.ptr += 1;
 			}
 			break;
 		case 0x87: /* ROTk */
@@ -2512,27 +2502,25 @@ uxn_eval(Uxn *u, Uint16 vec)
 				u->wst.ptr += 4;
 			}
 			break;
-		case 0xa6: /* OVR2k */
-			__asm__("evaluxn_a6_OVR2k:");
+		case 0xa6: /* NIP2k */
+			__asm__("evaluxn_a6_NIP2k:");
 			{
-				Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2], c = u->wst.dat[u->wst.ptr - 3], d = u->wst.dat[u->wst.ptr - 4];
-				u->wst.dat[u->wst.ptr] = d;
-				u->wst.dat[u->wst.ptr + 1] = c;
-				u->wst.dat[u->wst.ptr + 2] = b;
-				u->wst.dat[u->wst.ptr + 3] = a;
-				u->wst.dat[u->wst.ptr + 4] = d;
-				u->wst.dat[u->wst.ptr + 5] = c;
+				Uint16 a;
+				(u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8));
+				a = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8));
+				u->wst.dat[u->wst.ptr] = a >> 8;
+				u->wst.dat[u->wst.ptr + 1] = a & 0xff;
 #ifndef NO_STACK_CHECKS
 				if(__builtin_expect(u->wst.ptr < 4, 0)) {
 					u->wst.error = 1;
 					goto error;
 				}
-				if(__builtin_expect(u->wst.ptr > 249, 0)) {
+				if(__builtin_expect(u->wst.ptr > 253, 0)) {
 					u->wst.error = 2;
 					goto error;
 				}
 #endif
-				u->wst.ptr += 6;
+				u->wst.ptr += 2;
 			}
 			break;
 		case 0xa7: /* ROT2k */
@@ -3035,24 +3023,24 @@ uxn_eval(Uxn *u, Uint16 vec)
 				u->rst.ptr += 2;
 			}
 			break;
-		case 0xc6: /* OVRkr */
-			__asm__("evaluxn_c6_OVRkr:");
+		case 0xc6: /* NIPkr */
+			__asm__("evaluxn_c6_NIPkr:");
 			{
-				Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
-				u->rst.dat[u->rst.ptr] = b;
-				u->rst.dat[u->rst.ptr + 1] = a;
-				u->rst.dat[u->rst.ptr + 2] = b;
+				Uint8 a;
+				u->rst.dat[u->rst.ptr - 1];
+				a = u->rst.dat[u->rst.ptr - 2];
+				u->rst.dat[u->rst.ptr] = a;
 #ifndef NO_STACK_CHECKS
 				if(__builtin_expect(u->rst.ptr < 2, 0)) {
 					u->rst.error = 1;
 					goto error;
 				}
-				if(__builtin_expect(u->rst.ptr > 252, 0)) {
+				if(__builtin_expect(u->rst.ptr > 254, 0)) {
 					u->rst.error = 2;
 					goto error;
 				}
 #endif
-				u->rst.ptr += 3;
+				u->rst.ptr += 1;
 			}
 			break;
 		case 0xc7: /* ROTkr */
@@ -3543,27 +3531,25 @@ uxn_eval(Uxn *u, Uint16 vec)
 				u->rst.ptr += 4;
 			}
 			break;
-		case 0xe6: /* OVR2kr */
-			__asm__("evaluxn_e6_OVR2kr:");
+		case 0xe6: /* NIP2kr */
+			__asm__("evaluxn_e6_NIP2kr:");
 			{
-				Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2], c = u->rst.dat[u->rst.ptr - 3], d = u->rst.dat[u->rst.ptr - 4];
-				u->rst.dat[u->rst.ptr] = d;
-				u->rst.dat[u->rst.ptr + 1] = c;
-				u->rst.dat[u->rst.ptr + 2] = b;
-				u->rst.dat[u->rst.ptr + 3] = a;
-				u->rst.dat[u->rst.ptr + 4] = d;
-				u->rst.dat[u->rst.ptr + 5] = c;
+				Uint16 a;
+				(u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8));
+				a = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8));
+				u->rst.dat[u->rst.ptr] = a >> 8;
+				u->rst.dat[u->rst.ptr + 1] = a & 0xff;
 #ifndef NO_STACK_CHECKS
 				if(__builtin_expect(u->rst.ptr < 4, 0)) {
 					u->rst.error = 1;
 					goto error;
 				}
-				if(__builtin_expect(u->rst.ptr > 249, 0)) {
+				if(__builtin_expect(u->rst.ptr > 253, 0)) {
 					u->rst.error = 2;
 					goto error;
 				}
 #endif
-				u->rst.ptr += 6;
+				u->rst.ptr += 2;
 			}
 			break;
 		case 0xe7: /* ROT2kr */