2021-05-23 11:41:41 -04:00
|
|
|
#include "uxn.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
Copyright (u) 2021 Devine Lu Linvega
|
|
|
|
Copyright (u) 2021 Andrew Alderwick
|
|
|
|
|
|
|
|
Permission to use, copy, modify, and distribute this software for any
|
|
|
|
purpose with or without fee is hereby granted, provided that the above
|
|
|
|
copyright notice and this permission notice appear in all copies.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
WITH REGARD TO THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2021-05-23 12:33:00 -04:00
|
|
|
/*
|
|
|
|
^
|
|
|
|
/!\ THIS FILE IS AUTOMATICALLY GENERATED
|
|
|
|
---
|
|
|
|
|
|
|
|
Its contents can get overwritten with the processed contents of src/uxn.c.
|
|
|
|
See etc/mkuxn-fast.moon for instructions.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2021-08-29 17:28:30 -04:00
|
|
|
#define MODE_RETURN 0x20
|
|
|
|
#define MODE_SHORT 0x40
|
2021-08-05 13:38:25 -04:00
|
|
|
#define MODE_KEEP 0x80
|
|
|
|
|
2021-05-23 12:33:00 -04:00
|
|
|
#pragma mark - Operations
|
|
|
|
|
2021-05-23 11:41:41 -04:00
|
|
|
/* clang-format off */
|
2021-08-05 13:38:25 -04:00
|
|
|
static void mempoke8(Uint8 *m, Uint16 a, Uint8 b) { m[a] = b; }
|
|
|
|
static Uint8 mempeek8(Uint8 *m, Uint16 a) { return m[a]; }
|
|
|
|
static void devpoke8(Device *d, Uint8 a, Uint8 b) { d->dat[a & 0xf] = b; d->talk(d, a & 0x0f, 1); }
|
|
|
|
static Uint8 devpeek8(Device *d, Uint8 a) { d->talk(d, a & 0x0f, 0); return d->dat[a & 0xf]; }
|
2021-05-23 11:41:41 -04:00
|
|
|
void mempoke16(Uint8 *m, Uint16 a, Uint16 b) { mempoke8(m, a, b >> 8); mempoke8(m, a + 1, b); }
|
|
|
|
Uint16 mempeek16(Uint8 *m, Uint16 a) { return (mempeek8(m, a) << 8) + mempeek8(m, a + 1); }
|
2021-08-05 13:38:25 -04:00
|
|
|
static void devpoke16(Device *d, Uint8 a, Uint16 b) { devpoke8(d, a, b >> 8); devpoke8(d, a + 1, b); }
|
2021-06-08 17:58:02 -04:00
|
|
|
|
2021-05-23 11:41:41 -04:00
|
|
|
/* clang-format on */
|
|
|
|
|
2021-05-23 12:33:00 -04:00
|
|
|
#pragma mark - Core
|
|
|
|
|
2021-05-23 11:41:41 -04:00
|
|
|
int
|
2021-08-01 17:46:43 -04:00
|
|
|
uxn_eval(Uxn *u, Uint16 vec)
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
Uint8 instr;
|
2021-08-17 22:30:34 -04:00
|
|
|
if(!vec || u->dev[0].dat[0xf])
|
2021-07-28 13:29:09 -04:00
|
|
|
return 0;
|
2021-05-23 11:41:41 -04:00
|
|
|
u->ram.ptr = vec;
|
2021-08-04 23:14:53 -04:00
|
|
|
if(u->wst.ptr > 0xf8) u->wst.ptr = 0xf8;
|
2021-08-17 17:48:48 -04:00
|
|
|
while((instr = u->ram.dat[u->ram.ptr++])) {
|
2021-05-23 11:41:41 -04:00
|
|
|
switch(instr) {
|
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic ignored "-Wunused-value"
|
|
|
|
#pragma GCC diagnostic ignored "-Wunused-variable"
|
2021-08-17 17:48:48 -04:00
|
|
|
case 0x00: /* LIT */
|
|
|
|
case 0x80: /* LITk */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, u->ram.ptr++);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
|
|
u->wst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr += 1;
|
|
|
|
}
|
|
|
|
break;
|
2021-08-17 17:48:48 -04:00
|
|
|
case 0x01: /* INC */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
u->wst.dat[u->wst.ptr - 1] = a + 1;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
2021-08-15 16:34:33 -04:00
|
|
|
case 0x02: /* POP */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
u->wst.dat[u->wst.ptr - 1];
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 1;
|
|
|
|
}
|
|
|
|
break;
|
2021-08-15 16:34:33 -04:00
|
|
|
case 0x03: /* DUP */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
u->wst.dat[u->wst.ptr] = a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 1, 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;
|
|
|
|
}
|
|
|
|
break;
|
2021-08-15 16:34:33 -04:00
|
|
|
case 0x04: /* NIP */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
u->wst.dat[u->wst.ptr - 2];
|
|
|
|
u->wst.dat[u->wst.ptr - 2] = a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 1;
|
|
|
|
}
|
|
|
|
break;
|
2021-05-23 11:41:41 -04:00
|
|
|
case 0x05: /* SWP */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
|
|
|
|
u->wst.dat[u->wst.ptr - 2] = a;
|
|
|
|
u->wst.dat[u->wst.ptr - 1] = b;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
2021-08-15 16:06:54 -04:00
|
|
|
case 0x06: /* OVR */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-15 16:06:54 -04:00
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
|
|
|
|
u->wst.dat[u->wst.ptr] = b;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
2021-08-15 16:06:54 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
|
|
u->wst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
2021-05-23 11:41:41 -04:00
|
|
|
#endif
|
2021-08-15 16:06:54 -04:00
|
|
|
u->wst.ptr += 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x07: /* ROT */
|
|
|
|
{
|
|
|
|
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];
|
|
|
|
u->wst.dat[u->wst.ptr - 3] = b;
|
|
|
|
u->wst.dat[u->wst.ptr - 2] = a;
|
|
|
|
u->wst.dat[u->wst.ptr - 1] = c;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x08: /* EQU */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
|
|
|
|
u->wst.dat[u->wst.ptr - 2] = b == a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x09: /* NEQ */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
|
|
|
|
u->wst.dat[u->wst.ptr - 2] = b != a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x0a: /* GTH */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
|
|
|
|
u->wst.dat[u->wst.ptr - 2] = b > a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x0b: /* LTH */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
|
|
|
|
u->wst.dat[u->wst.ptr - 2] = b < a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x0c: /* JMP */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
u->ram.ptr += (Sint8)a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x0d: /* JCN */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
if(u->wst.dat[u->wst.ptr - 2]) u->ram.ptr += (Sint8)a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x0e: /* JSR */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
u->rst.dat[u->rst.ptr] = u->ram.ptr >> 8;
|
|
|
|
u->rst.dat[u->rst.ptr + 1] = u->ram.ptr & 0xff;
|
|
|
|
u->ram.ptr += (Sint8)a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 1;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
|
|
u->rst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr += 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x0f: /* STH */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
u->rst.dat[u->rst.ptr] = a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 1;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x10: /* LDZ */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
u->wst.dat[u->wst.ptr - 1] = mempeek8(u->ram.dat, a);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x11: /* STZ */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
Uint8 b = u->wst.dat[u->wst.ptr - 2];
|
|
|
|
mempoke8(u->ram.dat, a, b);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x12: /* LDR */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
u->wst.dat[u->wst.ptr - 1] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x13: /* STR */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
Uint8 b = u->wst.dat[u->wst.ptr - 2];
|
|
|
|
mempoke8(u->ram.dat, u->ram.ptr + (Sint8)a, b);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x14: /* LDA */
|
|
|
|
{
|
|
|
|
Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8));
|
|
|
|
u->wst.dat[u->wst.ptr - 2] = mempeek8(u->ram.dat, a);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x15: /* STA */
|
|
|
|
{
|
|
|
|
Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8));
|
|
|
|
Uint8 b = u->wst.dat[u->wst.ptr - 3];
|
|
|
|
mempoke8(u->ram.dat, a, b);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 3;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x16: /* DEI */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
u->wst.dat[u->wst.ptr - 1] = devpeek8(&u->dev[a >> 4], a);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x17: /* DEO */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
|
|
|
|
devpoke8(&u->dev[a >> 4], a, b);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x18: /* ADD */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
|
|
|
|
u->wst.dat[u->wst.ptr - 2] = b + a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x19: /* SUB */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
|
|
|
|
u->wst.dat[u->wst.ptr - 2] = b - a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x1a: /* MUL */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
|
|
|
|
u->wst.dat[u->wst.ptr - 2] = b * a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x1b: /* DIV */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
|
2021-06-08 17:58:02 -04:00
|
|
|
if(a == 0) {
|
|
|
|
u->wst.error = 3;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
goto error;
|
|
|
|
#endif
|
|
|
|
a = 1;
|
|
|
|
}
|
2021-05-23 11:41:41 -04:00
|
|
|
u->wst.dat[u->wst.ptr - 2] = b / a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x1c: /* AND */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
|
|
|
|
u->wst.dat[u->wst.ptr - 2] = b & a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x1d: /* ORA */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
|
|
|
|
u->wst.dat[u->wst.ptr - 2] = b | a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x1e: /* EOR */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
|
|
|
|
u->wst.dat[u->wst.ptr - 2] = b ^ a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x1f: /* SFT */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
|
|
|
|
u->wst.dat[u->wst.ptr - 2] = b >> (a & 0x07) << ((a & 0x70) >> 4);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 1;
|
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x20: /* LITr */
|
|
|
|
case 0xa0: /* LITkr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, u->ram.ptr++);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr += 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x21: /* INCr */
|
2021-08-17 17:48:48 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
u->rst.dat[u->rst.ptr - 1] = a + 1;
|
2021-08-17 17:48:48 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-08-17 17:48:48 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x22: /* POPr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.dat[u->rst.ptr - 1];
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr -= 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x23: /* DUPr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
u->rst.dat[u->rst.ptr] = a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr += 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x24: /* NIPr */
|
2021-08-15 16:34:33 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
u->rst.dat[u->rst.ptr - 2];
|
|
|
|
u->rst.dat[u->rst.ptr - 2] = a;
|
2021-08-15 16:34:33 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-08-15 16:34:33 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr -= 1;
|
2021-08-15 16:34:33 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x25: /* SWPr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
|
|
|
|
u->rst.dat[u->rst.ptr - 2] = a;
|
|
|
|
u->rst.dat[u->rst.ptr - 1] = b;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x26: /* OVRr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
|
|
|
|
u->rst.dat[u->rst.ptr] = b;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
2021-08-15 16:06:54 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-05-23 11:41:41 -04:00
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr += 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x27: /* ROTr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
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];
|
|
|
|
u->rst.dat[u->rst.ptr - 3] = b;
|
|
|
|
u->rst.dat[u->rst.ptr - 2] = a;
|
|
|
|
u->rst.dat[u->rst.ptr - 1] = c;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x28: /* EQUr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
|
|
|
|
u->rst.dat[u->rst.ptr - 2] = b == a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr -= 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x29: /* NEQr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
|
|
|
|
u->rst.dat[u->rst.ptr - 2] = b != a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr -= 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x2a: /* GTHr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
|
|
|
|
u->rst.dat[u->rst.ptr - 2] = b > a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr -= 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x2b: /* LTHr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
|
|
|
|
u->rst.dat[u->rst.ptr - 2] = b < a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr -= 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x2c: /* JMPr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
u->ram.ptr += (Sint8)a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr -= 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x2d: /* JCNr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
if(u->rst.dat[u->rst.ptr - 2]) u->ram.ptr += (Sint8)a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr -= 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x2e: /* JSRr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
u->wst.dat[u->wst.ptr] = u->ram.ptr >> 8;
|
|
|
|
u->wst.dat[u->wst.ptr + 1] = u->ram.ptr & 0xff;
|
|
|
|
u->ram.ptr += (Sint8)a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr -= 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
|
|
u->wst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr += 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x2f: /* STHr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
u->wst.dat[u->wst.ptr] = a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr -= 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
|
|
u->wst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr += 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x30: /* LDZr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
u->rst.dat[u->rst.ptr - 1] = mempeek8(u->ram.dat, a);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x31: /* STZr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
Uint8 b = u->rst.dat[u->rst.ptr - 2];
|
|
|
|
mempoke8(u->ram.dat, a, b);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr -= 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x32: /* LDRr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
u->rst.dat[u->rst.ptr - 1] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x33: /* STRr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
Uint8 b = u->rst.dat[u->rst.ptr - 2];
|
|
|
|
mempoke8(u->ram.dat, u->ram.ptr + (Sint8)a, b);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr -= 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x34: /* LDAr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8));
|
|
|
|
u->rst.dat[u->rst.ptr - 2] = mempeek8(u->ram.dat, a);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr -= 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x35: /* STAr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8));
|
|
|
|
Uint8 b = u->rst.dat[u->rst.ptr - 3];
|
|
|
|
mempoke8(u->ram.dat, a, b);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr -= 3;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x36: /* DEIr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
u->rst.dat[u->rst.ptr - 1] = devpeek8(&u->dev[a >> 4], a);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x37: /* DEOr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
|
|
|
|
devpoke8(&u->dev[a >> 4], a, b);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr -= 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x38: /* ADDr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
|
|
|
|
u->rst.dat[u->rst.ptr - 2] = b + a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr -= 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x39: /* SUBr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
|
|
|
|
u->rst.dat[u->rst.ptr - 2] = b - a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr -= 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x3a: /* MULr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
|
|
|
|
u->rst.dat[u->rst.ptr - 2] = b * a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr -= 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x3b: /* DIVr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
|
2021-06-08 17:58:02 -04:00
|
|
|
if(a == 0) {
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.error = 3;
|
2021-06-08 17:58:02 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
goto error;
|
|
|
|
#endif
|
|
|
|
a = 1;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.dat[u->rst.ptr - 2] = b / a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr -= 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x3c: /* ANDr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
|
|
|
|
u->rst.dat[u->rst.ptr - 2] = b & a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr -= 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x3d: /* ORAr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
|
|
|
|
u->rst.dat[u->rst.ptr - 2] = b | a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr -= 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x3e: /* EORr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
|
|
|
|
u->rst.dat[u->rst.ptr - 2] = b ^ a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr -= 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x3f: /* SFTr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
|
|
|
|
u->rst.dat[u->rst.ptr - 2] = b >> (a & 0x07) << ((a & 0x70) >> 4);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr -= 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x40: /* LIT2 */
|
|
|
|
case 0xc0: /* LIT2k */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
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++);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
|
|
u->wst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr += 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x41: /* INC2 */
|
2021-08-17 17:48:48 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8));
|
|
|
|
u->wst.dat[u->wst.ptr - 2] = (a + 1) >> 8;
|
|
|
|
u->wst.dat[u->wst.ptr - 1] = (a + 1) & 0xff;
|
2021-08-17 17:48:48 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-08-17 17:48:48 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x42: /* POP2 */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
(u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8));
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr -= 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x43: /* DUP2 */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
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;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
|
|
u->wst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr += 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x44: /* NIP2 */
|
2021-08-15 16:34:33 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8));
|
|
|
|
(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;
|
2021-08-15 16:34:33 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-08-15 16:34:33 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr -= 2;
|
2021-08-15 16:34:33 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x45: /* SWP2 */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
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 - 4] = b;
|
|
|
|
u->wst.dat[u->wst.ptr - 3] = a;
|
|
|
|
u->wst.dat[u->wst.ptr - 2] = d;
|
|
|
|
u->wst.dat[u->wst.ptr - 1] = c;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x46: /* OVR2 */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
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;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
|
|
u->wst.error = 2;
|
2021-08-15 16:06:54 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-05-23 11:41:41 -04:00
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr += 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x47: /* ROT2 */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
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], e = u->wst.dat[u->wst.ptr - 5], f = u->wst.dat[u->wst.ptr - 6];
|
|
|
|
u->wst.dat[u->wst.ptr - 6] = d;
|
|
|
|
u->wst.dat[u->wst.ptr - 5] = c;
|
|
|
|
u->wst.dat[u->wst.ptr - 4] = b;
|
|
|
|
u->wst.dat[u->wst.ptr - 3] = a;
|
|
|
|
u->wst.dat[u->wst.ptr - 2] = f;
|
|
|
|
u->wst.dat[u->wst.ptr - 1] = e;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 6, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x48: /* EQU2 */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8));
|
|
|
|
u->wst.dat[u->wst.ptr - 4] = b == a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr -= 3;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x49: /* NEQ2 */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8));
|
|
|
|
u->wst.dat[u->wst.ptr - 4] = b != a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr -= 3;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x4a: /* GTH2 */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8));
|
|
|
|
u->wst.dat[u->wst.ptr - 4] = b > a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr -= 3;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x4b: /* LTH2 */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8));
|
|
|
|
u->wst.dat[u->wst.ptr - 4] = b < a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr -= 3;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x4c: /* JMP2 */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
u->ram.ptr = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8));
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr -= 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x4d: /* JCN2 */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8));
|
|
|
|
if(u->wst.dat[u->wst.ptr - 3]) u->ram.ptr = a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr -= 3;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x4e: /* JSR2 */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.dat[u->rst.ptr] = u->ram.ptr >> 8;
|
|
|
|
u->rst.dat[u->rst.ptr + 1] = u->ram.ptr & 0xff;
|
|
|
|
u->ram.ptr = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8));
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr -= 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
|
|
u->rst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr += 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x4f: /* STH2 */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
|
|
|
|
u->rst.dat[u->rst.ptr] = b;
|
|
|
|
u->rst.dat[u->rst.ptr + 1] = a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr -= 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
|
|
u->rst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr += 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x50: /* LDZ2 */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
u->wst.dat[u->wst.ptr - 1] = mempeek8(u->ram.dat, a);
|
|
|
|
u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, a + 1);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
|
|
u->wst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr += 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x51: /* STZ2 */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8));
|
|
|
|
mempoke16(u->ram.dat, a, b);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr -= 3;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x52: /* LDR2 */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
u->wst.dat[u->wst.ptr - 1] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a);
|
|
|
|
u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a + 1);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
|
|
u->wst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr += 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x53: /* STR2 */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8));
|
|
|
|
mempoke16(u->ram.dat, u->ram.ptr + (Sint8)a, b);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr -= 3;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x54: /* LDA2 */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8));
|
|
|
|
u->wst.dat[u->wst.ptr - 2] = mempeek8(u->ram.dat, a);
|
|
|
|
u->wst.dat[u->wst.ptr - 1] = mempeek8(u->ram.dat, a + 1);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x55: /* STA2 */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8));
|
|
|
|
Uint16 b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8));
|
|
|
|
mempoke16(u->ram.dat, a, b);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr -= 4;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x56: /* DEI2 */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
u->wst.dat[u->wst.ptr - 1] = devpeek8(&u->dev[a >> 4], a);
|
|
|
|
u->wst.dat[u->wst.ptr] = devpeek8(&u->dev[a >> 4], a + 1);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
|
|
u->wst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr += 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x57: /* DEO2 */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8));
|
|
|
|
devpoke16(&u->dev[a >> 4], a, b);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr -= 3;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x58: /* ADD2 */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8));
|
|
|
|
u->wst.dat[u->wst.ptr - 4] = (b + a) >> 8;
|
|
|
|
u->wst.dat[u->wst.ptr - 3] = (b + a) & 0xff;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr -= 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x59: /* SUB2 */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8));
|
|
|
|
u->wst.dat[u->wst.ptr - 4] = (b - a) >> 8;
|
|
|
|
u->wst.dat[u->wst.ptr - 3] = (b - a) & 0xff;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr -= 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x5a: /* MUL2 */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8));
|
|
|
|
u->wst.dat[u->wst.ptr - 4] = (b * a) >> 8;
|
|
|
|
u->wst.dat[u->wst.ptr - 3] = (b * a) & 0xff;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr -= 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x5b: /* DIV2 */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8));
|
2021-06-08 17:58:02 -04:00
|
|
|
if(a == 0) {
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.error = 3;
|
2021-06-08 17:58:02 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
goto error;
|
|
|
|
#endif
|
|
|
|
a = 1;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.dat[u->wst.ptr - 4] = (b / a) >> 8;
|
|
|
|
u->wst.dat[u->wst.ptr - 3] = (b / a) & 0xff;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr -= 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x5c: /* AND2 */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
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 - 4] = d & b;
|
|
|
|
u->wst.dat[u->wst.ptr - 3] = c & a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr -= 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x5d: /* ORA2 */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
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 - 4] = d | b;
|
|
|
|
u->wst.dat[u->wst.ptr - 3] = c | a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr -= 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x5e: /* EOR2 */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
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 - 4] = d ^ b;
|
|
|
|
u->wst.dat[u->wst.ptr - 3] = c ^ a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr -= 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0x5f: /* SFT2 */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8));
|
|
|
|
u->wst.dat[u->wst.ptr - 3] = (b >> (a & 0x0f) << ((a & 0xf0) >> 4)) >> 8;
|
|
|
|
u->wst.dat[u->wst.ptr - 2] = (b >> (a & 0x0f) << ((a & 0xf0) >> 4)) & 0xff;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr -= 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-17 17:48:48 -04:00
|
|
|
case 0x60: /* LIT2r */
|
|
|
|
case 0xe0: /* LIT2kr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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++);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
|
|
u->rst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr += 2;
|
|
|
|
}
|
|
|
|
break;
|
2021-08-17 17:48:48 -04:00
|
|
|
case 0x61: /* INC2r */
|
|
|
|
{
|
|
|
|
Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8));
|
|
|
|
u->rst.dat[u->rst.ptr - 2] = (a + 1) >> 8;
|
|
|
|
u->rst.dat[u->rst.ptr - 1] = (a + 1) & 0xff;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
2021-08-15 16:34:33 -04:00
|
|
|
case 0x62: /* POP2r */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
(u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8));
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 2;
|
|
|
|
}
|
|
|
|
break;
|
2021-08-15 16:34:33 -04:00
|
|
|
case 0x63: /* DUP2r */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 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;
|
|
|
|
}
|
|
|
|
break;
|
2021-08-15 16:34:33 -04:00
|
|
|
case 0x64: /* NIP2r */
|
|
|
|
{
|
|
|
|
Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8));
|
|
|
|
(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;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 2;
|
|
|
|
}
|
|
|
|
break;
|
2021-05-23 11:41:41 -04:00
|
|
|
case 0x65: /* SWP2r */
|
|
|
|
{
|
|
|
|
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 - 4] = b;
|
|
|
|
u->rst.dat[u->rst.ptr - 3] = a;
|
|
|
|
u->rst.dat[u->rst.ptr - 2] = d;
|
|
|
|
u->rst.dat[u->rst.ptr - 1] = c;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
2021-08-15 16:06:54 -04:00
|
|
|
case 0x66: /* OVR2r */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-15 16:06:54 -04:00
|
|
|
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;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
2021-08-15 16:06:54 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
|
|
u->rst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
2021-05-23 11:41:41 -04:00
|
|
|
#endif
|
2021-08-15 16:06:54 -04:00
|
|
|
u->rst.ptr += 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x67: /* ROT2r */
|
|
|
|
{
|
|
|
|
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], e = u->rst.dat[u->rst.ptr - 5], f = u->rst.dat[u->rst.ptr - 6];
|
|
|
|
u->rst.dat[u->rst.ptr - 6] = d;
|
|
|
|
u->rst.dat[u->rst.ptr - 5] = c;
|
|
|
|
u->rst.dat[u->rst.ptr - 4] = b;
|
|
|
|
u->rst.dat[u->rst.ptr - 3] = a;
|
|
|
|
u->rst.dat[u->rst.ptr - 2] = f;
|
|
|
|
u->rst.dat[u->rst.ptr - 1] = e;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 6, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x68: /* EQU2r */
|
|
|
|
{
|
|
|
|
Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8));
|
|
|
|
u->rst.dat[u->rst.ptr - 4] = b == a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 3;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x69: /* NEQ2r */
|
|
|
|
{
|
|
|
|
Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8));
|
|
|
|
u->rst.dat[u->rst.ptr - 4] = b != a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 3;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x6a: /* GTH2r */
|
|
|
|
{
|
|
|
|
Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8));
|
|
|
|
u->rst.dat[u->rst.ptr - 4] = b > a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 3;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x6b: /* LTH2r */
|
|
|
|
{
|
|
|
|
Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8));
|
|
|
|
u->rst.dat[u->rst.ptr - 4] = b < a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 3;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x6c: /* JMP2r */
|
|
|
|
{
|
|
|
|
u->ram.ptr = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8));
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x6d: /* JCN2r */
|
|
|
|
{
|
|
|
|
Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8));
|
|
|
|
if(u->rst.dat[u->rst.ptr - 3]) u->ram.ptr = a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 3;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x6e: /* JSR2r */
|
|
|
|
{
|
|
|
|
u->wst.dat[u->wst.ptr] = u->ram.ptr >> 8;
|
|
|
|
u->wst.dat[u->wst.ptr + 1] = u->ram.ptr & 0xff;
|
|
|
|
u->ram.ptr = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8));
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 2;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
|
|
u->wst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr += 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x6f: /* STH2r */
|
|
|
|
{
|
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
|
|
|
|
u->wst.dat[u->wst.ptr] = b;
|
|
|
|
u->wst.dat[u->wst.ptr + 1] = a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 2;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
|
|
u->wst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr += 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x70: /* LDZ2r */
|
|
|
|
{
|
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
u->rst.dat[u->rst.ptr - 1] = mempeek8(u->ram.dat, a);
|
|
|
|
u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, a + 1);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 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;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x71: /* STZ2r */
|
|
|
|
{
|
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
Uint16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8));
|
|
|
|
mempoke16(u->ram.dat, a, b);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 3;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x72: /* LDR2r */
|
|
|
|
{
|
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
u->rst.dat[u->rst.ptr - 1] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a);
|
|
|
|
u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a + 1);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 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;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x73: /* STR2r */
|
|
|
|
{
|
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
Uint16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8));
|
|
|
|
mempoke16(u->ram.dat, u->ram.ptr + (Sint8)a, b);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 3;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x74: /* LDA2r */
|
|
|
|
{
|
|
|
|
Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8));
|
|
|
|
u->rst.dat[u->rst.ptr - 2] = mempeek8(u->ram.dat, a);
|
|
|
|
u->rst.dat[u->rst.ptr - 1] = mempeek8(u->ram.dat, a + 1);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x75: /* STA2r */
|
|
|
|
{
|
|
|
|
Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8));
|
|
|
|
Uint16 b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8));
|
|
|
|
mempoke16(u->ram.dat, a, b);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 4;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x76: /* DEI2r */
|
|
|
|
{
|
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
u->rst.dat[u->rst.ptr - 1] = devpeek8(&u->dev[a >> 4], a);
|
|
|
|
u->rst.dat[u->rst.ptr] = devpeek8(&u->dev[a >> 4], a + 1);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 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;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x77: /* DEO2r */
|
|
|
|
{
|
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
Uint16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8));
|
|
|
|
devpoke16(&u->dev[a >> 4], a, b);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 3;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x78: /* ADD2r */
|
|
|
|
{
|
|
|
|
Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8));
|
|
|
|
u->rst.dat[u->rst.ptr - 4] = (b + a) >> 8;
|
|
|
|
u->rst.dat[u->rst.ptr - 3] = (b + a) & 0xff;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x79: /* SUB2r */
|
|
|
|
{
|
|
|
|
Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8));
|
|
|
|
u->rst.dat[u->rst.ptr - 4] = (b - a) >> 8;
|
|
|
|
u->rst.dat[u->rst.ptr - 3] = (b - a) & 0xff;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x7a: /* MUL2r */
|
|
|
|
{
|
|
|
|
Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8));
|
|
|
|
u->rst.dat[u->rst.ptr - 4] = (b * a) >> 8;
|
|
|
|
u->rst.dat[u->rst.ptr - 3] = (b * a) & 0xff;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x7b: /* DIV2r */
|
|
|
|
{
|
|
|
|
Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8));
|
2021-06-08 17:58:02 -04:00
|
|
|
if(a == 0) {
|
|
|
|
u->rst.error = 3;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
goto error;
|
|
|
|
#endif
|
|
|
|
a = 1;
|
|
|
|
}
|
2021-05-23 11:41:41 -04:00
|
|
|
u->rst.dat[u->rst.ptr - 4] = (b / a) >> 8;
|
|
|
|
u->rst.dat[u->rst.ptr - 3] = (b / a) & 0xff;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x7c: /* AND2r */
|
|
|
|
{
|
|
|
|
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 - 4] = d & b;
|
|
|
|
u->rst.dat[u->rst.ptr - 3] = c & a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x7d: /* ORA2r */
|
|
|
|
{
|
|
|
|
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 - 4] = d | b;
|
|
|
|
u->rst.dat[u->rst.ptr - 3] = c | a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x7e: /* EOR2r */
|
|
|
|
{
|
|
|
|
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 - 4] = d ^ b;
|
|
|
|
u->rst.dat[u->rst.ptr - 3] = c ^ a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x7f: /* SFT2r */
|
|
|
|
{
|
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
Uint16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8));
|
|
|
|
u->rst.dat[u->rst.ptr - 3] = (b >> (a & 0x0f) << ((a & 0xf0) >> 4)) >> 8;
|
|
|
|
u->rst.dat[u->rst.ptr - 2] = (b >> (a & 0x0f) << ((a & 0xf0) >> 4)) & 0xff;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 1;
|
|
|
|
}
|
|
|
|
break;
|
2021-08-17 17:48:48 -04:00
|
|
|
case 0x81: /* INCk */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
u->wst.dat[u->wst.ptr] = a + 1;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 1, 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;
|
|
|
|
}
|
|
|
|
break;
|
2021-08-15 16:34:33 -04:00
|
|
|
case 0x82: /* POPk */
|
2021-08-15 16:22:01 -04:00
|
|
|
{
|
2021-08-15 16:34:33 -04:00
|
|
|
u->wst.dat[u->wst.ptr - 1];
|
2021-08-15 16:22:01 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-15 16:34:33 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
2021-08-15 16:22:01 -04:00
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
2021-08-15 16:34:33 -04:00
|
|
|
case 0x83: /* DUPk */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-15 16:34:33 -04:00
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
u->wst.dat[u->wst.ptr] = a;
|
|
|
|
u->wst.dat[u->wst.ptr + 1] = a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
2021-08-15 16:34:33 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
|
|
u->wst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
2021-05-23 11:41:41 -04:00
|
|
|
#endif
|
2021-08-15 16:34:33 -04:00
|
|
|
u->wst.ptr += 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-15 16:34:33 -04:00
|
|
|
case 0x84: /* NIPk */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
2021-08-15 16:34:33 -04:00
|
|
|
u->wst.dat[u->wst.ptr - 2];
|
2021-05-23 11:41:41 -04:00
|
|
|
u->wst.dat[u->wst.ptr] = a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-15 16:34:33 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
2021-05-23 11:41:41 -04:00
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
2021-08-15 16:34:33 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
2021-05-23 11:41:41 -04:00
|
|
|
u->wst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-15 16:34:33 -04:00
|
|
|
u->wst.ptr += 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x85: /* SWPk */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
|
|
|
|
u->wst.dat[u->wst.ptr] = a;
|
|
|
|
u->wst.dat[u->wst.ptr + 1] = b;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 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;
|
|
|
|
}
|
|
|
|
break;
|
2021-08-15 16:06:54 -04:00
|
|
|
case 0x86: /* OVRk */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-15 16:06:54 -04:00
|
|
|
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;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
2021-08-15 16:06:54 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr > 252, 0)) {
|
2021-05-23 11:41:41 -04:00
|
|
|
u->wst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-15 16:06:54 -04:00
|
|
|
u->wst.ptr += 3;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x87: /* ROTk */
|
|
|
|
{
|
|
|
|
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];
|
|
|
|
u->wst.dat[u->wst.ptr] = b;
|
|
|
|
u->wst.dat[u->wst.ptr + 1] = a;
|
|
|
|
u->wst.dat[u->wst.ptr + 2] = c;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if(__builtin_expect(u->wst.ptr > 252, 0)) {
|
|
|
|
u->wst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr += 3;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x88: /* EQUk */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
|
|
|
|
u->wst.dat[u->wst.ptr] = b == 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 > 254, 0)) {
|
|
|
|
u->wst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x89: /* NEQk */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
|
|
|
|
u->wst.dat[u->wst.ptr] = b != 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 > 254, 0)) {
|
|
|
|
u->wst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x8a: /* GTHk */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
|
|
|
|
u->wst.dat[u->wst.ptr] = b > 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 > 254, 0)) {
|
|
|
|
u->wst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x8b: /* LTHk */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
|
|
|
|
u->wst.dat[u->wst.ptr] = b < 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 > 254, 0)) {
|
|
|
|
u->wst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x8c: /* JMPk */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
u->ram.ptr += (Sint8)a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x8d: /* JCNk */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
if(u->wst.dat[u->wst.ptr - 2]) u->ram.ptr += (Sint8)a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x8e: /* JSRk */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
u->rst.dat[u->rst.ptr] = u->ram.ptr >> 8;
|
|
|
|
u->rst.dat[u->rst.ptr + 1] = u->ram.ptr & 0xff;
|
|
|
|
u->ram.ptr += (Sint8)a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
|
|
u->rst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr += 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x8f: /* STHk */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
u->rst.dat[u->rst.ptr] = a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x90: /* LDZk */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, a);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 1, 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;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x91: /* STZk */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
Uint8 b = u->wst.dat[u->wst.ptr - 2];
|
|
|
|
mempoke8(u->ram.dat, a, b);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x92: /* LDRk */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 1, 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;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x93: /* STRk */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
Uint8 b = u->wst.dat[u->wst.ptr - 2];
|
|
|
|
mempoke8(u->ram.dat, u->ram.ptr + (Sint8)a, b);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x94: /* LDAk */
|
|
|
|
{
|
|
|
|
Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8));
|
|
|
|
u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, 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 > 254, 0)) {
|
|
|
|
u->wst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x95: /* STAk */
|
|
|
|
{
|
|
|
|
Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8));
|
|
|
|
Uint8 b = u->wst.dat[u->wst.ptr - 3];
|
|
|
|
mempoke8(u->ram.dat, a, b);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x96: /* DEIk */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
u->wst.dat[u->wst.ptr] = devpeek8(&u->dev[a >> 4], a);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 1, 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;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x97: /* DEOk */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
|
|
|
|
devpoke8(&u->dev[a >> 4], a, b);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x98: /* ADDk */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
|
|
|
|
u->wst.dat[u->wst.ptr] = b + 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 > 254, 0)) {
|
|
|
|
u->wst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x99: /* SUBk */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
|
|
|
|
u->wst.dat[u->wst.ptr] = b - 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 > 254, 0)) {
|
|
|
|
u->wst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x9a: /* MULk */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
|
|
|
|
u->wst.dat[u->wst.ptr] = b * 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 > 254, 0)) {
|
|
|
|
u->wst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x9b: /* DIVk */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
|
2021-06-08 17:58:02 -04:00
|
|
|
if(a == 0) {
|
|
|
|
u->wst.error = 3;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
goto error;
|
|
|
|
#endif
|
|
|
|
a = 1;
|
|
|
|
}
|
2021-05-23 11:41:41 -04:00
|
|
|
u->wst.dat[u->wst.ptr] = b / 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 > 254, 0)) {
|
|
|
|
u->wst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x9c: /* ANDk */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
|
|
|
|
u->wst.dat[u->wst.ptr] = b & 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 > 254, 0)) {
|
|
|
|
u->wst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x9d: /* ORAk */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
|
|
|
|
u->wst.dat[u->wst.ptr] = b | 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 > 254, 0)) {
|
|
|
|
u->wst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x9e: /* EORk */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
|
|
|
|
u->wst.dat[u->wst.ptr] = b ^ 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 > 254, 0)) {
|
|
|
|
u->wst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x9f: /* SFTk */
|
|
|
|
{
|
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
|
|
|
|
u->wst.dat[u->wst.ptr] = b >> (a & 0x07) << ((a & 0x70) >> 4);
|
|
|
|
#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;
|
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xa1: /* INCkr */
|
2021-08-17 17:48:48 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
u->rst.dat[u->rst.ptr] = a + 1;
|
2021-08-17 17:48:48 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-08-17 17:48:48 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
2021-08-17 17:48:48 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr += 1;
|
2021-08-17 17:48:48 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xa2: /* POPkr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.dat[u->rst.ptr - 1];
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xa3: /* DUPkr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
u->rst.dat[u->rst.ptr] = a;
|
|
|
|
u->rst.dat[u->rst.ptr + 1] = a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
|
|
u->rst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr += 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xa4: /* NIPkr */
|
2021-08-15 16:34:33 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
u->rst.dat[u->rst.ptr - 2];
|
|
|
|
u->rst.dat[u->rst.ptr] = a;
|
2021-08-15 16:34:33 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-08-15 16:34:33 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
2021-08-15 16:34:33 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr += 1;
|
2021-08-15 16:34:33 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xa5: /* SWPkr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
|
|
|
|
u->rst.dat[u->rst.ptr] = a;
|
|
|
|
u->rst.dat[u->rst.ptr + 1] = b;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
|
|
u->rst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr += 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xa6: /* OVRkr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
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;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr > 252, 0)) {
|
|
|
|
u->rst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr += 3;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xa7: /* ROTkr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
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];
|
|
|
|
u->rst.dat[u->rst.ptr] = b;
|
|
|
|
u->rst.dat[u->rst.ptr + 1] = a;
|
|
|
|
u->rst.dat[u->rst.ptr + 2] = c;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr > 252, 0)) {
|
|
|
|
u->rst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr += 3;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xa8: /* EQUkr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
|
|
|
|
u->rst.dat[u->rst.ptr] = b == a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr += 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xa9: /* NEQkr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
|
|
|
|
u->rst.dat[u->rst.ptr] = b != a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr += 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xaa: /* GTHkr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
|
|
|
|
u->rst.dat[u->rst.ptr] = b > a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr += 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xab: /* LTHkr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
|
|
|
|
u->rst.dat[u->rst.ptr] = b < a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr += 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xac: /* JMPkr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
u->ram.ptr += (Sint8)a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xad: /* JCNkr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
if(u->rst.dat[u->rst.ptr - 2]) u->ram.ptr += (Sint8)a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xae: /* JSRkr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
u->wst.dat[u->wst.ptr] = u->ram.ptr >> 8;
|
|
|
|
u->wst.dat[u->wst.ptr + 1] = u->ram.ptr & 0xff;
|
|
|
|
u->ram.ptr += (Sint8)a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
|
|
u->wst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr += 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xaf: /* STHkr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
u->wst.dat[u->wst.ptr] = a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
|
|
u->wst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr += 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xb0: /* LDZkr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, a);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr += 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xb1: /* STZkr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
Uint8 b = u->rst.dat[u->rst.ptr - 2];
|
|
|
|
mempoke8(u->ram.dat, a, b);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xb2: /* LDRkr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr += 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xb3: /* STRkr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
Uint8 b = u->rst.dat[u->rst.ptr - 2];
|
|
|
|
mempoke8(u->ram.dat, u->ram.ptr + (Sint8)a, b);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xb4: /* LDAkr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8));
|
|
|
|
u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, a);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr += 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xb5: /* STAkr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8));
|
|
|
|
Uint8 b = u->rst.dat[u->rst.ptr - 3];
|
|
|
|
mempoke8(u->ram.dat, a, b);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xb6: /* DEIkr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
u->rst.dat[u->rst.ptr] = devpeek8(&u->dev[a >> 4], a);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr += 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xb7: /* DEOkr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
|
|
|
|
devpoke8(&u->dev[a >> 4], a, b);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xb8: /* ADDkr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
|
|
|
|
u->rst.dat[u->rst.ptr] = b + a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr += 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xb9: /* SUBkr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
|
|
|
|
u->rst.dat[u->rst.ptr] = b - a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr += 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xba: /* MULkr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
|
|
|
|
u->rst.dat[u->rst.ptr] = b * a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr += 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xbb: /* DIVkr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
|
2021-06-08 17:58:02 -04:00
|
|
|
if(a == 0) {
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.error = 3;
|
2021-06-08 17:58:02 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
goto error;
|
|
|
|
#endif
|
|
|
|
a = 1;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.dat[u->rst.ptr] = b / a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr += 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xbc: /* ANDkr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
|
|
|
|
u->rst.dat[u->rst.ptr] = b & a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr += 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xbd: /* ORAkr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
|
|
|
|
u->rst.dat[u->rst.ptr] = b | a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr += 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xbe: /* EORkr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
|
|
|
|
u->rst.dat[u->rst.ptr] = b ^ a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr += 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xbf: /* SFTkr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
|
|
|
|
u->rst.dat[u->rst.ptr] = b >> (a & 0x07) << ((a & 0x70) >> 4);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr += 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xc1: /* INC2k */
|
2021-08-17 17:48:48 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8));
|
|
|
|
u->wst.dat[u->wst.ptr] = (a + 1) >> 8;
|
|
|
|
u->wst.dat[u->wst.ptr + 1] = (a + 1) & 0xff;
|
2021-08-17 17:48:48 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-08-17 17:48:48 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
|
|
u->wst.error = 2;
|
2021-08-17 17:48:48 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr += 2;
|
2021-08-17 17:48:48 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xc2: /* POP2k */
|
2021-08-15 16:22:01 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
(u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8));
|
2021-08-15 16:22:01 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-08-15 16:22:01 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xc3: /* DUP2k */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
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;
|
|
|
|
u->wst.dat[u->wst.ptr + 3] = a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr > 251, 0)) {
|
|
|
|
u->wst.error = 2;
|
2021-08-15 16:34:33 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-05-23 11:41:41 -04:00
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr += 4;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xc4: /* NIP2k */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8));
|
|
|
|
(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;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
|
|
u->wst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr += 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xc5: /* SWP2k */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
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] = b;
|
|
|
|
u->wst.dat[u->wst.ptr + 1] = a;
|
|
|
|
u->wst.dat[u->wst.ptr + 2] = d;
|
|
|
|
u->wst.dat[u->wst.ptr + 3] = c;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr > 251, 0)) {
|
|
|
|
u->wst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr += 4;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xc6: /* OVR2k */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
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;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr > 249, 0)) {
|
|
|
|
u->wst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr += 6;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xc7: /* ROT2k */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
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], e = u->wst.dat[u->wst.ptr - 5], f = u->wst.dat[u->wst.ptr - 6];
|
|
|
|
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] = f;
|
|
|
|
u->wst.dat[u->wst.ptr + 5] = e;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 6, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr > 249, 0)) {
|
|
|
|
u->wst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr += 6;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xc8: /* EQU2k */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8));
|
|
|
|
u->wst.dat[u->wst.ptr] = b == a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
|
|
u->wst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr += 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xc9: /* NEQ2k */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8));
|
|
|
|
u->wst.dat[u->wst.ptr] = b != a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
|
|
u->wst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr += 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xca: /* GTH2k */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8));
|
|
|
|
u->wst.dat[u->wst.ptr] = b > a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
|
|
u->wst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr += 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xcb: /* LTH2k */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8));
|
|
|
|
u->wst.dat[u->wst.ptr] = b < a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
|
|
u->wst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr += 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xcc: /* JMP2k */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
u->ram.ptr = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8));
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xcd: /* JCN2k */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8));
|
|
|
|
if(u->wst.dat[u->wst.ptr - 3]) u->ram.ptr = a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xce: /* JSR2k */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.dat[u->rst.ptr] = u->ram.ptr >> 8;
|
|
|
|
u->rst.dat[u->rst.ptr + 1] = u->ram.ptr & 0xff;
|
|
|
|
u->ram.ptr = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8));
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
|
|
u->rst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr += 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xcf: /* STH2k */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2];
|
|
|
|
u->rst.dat[u->rst.ptr] = b;
|
|
|
|
u->rst.dat[u->rst.ptr + 1] = a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
|
|
u->rst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->rst.ptr += 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xd0: /* LDZ2k */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, a);
|
|
|
|
u->wst.dat[u->wst.ptr + 1] = mempeek8(u->ram.dat, a + 1);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
|
|
u->wst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr += 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xd1: /* STZ2k */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8));
|
|
|
|
mempoke16(u->ram.dat, a, b);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xd2: /* LDR2k */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a);
|
|
|
|
u->wst.dat[u->wst.ptr + 1] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a + 1);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
|
|
u->wst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr += 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xd3: /* STR2k */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8));
|
|
|
|
mempoke16(u->ram.dat, u->ram.ptr + (Sint8)a, b);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xd4: /* LDA2k */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8));
|
|
|
|
u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, a);
|
|
|
|
u->wst.dat[u->wst.ptr + 1] = mempeek8(u->ram.dat, a + 1);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
|
|
u->wst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr += 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xd5: /* STA2k */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8));
|
|
|
|
Uint16 b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8));
|
|
|
|
mempoke16(u->ram.dat, a, b);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xd6: /* DEI2k */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
u->wst.dat[u->wst.ptr] = devpeek8(&u->dev[a >> 4], a);
|
|
|
|
u->wst.dat[u->wst.ptr + 1] = devpeek8(&u->dev[a >> 4], a + 1);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
|
|
u->wst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr += 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xd7: /* DEO2k */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8));
|
|
|
|
devpoke16(&u->dev[a >> 4], a, b);
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xd8: /* ADD2k */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8));
|
|
|
|
u->wst.dat[u->wst.ptr] = (b + a) >> 8;
|
|
|
|
u->wst.dat[u->wst.ptr + 1] = (b + a) & 0xff;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
|
|
u->wst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr += 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xd9: /* SUB2k */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8));
|
|
|
|
u->wst.dat[u->wst.ptr] = (b - a) >> 8;
|
|
|
|
u->wst.dat[u->wst.ptr + 1] = (b - a) & 0xff;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
|
|
u->wst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr += 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xda: /* MUL2k */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8));
|
|
|
|
u->wst.dat[u->wst.ptr] = (b * a) >> 8;
|
|
|
|
u->wst.dat[u->wst.ptr + 1] = (b * a) & 0xff;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
|
|
u->wst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr += 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xdb: /* DIV2k */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)), b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8));
|
2021-06-08 17:58:02 -04:00
|
|
|
if(a == 0) {
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.error = 3;
|
2021-06-08 17:58:02 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
goto error;
|
|
|
|
#endif
|
|
|
|
a = 1;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.dat[u->wst.ptr] = (b / a) >> 8;
|
|
|
|
u->wst.dat[u->wst.ptr + 1] = (b / a) & 0xff;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
|
|
u->wst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr += 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xdc: /* AND2k */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
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 & b;
|
|
|
|
u->wst.dat[u->wst.ptr + 1] = c & a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
|
|
u->wst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr += 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xdd: /* ORA2k */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
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 | b;
|
|
|
|
u->wst.dat[u->wst.ptr + 1] = c | a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
|
|
u->wst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr += 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xde: /* EOR2k */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
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 ^ b;
|
|
|
|
u->wst.dat[u->wst.ptr + 1] = c ^ a;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
|
|
u->wst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr += 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-29 17:28:30 -04:00
|
|
|
case 0xdf: /* SFT2k */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-29 17:28:30 -04:00
|
|
|
Uint8 a = u->wst.dat[u->wst.ptr - 1];
|
|
|
|
Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8));
|
|
|
|
u->wst.dat[u->wst.ptr] = (b >> (a & 0x0f) << ((a & 0xf0) >> 4)) >> 8;
|
|
|
|
u->wst.dat[u->wst.ptr + 1] = (b >> (a & 0x0f) << ((a & 0xf0) >> 4)) & 0xff;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
|
|
u->wst.error = 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
2021-08-29 17:28:30 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
|
|
u->wst.error = 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-29 17:28:30 -04:00
|
|
|
u->wst.ptr += 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
2021-08-17 17:48:48 -04:00
|
|
|
case 0xe1: /* INC2kr */
|
|
|
|
{
|
|
|
|
Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8));
|
|
|
|
u->rst.dat[u->rst.ptr] = (a + 1) >> 8;
|
|
|
|
u->rst.dat[u->rst.ptr + 1] = (a + 1) & 0xff;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 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;
|
|
|
|
}
|
|
|
|
break;
|
2021-08-15 16:34:33 -04:00
|
|
|
case 0xe2: /* POP2kr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
(u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8));
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
2021-08-15 16:34:33 -04:00
|
|
|
case 0xe3: /* DUP2kr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
u->rst.dat[u->rst.ptr + 3] = 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 > 251, 0)) {
|
|
|
|
u->rst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr += 4;
|
|
|
|
}
|
|
|
|
break;
|
2021-08-15 16:34:33 -04:00
|
|
|
case 0xe4: /* NIP2kr */
|
|
|
|
{
|
|
|
|
Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8));
|
|
|
|
(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 > 253, 0)) {
|
|
|
|
u->rst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr += 2;
|
|
|
|
}
|
|
|
|
break;
|
2021-05-23 11:41:41 -04:00
|
|
|
case 0xe5: /* SWP2kr */
|
|
|
|
{
|
|
|
|
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] = b;
|
|
|
|
u->rst.dat[u->rst.ptr + 1] = a;
|
|
|
|
u->rst.dat[u->rst.ptr + 2] = d;
|
|
|
|
u->rst.dat[u->rst.ptr + 3] = c;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if(__builtin_expect(u->rst.ptr > 251, 0)) {
|
|
|
|
u->rst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr += 4;
|
|
|
|
}
|
|
|
|
break;
|
2021-08-15 16:06:54 -04:00
|
|
|
case 0xe6: /* OVR2kr */
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-15 16:06:54 -04:00
|
|
|
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;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
2021-08-15 16:06:54 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr > 249, 0)) {
|
2021-05-23 11:41:41 -04:00
|
|
|
u->rst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-15 16:06:54 -04:00
|
|
|
u->rst.ptr += 6;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xe7: /* ROT2kr */
|
|
|
|
{
|
|
|
|
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], e = u->rst.dat[u->rst.ptr - 5], f = u->rst.dat[u->rst.ptr - 6];
|
|
|
|
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] = f;
|
|
|
|
u->rst.dat[u->rst.ptr + 5] = e;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 6, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if(__builtin_expect(u->rst.ptr > 249, 0)) {
|
|
|
|
u->rst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr += 6;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xe8: /* EQU2kr */
|
|
|
|
{
|
|
|
|
Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8));
|
|
|
|
u->rst.dat[u->rst.ptr] = b == a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 4, 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;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xe9: /* NEQ2kr */
|
|
|
|
{
|
|
|
|
Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8));
|
|
|
|
u->rst.dat[u->rst.ptr] = b != a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 4, 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;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xea: /* GTH2kr */
|
|
|
|
{
|
|
|
|
Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8));
|
|
|
|
u->rst.dat[u->rst.ptr] = b > a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 4, 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;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xeb: /* LTH2kr */
|
|
|
|
{
|
|
|
|
Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8));
|
|
|
|
u->rst.dat[u->rst.ptr] = b < a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 4, 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;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xec: /* JMP2kr */
|
|
|
|
{
|
|
|
|
u->ram.ptr = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8));
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xed: /* JCN2kr */
|
|
|
|
{
|
|
|
|
Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8));
|
|
|
|
if(u->rst.dat[u->rst.ptr - 3]) u->ram.ptr = a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xee: /* JSR2kr */
|
|
|
|
{
|
|
|
|
u->wst.dat[u->wst.ptr] = u->ram.ptr >> 8;
|
|
|
|
u->wst.dat[u->wst.ptr + 1] = u->ram.ptr & 0xff;
|
|
|
|
u->ram.ptr = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8));
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
|
|
u->wst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr += 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xef: /* STH2kr */
|
|
|
|
{
|
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2];
|
|
|
|
u->wst.dat[u->wst.ptr] = b;
|
|
|
|
u->wst.dat[u->wst.ptr + 1] = a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
|
|
u->wst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr += 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xf0: /* LDZ2kr */
|
|
|
|
{
|
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, a);
|
|
|
|
u->rst.dat[u->rst.ptr + 1] = mempeek8(u->ram.dat, a + 1);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 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;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xf1: /* STZ2kr */
|
|
|
|
{
|
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
Uint16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8));
|
|
|
|
mempoke16(u->ram.dat, a, b);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xf2: /* LDR2kr */
|
|
|
|
{
|
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a);
|
|
|
|
u->rst.dat[u->rst.ptr + 1] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a + 1);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 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;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xf3: /* STR2kr */
|
|
|
|
{
|
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
Uint16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8));
|
|
|
|
mempoke16(u->ram.dat, u->ram.ptr + (Sint8)a, b);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xf4: /* LDA2kr */
|
|
|
|
{
|
|
|
|
Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8));
|
|
|
|
u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, a);
|
|
|
|
u->rst.dat[u->rst.ptr + 1] = mempeek8(u->ram.dat, a + 1);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 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;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xf5: /* STA2kr */
|
|
|
|
{
|
|
|
|
Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8));
|
|
|
|
Uint16 b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8));
|
|
|
|
mempoke16(u->ram.dat, a, b);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xf6: /* DEI2kr */
|
|
|
|
{
|
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
u->rst.dat[u->rst.ptr] = devpeek8(&u->dev[a >> 4], a);
|
|
|
|
u->rst.dat[u->rst.ptr + 1] = devpeek8(&u->dev[a >> 4], a + 1);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 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;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xf7: /* DEO2kr */
|
|
|
|
{
|
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
Uint16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8));
|
|
|
|
devpoke16(&u->dev[a >> 4], a, b);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xf8: /* ADD2kr */
|
|
|
|
{
|
|
|
|
Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8));
|
|
|
|
u->rst.dat[u->rst.ptr] = (b + a) >> 8;
|
|
|
|
u->rst.dat[u->rst.ptr + 1] = (b + 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;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xf9: /* SUB2kr */
|
|
|
|
{
|
|
|
|
Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8));
|
|
|
|
u->rst.dat[u->rst.ptr] = (b - a) >> 8;
|
|
|
|
u->rst.dat[u->rst.ptr + 1] = (b - 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;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xfa: /* MUL2kr */
|
|
|
|
{
|
|
|
|
Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8));
|
|
|
|
u->rst.dat[u->rst.ptr] = (b * a) >> 8;
|
|
|
|
u->rst.dat[u->rst.ptr + 1] = (b * 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;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xfb: /* DIV2kr */
|
|
|
|
{
|
|
|
|
Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)), b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8));
|
2021-06-08 17:58:02 -04:00
|
|
|
if(a == 0) {
|
|
|
|
u->rst.error = 3;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
goto error;
|
|
|
|
#endif
|
|
|
|
a = 1;
|
|
|
|
}
|
2021-05-23 11:41:41 -04:00
|
|
|
u->rst.dat[u->rst.ptr] = (b / a) >> 8;
|
|
|
|
u->rst.dat[u->rst.ptr + 1] = (b / 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;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xfc: /* AND2kr */
|
|
|
|
{
|
|
|
|
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 & b;
|
|
|
|
u->rst.dat[u->rst.ptr + 1] = c & a;
|
|
|
|
#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;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xfd: /* ORA2kr */
|
|
|
|
{
|
|
|
|
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 | b;
|
|
|
|
u->rst.dat[u->rst.ptr + 1] = c | a;
|
|
|
|
#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;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xfe: /* EOR2kr */
|
|
|
|
{
|
|
|
|
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 ^ b;
|
|
|
|
u->rst.dat[u->rst.ptr + 1] = c ^ a;
|
|
|
|
#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;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xff: /* SFT2kr */
|
|
|
|
{
|
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
Uint16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8));
|
|
|
|
u->rst.dat[u->rst.ptr] = (b >> (a & 0x0f) << ((a & 0xf0) >> 4)) >> 8;
|
|
|
|
u->rst.dat[u->rst.ptr + 1] = (b >> (a & 0x0f) << ((a & 0xf0) >> 4)) & 0xff;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 3, 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;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
#pragma GCC diagnostic pop
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
error:
|
2021-06-08 17:58:02 -04:00
|
|
|
if(u->wst.error)
|
2021-08-01 17:46:43 -04:00
|
|
|
return uxn_halt(u, u->wst.error, "Working-stack", instr);
|
2021-06-08 17:58:02 -04:00
|
|
|
else
|
2021-08-01 17:46:43 -04:00
|
|
|
return uxn_halt(u, u->rst.error, "Return-stack", instr);
|
2021-05-23 11:41:41 -04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2021-08-01 17:46:43 -04:00
|
|
|
uxn_boot(Uxn *u)
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
2021-08-01 17:40:14 -04:00
|
|
|
unsigned int i;
|
2021-05-23 11:41:41 -04:00
|
|
|
char *cptr = (char *)u;
|
|
|
|
for(i = 0; i < sizeof(*u); i++)
|
2021-08-29 17:28:30 -04:00
|
|
|
cptr[i] = 0x00;
|
2021-05-23 11:41:41 -04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
Device *
|
2021-08-01 17:46:43 -04:00
|
|
|
uxn_port(Uxn *u, Uint8 id, char *name, void (*talkfn)(Device *d, Uint8 b0, Uint8 w))
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
Device *d = &u->dev[id];
|
|
|
|
d->addr = id * 0x10;
|
|
|
|
d->u = u;
|
|
|
|
d->mem = u->ram.dat;
|
|
|
|
d->talk = talkfn;
|
2021-08-02 01:51:51 -04:00
|
|
|
(void)name;
|
2021-05-23 11:41:41 -04:00
|
|
|
return d;
|
|
|
|
}
|