| ... | ... |
@@ -917,9 +917,9 @@ |
| 917 | 917 |
@asma-opcodes |
| 918 | 918 |
&BRK :&AND :&DEI &_disasm "BRK 00 |
| 919 | 919 |
&_entry :&EQU :&ROT "LIT 00 |
| 920 |
- &NIP :&MUL :&OVR "NIP 00 |
|
| 921 | 920 |
&POP $2 $2 "POP 00 |
| 922 | 921 |
&DUP :&DIV :&EOR "DUP 00 |
| 922 |
+ &NIP :&MUL :&OVR "NIP 00 |
|
| 923 | 923 |
&SWP $2 $2 "SWP 00 |
| 924 | 924 |
&OVR :&ORA :&POP "OVR 00 |
| 925 | 925 |
&ROT :&NIP :&STR "ROT 00 |
| ... | ... |
@@ -81,23 +81,8 @@ uxn_eval(Uxn *u, Uint16 vec) |
| 81 | 81 |
u->wst.ptr += 1; |
| 82 | 82 |
} |
| 83 | 83 |
break; |
| 84 |
- case 0x02: /* NIP */ |
|
| 85 |
- __asm__("evaluxn_02_NIP:");
|
|
| 86 |
- {
|
|
| 87 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 88 |
- u->wst.dat[u->wst.ptr - 2]; |
|
| 89 |
- u->wst.dat[u->wst.ptr - 2] = a; |
|
| 90 |
-#ifndef NO_STACK_CHECKS |
|
| 91 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 92 |
- u->wst.error = 1; |
|
| 93 |
- goto error; |
|
| 94 |
- } |
|
| 95 |
-#endif |
|
| 96 |
- u->wst.ptr -= 1; |
|
| 97 |
- } |
|
| 98 |
- break; |
|
| 99 |
- case 0x03: /* POP */ |
|
| 100 |
- __asm__("evaluxn_03_POP:");
|
|
| 84 |
+ case 0x02: /* POP */ |
|
| 85 |
+ __asm__("evaluxn_02_POP:");
|
|
| 101 | 86 |
{
|
| 102 | 87 |
u->wst.dat[u->wst.ptr - 1]; |
| 103 | 88 |
#ifndef NO_STACK_CHECKS |
| ... | ... |
@@ -109,8 +94,8 @@ uxn_eval(Uxn *u, Uint16 vec) |
| 109 | 94 |
u->wst.ptr -= 1; |
| 110 | 95 |
} |
| 111 | 96 |
break; |
| 112 |
- case 0x04: /* DUP */ |
|
| 113 |
- __asm__("evaluxn_04_DUP:");
|
|
| 97 |
+ case 0x03: /* DUP */ |
|
| 98 |
+ __asm__("evaluxn_03_DUP:");
|
|
| 114 | 99 |
{
|
| 115 | 100 |
Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
| 116 | 101 |
u->wst.dat[u->wst.ptr] = a; |
| ... | ... |
@@ -127,6 +112,21 @@ uxn_eval(Uxn *u, Uint16 vec) |
| 127 | 112 |
u->wst.ptr += 1; |
| 128 | 113 |
} |
| 129 | 114 |
break; |
| 115 |
+ case 0x04: /* NIP */ |
|
| 116 |
+ __asm__("evaluxn_04_NIP:");
|
|
| 117 |
+ {
|
|
| 118 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 119 |
+ u->wst.dat[u->wst.ptr - 2]; |
|
| 120 |
+ u->wst.dat[u->wst.ptr - 2] = a; |
|
| 121 |
+#ifndef NO_STACK_CHECKS |
|
| 122 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 123 |
+ u->wst.error = 1; |
|
| 124 |
+ goto error; |
|
| 125 |
+ } |
|
| 126 |
+#endif |
|
| 127 |
+ u->wst.ptr -= 1; |
|
| 128 |
+ } |
|
| 129 |
+ break; |
|
| 130 | 130 |
case 0x05: /* SWP */ |
| 131 | 131 |
__asm__("evaluxn_05_SWP:");
|
| 132 | 132 |
{
|
| ... | ... |
@@ -548,24 +548,8 @@ uxn_eval(Uxn *u, Uint16 vec) |
| 548 | 548 |
u->wst.ptr += 2; |
| 549 | 549 |
} |
| 550 | 550 |
break; |
| 551 |
- case 0x22: /* NIP2 */ |
|
| 552 |
- __asm__("evaluxn_22_NIP2:");
|
|
| 553 |
- {
|
|
| 554 |
- Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 555 |
- (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
|
| 556 |
- u->wst.dat[u->wst.ptr - 4] = a >> 8; |
|
| 557 |
- u->wst.dat[u->wst.ptr - 3] = a & 0xff; |
|
| 558 |
-#ifndef NO_STACK_CHECKS |
|
| 559 |
- if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 560 |
- u->wst.error = 1; |
|
| 561 |
- goto error; |
|
| 562 |
- } |
|
| 563 |
-#endif |
|
| 564 |
- u->wst.ptr -= 2; |
|
| 565 |
- } |
|
| 566 |
- break; |
|
| 567 |
- case 0x23: /* POP2 */ |
|
| 568 |
- __asm__("evaluxn_23_POP2:");
|
|
| 551 |
+ case 0x22: /* POP2 */ |
|
| 552 |
+ __asm__("evaluxn_22_POP2:");
|
|
| 569 | 553 |
{
|
| 570 | 554 |
(u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
| 571 | 555 |
#ifndef NO_STACK_CHECKS |
| ... | ... |
@@ -577,8 +561,8 @@ uxn_eval(Uxn *u, Uint16 vec) |
| 577 | 561 |
u->wst.ptr -= 2; |
| 578 | 562 |
} |
| 579 | 563 |
break; |
| 580 |
- case 0x24: /* DUP2 */ |
|
| 581 |
- __asm__("evaluxn_24_DUP2:");
|
|
| 564 |
+ case 0x23: /* DUP2 */ |
|
| 565 |
+ __asm__("evaluxn_23_DUP2:");
|
|
| 582 | 566 |
{
|
| 583 | 567 |
Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
| 584 | 568 |
u->wst.dat[u->wst.ptr] = b; |
| ... | ... |
@@ -596,6 +580,22 @@ uxn_eval(Uxn *u, Uint16 vec) |
| 596 | 580 |
u->wst.ptr += 2; |
| 597 | 581 |
} |
| 598 | 582 |
break; |
| 583 |
+ case 0x24: /* NIP2 */ |
|
| 584 |
+ __asm__("evaluxn_24_NIP2:");
|
|
| 585 |
+ {
|
|
| 586 |
+ Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 587 |
+ (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
|
| 588 |
+ u->wst.dat[u->wst.ptr - 4] = a >> 8; |
|
| 589 |
+ u->wst.dat[u->wst.ptr - 3] = a & 0xff; |
|
| 590 |
+#ifndef NO_STACK_CHECKS |
|
| 591 |
+ if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 592 |
+ u->wst.error = 1; |
|
| 593 |
+ goto error; |
|
| 594 |
+ } |
|
| 595 |
+#endif |
|
| 596 |
+ u->wst.ptr -= 2; |
|
| 597 |
+ } |
|
| 598 |
+ break; |
|
| 599 | 599 |
case 0x25: /* SWP2 */ |
| 600 | 600 |
__asm__("evaluxn_25_SWP2:");
|
| 601 | 601 |
{
|
| ... | ... |
@@ -1049,23 +1049,8 @@ uxn_eval(Uxn *u, Uint16 vec) |
| 1049 | 1049 |
u->rst.ptr += 1; |
| 1050 | 1050 |
} |
| 1051 | 1051 |
break; |
| 1052 |
- case 0x42: /* NIPr */ |
|
| 1053 |
- __asm__("evaluxn_42_NIPr:");
|
|
| 1054 |
- {
|
|
| 1055 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1056 |
- u->rst.dat[u->rst.ptr - 2]; |
|
| 1057 |
- u->rst.dat[u->rst.ptr - 2] = a; |
|
| 1058 |
-#ifndef NO_STACK_CHECKS |
|
| 1059 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1060 |
- u->rst.error = 1; |
|
| 1061 |
- goto error; |
|
| 1062 |
- } |
|
| 1063 |
-#endif |
|
| 1064 |
- u->rst.ptr -= 1; |
|
| 1065 |
- } |
|
| 1066 |
- break; |
|
| 1067 |
- case 0x43: /* POPr */ |
|
| 1068 |
- __asm__("evaluxn_43_POPr:");
|
|
| 1052 |
+ case 0x42: /* POPr */ |
|
| 1053 |
+ __asm__("evaluxn_42_POPr:");
|
|
| 1069 | 1054 |
{
|
| 1070 | 1055 |
u->rst.dat[u->rst.ptr - 1]; |
| 1071 | 1056 |
#ifndef NO_STACK_CHECKS |
| ... | ... |
@@ -1077,8 +1062,8 @@ uxn_eval(Uxn *u, Uint16 vec) |
| 1077 | 1062 |
u->rst.ptr -= 1; |
| 1078 | 1063 |
} |
| 1079 | 1064 |
break; |
| 1080 |
- case 0x44: /* DUPr */ |
|
| 1081 |
- __asm__("evaluxn_44_DUPr:");
|
|
| 1065 |
+ case 0x43: /* DUPr */ |
|
| 1066 |
+ __asm__("evaluxn_43_DUPr:");
|
|
| 1082 | 1067 |
{
|
| 1083 | 1068 |
Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
| 1084 | 1069 |
u->rst.dat[u->rst.ptr] = a; |
| ... | ... |
@@ -1095,6 +1080,21 @@ uxn_eval(Uxn *u, Uint16 vec) |
| 1095 | 1080 |
u->rst.ptr += 1; |
| 1096 | 1081 |
} |
| 1097 | 1082 |
break; |
| 1083 |
+ case 0x44: /* NIPr */ |
|
| 1084 |
+ __asm__("evaluxn_44_NIPr:");
|
|
| 1085 |
+ {
|
|
| 1086 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1087 |
+ u->rst.dat[u->rst.ptr - 2]; |
|
| 1088 |
+ u->rst.dat[u->rst.ptr - 2] = a; |
|
| 1089 |
+#ifndef NO_STACK_CHECKS |
|
| 1090 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1091 |
+ u->rst.error = 1; |
|
| 1092 |
+ goto error; |
|
| 1093 |
+ } |
|
| 1094 |
+#endif |
|
| 1095 |
+ u->rst.ptr -= 1; |
|
| 1096 |
+ } |
|
| 1097 |
+ break; |
|
| 1098 | 1098 |
case 0x45: /* SWPr */ |
| 1099 | 1099 |
__asm__("evaluxn_45_SWPr:");
|
| 1100 | 1100 |
{
|
| ... | ... |
@@ -1516,24 +1516,8 @@ uxn_eval(Uxn *u, Uint16 vec) |
| 1516 | 1516 |
u->rst.ptr += 2; |
| 1517 | 1517 |
} |
| 1518 | 1518 |
break; |
| 1519 |
- case 0x62: /* NIP2r */ |
|
| 1520 |
- __asm__("evaluxn_62_NIP2r:");
|
|
| 1521 |
- {
|
|
| 1522 |
- Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 1523 |
- (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
|
| 1524 |
- u->rst.dat[u->rst.ptr - 4] = a >> 8; |
|
| 1525 |
- u->rst.dat[u->rst.ptr - 3] = a & 0xff; |
|
| 1526 |
-#ifndef NO_STACK_CHECKS |
|
| 1527 |
- if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 1528 |
- u->rst.error = 1; |
|
| 1529 |
- goto error; |
|
| 1530 |
- } |
|
| 1531 |
-#endif |
|
| 1532 |
- u->rst.ptr -= 2; |
|
| 1533 |
- } |
|
| 1534 |
- break; |
|
| 1535 |
- case 0x63: /* POP2r */ |
|
| 1536 |
- __asm__("evaluxn_63_POP2r:");
|
|
| 1519 |
+ case 0x62: /* POP2r */ |
|
| 1520 |
+ __asm__("evaluxn_62_POP2r:");
|
|
| 1537 | 1521 |
{
|
| 1538 | 1522 |
(u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
| 1539 | 1523 |
#ifndef NO_STACK_CHECKS |
| ... | ... |
@@ -1545,8 +1529,8 @@ uxn_eval(Uxn *u, Uint16 vec) |
| 1545 | 1529 |
u->rst.ptr -= 2; |
| 1546 | 1530 |
} |
| 1547 | 1531 |
break; |
| 1548 |
- case 0x64: /* DUP2r */ |
|
| 1549 |
- __asm__("evaluxn_64_DUP2r:");
|
|
| 1532 |
+ case 0x63: /* DUP2r */ |
|
| 1533 |
+ __asm__("evaluxn_63_DUP2r:");
|
|
| 1550 | 1534 |
{
|
| 1551 | 1535 |
Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
| 1552 | 1536 |
u->rst.dat[u->rst.ptr] = b; |
| ... | ... |
@@ -1564,6 +1548,22 @@ uxn_eval(Uxn *u, Uint16 vec) |
| 1564 | 1548 |
u->rst.ptr += 2; |
| 1565 | 1549 |
} |
| 1566 | 1550 |
break; |
| 1551 |
+ case 0x64: /* NIP2r */ |
|
| 1552 |
+ __asm__("evaluxn_64_NIP2r:");
|
|
| 1553 |
+ {
|
|
| 1554 |
+ Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 1555 |
+ (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
|
| 1556 |
+ u->rst.dat[u->rst.ptr - 4] = a >> 8; |
|
| 1557 |
+ u->rst.dat[u->rst.ptr - 3] = a & 0xff; |
|
| 1558 |
+#ifndef NO_STACK_CHECKS |
|
| 1559 |
+ if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 1560 |
+ u->rst.error = 1; |
|
| 1561 |
+ goto error; |
|
| 1562 |
+ } |
|
| 1563 |
+#endif |
|
| 1564 |
+ u->rst.ptr -= 2; |
|
| 1565 |
+ } |
|
| 1566 |
+ break; |
|
| 1567 | 1567 |
case 0x65: /* SWP2r */ |
| 1568 | 1568 |
__asm__("evaluxn_65_SWP2r:");
|
| 1569 | 1569 |
{
|
| ... | ... |
@@ -2003,54 +2003,54 @@ uxn_eval(Uxn *u, Uint16 vec) |
| 2003 | 2003 |
u->rst.ptr -= 1; |
| 2004 | 2004 |
} |
| 2005 | 2005 |
break; |
| 2006 |
- case 0x82: /* NIPk */ |
|
| 2007 |
- __asm__("evaluxn_82_NIPk:");
|
|
| 2006 |
+ case 0x82: /* POPk */ |
|
| 2007 |
+ __asm__("evaluxn_82_POPk:");
|
|
| 2008 | 2008 |
{
|
| 2009 |
- Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 2010 |
- u->wst.dat[u->wst.ptr - 2]; |
|
| 2011 |
- u->wst.dat[u->wst.ptr] = a; |
|
| 2009 |
+ u->wst.dat[u->wst.ptr - 1]; |
|
| 2012 | 2010 |
#ifndef NO_STACK_CHECKS |
| 2013 |
- if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2011 |
+ if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 2014 | 2012 |
u->wst.error = 1; |
| 2015 | 2013 |
goto error; |
| 2016 | 2014 |
} |
| 2017 |
- if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2018 |
- u->wst.error = 2; |
|
| 2019 |
- goto error; |
|
| 2020 |
- } |
|
| 2021 | 2015 |
#endif |
| 2022 |
- u->wst.ptr += 1; |
|
| 2023 | 2016 |
} |
| 2024 | 2017 |
break; |
| 2025 |
- case 0x83: /* POPk */ |
|
| 2026 |
- __asm__("evaluxn_83_POPk:");
|
|
| 2018 |
+ case 0x83: /* DUPk */ |
|
| 2019 |
+ __asm__("evaluxn_83_DUPk:");
|
|
| 2027 | 2020 |
{
|
| 2028 |
- u->wst.dat[u->wst.ptr - 1]; |
|
| 2021 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 2022 |
+ u->wst.dat[u->wst.ptr] = a; |
|
| 2023 |
+ u->wst.dat[u->wst.ptr + 1] = a; |
|
| 2029 | 2024 |
#ifndef NO_STACK_CHECKS |
| 2030 | 2025 |
if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
| 2031 | 2026 |
u->wst.error = 1; |
| 2032 | 2027 |
goto error; |
| 2033 | 2028 |
} |
| 2029 |
+ if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 2030 |
+ u->wst.error = 2; |
|
| 2031 |
+ goto error; |
|
| 2032 |
+ } |
|
| 2034 | 2033 |
#endif |
| 2034 |
+ u->wst.ptr += 2; |
|
| 2035 | 2035 |
} |
| 2036 | 2036 |
break; |
| 2037 |
- case 0x84: /* DUPk */ |
|
| 2038 |
- __asm__("evaluxn_84_DUPk:");
|
|
| 2037 |
+ case 0x84: /* NIPk */ |
|
| 2038 |
+ __asm__("evaluxn_84_NIPk:");
|
|
| 2039 | 2039 |
{
|
| 2040 | 2040 |
Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
| 2041 |
+ u->wst.dat[u->wst.ptr - 2]; |
|
| 2041 | 2042 |
u->wst.dat[u->wst.ptr] = a; |
| 2042 |
- u->wst.dat[u->wst.ptr + 1] = a; |
|
| 2043 | 2043 |
#ifndef NO_STACK_CHECKS |
| 2044 |
- if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 2044 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2045 | 2045 |
u->wst.error = 1; |
| 2046 | 2046 |
goto error; |
| 2047 | 2047 |
} |
| 2048 |
- if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 2048 |
+ if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2049 | 2049 |
u->wst.error = 2; |
| 2050 | 2050 |
goto error; |
| 2051 | 2051 |
} |
| 2052 | 2052 |
#endif |
| 2053 |
- u->wst.ptr += 2; |
|
| 2053 |
+ u->wst.ptr += 1; |
|
| 2054 | 2054 |
} |
| 2055 | 2055 |
break; |
| 2056 | 2056 |
case 0x85: /* SWPk */ |
| ... | ... |
@@ -2526,28 +2526,8 @@ uxn_eval(Uxn *u, Uint16 vec) |
| 2526 | 2526 |
u->wst.ptr += 1; |
| 2527 | 2527 |
} |
| 2528 | 2528 |
break; |
| 2529 |
- case 0xa2: /* NIP2k */ |
|
| 2530 |
- __asm__("evaluxn_a2_NIP2k:");
|
|
| 2531 |
- {
|
|
| 2532 |
- Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 2533 |
- (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
|
| 2534 |
- u->wst.dat[u->wst.ptr] = a >> 8; |
|
| 2535 |
- u->wst.dat[u->wst.ptr + 1] = a & 0xff; |
|
| 2536 |
-#ifndef NO_STACK_CHECKS |
|
| 2537 |
- if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 2538 |
- u->wst.error = 1; |
|
| 2539 |
- goto error; |
|
| 2540 |
- } |
|
| 2541 |
- if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 2542 |
- u->wst.error = 2; |
|
| 2543 |
- goto error; |
|
| 2544 |
- } |
|
| 2545 |
-#endif |
|
| 2546 |
- u->wst.ptr += 2; |
|
| 2547 |
- } |
|
| 2548 |
- break; |
|
| 2549 |
- case 0xa3: /* POP2k */ |
|
| 2550 |
- __asm__("evaluxn_a3_POP2k:");
|
|
| 2529 |
+ case 0xa2: /* POP2k */ |
|
| 2530 |
+ __asm__("evaluxn_a2_POP2k:");
|
|
| 2551 | 2531 |
{
|
| 2552 | 2532 |
(u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
| 2553 | 2533 |
#ifndef NO_STACK_CHECKS |
| ... | ... |
@@ -2558,8 +2538,8 @@ uxn_eval(Uxn *u, Uint16 vec) |
| 2558 | 2538 |
#endif |
| 2559 | 2539 |
} |
| 2560 | 2540 |
break; |
| 2561 |
- case 0xa4: /* DUP2k */ |
|
| 2562 |
- __asm__("evaluxn_a4_DUP2k:");
|
|
| 2541 |
+ case 0xa3: /* DUP2k */ |
|
| 2542 |
+ __asm__("evaluxn_a3_DUP2k:");
|
|
| 2563 | 2543 |
{
|
| 2564 | 2544 |
Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
| 2565 | 2545 |
u->wst.dat[u->wst.ptr] = b; |
| ... | ... |
@@ -2579,6 +2559,26 @@ uxn_eval(Uxn *u, Uint16 vec) |
| 2579 | 2559 |
u->wst.ptr += 4; |
| 2580 | 2560 |
} |
| 2581 | 2561 |
break; |
| 2562 |
+ case 0xa4: /* NIP2k */ |
|
| 2563 |
+ __asm__("evaluxn_a4_NIP2k:");
|
|
| 2564 |
+ {
|
|
| 2565 |
+ Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 2566 |
+ (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
|
| 2567 |
+ u->wst.dat[u->wst.ptr] = a >> 8; |
|
| 2568 |
+ u->wst.dat[u->wst.ptr + 1] = a & 0xff; |
|
| 2569 |
+#ifndef NO_STACK_CHECKS |
|
| 2570 |
+ if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 2571 |
+ u->wst.error = 1; |
|
| 2572 |
+ goto error; |
|
| 2573 |
+ } |
|
| 2574 |
+ if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 2575 |
+ u->wst.error = 2; |
|
| 2576 |
+ goto error; |
|
| 2577 |
+ } |
|
| 2578 |
+#endif |
|
| 2579 |
+ u->wst.ptr += 2; |
|
| 2580 |
+ } |
|
| 2581 |
+ break; |
|
| 2582 | 2582 |
case 0xa5: /* SWP2k */ |
| 2583 | 2583 |
__asm__("evaluxn_a5_SWP2k:");
|
| 2584 | 2584 |
{
|
| ... | ... |
@@ -3073,54 +3073,54 @@ uxn_eval(Uxn *u, Uint16 vec) |
| 3073 | 3073 |
u->wst.ptr += 2; |
| 3074 | 3074 |
} |
| 3075 | 3075 |
break; |
| 3076 |
- case 0xc2: /* NIPkr */ |
|
| 3077 |
- __asm__("evaluxn_c2_NIPkr:");
|
|
| 3076 |
+ case 0xc2: /* POPkr */ |
|
| 3077 |
+ __asm__("evaluxn_c2_POPkr:");
|
|
| 3078 | 3078 |
{
|
| 3079 |
- Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 3080 |
- u->rst.dat[u->rst.ptr - 2]; |
|
| 3081 |
- u->rst.dat[u->rst.ptr] = a; |
|
| 3079 |
+ u->rst.dat[u->rst.ptr - 1]; |
|
| 3082 | 3080 |
#ifndef NO_STACK_CHECKS |
| 3083 |
- if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3081 |
+ if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 3084 | 3082 |
u->rst.error = 1; |
| 3085 | 3083 |
goto error; |
| 3086 | 3084 |
} |
| 3087 |
- if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3088 |
- u->rst.error = 2; |
|
| 3089 |
- goto error; |
|
| 3090 |
- } |
|
| 3091 | 3085 |
#endif |
| 3092 |
- u->rst.ptr += 1; |
|
| 3093 | 3086 |
} |
| 3094 | 3087 |
break; |
| 3095 |
- case 0xc3: /* POPkr */ |
|
| 3096 |
- __asm__("evaluxn_c3_POPkr:");
|
|
| 3088 |
+ case 0xc3: /* DUPkr */ |
|
| 3089 |
+ __asm__("evaluxn_c3_DUPkr:");
|
|
| 3097 | 3090 |
{
|
| 3098 |
- u->rst.dat[u->rst.ptr - 1]; |
|
| 3091 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 3092 |
+ u->rst.dat[u->rst.ptr] = a; |
|
| 3093 |
+ u->rst.dat[u->rst.ptr + 1] = a; |
|
| 3099 | 3094 |
#ifndef NO_STACK_CHECKS |
| 3100 | 3095 |
if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
| 3101 | 3096 |
u->rst.error = 1; |
| 3102 | 3097 |
goto error; |
| 3103 | 3098 |
} |
| 3099 |
+ if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 3100 |
+ u->rst.error = 2; |
|
| 3101 |
+ goto error; |
|
| 3102 |
+ } |
|
| 3104 | 3103 |
#endif |
| 3104 |
+ u->rst.ptr += 2; |
|
| 3105 | 3105 |
} |
| 3106 | 3106 |
break; |
| 3107 |
- case 0xc4: /* DUPkr */ |
|
| 3108 |
- __asm__("evaluxn_c4_DUPkr:");
|
|
| 3107 |
+ case 0xc4: /* NIPkr */ |
|
| 3108 |
+ __asm__("evaluxn_c4_NIPkr:");
|
|
| 3109 | 3109 |
{
|
| 3110 | 3110 |
Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
| 3111 |
+ u->rst.dat[u->rst.ptr - 2]; |
|
| 3111 | 3112 |
u->rst.dat[u->rst.ptr] = a; |
| 3112 |
- u->rst.dat[u->rst.ptr + 1] = a; |
|
| 3113 | 3113 |
#ifndef NO_STACK_CHECKS |
| 3114 |
- if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 3114 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3115 | 3115 |
u->rst.error = 1; |
| 3116 | 3116 |
goto error; |
| 3117 | 3117 |
} |
| 3118 |
- if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 3118 |
+ if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3119 | 3119 |
u->rst.error = 2; |
| 3120 | 3120 |
goto error; |
| 3121 | 3121 |
} |
| 3122 | 3122 |
#endif |
| 3123 |
- u->rst.ptr += 2; |
|
| 3123 |
+ u->rst.ptr += 1; |
|
| 3124 | 3124 |
} |
| 3125 | 3125 |
break; |
| 3126 | 3126 |
case 0xc5: /* SWPkr */ |
| ... | ... |
@@ -3596,28 +3596,8 @@ uxn_eval(Uxn *u, Uint16 vec) |
| 3596 | 3596 |
u->rst.ptr += 1; |
| 3597 | 3597 |
} |
| 3598 | 3598 |
break; |
| 3599 |
- case 0xe2: /* NIP2kr */ |
|
| 3600 |
- __asm__("evaluxn_e2_NIP2kr:");
|
|
| 3601 |
- {
|
|
| 3602 |
- Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 3603 |
- (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
|
| 3604 |
- u->rst.dat[u->rst.ptr] = a >> 8; |
|
| 3605 |
- u->rst.dat[u->rst.ptr + 1] = a & 0xff; |
|
| 3606 |
-#ifndef NO_STACK_CHECKS |
|
| 3607 |
- if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 3608 |
- u->rst.error = 1; |
|
| 3609 |
- goto error; |
|
| 3610 |
- } |
|
| 3611 |
- if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 3612 |
- u->rst.error = 2; |
|
| 3613 |
- goto error; |
|
| 3614 |
- } |
|
| 3615 |
-#endif |
|
| 3616 |
- u->rst.ptr += 2; |
|
| 3617 |
- } |
|
| 3618 |
- break; |
|
| 3619 |
- case 0xe3: /* POP2kr */ |
|
| 3620 |
- __asm__("evaluxn_e3_POP2kr:");
|
|
| 3599 |
+ case 0xe2: /* POP2kr */ |
|
| 3600 |
+ __asm__("evaluxn_e2_POP2kr:");
|
|
| 3621 | 3601 |
{
|
| 3622 | 3602 |
(u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
| 3623 | 3603 |
#ifndef NO_STACK_CHECKS |
| ... | ... |
@@ -3628,8 +3608,8 @@ uxn_eval(Uxn *u, Uint16 vec) |
| 3628 | 3608 |
#endif |
| 3629 | 3609 |
} |
| 3630 | 3610 |
break; |
| 3631 |
- case 0xe4: /* DUP2kr */ |
|
| 3632 |
- __asm__("evaluxn_e4_DUP2kr:");
|
|
| 3611 |
+ case 0xe3: /* DUP2kr */ |
|
| 3612 |
+ __asm__("evaluxn_e3_DUP2kr:");
|
|
| 3633 | 3613 |
{
|
| 3634 | 3614 |
Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
| 3635 | 3615 |
u->rst.dat[u->rst.ptr] = b; |
| ... | ... |
@@ -3649,6 +3629,26 @@ uxn_eval(Uxn *u, Uint16 vec) |
| 3649 | 3629 |
u->rst.ptr += 4; |
| 3650 | 3630 |
} |
| 3651 | 3631 |
break; |
| 3632 |
+ case 0xe4: /* NIP2kr */ |
|
| 3633 |
+ __asm__("evaluxn_e4_NIP2kr:");
|
|
| 3634 |
+ {
|
|
| 3635 |
+ Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 3636 |
+ (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
|
| 3637 |
+ u->rst.dat[u->rst.ptr] = a >> 8; |
|
| 3638 |
+ u->rst.dat[u->rst.ptr + 1] = a & 0xff; |
|
| 3639 |
+#ifndef NO_STACK_CHECKS |
|
| 3640 |
+ if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 3641 |
+ u->rst.error = 1; |
|
| 3642 |
+ goto error; |
|
| 3643 |
+ } |
|
| 3644 |
+ if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 3645 |
+ u->rst.error = 2; |
|
| 3646 |
+ goto error; |
|
| 3647 |
+ } |
|
| 3648 |
+#endif |
|
| 3649 |
+ u->rst.ptr += 2; |
|
| 3650 |
+ } |
|
| 3651 |
+ break; |
|
| 3652 | 3652 |
case 0xe5: /* SWP2kr */ |
| 3653 | 3653 |
__asm__("evaluxn_e5_SWP2kr:");
|
| 3654 | 3654 |
{
|
| ... | ... |
@@ -35,9 +35,9 @@ static Uint16 devpeek16(Device *d, Uint16 a) { return (devpeek8(d, a) << 8) + de
|
| 35 | 35 |
/* Stack */ |
| 36 | 36 |
static void op_brk(Uxn *u) { u->ram.ptr = 0; }
|
| 37 | 37 |
static void op_lit(Uxn *u) { push8(u->src, mempeek8(u->ram.dat, u->ram.ptr++)); }
|
| 38 |
-static void op_nip(Uxn *u) { Uint8 a = pop8(u->src); pop8(u->src); push8(u->src, a); }
|
|
| 39 | 38 |
static void op_pop(Uxn *u) { pop8(u->src); }
|
| 40 | 39 |
static void op_dup(Uxn *u) { Uint8 a = pop8(u->src); push8(u->src, a); push8(u->src, a); }
|
| 40 |
+static void op_nip(Uxn *u) { Uint8 a = pop8(u->src); pop8(u->src); push8(u->src, a); }
|
|
| 41 | 41 |
static void op_swp(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, a); push8(u->src, b); }
|
| 42 | 42 |
static void op_ovr(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b); push8(u->src, a); push8(u->src, b); }
|
| 43 | 43 |
static void op_rot(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src), c = pop8(u->src); push8(u->src, b); push8(u->src, a); push8(u->src, c); }
|
| ... | ... |
@@ -70,9 +70,9 @@ static void op_eor(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->
|
| 70 | 70 |
static void op_sft(Uxn *u) { Uint8 a = pop8(u->src), b = pop8(u->src); push8(u->src, b >> (a & 0x07) << ((a & 0x70) >> 4)); }
|
| 71 | 71 |
/* Stack */ |
| 72 | 72 |
static void op_lit16(Uxn *u) { push16(u->src, mempeek16(u->ram.dat, u->ram.ptr++)); u->ram.ptr++; }
|
| 73 |
-static void op_nip16(Uxn *u) { Uint16 a = pop16(u->src); pop16(u->src); push16(u->src, a); }
|
|
| 74 | 73 |
static void op_pop16(Uxn *u) { pop16(u->src); }
|
| 75 | 74 |
static void op_dup16(Uxn *u) { Uint16 a = pop16(u->src); push16(u->src, a); push16(u->src, a); }
|
| 75 |
+static void op_nip16(Uxn *u) { Uint16 a = pop16(u->src); pop16(u->src); push16(u->src, a); }
|
|
| 76 | 76 |
static void op_swp16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->src, a); push16(u->src, b); }
|
| 77 | 77 |
static void op_ovr16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->src, b); push16(u->src, a); push16(u->src, b); }
|
| 78 | 78 |
static void op_rot16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src), c = pop16(u->src); push16(u->src, b); push16(u->src, a); push16(u->src, c); }
|
| ... | ... |
@@ -105,12 +105,12 @@ static void op_eor16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push
|
| 105 | 105 |
static void op_sft16(Uxn *u) { Uint8 a = pop8(u->src); Uint16 b = pop16(u->src); push16(u->src, b >> (a & 0x0f) << ((a & 0xf0) >> 4)); }
|
| 106 | 106 |
|
| 107 | 107 |
static void (*ops[])(Uxn *u) = {
|
| 108 |
- op_brk, op_lit, op_nip, op_pop, op_dup, op_swp, op_ovr, op_rot, |
|
| 108 |
+ op_brk, op_lit, op_pop, op_dup, op_nip, op_swp, op_ovr, op_rot, |
|
| 109 | 109 |
op_equ, op_neq, op_gth, op_lth, op_jmp, op_jnz, op_jsr, op_sth, |
| 110 | 110 |
op_pek, op_pok, op_ldr, op_str, op_lda, op_sta, op_dei, op_deo, |
| 111 | 111 |
op_add, op_sub, op_mul, op_div, op_and, op_ora, op_eor, op_sft, |
| 112 | 112 |
/* 16-bit */ |
| 113 |
- op_brk, op_lit16, op_nip16, op_pop16, op_dup16, op_swp16, op_ovr16, op_rot16, |
|
| 113 |
+ op_brk, op_lit16, op_pop16, op_dup16, op_nip16, op_swp16, op_ovr16, op_rot16, |
|
| 114 | 114 |
op_equ16, op_neq16, op_gth16, op_lth16, op_jmp16, op_jnz16, op_jsr16, op_sth16, |
| 115 | 115 |
op_pek16, op_pok16, op_ldr16, op_str16, op_lda16, op_sta16, op_dei16, op_deo16, |
| 116 | 116 |
op_add16, op_sub16, op_mul16, op_div16, op_and16, op_ora16, op_eor16, op_sft16 |
| ... | ... |
@@ -40,7 +40,7 @@ Program p; |
| 40 | 40 |
/* clang-format off */ |
| 41 | 41 |
|
| 42 | 42 |
static char ops[][4] = {
|
| 43 |
- "BRK", "LIT", "NIP", "POP", "DUP", "SWP", "OVR", "ROT", |
|
| 43 |
+ "BRK", "LIT", "POP", "DUP", "NIP", "SWP", "OVR", "ROT", |
|
| 44 | 44 |
"EQU", "NEQ", "GTH", "LTH", "JMP", "JCN", "JSR", "STH", |
| 45 | 45 |
"LDZ", "STZ", "LDR", "STR", "LDA", "STA", "DEI", "DEO", |
| 46 | 46 |
"ADD", "SUB", "MUL", "DIV", "AND", "ORA", "EOR", "SFT" |