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-05 13:38:25 -04:00
|
|
|
#define MODE_RETURN 0x40
|
|
|
|
#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-07-28 13:29:09 -04:00
|
|
|
if(u->dev[0].dat[0xf])
|
|
|
|
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-05-23 11:41:41 -04:00
|
|
|
while(u->ram.ptr) {
|
|
|
|
instr = u->ram.dat[u->ram.ptr++];
|
|
|
|
switch(instr) {
|
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic ignored "-Wunused-value"
|
|
|
|
#pragma GCC diagnostic ignored "-Wunused-variable"
|
|
|
|
case 0x00: /* BRK */
|
|
|
|
case 0x20: /* BRK2 */
|
|
|
|
case 0x40: /* BRKr */
|
|
|
|
case 0x60: /* BRK2r */
|
|
|
|
case 0x80: /* BRKk */
|
|
|
|
case 0xa0: /* BRK2k */
|
|
|
|
case 0xc0: /* BRKkr */
|
|
|
|
case 0xe0: /* BRK2kr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_00_BRK:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
u->ram.ptr = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x01: /* LIT */
|
|
|
|
case 0x81: /* LITk */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_01_LIT:");
|
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;
|
|
|
|
case 0x02: /* NOP */
|
|
|
|
case 0x22: /* NOP2 */
|
|
|
|
case 0x42: /* NOPr */
|
|
|
|
case 0x62: /* NOP2r */
|
|
|
|
case 0x82: /* NOPk */
|
|
|
|
case 0xa2: /* NOP2k */
|
|
|
|
case 0xc2: /* NOPkr */
|
|
|
|
case 0xe2: /* NOP2kr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_02_NOP:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
(void)u;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x03: /* POP */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_03_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;
|
|
|
|
case 0x04: /* DUP */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_04_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;
|
|
|
|
case 0x05: /* SWP */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_05_SWP:");
|
2021-05-23 11:41:41 -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 - 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 */
|
|
|
|
__asm__("evaluxn_06_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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_07_ROT:");
|
2021-05-23 11:41:41 -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];
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_08_EQU:");
|
2021-05-23 11:41:41 -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 - 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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_09_NEQ:");
|
2021-05-23 11:41:41 -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 - 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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_0a_GTH:");
|
2021-05-23 11:41:41 -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 - 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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_0b_LTH:");
|
2021-05-23 11:41:41 -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 - 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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_0c_JMP:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_0d_JCN:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_0e_JSR:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_0f_STH:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_10_LDZ:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_11_STZ:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_12_LDR:");
|
2021-05-23 11:41:41 -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);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x13: /* STR */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_13_STR:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_14_LDA:");
|
2021-05-23 11:41:41 -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);
|
|
|
|
#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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_15_STA:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_16_DEI:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_17_DEO:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_18_ADD:");
|
2021-05-23 11:41:41 -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 - 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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_19_SUB:");
|
2021-05-23 11:41:41 -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 - 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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_1a_MUL:");
|
2021-05-23 11:41:41 -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 - 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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_1b_DIV:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_1c_AND:");
|
2021-05-23 11:41:41 -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 - 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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_1d_ORA:");
|
2021-05-23 11:41:41 -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 - 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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_1e_EOR:");
|
2021-05-23 11:41:41 -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 - 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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_1f_SFT:");
|
2021-05-23 11:41:41 -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 - 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;
|
|
|
|
case 0x21: /* LIT2 */
|
|
|
|
case 0xa1: /* LIT2k */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_21_LIT2:");
|
2021-05-23 11:41:41 -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++);
|
|
|
|
#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 0x23: /* POP2 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_23_POP2:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
(u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8));
|
|
|
|
#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 0x24: /* DUP2 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_24_DUP2:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#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;
|
|
|
|
case 0x25: /* SWP2 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_25_SWP2:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
2021-08-15 16:06:54 -04:00
|
|
|
case 0x26: /* OVR2 */
|
|
|
|
__asm__("evaluxn_26_OVR2:");
|
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], 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
|
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
2021-08-15 16:06:54 -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:06:54 -04:00
|
|
|
u->wst.ptr += 2;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x27: /* ROT2 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_27_ROT2:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 6, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x28: /* EQU2 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_28_EQU2:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 3;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x29: /* NEQ2 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_29_NEQ2:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 3;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x2a: /* GTH2 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_2a_GTH2:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 3;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x2b: /* LTH2 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_2b_LTH2:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 3;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x2c: /* JMP2 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_2c_JMP2:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
u->ram.ptr = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8));
|
|
|
|
#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 0x2d: /* JCN2 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_2d_JCN2:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#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 0x2e: /* JSR2 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_2e_JSR2:");
|
2021-05-23 11:41:41 -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));
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 2;
|
|
|
|
#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 0x2f: /* STH2 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_2f_STH2:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 2;
|
|
|
|
#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 0x30: /* LDZ2 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_30_LDZ2:");
|
2021-05-23 11:41:41 -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);
|
|
|
|
#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 0x31: /* STZ2 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_31_STZ2:");
|
2021-05-23 11:41:41 -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);
|
|
|
|
#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 0x32: /* LDR2 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_32_LDR2:");
|
2021-05-23 11:41:41 -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);
|
|
|
|
#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 0x33: /* STR2 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_33_STR2:");
|
2021-05-23 11:41:41 -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);
|
|
|
|
#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 0x34: /* LDA2 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_34_LDA2:");
|
2021-05-23 11:41:41 -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);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x35: /* STA2 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_35_STA2:");
|
2021-05-23 11:41:41 -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);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 4;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x36: /* DEI2 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_36_DEI2:");
|
2021-05-23 11:41:41 -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);
|
|
|
|
#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 0x37: /* DEO2 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_37_DEO2:");
|
2021-05-23 11:41:41 -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);
|
|
|
|
#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 0x38: /* ADD2 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_38_ADD2:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x39: /* SUB2 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_39_SUB2:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x3a: /* MUL2 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_3a_MUL2:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x3b: /* DIV2 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_3b_DIV2:");
|
2021-05-23 11:41:41 -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) {
|
|
|
|
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 - 4] = (b / a) >> 8;
|
|
|
|
u->wst.dat[u->wst.ptr - 3] = (b / a) & 0xff;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x3c: /* AND2 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_3c_AND2:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x3d: /* ORA2 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_3d_ORA2:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x3e: /* EOR2 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_3e_EOR2:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x3f: /* SFT2 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_3f_SFT2:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr -= 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x41: /* LITr */
|
|
|
|
case 0xc1: /* LITkr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_41_LITr:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, u->ram.ptr++);
|
|
|
|
#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 0x43: /* POPr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_43_POPr:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
u->rst.dat[u->rst.ptr - 1];
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x44: /* DUPr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_44_DUPr:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
u->rst.dat[u->rst.ptr] = a;
|
|
|
|
#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 0x45: /* SWPr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_45_SWPr:");
|
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 - 2] = a;
|
|
|
|
u->rst.dat[u->rst.ptr - 1] = b;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
2021-08-15 16:06:54 -04:00
|
|
|
case 0x46: /* OVRr */
|
|
|
|
__asm__("evaluxn_46_OVRr:");
|
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];
|
|
|
|
u->rst.dat[u->rst.ptr] = b;
|
2021-05-23 11:41:41 -04:00
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
2021-08-15 16:06:54 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr > 254, 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 += 1;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x47: /* ROTr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_47_ROTr:");
|
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], 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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x48: /* EQUr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_48_EQUr:");
|
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 - 2] = b == a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x49: /* NEQr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_49_NEQr:");
|
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 - 2] = b != a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x4a: /* GTHr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_4a_GTHr:");
|
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 - 2] = b > a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x4b: /* LTHr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_4b_LTHr:");
|
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 - 2] = b < a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x4c: /* JMPr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_4c_JMPr:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
u->ram.ptr += (Sint8)a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x4d: /* JCNr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_4d_JCNr:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
if(u->rst.dat[u->rst.ptr - 2]) u->ram.ptr += (Sint8)a;
|
|
|
|
#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 0x4e: /* JSRr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_4e_JSRr:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 1;
|
|
|
|
#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 0x4f: /* STHr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_4f_STHr:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
u->wst.dat[u->wst.ptr] = a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 1;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
|
|
u->wst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x50: /* LDZr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_50_LDZr:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
u->rst.dat[u->rst.ptr - 1] = mempeek8(u->ram.dat, a);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x51: /* STZr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_51_STZr:");
|
2021-05-23 11:41:41 -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);
|
|
|
|
#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 0x52: /* LDRr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_52_LDRr:");
|
2021-05-23 11:41:41 -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);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x53: /* STRr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_53_STRr:");
|
2021-05-23 11:41:41 -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);
|
|
|
|
#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 0x54: /* LDAr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_54_LDAr:");
|
2021-05-23 11:41:41 -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);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x55: /* STAr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_55_STAr:");
|
2021-05-23 11:41:41 -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);
|
|
|
|
#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 0x56: /* DEIr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_56_DEIr:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
u->rst.dat[u->rst.ptr - 1] = devpeek8(&u->dev[a >> 4], a);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x57: /* DEOr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_57_DEOr:");
|
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];
|
|
|
|
devpoke8(&u->dev[a >> 4], a, b);
|
|
|
|
#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 0x58: /* ADDr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_58_ADDr:");
|
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 - 2] = b + a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x59: /* SUBr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_59_SUBr:");
|
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 - 2] = b - a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x5a: /* MULr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_5a_MULr:");
|
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 - 2] = b * a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x5b: /* DIVr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_5b_DIVr:");
|
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];
|
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 - 2] = b / a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x5c: /* ANDr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_5c_ANDr:");
|
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 - 2] = b & a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x5d: /* ORAr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_5d_ORAr:");
|
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 - 2] = b | a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x5e: /* EORr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_5e_EORr:");
|
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 - 2] = b ^ a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x5f: /* SFTr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_5f_SFTr:");
|
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 - 2] = b >> (a & 0x07) << ((a & 0x70) >> 4);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr -= 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x61: /* LIT2r */
|
|
|
|
case 0xe1: /* LIT2kr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_61_LIT2r:");
|
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;
|
|
|
|
case 0x63: /* POP2r */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_63_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;
|
|
|
|
case 0x64: /* DUP2r */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_64_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;
|
|
|
|
case 0x65: /* SWP2r */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_65_SWP2r:");
|
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], 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 */
|
|
|
|
__asm__("evaluxn_66_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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_67_ROT2r:");
|
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], 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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_68_EQU2r:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_69_NEQ2r:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_6a_GTH2r:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_6b_LTH2r:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_6c_JMP2r:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_6d_JCN2r:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_6e_JSR2r:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_6f_STH2r:");
|
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->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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_70_LDZ2r:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_71_STZ2r:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_72_LDR2r:");
|
2021-05-23 11:41:41 -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);
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_73_STR2r:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_74_LDA2r:");
|
2021-05-23 11:41:41 -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);
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_75_STA2r:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_76_DEI2r:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_77_DEO2r:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_78_ADD2r:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_79_SUB2r:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_7a_MUL2r:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_7b_DIV2r:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_7c_AND2r:");
|
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], 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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_7d_ORA2r:");
|
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], 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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_7e_EOR2r:");
|
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], 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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_7f_SFT2r:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
case 0x83: /* POPk */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_83_POPk:");
|
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
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x84: /* DUPk */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_84_DUPk:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 1, 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;
|
|
|
|
case 0x85: /* SWPk */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_85_SWPk:");
|
2021-05-23 11:41:41 -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] = 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 */
|
|
|
|
__asm__("evaluxn_86_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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_87_ROTk:");
|
2021-05-23 11:41:41 -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];
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_88_EQUk:");
|
2021-05-23 11:41:41 -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 == 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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_89_NEQk:");
|
2021-05-23 11:41:41 -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 != 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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_8a_GTHk:");
|
2021-05-23 11:41:41 -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 > 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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_8b_LTHk:");
|
2021-05-23 11:41:41 -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 < 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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_8c_JMPk:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_8d_JCNk:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_8e_JSRk:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_8f_STHk:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_90_LDZk:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_91_STZk:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_92_LDRk:");
|
2021-05-23 11:41:41 -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);
|
|
|
|
#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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_93_STRk:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_94_LDAk:");
|
2021-05-23 11:41:41 -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);
|
|
|
|
#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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_95_STAk:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_96_DEIk:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_97_DEOk:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_98_ADDk:");
|
2021-05-23 11:41:41 -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 + 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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_99_SUBk:");
|
2021-05-23 11:41:41 -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 - 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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_9a_MULk:");
|
2021-05-23 11:41:41 -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 * 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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_9b_DIVk:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_9c_ANDk:");
|
2021-05-23 11:41:41 -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 & 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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_9d_ORAk:");
|
2021-05-23 11:41:41 -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 | 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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_9e_EORk:");
|
2021-05-23 11:41:41 -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 ^ 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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_9f_SFTk:");
|
2021-05-23 11:41:41 -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 >> (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;
|
|
|
|
case 0xa3: /* POP2k */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_a3_POP2k:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
(u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8));
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xa4: /* DUP2k */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_a4_DUP2k:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if(__builtin_expect(u->wst.ptr > 251, 0)) {
|
|
|
|
u->wst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr += 4;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xa5: /* SWP2k */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_a5_SWP2k:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if(__builtin_expect(u->wst.ptr > 251, 0)) {
|
|
|
|
u->wst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr += 4;
|
|
|
|
}
|
|
|
|
break;
|
2021-08-15 16:06:54 -04:00
|
|
|
case 0xa6: /* OVR2k */
|
|
|
|
__asm__("evaluxn_a6_OVR2k:");
|
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], 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
|
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
2021-08-15 16:06:54 -04:00
|
|
|
if(__builtin_expect(u->wst.ptr > 249, 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 += 6;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xa7: /* ROT2k */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_a7_ROT2k:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 6, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if(__builtin_expect(u->wst.ptr > 249, 0)) {
|
|
|
|
u->wst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr += 6;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xa8: /* EQU2k */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_a8_EQU2k:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 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 0xa9: /* NEQ2k */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_a9_NEQ2k:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 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 0xaa: /* GTH2k */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_aa_GTH2k:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 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 0xab: /* LTH2k */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_ab_LTH2k:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 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 0xac: /* JMP2k */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_ac_JMP2k:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
u->ram.ptr = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8));
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xad: /* JCN2k */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_ad_JCN2k:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xae: /* JSR2k */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_ae_JSR2k:");
|
2021-05-23 11:41:41 -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));
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 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 0xaf: /* STH2k */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_af_STH2k:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 2, 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 0xb0: /* LDZ2k */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_b0_LDZ2k:");
|
2021-05-23 11:41:41 -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);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 1, 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;
|
|
|
|
case 0xb1: /* STZ2k */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_b1_STZ2k:");
|
2021-05-23 11:41:41 -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);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xb2: /* LDR2k */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_b2_LDR2k:");
|
2021-05-23 11:41:41 -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);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 1, 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;
|
|
|
|
case 0xb3: /* STR2k */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_b3_STR2k:");
|
2021-05-23 11:41:41 -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);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xb4: /* LDA2k */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_b4_LDA2k:");
|
2021-05-23 11:41:41 -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);
|
|
|
|
#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;
|
|
|
|
case 0xb5: /* STA2k */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_b5_STA2k:");
|
2021-05-23 11:41:41 -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);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xb6: /* DEI2k */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_b6_DEI2k:");
|
2021-05-23 11:41:41 -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);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 1, 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;
|
|
|
|
case 0xb7: /* DEO2k */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_b7_DEO2k:");
|
2021-05-23 11:41:41 -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);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xb8: /* ADD2k */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_b8_ADD2k:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
|
|
u->wst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr += 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xb9: /* SUB2k */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_b9_SUB2k:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
|
|
u->wst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr += 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xba: /* MUL2k */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_ba_MUL2k:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
|
|
u->wst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr += 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xbb: /* DIV2k */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_bb_DIV2k:");
|
2021-05-23 11:41:41 -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) {
|
|
|
|
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) >> 8;
|
|
|
|
u->wst.dat[u->wst.ptr + 1] = (b / a) & 0xff;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
|
|
u->wst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr += 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xbc: /* AND2k */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_bc_AND2k:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
|
|
u->wst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr += 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xbd: /* ORA2k */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_bd_ORA2k:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
|
|
u->wst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr += 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xbe: /* EOR2k */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_be_EOR2k:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
|
|
u->wst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
|
|
u->wst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->wst.ptr += 2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xbf: /* SFT2k */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_bf_SFT2k:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->wst.ptr < 3, 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;
|
|
|
|
case 0xc3: /* POPkr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_c3_POPkr:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
u->rst.dat[u->rst.ptr - 1];
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xc4: /* DUPkr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_c4_DUPkr:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#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 0xc5: /* SWPkr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_c5_SWPkr:");
|
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] = a;
|
|
|
|
u->rst.dat[u->rst.ptr + 1] = b;
|
|
|
|
#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:06:54 -04:00
|
|
|
case 0xc6: /* OVRkr */
|
|
|
|
__asm__("evaluxn_c6_OVRkr:");
|
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];
|
|
|
|
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
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
2021-08-15 16:06:54 -04:00
|
|
|
if(__builtin_expect(u->rst.ptr > 252, 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 += 3;
|
2021-05-23 11:41:41 -04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xc7: /* ROTkr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_c7_ROTkr:");
|
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], 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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if(__builtin_expect(u->rst.ptr > 252, 0)) {
|
|
|
|
u->rst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr += 3;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xc8: /* EQUkr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_c8_EQUkr:");
|
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 == 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 > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xc9: /* NEQkr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_c9_NEQkr:");
|
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 != 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 > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xca: /* GTHkr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_ca_GTHkr:");
|
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 > 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 > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xcb: /* LTHkr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_cb_LTHkr:");
|
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 < 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 > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xcc: /* JMPkr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_cc_JMPkr:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
u->ram.ptr += (Sint8)a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xcd: /* JCNkr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_cd_JCNkr:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
if(u->rst.dat[u->rst.ptr - 2]) u->ram.ptr += (Sint8)a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xce: /* JSRkr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_ce_JSRkr:");
|
2021-05-23 11:41:41 -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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 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 0xcf: /* STHkr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_cf_STHkr:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
u->wst.dat[u->wst.ptr] = a;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
|
|
u->rst.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 0xd0: /* LDZkr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_d0_LDZkr:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, a);
|
|
|
|
#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 0xd1: /* STZkr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_d1_STZkr:");
|
2021-05-23 11:41:41 -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);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xd2: /* LDRkr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_d2_LDRkr:");
|
2021-05-23 11:41:41 -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);
|
|
|
|
#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 0xd3: /* STRkr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_d3_STRkr:");
|
2021-05-23 11:41:41 -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);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xd4: /* LDAkr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_d4_LDAkr:");
|
2021-05-23 11:41:41 -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);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xd5: /* STAkr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_d5_STAkr:");
|
2021-05-23 11:41:41 -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);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xd6: /* DEIkr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_d6_DEIkr:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
Uint8 a = u->rst.dat[u->rst.ptr - 1];
|
|
|
|
u->rst.dat[u->rst.ptr] = devpeek8(&u->dev[a >> 4], a);
|
|
|
|
#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 0xd7: /* DEOkr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_d7_DEOkr:");
|
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];
|
|
|
|
devpoke8(&u->dev[a >> 4], a, b);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xd8: /* ADDkr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_d8_ADDkr:");
|
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 + 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 > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xd9: /* SUBkr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_d9_SUBkr:");
|
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 - 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 > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xda: /* MULkr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_da_MULkr:");
|
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 * 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 > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xdb: /* DIVkr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_db_DIVkr:");
|
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];
|
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;
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xdc: /* ANDkr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_dc_ANDkr:");
|
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 & 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 > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xdd: /* ORAkr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_dd_ORAkr:");
|
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 | 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 > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xde: /* EORkr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_de_EORkr:");
|
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 ^ 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 > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xdf: /* SFTkr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_df_SFTkr:");
|
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 >> (a & 0x07) << ((a & 0x70) >> 4);
|
|
|
|
#ifndef NO_STACK_CHECKS
|
|
|
|
if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
|
|
u->rst.error = 1;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
|
|
u->rst.error = 2;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
u->rst.ptr += 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0xe3: /* POP2kr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_e3_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;
|
|
|
|
case 0xe4: /* DUP2kr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_e4_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;
|
|
|
|
case 0xe5: /* SWP2kr */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_e5_SWP2kr:");
|
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], 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 */
|
|
|
|
__asm__("evaluxn_e6_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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_e7_ROT2kr:");
|
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], 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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_e8_EQU2kr:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_e9_NEQ2kr:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_ea_GTH2kr:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_eb_LTH2kr:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_ec_JMP2kr:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_ed_JCN2kr:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_ee_JSR2kr:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_ef_STH2kr:");
|
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->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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_f0_LDZ2kr:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_f1_STZ2kr:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_f2_LDR2kr:");
|
2021-05-23 11:41:41 -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);
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_f3_STR2kr:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_f4_LDA2kr:");
|
2021-05-23 11:41:41 -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);
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_f5_STA2kr:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_f6_DEI2kr:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_f7_DEO2kr:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_f8_ADD2kr:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_f9_SUB2kr:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_fa_MUL2kr:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_fb_DIV2kr:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_fc_AND2kr:");
|
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], 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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_fd_ORA2kr:");
|
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], 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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_fe_EOR2kr:");
|
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], 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 */
|
2021-05-23 14:05:17 -04:00
|
|
|
__asm__("evaluxn_ff_SFT2kr:");
|
2021-05-23 11:41:41 -04:00
|
|
|
{
|
|
|
|
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++)
|
|
|
|
cptr[i] = 0;
|
|
|
|
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;
|
|
|
|
}
|