| ... | ... |
@@ -917,12 +917,12 @@ |
| 917 | 917 |
@asma-opcodes |
| 918 | 918 |
&BRK :&AND :&DEI &_disasm "BRK 00 |
| 919 | 919 |
&_entry :&EQU :&ROT "LIT 00 |
| 920 |
- &NOP :&MUL :&OVR "NOP 00 |
|
| 920 |
+ &NIP :&MUL :&OVR "NIP 00 |
|
| 921 | 921 |
&POP $2 $2 "POP 00 |
| 922 | 922 |
&DUP :&DIV :&EOR "DUP 00 |
| 923 | 923 |
&SWP $2 $2 "SWP 00 |
| 924 | 924 |
&OVR :&ORA :&POP "OVR 00 |
| 925 |
- &ROT :&NOP :&STR "ROT 00 |
|
| 925 |
+ &ROT :&NIP :&STR "ROT 00 |
|
| 926 | 926 |
&EQU :&DEO :&JSR "EQU 00 |
| 927 | 927 |
&NEQ $2 $2 "NEQ 00 |
| 928 | 928 |
>H $2 $2 "GTH 00 |
| ... | ... |
@@ -81,17 +81,19 @@ uxn_eval(Uxn *u, Uint16 vec) |
| 81 | 81 |
u->wst.ptr += 1; |
| 82 | 82 |
} |
| 83 | 83 |
break; |
| 84 |
- case 0x02: /* NOP */ |
|
| 85 |
- case 0x22: /* NOP2 */ |
|
| 86 |
- case 0x42: /* NOPr */ |
|
| 87 |
- case 0x62: /* NOP2r */ |
|
| 88 |
- case 0x82: /* NOPk */ |
|
| 89 |
- case 0xa2: /* NOP2k */ |
|
| 90 |
- case 0xc2: /* NOPkr */ |
|
| 91 |
- case 0xe2: /* NOP2kr */ |
|
| 92 |
- __asm__("evaluxn_02_NOP:");
|
|
| 84 |
+ case 0x02: /* NIP */ |
|
| 85 |
+ __asm__("evaluxn_02_NIP:");
|
|
| 93 | 86 |
{
|
| 94 |
- (void)u; |
|
| 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; |
|
| 95 | 97 |
} |
| 96 | 98 |
break; |
| 97 | 99 |
case 0x03: /* POP */ |
| ... | ... |
@@ -546,6 +548,22 @@ uxn_eval(Uxn *u, Uint16 vec) |
| 546 | 548 |
u->wst.ptr += 2; |
| 547 | 549 |
} |
| 548 | 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; |
|
| 549 | 567 |
case 0x23: /* POP2 */ |
| 550 | 568 |
__asm__("evaluxn_23_POP2:");
|
| 551 | 569 |
{
|
| ... | ... |
@@ -1031,6 +1049,21 @@ uxn_eval(Uxn *u, Uint16 vec) |
| 1031 | 1049 |
u->rst.ptr += 1; |
| 1032 | 1050 |
} |
| 1033 | 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; |
|
| 1034 | 1067 |
case 0x43: /* POPr */ |
| 1035 | 1068 |
__asm__("evaluxn_43_POPr:");
|
| 1036 | 1069 |
{
|
| ... | ... |
@@ -1483,6 +1516,22 @@ uxn_eval(Uxn *u, Uint16 vec) |
| 1483 | 1516 |
u->rst.ptr += 2; |
| 1484 | 1517 |
} |
| 1485 | 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; |
|
| 1486 | 1535 |
case 0x63: /* POP2r */ |
| 1487 | 1536 |
__asm__("evaluxn_63_POP2r:");
|
| 1488 | 1537 |
{
|
| ... | ... |
@@ -1954,6 +2003,25 @@ uxn_eval(Uxn *u, Uint16 vec) |
| 1954 | 2003 |
u->rst.ptr -= 1; |
| 1955 | 2004 |
} |
| 1956 | 2005 |
break; |
| 2006 |
+ case 0x82: /* NIPk */ |
|
| 2007 |
+ __asm__("evaluxn_82_NIPk:");
|
|
| 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; |
|
| 2012 |
+#ifndef NO_STACK_CHECKS |
|
| 2013 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2014 |
+ u->wst.error = 1; |
|
| 2015 |
+ goto error; |
|
| 2016 |
+ } |
|
| 2017 |
+ if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2018 |
+ u->wst.error = 2; |
|
| 2019 |
+ goto error; |
|
| 2020 |
+ } |
|
| 2021 |
+#endif |
|
| 2022 |
+ u->wst.ptr += 1; |
|
| 2023 |
+ } |
|
| 2024 |
+ break; |
|
| 1957 | 2025 |
case 0x83: /* POPk */ |
| 1958 | 2026 |
__asm__("evaluxn_83_POPk:");
|
| 1959 | 2027 |
{
|
| ... | ... |
@@ -2458,6 +2526,26 @@ uxn_eval(Uxn *u, Uint16 vec) |
| 2458 | 2526 |
u->wst.ptr += 1; |
| 2459 | 2527 |
} |
| 2460 | 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; |
|
| 2461 | 2549 |
case 0xa3: /* POP2k */ |
| 2462 | 2550 |
__asm__("evaluxn_a3_POP2k:");
|
| 2463 | 2551 |
{
|
| ... | ... |
@@ -2985,6 +3073,25 @@ uxn_eval(Uxn *u, Uint16 vec) |
| 2985 | 3073 |
u->wst.ptr += 2; |
| 2986 | 3074 |
} |
| 2987 | 3075 |
break; |
| 3076 |
+ case 0xc2: /* NIPkr */ |
|
| 3077 |
+ __asm__("evaluxn_c2_NIPkr:");
|
|
| 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; |
|
| 3082 |
+#ifndef NO_STACK_CHECKS |
|
| 3083 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3084 |
+ u->rst.error = 1; |
|
| 3085 |
+ goto error; |
|
| 3086 |
+ } |
|
| 3087 |
+ if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3088 |
+ u->rst.error = 2; |
|
| 3089 |
+ goto error; |
|
| 3090 |
+ } |
|
| 3091 |
+#endif |
|
| 3092 |
+ u->rst.ptr += 1; |
|
| 3093 |
+ } |
|
| 3094 |
+ break; |
|
| 2988 | 3095 |
case 0xc3: /* POPkr */ |
| 2989 | 3096 |
__asm__("evaluxn_c3_POPkr:");
|
| 2990 | 3097 |
{
|
| ... | ... |
@@ -3489,6 +3596,26 @@ uxn_eval(Uxn *u, Uint16 vec) |
| 3489 | 3596 |
u->rst.ptr += 1; |
| 3490 | 3597 |
} |
| 3491 | 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; |
|
| 3492 | 3619 |
case 0xe3: /* POP2kr */ |
| 3493 | 3620 |
__asm__("evaluxn_e3_POP2kr:");
|
| 3494 | 3621 |
{
|
| ... | ... |
@@ -34,8 +34,8 @@ static void devpoke16(Device *d, Uint8 a, Uint16 b) { devpoke8(d, a, b >> 8);
|
| 34 | 34 |
static Uint16 devpeek16(Device *d, Uint16 a) { return (devpeek8(d, a) << 8) + devpeek8(d, a + 1); }
|
| 35 | 35 |
/* Stack */ |
| 36 | 36 |
static void op_brk(Uxn *u) { u->ram.ptr = 0; }
|
| 37 |
-static void op_nop(Uxn *u) { (void)u; }
|
|
| 38 | 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 | 39 |
static void op_pop(Uxn *u) { pop8(u->src); }
|
| 40 | 40 |
static void op_dup(Uxn *u) { Uint8 a = pop8(u->src); push8(u->src, a); 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); }
|
| ... | ... |
@@ -70,6 +70,7 @@ 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); }
|
|
| 73 | 74 |
static void op_pop16(Uxn *u) { pop16(u->src); }
|
| 74 | 75 |
static void op_dup16(Uxn *u) { Uint16 a = pop16(u->src); push16(u->src, a); push16(u->src, a); }
|
| 75 | 76 |
static void op_swp16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push16(u->src, a); push16(u->src, b); }
|
| ... | ... |
@@ -104,12 +105,12 @@ static void op_eor16(Uxn *u) { Uint16 a = pop16(u->src), b = pop16(u->src); push
|
| 104 | 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)); }
|
| 105 | 106 |
|
| 106 | 107 |
static void (*ops[])(Uxn *u) = {
|
| 107 |
- op_brk, op_lit, op_nop, op_pop, op_dup, op_swp, op_ovr, op_rot, |
|
| 108 |
+ op_brk, op_lit, op_nip, op_pop, op_dup, op_swp, op_ovr, op_rot, |
|
| 108 | 109 |
op_equ, op_neq, op_gth, op_lth, op_jmp, op_jnz, op_jsr, op_sth, |
| 109 | 110 |
op_pek, op_pok, op_ldr, op_str, op_lda, op_sta, op_dei, op_deo, |
| 110 | 111 |
op_add, op_sub, op_mul, op_div, op_and, op_ora, op_eor, op_sft, |
| 111 | 112 |
/* 16-bit */ |
| 112 |
- op_brk, op_lit16, op_nop, op_pop16, op_dup16, op_swp16, op_ovr16, op_rot16, |
|
| 113 |
+ op_brk, op_lit16, op_nip16, op_pop16, op_dup16, op_swp16, op_ovr16, op_rot16, |
|
| 113 | 114 |
op_equ16, op_neq16, op_gth16, op_lth16, op_jmp16, op_jnz16, op_jsr16, op_sth16, |
| 114 | 115 |
op_pek16, op_pok16, op_ldr16, op_str16, op_lda16, op_sta16, op_dei16, op_deo16, |
| 115 | 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", "NOP", "POP", "DUP", "SWP", "OVR", "ROT", |
|
| 43 |
+ "BRK", "LIT", "NIP", "POP", "DUP", "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" |