Browse code

Updated uxn-fast.c

Andrew Alderwick authored on 15/08/2021 19:05:19
Showing 1 changed files
... ...
@@ -139,22 +139,19 @@ uxn_eval(Uxn *u, Uint16 vec)
139 139
 #endif
140 140
 			}
141 141
 			break;
142
-		case 0x06: /* OVR */
143
-			__asm__("evaluxn_06_OVR:");
142
+		case 0x06: /* NIP */
143
+			__asm__("evaluxn_06_NIP:");
144 144
 			{
145
-				Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
146
-				u->wst.dat[u->wst.ptr] = b;
145
+				Uint8 a;
146
+				u->wst.dat[u->wst.ptr - 1];
147
+				a = u->wst.dat[u->wst.ptr - 2];
147 148
 #ifndef NO_STACK_CHECKS
148 149
 				if(__builtin_expect(u->wst.ptr < 2, 0)) {
149 150
 					u->wst.error = 1;
150 151
 					goto error;
151 152
 				}
152
-				if(__builtin_expect(u->wst.ptr > 254, 0)) {
153
-					u->wst.error = 2;
154
-					goto error;
155
-				}
156 153
 #endif
157
-				u->wst.ptr += 1;
154
+				u->wst.ptr -= 1;
158 155
 			}
159 156
 			break;
160 157
 		case 0x07: /* ROT */
... ...
@@ -594,23 +591,21 @@ uxn_eval(Uxn *u, Uint16 vec)
594 591
 #endif
595 592
 			}
596 593
 			break;
597
-		case 0x26: /* OVR2 */
598
-			__asm__("evaluxn_26_OVR2:");
594
+		case 0x26: /* NIP2 */
595
+			__asm__("evaluxn_26_NIP2:");
599 596
 			{
600
-				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];
601
-				u->wst.dat[u->wst.ptr] = d;
602
-				u->wst.dat[u->wst.ptr + 1] = c;
597
+				Uint16 a;
598
+				(u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8));
599
+				a = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8));
600
+				u->wst.dat[u->wst.ptr - 4] = a >> 8;
601
+				u->wst.dat[u->wst.ptr - 3] = a & 0xff;
603 602
 #ifndef NO_STACK_CHECKS
604 603
 				if(__builtin_expect(u->wst.ptr < 4, 0)) {
605 604
 					u->wst.error = 1;
606 605
 					goto error;
607 606
 				}
608
-				if(__builtin_expect(u->wst.ptr > 253, 0)) {
609
-					u->wst.error = 2;
610
-					goto error;
611
-				}
612 607
 #endif
613
-				u->wst.ptr += 2;
608
+				u->wst.ptr -= 2;
614 609
 			}
615 610
 			break;
616 611
 		case 0x27: /* ROT2 */
... ...
@@ -1076,22 +1071,19 @@ uxn_eval(Uxn *u, Uint16 vec)
1076 1071
 #endif
1077 1072
 			}
1078 1073
 			break;
1079
-		case 0x46: /* OVRr */
1080
-			__asm__("evaluxn_46_OVRr:");
1074
+		case 0x46: /* NIPr */
1075
+			__asm__("evaluxn_46_NIPr:");
1081 1076
 			{
1082
-				Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
1083
-				u->rst.dat[u->rst.ptr] = b;
1077
+				Uint8 a;
1078
+				u->rst.dat[u->rst.ptr - 1];
1079
+				a = u->rst.dat[u->rst.ptr - 2];
1084 1080
 #ifndef NO_STACK_CHECKS
1085 1081
 				if(__builtin_expect(u->rst.ptr < 2, 0)) {
1086 1082
 					u->rst.error = 1;
1087 1083
 					goto error;
1088 1084
 				}
1089
-				if(__builtin_expect(u->rst.ptr > 254, 0)) {
1090
-					u->rst.error = 2;
1091
-					goto error;
1092
-				}
1093 1085
 #endif
1094
-				u->rst.ptr += 1;
1086
+				u->rst.ptr -= 1;
1095 1087
 			}
1096 1088
 			break;
1097 1089
 		case 0x47: /* ROTr */
... ...
@@ -1531,23 +1523,21 @@ uxn_eval(Uxn *u, Uint16 vec)
1531 1523
 #endif
1532 1524
 			}
1533 1525
 			break;
1534
-		case 0x66: /* OVR2r */
1535
-			__asm__("evaluxn_66_OVR2r:");
1526
+		case 0x66: /* NIP2r */
1527
+			__asm__("evaluxn_66_NIP2r:");
1536 1528
 			{
1537
-				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];
1538
-				u->rst.dat[u->rst.ptr] = d;
1539
-				u->rst.dat[u->rst.ptr + 1] = c;
1529
+				Uint16 a;
1530
+				(u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8));
1531
+				a = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8));
1532
+				u->rst.dat[u->rst.ptr - 4] = a >> 8;
1533
+				u->rst.dat[u->rst.ptr - 3] = a & 0xff;
1540 1534
 #ifndef NO_STACK_CHECKS
1541 1535
 				if(__builtin_expect(u->rst.ptr < 4, 0)) {
1542 1536
 					u->rst.error = 1;
1543 1537
 					goto error;
1544 1538
 				}
1545
-				if(__builtin_expect(u->rst.ptr > 253, 0)) {
1546
-					u->rst.error = 2;
1547
-					goto error;
1548
-				}
1549 1539
 #endif
1550
-				u->rst.ptr += 2;
1540
+				u->rst.ptr -= 2;
1551 1541
 			}
1552 1542
 			break;
1553 1543
 		case 0x67: /* ROT2r */
... ...
@@ -2004,24 +1994,24 @@ uxn_eval(Uxn *u, Uint16 vec)
2004 1994
 				u->wst.ptr += 2;
2005 1995
 			}
2006 1996
 			break;
2007
-		case 0x86: /* OVRk */
2008
-			__asm__("evaluxn_86_OVRk:");
1997
+		case 0x86: /* NIPk */
1998
+			__asm__("evaluxn_86_NIPk:");
2009 1999
 			{
2010
-				Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
2011
-				u->wst.dat[u->wst.ptr] = b;
2012
-				u->wst.dat[u->wst.ptr + 1] = a;
2013
-				u->wst.dat[u->wst.ptr + 2] = b;
2000
+				Uint8 a;
2001
+				u->wst.dat[u->wst.ptr - 1];
2002
+				a = u->wst.dat[u->wst.ptr - 2];
2003
+				u->wst.dat[u->wst.ptr] = a;
2014 2004
 #ifndef NO_STACK_CHECKS
2015 2005
 				if(__builtin_expect(u->wst.ptr < 2, 0)) {
2016 2006
 					u->wst.error = 1;
2017 2007
 					goto error;
2018 2008
 				}
2019
-				if(__builtin_expect(u->wst.ptr > 252, 0)) {
2009
+				if(__builtin_expect(u->wst.ptr > 254, 0)) {
2020 2010
 					u->wst.error = 2;
2021 2011
 					goto error;
2022 2012
 				}
2023 2013
 #endif
2024
-				u->wst.ptr += 3;
2014
+				u->wst.ptr += 1;
2025 2015
 			}
2026 2016
 			break;
2027 2017
 		case 0x87: /* ROTk */
... ...
@@ -2512,27 +2502,25 @@ uxn_eval(Uxn *u, Uint16 vec)
2512 2502
 				u->wst.ptr += 4;
2513 2503
 			}
2514 2504
 			break;
2515
-		case 0xa6: /* OVR2k */
2516
-			__asm__("evaluxn_a6_OVR2k:");
2505
+		case 0xa6: /* NIP2k */
2506
+			__asm__("evaluxn_a6_NIP2k:");
2517 2507
 			{
2518
-				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];
2519
-				u->wst.dat[u->wst.ptr] = d;
2520
-				u->wst.dat[u->wst.ptr + 1] = c;
2521
-				u->wst.dat[u->wst.ptr + 2] = b;
2522
-				u->wst.dat[u->wst.ptr + 3] = a;
2523
-				u->wst.dat[u->wst.ptr + 4] = d;
2524
-				u->wst.dat[u->wst.ptr + 5] = c;
2508
+				Uint16 a;
2509
+				(u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8));
2510
+				a = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8));
2511
+				u->wst.dat[u->wst.ptr] = a >> 8;
2512
+				u->wst.dat[u->wst.ptr + 1] = a & 0xff;
2525 2513
 #ifndef NO_STACK_CHECKS
2526 2514
 				if(__builtin_expect(u->wst.ptr < 4, 0)) {
2527 2515
 					u->wst.error = 1;
2528 2516
 					goto error;
2529 2517
 				}
2530
-				if(__builtin_expect(u->wst.ptr > 249, 0)) {
2518
+				if(__builtin_expect(u->wst.ptr > 253, 0)) {
2531 2519
 					u->wst.error = 2;
2532 2520
 					goto error;
2533 2521
 				}
2534 2522
 #endif
2535
-				u->wst.ptr += 6;
2523
+				u->wst.ptr += 2;
2536 2524
 			}
2537 2525
 			break;
2538 2526
 		case 0xa7: /* ROT2k */
... ...
@@ -3035,24 +3023,24 @@ uxn_eval(Uxn *u, Uint16 vec)
3035 3023
 				u->rst.ptr += 2;
3036 3024
 			}
3037 3025
 			break;
3038
-		case 0xc6: /* OVRkr */
3039
-			__asm__("evaluxn_c6_OVRkr:");
3026
+		case 0xc6: /* NIPkr */
3027
+			__asm__("evaluxn_c6_NIPkr:");
3040 3028
 			{
3041
-				Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
3042
-				u->rst.dat[u->rst.ptr] = b;
3043
-				u->rst.dat[u->rst.ptr + 1] = a;
3044
-				u->rst.dat[u->rst.ptr + 2] = b;
3029
+				Uint8 a;
3030
+				u->rst.dat[u->rst.ptr - 1];
3031
+				a = u->rst.dat[u->rst.ptr - 2];
3032
+				u->rst.dat[u->rst.ptr] = a;
3045 3033
 #ifndef NO_STACK_CHECKS
3046 3034
 				if(__builtin_expect(u->rst.ptr < 2, 0)) {
3047 3035
 					u->rst.error = 1;
3048 3036
 					goto error;
3049 3037
 				}
3050
-				if(__builtin_expect(u->rst.ptr > 252, 0)) {
3038
+				if(__builtin_expect(u->rst.ptr > 254, 0)) {
3051 3039
 					u->rst.error = 2;
3052 3040
 					goto error;
3053 3041
 				}
3054 3042
 #endif
3055
-				u->rst.ptr += 3;
3043
+				u->rst.ptr += 1;
3056 3044
 			}
3057 3045
 			break;
3058 3046
 		case 0xc7: /* ROTkr */
... ...
@@ -3543,27 +3531,25 @@ uxn_eval(Uxn *u, Uint16 vec)
3543 3531
 				u->rst.ptr += 4;
3544 3532
 			}
3545 3533
 			break;
3546
-		case 0xe6: /* OVR2kr */
3547
-			__asm__("evaluxn_e6_OVR2kr:");
3534
+		case 0xe6: /* NIP2kr */
3535
+			__asm__("evaluxn_e6_NIP2kr:");
3548 3536
 			{
3549
-				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];
3550
-				u->rst.dat[u->rst.ptr] = d;
3551
-				u->rst.dat[u->rst.ptr + 1] = c;
3552
-				u->rst.dat[u->rst.ptr + 2] = b;
3553
-				u->rst.dat[u->rst.ptr + 3] = a;
3554
-				u->rst.dat[u->rst.ptr + 4] = d;
3555
-				u->rst.dat[u->rst.ptr + 5] = c;
3537
+				Uint16 a;
3538
+				(u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8));
3539
+				a = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8));
3540
+				u->rst.dat[u->rst.ptr] = a >> 8;
3541
+				u->rst.dat[u->rst.ptr + 1] = a & 0xff;
3556 3542
 #ifndef NO_STACK_CHECKS
3557 3543
 				if(__builtin_expect(u->rst.ptr < 4, 0)) {
3558 3544
 					u->rst.error = 1;
3559 3545
 					goto error;
3560 3546
 				}
3561
-				if(__builtin_expect(u->rst.ptr > 249, 0)) {
3547
+				if(__builtin_expect(u->rst.ptr > 253, 0)) {
3562 3548
 					u->rst.error = 2;
3563 3549
 					goto error;
3564 3550
 				}
3565 3551
 #endif
3566
-				u->rst.ptr += 6;
3552
+				u->rst.ptr += 2;
3567 3553
 			}
3568 3554
 			break;
3569 3555
 		case 0xe7: /* ROT2kr */