| ... | ... |
@@ -29,8 +29,8 @@ then |
| 29 | 29 |
cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined src/uxn.c src/debugger.c -o bin/debugger |
| 30 | 30 |
else |
| 31 | 31 |
cc src/assembler.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -o bin/uxnasm |
| 32 |
- cc src/uxn.c src/debugger.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -o bin/debugger |
|
| 33 |
- cc src/uxn.c src/devices/ppu.c src/devices/apu.c src/devices/mpu.c src/emulator.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -o bin/uxnemu |
|
| 32 |
+ cc src/uxn-fast.c src/debugger.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -o bin/debugger |
|
| 33 |
+ cc src/uxn-fast.c src/devices/ppu.c src/devices/apu.c src/devices/mpu.c src/emulator.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -o bin/uxnemu |
|
| 34 | 34 |
fi |
| 35 | 35 |
|
| 36 | 36 |
echo "Installing.." |
| ... | ... |
@@ -42,7 +42,7 @@ then |
| 42 | 42 |
fi |
| 43 | 43 |
|
| 44 | 44 |
echo "Assembling.." |
| 45 |
-./bin/uxnasm projects/examples/devices/controller.buttons.usm bin/boot.rom |
|
| 45 |
+./bin/uxnasm projects/demos/life.usm bin/boot.rom |
|
| 46 | 46 |
|
| 47 | 47 |
echo "Running.." |
| 48 | 48 |
if [ "${2}" = '--cli' ];
|
| 49 | 49 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,3992 @@ |
| 1 |
+#include <stdio.h> |
|
| 2 |
+#include "uxn.h" |
|
| 3 |
+ |
|
| 4 |
+/* |
|
| 5 |
+Copyright (u) 2021 Devine Lu Linvega |
|
| 6 |
+Copyright (u) 2021 Andrew Alderwick |
|
| 7 |
+ |
|
| 8 |
+Permission to use, copy, modify, and distribute this software for any |
|
| 9 |
+purpose with or without fee is hereby granted, provided that the above |
|
| 10 |
+copyright notice and this permission notice appear in all copies. |
|
| 11 |
+ |
|
| 12 |
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|
| 13 |
+WITH REGARD TO THIS SOFTWARE. |
|
| 14 |
+*/ |
|
| 15 |
+ |
|
| 16 |
+/* clang-format off */ |
|
| 17 |
+void mempoke8(Uint8 *m, Uint16 a, Uint8 b) { m[a] = b; }
|
|
| 18 |
+Uint8 mempeek8(Uint8 *m, Uint16 a) { return m[a]; }
|
|
| 19 |
+void devpoke8(Device *d, Uint8 a, Uint8 b) { d->dat[a & 0xf] = b; d->talk(d, a & 0x0f, 1); }
|
|
| 20 |
+Uint8 devpeek8(Device *d, Uint8 a) { d->talk(d, a & 0x0f, 0); return d->dat[a & 0xf]; }
|
|
| 21 |
+void mempoke16(Uint8 *m, Uint16 a, Uint16 b) { mempoke8(m, a, b >> 8); mempoke8(m, a + 1, b); }
|
|
| 22 |
+Uint16 mempeek16(Uint8 *m, Uint16 a) { return (mempeek8(m, a) << 8) + mempeek8(m, a + 1); }
|
|
| 23 |
+void devpoke16(Device *d, Uint8 a, Uint16 b) { devpoke8(d, a, b >> 8); devpoke8(d, a + 1, b); }
|
|
| 24 |
+Uint16 devpeek16(Device *d, Uint16 a) { return (devpeek8(d, a) << 8) + devpeek8(d, a + 1); }
|
|
| 25 |
+/* clang-format on */ |
|
| 26 |
+ |
|
| 27 |
+int |
|
| 28 |
+evaluxn(Uxn *u, Uint16 vec) |
|
| 29 |
+{
|
|
| 30 |
+ Uint8 instr; |
|
| 31 |
+ u->ram.ptr = vec; |
|
| 32 |
+ while(u->ram.ptr) {
|
|
| 33 |
+ instr = u->ram.dat[u->ram.ptr++]; |
|
| 34 |
+ switch(instr) {
|
|
| 35 |
+#pragma GCC diagnostic push |
|
| 36 |
+#pragma GCC diagnostic ignored "-Wunused-value" |
|
| 37 |
+#pragma GCC diagnostic ignored "-Wunused-variable" |
|
| 38 |
+ case 0x00: /* BRK */ |
|
| 39 |
+ case 0x20: /* BRK2 */ |
|
| 40 |
+ case 0x40: /* BRKr */ |
|
| 41 |
+ case 0x60: /* BRK2r */ |
|
| 42 |
+ case 0x80: /* BRKk */ |
|
| 43 |
+ case 0xa0: /* BRK2k */ |
|
| 44 |
+ case 0xc0: /* BRKkr */ |
|
| 45 |
+ case 0xe0: /* BRK2kr */ |
|
| 46 |
+ __asm__( "evaluxn_00_BRK:" ); |
|
| 47 |
+ {
|
|
| 48 |
+ u->ram.ptr = 0; |
|
| 49 |
+ } |
|
| 50 |
+ break; |
|
| 51 |
+ case 0x01: /* LIT */ |
|
| 52 |
+ case 0x81: /* LITk */ |
|
| 53 |
+ __asm__( "evaluxn_01_LIT:" ); |
|
| 54 |
+ {
|
|
| 55 |
+ u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, u->ram.ptr++); |
|
| 56 |
+#ifndef NO_STACK_CHECKS |
|
| 57 |
+ if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 58 |
+ u->wst.error = 2; |
|
| 59 |
+ goto error; |
|
| 60 |
+ } |
|
| 61 |
+#endif |
|
| 62 |
+ u->wst.ptr += 1; |
|
| 63 |
+ } |
|
| 64 |
+ break; |
|
| 65 |
+ case 0x02: /* NOP */ |
|
| 66 |
+ case 0x22: /* NOP2 */ |
|
| 67 |
+ case 0x42: /* NOPr */ |
|
| 68 |
+ case 0x62: /* NOP2r */ |
|
| 69 |
+ case 0x82: /* NOPk */ |
|
| 70 |
+ case 0xa2: /* NOP2k */ |
|
| 71 |
+ case 0xc2: /* NOPkr */ |
|
| 72 |
+ case 0xe2: /* NOP2kr */ |
|
| 73 |
+ __asm__( "evaluxn_02_NOP:" ); |
|
| 74 |
+ {
|
|
| 75 |
+ (void)u; |
|
| 76 |
+ } |
|
| 77 |
+ break; |
|
| 78 |
+ case 0x03: /* POP */ |
|
| 79 |
+ __asm__( "evaluxn_03_POP:" ); |
|
| 80 |
+ {
|
|
| 81 |
+ u->wst.dat[u->wst.ptr - 1]; |
|
| 82 |
+#ifndef NO_STACK_CHECKS |
|
| 83 |
+ if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 84 |
+ u->wst.error = 1; |
|
| 85 |
+ goto error; |
|
| 86 |
+ } |
|
| 87 |
+#endif |
|
| 88 |
+ u->wst.ptr -= 1; |
|
| 89 |
+ } |
|
| 90 |
+ break; |
|
| 91 |
+ case 0x04: /* DUP */ |
|
| 92 |
+ __asm__( "evaluxn_04_DUP:" ); |
|
| 93 |
+ {
|
|
| 94 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 95 |
+ u->wst.dat[u->wst.ptr] = a; |
|
| 96 |
+#ifndef NO_STACK_CHECKS |
|
| 97 |
+ if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 98 |
+ u->wst.error = 1; |
|
| 99 |
+ goto error; |
|
| 100 |
+ } |
|
| 101 |
+ if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 102 |
+ u->wst.error = 2; |
|
| 103 |
+ goto error; |
|
| 104 |
+ } |
|
| 105 |
+#endif |
|
| 106 |
+ u->wst.ptr += 1; |
|
| 107 |
+ } |
|
| 108 |
+ break; |
|
| 109 |
+ case 0x05: /* SWP */ |
|
| 110 |
+ __asm__( "evaluxn_05_SWP:" ); |
|
| 111 |
+ {
|
|
| 112 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 113 |
+ u->wst.dat[u->wst.ptr - 2] = a; |
|
| 114 |
+ u->wst.dat[u->wst.ptr - 1] = b; |
|
| 115 |
+#ifndef NO_STACK_CHECKS |
|
| 116 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 117 |
+ u->wst.error = 1; |
|
| 118 |
+ goto error; |
|
| 119 |
+ } |
|
| 120 |
+#endif |
|
| 121 |
+ } |
|
| 122 |
+ break; |
|
| 123 |
+ case 0x06: /* OVR */ |
|
| 124 |
+ __asm__( "evaluxn_06_OVR:" ); |
|
| 125 |
+ {
|
|
| 126 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 127 |
+ u->wst.dat[u->wst.ptr] = b; |
|
| 128 |
+#ifndef NO_STACK_CHECKS |
|
| 129 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 130 |
+ u->wst.error = 1; |
|
| 131 |
+ goto error; |
|
| 132 |
+ } |
|
| 133 |
+ if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 134 |
+ u->wst.error = 2; |
|
| 135 |
+ goto error; |
|
| 136 |
+ } |
|
| 137 |
+#endif |
|
| 138 |
+ u->wst.ptr += 1; |
|
| 139 |
+ } |
|
| 140 |
+ break; |
|
| 141 |
+ case 0x07: /* ROT */ |
|
| 142 |
+ __asm__( "evaluxn_07_ROT:" ); |
|
| 143 |
+ {
|
|
| 144 |
+ 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]; |
|
| 145 |
+ u->wst.dat[u->wst.ptr - 3] = b; |
|
| 146 |
+ u->wst.dat[u->wst.ptr - 2] = a; |
|
| 147 |
+ u->wst.dat[u->wst.ptr - 1] = c; |
|
| 148 |
+#ifndef NO_STACK_CHECKS |
|
| 149 |
+ if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
| 150 |
+ u->wst.error = 1; |
|
| 151 |
+ goto error; |
|
| 152 |
+ } |
|
| 153 |
+#endif |
|
| 154 |
+ } |
|
| 155 |
+ break; |
|
| 156 |
+ case 0x08: /* EQU */ |
|
| 157 |
+ __asm__( "evaluxn_08_EQU:" ); |
|
| 158 |
+ {
|
|
| 159 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 160 |
+ u->wst.dat[u->wst.ptr - 2] = b == a; |
|
| 161 |
+#ifndef NO_STACK_CHECKS |
|
| 162 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 163 |
+ u->wst.error = 1; |
|
| 164 |
+ goto error; |
|
| 165 |
+ } |
|
| 166 |
+#endif |
|
| 167 |
+ u->wst.ptr -= 1; |
|
| 168 |
+ } |
|
| 169 |
+ break; |
|
| 170 |
+ case 0x09: /* NEQ */ |
|
| 171 |
+ __asm__( "evaluxn_09_NEQ:" ); |
|
| 172 |
+ {
|
|
| 173 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 174 |
+ u->wst.dat[u->wst.ptr - 2] = b != a; |
|
| 175 |
+#ifndef NO_STACK_CHECKS |
|
| 176 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 177 |
+ u->wst.error = 1; |
|
| 178 |
+ goto error; |
|
| 179 |
+ } |
|
| 180 |
+#endif |
|
| 181 |
+ u->wst.ptr -= 1; |
|
| 182 |
+ } |
|
| 183 |
+ break; |
|
| 184 |
+ case 0x0a: /* GTH */ |
|
| 185 |
+ __asm__( "evaluxn_0a_GTH:" ); |
|
| 186 |
+ {
|
|
| 187 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 188 |
+ u->wst.dat[u->wst.ptr - 2] = b > a; |
|
| 189 |
+#ifndef NO_STACK_CHECKS |
|
| 190 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 191 |
+ u->wst.error = 1; |
|
| 192 |
+ goto error; |
|
| 193 |
+ } |
|
| 194 |
+#endif |
|
| 195 |
+ u->wst.ptr -= 1; |
|
| 196 |
+ } |
|
| 197 |
+ break; |
|
| 198 |
+ case 0x0b: /* LTH */ |
|
| 199 |
+ __asm__( "evaluxn_0b_LTH:" ); |
|
| 200 |
+ {
|
|
| 201 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 202 |
+ u->wst.dat[u->wst.ptr - 2] = b < a; |
|
| 203 |
+#ifndef NO_STACK_CHECKS |
|
| 204 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 205 |
+ u->wst.error = 1; |
|
| 206 |
+ goto error; |
|
| 207 |
+ } |
|
| 208 |
+#endif |
|
| 209 |
+ u->wst.ptr -= 1; |
|
| 210 |
+ } |
|
| 211 |
+ break; |
|
| 212 |
+ case 0x0c: /* JMP */ |
|
| 213 |
+ __asm__( "evaluxn_0c_JMP:" ); |
|
| 214 |
+ {
|
|
| 215 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 216 |
+ u->ram.ptr += (Sint8)a; |
|
| 217 |
+#ifndef NO_STACK_CHECKS |
|
| 218 |
+ if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 219 |
+ u->wst.error = 1; |
|
| 220 |
+ goto error; |
|
| 221 |
+ } |
|
| 222 |
+#endif |
|
| 223 |
+ u->wst.ptr -= 1; |
|
| 224 |
+ } |
|
| 225 |
+ break; |
|
| 226 |
+ case 0x0d: /* JCN */ |
|
| 227 |
+ __asm__( "evaluxn_0d_JCN:" ); |
|
| 228 |
+ {
|
|
| 229 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 230 |
+ if(u->wst.dat[u->wst.ptr - 2]) u->ram.ptr += (Sint8)a; |
|
| 231 |
+#ifndef NO_STACK_CHECKS |
|
| 232 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 233 |
+ u->wst.error = 1; |
|
| 234 |
+ goto error; |
|
| 235 |
+ } |
|
| 236 |
+#endif |
|
| 237 |
+ u->wst.ptr -= 2; |
|
| 238 |
+ } |
|
| 239 |
+ break; |
|
| 240 |
+ case 0x0e: /* JSR */ |
|
| 241 |
+ __asm__( "evaluxn_0e_JSR:" ); |
|
| 242 |
+ {
|
|
| 243 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 244 |
+ u->rst.dat[u->rst.ptr] = u->ram.ptr >> 8; |
|
| 245 |
+ u->rst.dat[u->rst.ptr + 1] = u->ram.ptr & 0xff; |
|
| 246 |
+ u->ram.ptr += (Sint8)a; |
|
| 247 |
+#ifndef NO_STACK_CHECKS |
|
| 248 |
+ if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 249 |
+ u->wst.error = 1; |
|
| 250 |
+ goto error; |
|
| 251 |
+ } |
|
| 252 |
+#endif |
|
| 253 |
+ u->wst.ptr -= 1; |
|
| 254 |
+#ifndef NO_STACK_CHECKS |
|
| 255 |
+ if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 256 |
+ u->rst.error = 2; |
|
| 257 |
+ goto error; |
|
| 258 |
+ } |
|
| 259 |
+#endif |
|
| 260 |
+ u->rst.ptr += 2; |
|
| 261 |
+ } |
|
| 262 |
+ break; |
|
| 263 |
+ case 0x0f: /* STH */ |
|
| 264 |
+ __asm__( "evaluxn_0f_STH:" ); |
|
| 265 |
+ {
|
|
| 266 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 267 |
+ u->rst.dat[u->rst.ptr] = a; |
|
| 268 |
+#ifndef NO_STACK_CHECKS |
|
| 269 |
+ if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 270 |
+ u->wst.error = 1; |
|
| 271 |
+ goto error; |
|
| 272 |
+ } |
|
| 273 |
+#endif |
|
| 274 |
+ u->wst.ptr -= 1; |
|
| 275 |
+#ifndef NO_STACK_CHECKS |
|
| 276 |
+ if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 277 |
+ u->rst.error = 2; |
|
| 278 |
+ goto error; |
|
| 279 |
+ } |
|
| 280 |
+#endif |
|
| 281 |
+ u->rst.ptr += 1; |
|
| 282 |
+ } |
|
| 283 |
+ break; |
|
| 284 |
+ case 0x10: /* LDZ */ |
|
| 285 |
+ __asm__( "evaluxn_10_LDZ:" ); |
|
| 286 |
+ {
|
|
| 287 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 288 |
+ u->wst.dat[u->wst.ptr - 1] = mempeek8(u->ram.dat, a); |
|
| 289 |
+#ifndef NO_STACK_CHECKS |
|
| 290 |
+ if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 291 |
+ u->wst.error = 1; |
|
| 292 |
+ goto error; |
|
| 293 |
+ } |
|
| 294 |
+#endif |
|
| 295 |
+ } |
|
| 296 |
+ break; |
|
| 297 |
+ case 0x11: /* STZ */ |
|
| 298 |
+ __asm__( "evaluxn_11_STZ:" ); |
|
| 299 |
+ {
|
|
| 300 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 301 |
+ Uint8 b = u->wst.dat[u->wst.ptr - 2]; |
|
| 302 |
+ mempoke8(u->ram.dat, a, b); |
|
| 303 |
+#ifndef NO_STACK_CHECKS |
|
| 304 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 305 |
+ u->wst.error = 1; |
|
| 306 |
+ goto error; |
|
| 307 |
+ } |
|
| 308 |
+#endif |
|
| 309 |
+ u->wst.ptr -= 2; |
|
| 310 |
+ } |
|
| 311 |
+ break; |
|
| 312 |
+ case 0x12: /* LDR */ |
|
| 313 |
+ __asm__( "evaluxn_12_LDR:" ); |
|
| 314 |
+ {
|
|
| 315 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 316 |
+ u->wst.dat[u->wst.ptr - 1] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a); |
|
| 317 |
+#ifndef NO_STACK_CHECKS |
|
| 318 |
+ if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 319 |
+ u->wst.error = 1; |
|
| 320 |
+ goto error; |
|
| 321 |
+ } |
|
| 322 |
+#endif |
|
| 323 |
+ } |
|
| 324 |
+ break; |
|
| 325 |
+ case 0x13: /* STR */ |
|
| 326 |
+ __asm__( "evaluxn_13_STR:" ); |
|
| 327 |
+ {
|
|
| 328 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 329 |
+ Uint8 b = u->wst.dat[u->wst.ptr - 2]; |
|
| 330 |
+ mempoke8(u->ram.dat, u->ram.ptr + (Sint8)a, b); |
|
| 331 |
+#ifndef NO_STACK_CHECKS |
|
| 332 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 333 |
+ u->wst.error = 1; |
|
| 334 |
+ goto error; |
|
| 335 |
+ } |
|
| 336 |
+#endif |
|
| 337 |
+ u->wst.ptr -= 2; |
|
| 338 |
+ } |
|
| 339 |
+ break; |
|
| 340 |
+ case 0x14: /* LDA */ |
|
| 341 |
+ __asm__( "evaluxn_14_LDA:" ); |
|
| 342 |
+ {
|
|
| 343 |
+ Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 344 |
+ u->wst.dat[u->wst.ptr - 2] = mempeek8(u->ram.dat, a); |
|
| 345 |
+#ifndef NO_STACK_CHECKS |
|
| 346 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 347 |
+ u->wst.error = 1; |
|
| 348 |
+ goto error; |
|
| 349 |
+ } |
|
| 350 |
+#endif |
|
| 351 |
+ u->wst.ptr -= 1; |
|
| 352 |
+ } |
|
| 353 |
+ break; |
|
| 354 |
+ case 0x15: /* STA */ |
|
| 355 |
+ __asm__( "evaluxn_15_STA:" ); |
|
| 356 |
+ {
|
|
| 357 |
+ Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 358 |
+ Uint8 b = u->wst.dat[u->wst.ptr - 3]; |
|
| 359 |
+ mempoke8(u->ram.dat, a, b); |
|
| 360 |
+#ifndef NO_STACK_CHECKS |
|
| 361 |
+ if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
| 362 |
+ u->wst.error = 1; |
|
| 363 |
+ goto error; |
|
| 364 |
+ } |
|
| 365 |
+#endif |
|
| 366 |
+ u->wst.ptr -= 3; |
|
| 367 |
+ } |
|
| 368 |
+ break; |
|
| 369 |
+ case 0x16: /* DEI */ |
|
| 370 |
+ __asm__( "evaluxn_16_DEI:" ); |
|
| 371 |
+ {
|
|
| 372 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 373 |
+ u->wst.dat[u->wst.ptr - 1] = devpeek8(&u->dev[a >> 4], a); |
|
| 374 |
+#ifndef NO_STACK_CHECKS |
|
| 375 |
+ if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 376 |
+ u->wst.error = 1; |
|
| 377 |
+ goto error; |
|
| 378 |
+ } |
|
| 379 |
+#endif |
|
| 380 |
+ } |
|
| 381 |
+ break; |
|
| 382 |
+ case 0x17: /* DEO */ |
|
| 383 |
+ __asm__( "evaluxn_17_DEO:" ); |
|
| 384 |
+ {
|
|
| 385 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 386 |
+ devpoke8(&u->dev[a >> 4], a, b); |
|
| 387 |
+#ifndef NO_STACK_CHECKS |
|
| 388 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 389 |
+ u->wst.error = 1; |
|
| 390 |
+ goto error; |
|
| 391 |
+ } |
|
| 392 |
+#endif |
|
| 393 |
+ u->wst.ptr -= 2; |
|
| 394 |
+ } |
|
| 395 |
+ break; |
|
| 396 |
+ case 0x18: /* ADD */ |
|
| 397 |
+ __asm__( "evaluxn_18_ADD:" ); |
|
| 398 |
+ {
|
|
| 399 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 400 |
+ u->wst.dat[u->wst.ptr - 2] = b + a; |
|
| 401 |
+#ifndef NO_STACK_CHECKS |
|
| 402 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 403 |
+ u->wst.error = 1; |
|
| 404 |
+ goto error; |
|
| 405 |
+ } |
|
| 406 |
+#endif |
|
| 407 |
+ u->wst.ptr -= 1; |
|
| 408 |
+ } |
|
| 409 |
+ break; |
|
| 410 |
+ case 0x19: /* SUB */ |
|
| 411 |
+ __asm__( "evaluxn_19_SUB:" ); |
|
| 412 |
+ {
|
|
| 413 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 414 |
+ u->wst.dat[u->wst.ptr - 2] = b - a; |
|
| 415 |
+#ifndef NO_STACK_CHECKS |
|
| 416 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 417 |
+ u->wst.error = 1; |
|
| 418 |
+ goto error; |
|
| 419 |
+ } |
|
| 420 |
+#endif |
|
| 421 |
+ u->wst.ptr -= 1; |
|
| 422 |
+ } |
|
| 423 |
+ break; |
|
| 424 |
+ case 0x1a: /* MUL */ |
|
| 425 |
+ __asm__( "evaluxn_1a_MUL:" ); |
|
| 426 |
+ {
|
|
| 427 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 428 |
+ u->wst.dat[u->wst.ptr - 2] = b * a; |
|
| 429 |
+#ifndef NO_STACK_CHECKS |
|
| 430 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 431 |
+ u->wst.error = 1; |
|
| 432 |
+ goto error; |
|
| 433 |
+ } |
|
| 434 |
+#endif |
|
| 435 |
+ u->wst.ptr -= 1; |
|
| 436 |
+ } |
|
| 437 |
+ break; |
|
| 438 |
+ case 0x1b: /* DIV */ |
|
| 439 |
+ __asm__( "evaluxn_1b_DIV:" ); |
|
| 440 |
+ {
|
|
| 441 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 442 |
+ u->wst.dat[u->wst.ptr - 2] = b / a; |
|
| 443 |
+#ifndef NO_STACK_CHECKS |
|
| 444 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 445 |
+ u->wst.error = 1; |
|
| 446 |
+ goto error; |
|
| 447 |
+ } |
|
| 448 |
+#endif |
|
| 449 |
+ u->wst.ptr -= 1; |
|
| 450 |
+ } |
|
| 451 |
+ break; |
|
| 452 |
+ case 0x1c: /* AND */ |
|
| 453 |
+ __asm__( "evaluxn_1c_AND:" ); |
|
| 454 |
+ {
|
|
| 455 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 456 |
+ u->wst.dat[u->wst.ptr - 2] = b & a; |
|
| 457 |
+#ifndef NO_STACK_CHECKS |
|
| 458 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 459 |
+ u->wst.error = 1; |
|
| 460 |
+ goto error; |
|
| 461 |
+ } |
|
| 462 |
+#endif |
|
| 463 |
+ u->wst.ptr -= 1; |
|
| 464 |
+ } |
|
| 465 |
+ break; |
|
| 466 |
+ case 0x1d: /* ORA */ |
|
| 467 |
+ __asm__( "evaluxn_1d_ORA:" ); |
|
| 468 |
+ {
|
|
| 469 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 470 |
+ u->wst.dat[u->wst.ptr - 2] = b | a; |
|
| 471 |
+#ifndef NO_STACK_CHECKS |
|
| 472 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 473 |
+ u->wst.error = 1; |
|
| 474 |
+ goto error; |
|
| 475 |
+ } |
|
| 476 |
+#endif |
|
| 477 |
+ u->wst.ptr -= 1; |
|
| 478 |
+ } |
|
| 479 |
+ break; |
|
| 480 |
+ case 0x1e: /* EOR */ |
|
| 481 |
+ __asm__( "evaluxn_1e_EOR:" ); |
|
| 482 |
+ {
|
|
| 483 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 484 |
+ u->wst.dat[u->wst.ptr - 2] = b ^ a; |
|
| 485 |
+#ifndef NO_STACK_CHECKS |
|
| 486 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 487 |
+ u->wst.error = 1; |
|
| 488 |
+ goto error; |
|
| 489 |
+ } |
|
| 490 |
+#endif |
|
| 491 |
+ u->wst.ptr -= 1; |
|
| 492 |
+ } |
|
| 493 |
+ break; |
|
| 494 |
+ case 0x1f: /* SFT */ |
|
| 495 |
+ __asm__( "evaluxn_1f_SFT:" ); |
|
| 496 |
+ {
|
|
| 497 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 498 |
+ u->wst.dat[u->wst.ptr - 2] = b >> (a & 0x07) << ((a & 0x70) >> 4); |
|
| 499 |
+#ifndef NO_STACK_CHECKS |
|
| 500 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 501 |
+ u->wst.error = 1; |
|
| 502 |
+ goto error; |
|
| 503 |
+ } |
|
| 504 |
+#endif |
|
| 505 |
+ u->wst.ptr -= 1; |
|
| 506 |
+ } |
|
| 507 |
+ break; |
|
| 508 |
+ case 0x21: /* LIT2 */ |
|
| 509 |
+ case 0xa1: /* LIT2k */ |
|
| 510 |
+ __asm__( "evaluxn_21_LIT2:" ); |
|
| 511 |
+ {
|
|
| 512 |
+ u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, u->ram.ptr++); |
|
| 513 |
+ u->wst.dat[u->wst.ptr + 1] = mempeek8(u->ram.dat, u->ram.ptr++); |
|
| 514 |
+#ifndef NO_STACK_CHECKS |
|
| 515 |
+ if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 516 |
+ u->wst.error = 2; |
|
| 517 |
+ goto error; |
|
| 518 |
+ } |
|
| 519 |
+#endif |
|
| 520 |
+ u->wst.ptr += 2; |
|
| 521 |
+ } |
|
| 522 |
+ break; |
|
| 523 |
+ case 0x23: /* POP2 */ |
|
| 524 |
+ __asm__( "evaluxn_23_POP2:" ); |
|
| 525 |
+ {
|
|
| 526 |
+ (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 527 |
+#ifndef NO_STACK_CHECKS |
|
| 528 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 529 |
+ u->wst.error = 1; |
|
| 530 |
+ goto error; |
|
| 531 |
+ } |
|
| 532 |
+#endif |
|
| 533 |
+ u->wst.ptr -= 2; |
|
| 534 |
+ } |
|
| 535 |
+ break; |
|
| 536 |
+ case 0x24: /* DUP2 */ |
|
| 537 |
+ __asm__( "evaluxn_24_DUP2:" ); |
|
| 538 |
+ {
|
|
| 539 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 540 |
+ u->wst.dat[u->wst.ptr] = b; |
|
| 541 |
+ u->wst.dat[u->wst.ptr + 1] = a; |
|
| 542 |
+#ifndef NO_STACK_CHECKS |
|
| 543 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 544 |
+ u->wst.error = 1; |
|
| 545 |
+ goto error; |
|
| 546 |
+ } |
|
| 547 |
+ if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 548 |
+ u->wst.error = 2; |
|
| 549 |
+ goto error; |
|
| 550 |
+ } |
|
| 551 |
+#endif |
|
| 552 |
+ u->wst.ptr += 2; |
|
| 553 |
+ } |
|
| 554 |
+ break; |
|
| 555 |
+ case 0x25: /* SWP2 */ |
|
| 556 |
+ __asm__( "evaluxn_25_SWP2:" ); |
|
| 557 |
+ {
|
|
| 558 |
+ 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]; |
|
| 559 |
+ u->wst.dat[u->wst.ptr - 4] = b; |
|
| 560 |
+ u->wst.dat[u->wst.ptr - 3] = a; |
|
| 561 |
+ u->wst.dat[u->wst.ptr - 2] = d; |
|
| 562 |
+ u->wst.dat[u->wst.ptr - 1] = c; |
|
| 563 |
+#ifndef NO_STACK_CHECKS |
|
| 564 |
+ if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 565 |
+ u->wst.error = 1; |
|
| 566 |
+ goto error; |
|
| 567 |
+ } |
|
| 568 |
+#endif |
|
| 569 |
+ } |
|
| 570 |
+ break; |
|
| 571 |
+ case 0x26: /* OVR2 */ |
|
| 572 |
+ __asm__( "evaluxn_26_OVR2:" ); |
|
| 573 |
+ {
|
|
| 574 |
+ 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]; |
|
| 575 |
+ u->wst.dat[u->wst.ptr] = d; |
|
| 576 |
+ u->wst.dat[u->wst.ptr + 1] = c; |
|
| 577 |
+#ifndef NO_STACK_CHECKS |
|
| 578 |
+ if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 579 |
+ u->wst.error = 1; |
|
| 580 |
+ goto error; |
|
| 581 |
+ } |
|
| 582 |
+ if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 583 |
+ u->wst.error = 2; |
|
| 584 |
+ goto error; |
|
| 585 |
+ } |
|
| 586 |
+#endif |
|
| 587 |
+ u->wst.ptr += 2; |
|
| 588 |
+ } |
|
| 589 |
+ break; |
|
| 590 |
+ case 0x27: /* ROT2 */ |
|
| 591 |
+ __asm__( "evaluxn_27_ROT2:" ); |
|
| 592 |
+ {
|
|
| 593 |
+ 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]; |
|
| 594 |
+ u->wst.dat[u->wst.ptr - 6] = d; |
|
| 595 |
+ u->wst.dat[u->wst.ptr - 5] = c; |
|
| 596 |
+ u->wst.dat[u->wst.ptr - 4] = b; |
|
| 597 |
+ u->wst.dat[u->wst.ptr - 3] = a; |
|
| 598 |
+ u->wst.dat[u->wst.ptr - 2] = f; |
|
| 599 |
+ u->wst.dat[u->wst.ptr - 1] = e; |
|
| 600 |
+#ifndef NO_STACK_CHECKS |
|
| 601 |
+ if(__builtin_expect(u->wst.ptr < 6, 0)) {
|
|
| 602 |
+ u->wst.error = 1; |
|
| 603 |
+ goto error; |
|
| 604 |
+ } |
|
| 605 |
+#endif |
|
| 606 |
+ } |
|
| 607 |
+ break; |
|
| 608 |
+ case 0x28: /* EQU2 */ |
|
| 609 |
+ __asm__( "evaluxn_28_EQU2:" ); |
|
| 610 |
+ {
|
|
| 611 |
+ 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)); |
|
| 612 |
+ u->wst.dat[u->wst.ptr - 4] = b == a; |
|
| 613 |
+#ifndef NO_STACK_CHECKS |
|
| 614 |
+ if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 615 |
+ u->wst.error = 1; |
|
| 616 |
+ goto error; |
|
| 617 |
+ } |
|
| 618 |
+#endif |
|
| 619 |
+ u->wst.ptr -= 3; |
|
| 620 |
+ } |
|
| 621 |
+ break; |
|
| 622 |
+ case 0x29: /* NEQ2 */ |
|
| 623 |
+ __asm__( "evaluxn_29_NEQ2:" ); |
|
| 624 |
+ {
|
|
| 625 |
+ 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)); |
|
| 626 |
+ u->wst.dat[u->wst.ptr - 4] = b != a; |
|
| 627 |
+#ifndef NO_STACK_CHECKS |
|
| 628 |
+ if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 629 |
+ u->wst.error = 1; |
|
| 630 |
+ goto error; |
|
| 631 |
+ } |
|
| 632 |
+#endif |
|
| 633 |
+ u->wst.ptr -= 3; |
|
| 634 |
+ } |
|
| 635 |
+ break; |
|
| 636 |
+ case 0x2a: /* GTH2 */ |
|
| 637 |
+ __asm__( "evaluxn_2a_GTH2:" ); |
|
| 638 |
+ {
|
|
| 639 |
+ 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)); |
|
| 640 |
+ u->wst.dat[u->wst.ptr - 4] = b > a; |
|
| 641 |
+#ifndef NO_STACK_CHECKS |
|
| 642 |
+ if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 643 |
+ u->wst.error = 1; |
|
| 644 |
+ goto error; |
|
| 645 |
+ } |
|
| 646 |
+#endif |
|
| 647 |
+ u->wst.ptr -= 3; |
|
| 648 |
+ } |
|
| 649 |
+ break; |
|
| 650 |
+ case 0x2b: /* LTH2 */ |
|
| 651 |
+ __asm__( "evaluxn_2b_LTH2:" ); |
|
| 652 |
+ {
|
|
| 653 |
+ 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)); |
|
| 654 |
+ u->wst.dat[u->wst.ptr - 4] = b < a; |
|
| 655 |
+#ifndef NO_STACK_CHECKS |
|
| 656 |
+ if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 657 |
+ u->wst.error = 1; |
|
| 658 |
+ goto error; |
|
| 659 |
+ } |
|
| 660 |
+#endif |
|
| 661 |
+ u->wst.ptr -= 3; |
|
| 662 |
+ } |
|
| 663 |
+ break; |
|
| 664 |
+ case 0x2c: /* JMP2 */ |
|
| 665 |
+ __asm__( "evaluxn_2c_JMP2:" ); |
|
| 666 |
+ {
|
|
| 667 |
+ u->ram.ptr = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 668 |
+#ifndef NO_STACK_CHECKS |
|
| 669 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 670 |
+ u->wst.error = 1; |
|
| 671 |
+ goto error; |
|
| 672 |
+ } |
|
| 673 |
+#endif |
|
| 674 |
+ u->wst.ptr -= 2; |
|
| 675 |
+ } |
|
| 676 |
+ break; |
|
| 677 |
+ case 0x2d: /* JCN2 */ |
|
| 678 |
+ __asm__( "evaluxn_2d_JCN2:" ); |
|
| 679 |
+ {
|
|
| 680 |
+ Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 681 |
+ if(u->wst.dat[u->wst.ptr - 3]) u->ram.ptr = a; |
|
| 682 |
+#ifndef NO_STACK_CHECKS |
|
| 683 |
+ if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
| 684 |
+ u->wst.error = 1; |
|
| 685 |
+ goto error; |
|
| 686 |
+ } |
|
| 687 |
+#endif |
|
| 688 |
+ u->wst.ptr -= 3; |
|
| 689 |
+ } |
|
| 690 |
+ break; |
|
| 691 |
+ case 0x2e: /* JSR2 */ |
|
| 692 |
+ __asm__( "evaluxn_2e_JSR2:" ); |
|
| 693 |
+ {
|
|
| 694 |
+ u->rst.dat[u->rst.ptr] = u->ram.ptr >> 8; |
|
| 695 |
+ u->rst.dat[u->rst.ptr + 1] = u->ram.ptr & 0xff; |
|
| 696 |
+ u->ram.ptr = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 697 |
+#ifndef NO_STACK_CHECKS |
|
| 698 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 699 |
+ u->wst.error = 1; |
|
| 700 |
+ goto error; |
|
| 701 |
+ } |
|
| 702 |
+#endif |
|
| 703 |
+ u->wst.ptr -= 2; |
|
| 704 |
+#ifndef NO_STACK_CHECKS |
|
| 705 |
+ if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 706 |
+ u->rst.error = 2; |
|
| 707 |
+ goto error; |
|
| 708 |
+ } |
|
| 709 |
+#endif |
|
| 710 |
+ u->rst.ptr += 2; |
|
| 711 |
+ } |
|
| 712 |
+ break; |
|
| 713 |
+ case 0x2f: /* STH2 */ |
|
| 714 |
+ __asm__( "evaluxn_2f_STH2:" ); |
|
| 715 |
+ {
|
|
| 716 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 717 |
+ u->rst.dat[u->rst.ptr] = b; |
|
| 718 |
+ u->rst.dat[u->rst.ptr + 1] = a; |
|
| 719 |
+#ifndef NO_STACK_CHECKS |
|
| 720 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 721 |
+ u->wst.error = 1; |
|
| 722 |
+ goto error; |
|
| 723 |
+ } |
|
| 724 |
+#endif |
|
| 725 |
+ u->wst.ptr -= 2; |
|
| 726 |
+#ifndef NO_STACK_CHECKS |
|
| 727 |
+ if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 728 |
+ u->rst.error = 2; |
|
| 729 |
+ goto error; |
|
| 730 |
+ } |
|
| 731 |
+#endif |
|
| 732 |
+ u->rst.ptr += 2; |
|
| 733 |
+ } |
|
| 734 |
+ break; |
|
| 735 |
+ case 0x30: /* LDZ2 */ |
|
| 736 |
+ __asm__( "evaluxn_30_LDZ2:" ); |
|
| 737 |
+ {
|
|
| 738 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 739 |
+ u->wst.dat[u->wst.ptr - 1] = mempeek8(u->ram.dat, a); |
|
| 740 |
+ u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, a + 1); |
|
| 741 |
+#ifndef NO_STACK_CHECKS |
|
| 742 |
+ if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 743 |
+ u->wst.error = 1; |
|
| 744 |
+ goto error; |
|
| 745 |
+ } |
|
| 746 |
+ if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 747 |
+ u->wst.error = 2; |
|
| 748 |
+ goto error; |
|
| 749 |
+ } |
|
| 750 |
+#endif |
|
| 751 |
+ u->wst.ptr += 1; |
|
| 752 |
+ } |
|
| 753 |
+ break; |
|
| 754 |
+ case 0x31: /* STZ2 */ |
|
| 755 |
+ __asm__( "evaluxn_31_STZ2:" ); |
|
| 756 |
+ {
|
|
| 757 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 758 |
+ Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); |
|
| 759 |
+ mempoke16(u->ram.dat, a, b); |
|
| 760 |
+#ifndef NO_STACK_CHECKS |
|
| 761 |
+ if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
| 762 |
+ u->wst.error = 1; |
|
| 763 |
+ goto error; |
|
| 764 |
+ } |
|
| 765 |
+#endif |
|
| 766 |
+ u->wst.ptr -= 3; |
|
| 767 |
+ } |
|
| 768 |
+ break; |
|
| 769 |
+ case 0x32: /* LDR2 */ |
|
| 770 |
+ __asm__( "evaluxn_32_LDR2:" ); |
|
| 771 |
+ {
|
|
| 772 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 773 |
+ u->wst.dat[u->wst.ptr - 1] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a); |
|
| 774 |
+ u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a + 1); |
|
| 775 |
+#ifndef NO_STACK_CHECKS |
|
| 776 |
+ if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 777 |
+ u->wst.error = 1; |
|
| 778 |
+ goto error; |
|
| 779 |
+ } |
|
| 780 |
+ if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 781 |
+ u->wst.error = 2; |
|
| 782 |
+ goto error; |
|
| 783 |
+ } |
|
| 784 |
+#endif |
|
| 785 |
+ u->wst.ptr += 1; |
|
| 786 |
+ } |
|
| 787 |
+ break; |
|
| 788 |
+ case 0x33: /* STR2 */ |
|
| 789 |
+ __asm__( "evaluxn_33_STR2:" ); |
|
| 790 |
+ {
|
|
| 791 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 792 |
+ Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); |
|
| 793 |
+ mempoke16(u->ram.dat, u->ram.ptr + (Sint8)a, b); |
|
| 794 |
+#ifndef NO_STACK_CHECKS |
|
| 795 |
+ if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
| 796 |
+ u->wst.error = 1; |
|
| 797 |
+ goto error; |
|
| 798 |
+ } |
|
| 799 |
+#endif |
|
| 800 |
+ u->wst.ptr -= 3; |
|
| 801 |
+ } |
|
| 802 |
+ break; |
|
| 803 |
+ case 0x34: /* LDA2 */ |
|
| 804 |
+ __asm__( "evaluxn_34_LDA2:" ); |
|
| 805 |
+ {
|
|
| 806 |
+ Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 807 |
+ u->wst.dat[u->wst.ptr - 2] = mempeek8(u->ram.dat, a); |
|
| 808 |
+ u->wst.dat[u->wst.ptr - 1] = mempeek8(u->ram.dat, a + 1); |
|
| 809 |
+#ifndef NO_STACK_CHECKS |
|
| 810 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 811 |
+ u->wst.error = 1; |
|
| 812 |
+ goto error; |
|
| 813 |
+ } |
|
| 814 |
+#endif |
|
| 815 |
+ } |
|
| 816 |
+ break; |
|
| 817 |
+ case 0x35: /* STA2 */ |
|
| 818 |
+ __asm__( "evaluxn_35_STA2:" ); |
|
| 819 |
+ {
|
|
| 820 |
+ Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 821 |
+ Uint16 b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
|
| 822 |
+ mempoke16(u->ram.dat, a, b); |
|
| 823 |
+#ifndef NO_STACK_CHECKS |
|
| 824 |
+ if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 825 |
+ u->wst.error = 1; |
|
| 826 |
+ goto error; |
|
| 827 |
+ } |
|
| 828 |
+#endif |
|
| 829 |
+ u->wst.ptr -= 4; |
|
| 830 |
+ } |
|
| 831 |
+ break; |
|
| 832 |
+ case 0x36: /* DEI2 */ |
|
| 833 |
+ __asm__( "evaluxn_36_DEI2:" ); |
|
| 834 |
+ {
|
|
| 835 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 836 |
+ u->wst.dat[u->wst.ptr - 1] = devpeek8(&u->dev[a >> 4], a); |
|
| 837 |
+ u->wst.dat[u->wst.ptr] = devpeek8(&u->dev[a >> 4], a + 1); |
|
| 838 |
+#ifndef NO_STACK_CHECKS |
|
| 839 |
+ if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 840 |
+ u->wst.error = 1; |
|
| 841 |
+ goto error; |
|
| 842 |
+ } |
|
| 843 |
+ if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 844 |
+ u->wst.error = 2; |
|
| 845 |
+ goto error; |
|
| 846 |
+ } |
|
| 847 |
+#endif |
|
| 848 |
+ u->wst.ptr += 1; |
|
| 849 |
+ } |
|
| 850 |
+ break; |
|
| 851 |
+ case 0x37: /* DEO2 */ |
|
| 852 |
+ __asm__( "evaluxn_37_DEO2:" ); |
|
| 853 |
+ {
|
|
| 854 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 855 |
+ Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); |
|
| 856 |
+ devpoke16(&u->dev[a >> 4], a, b); |
|
| 857 |
+#ifndef NO_STACK_CHECKS |
|
| 858 |
+ if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
| 859 |
+ u->wst.error = 1; |
|
| 860 |
+ goto error; |
|
| 861 |
+ } |
|
| 862 |
+#endif |
|
| 863 |
+ u->wst.ptr -= 3; |
|
| 864 |
+ } |
|
| 865 |
+ break; |
|
| 866 |
+ case 0x38: /* ADD2 */ |
|
| 867 |
+ __asm__( "evaluxn_38_ADD2:" ); |
|
| 868 |
+ {
|
|
| 869 |
+ 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)); |
|
| 870 |
+ u->wst.dat[u->wst.ptr - 4] = (b + a) >> 8; |
|
| 871 |
+ u->wst.dat[u->wst.ptr - 3] = (b + a) & 0xff; |
|
| 872 |
+#ifndef NO_STACK_CHECKS |
|
| 873 |
+ if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 874 |
+ u->wst.error = 1; |
|
| 875 |
+ goto error; |
|
| 876 |
+ } |
|
| 877 |
+#endif |
|
| 878 |
+ u->wst.ptr -= 2; |
|
| 879 |
+ } |
|
| 880 |
+ break; |
|
| 881 |
+ case 0x39: /* SUB2 */ |
|
| 882 |
+ __asm__( "evaluxn_39_SUB2:" ); |
|
| 883 |
+ {
|
|
| 884 |
+ 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)); |
|
| 885 |
+ u->wst.dat[u->wst.ptr - 4] = (b - a) >> 8; |
|
| 886 |
+ u->wst.dat[u->wst.ptr - 3] = (b - a) & 0xff; |
|
| 887 |
+#ifndef NO_STACK_CHECKS |
|
| 888 |
+ if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 889 |
+ u->wst.error = 1; |
|
| 890 |
+ goto error; |
|
| 891 |
+ } |
|
| 892 |
+#endif |
|
| 893 |
+ u->wst.ptr -= 2; |
|
| 894 |
+ } |
|
| 895 |
+ break; |
|
| 896 |
+ case 0x3a: /* MUL2 */ |
|
| 897 |
+ __asm__( "evaluxn_3a_MUL2:" ); |
|
| 898 |
+ {
|
|
| 899 |
+ 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)); |
|
| 900 |
+ u->wst.dat[u->wst.ptr - 4] = (b * a) >> 8; |
|
| 901 |
+ u->wst.dat[u->wst.ptr - 3] = (b * a) & 0xff; |
|
| 902 |
+#ifndef NO_STACK_CHECKS |
|
| 903 |
+ if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 904 |
+ u->wst.error = 1; |
|
| 905 |
+ goto error; |
|
| 906 |
+ } |
|
| 907 |
+#endif |
|
| 908 |
+ u->wst.ptr -= 2; |
|
| 909 |
+ } |
|
| 910 |
+ break; |
|
| 911 |
+ case 0x3b: /* DIV2 */ |
|
| 912 |
+ __asm__( "evaluxn_3b_DIV2:" ); |
|
| 913 |
+ {
|
|
| 914 |
+ 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)); |
|
| 915 |
+ u->wst.dat[u->wst.ptr - 4] = (b / a) >> 8; |
|
| 916 |
+ u->wst.dat[u->wst.ptr - 3] = (b / a) & 0xff; |
|
| 917 |
+#ifndef NO_STACK_CHECKS |
|
| 918 |
+ if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 919 |
+ u->wst.error = 1; |
|
| 920 |
+ goto error; |
|
| 921 |
+ } |
|
| 922 |
+#endif |
|
| 923 |
+ u->wst.ptr -= 2; |
|
| 924 |
+ } |
|
| 925 |
+ break; |
|
| 926 |
+ case 0x3c: /* AND2 */ |
|
| 927 |
+ __asm__( "evaluxn_3c_AND2:" ); |
|
| 928 |
+ {
|
|
| 929 |
+ 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]; |
|
| 930 |
+ u->wst.dat[u->wst.ptr - 4] = d & b; |
|
| 931 |
+ u->wst.dat[u->wst.ptr - 3] = c & a; |
|
| 932 |
+#ifndef NO_STACK_CHECKS |
|
| 933 |
+ if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 934 |
+ u->wst.error = 1; |
|
| 935 |
+ goto error; |
|
| 936 |
+ } |
|
| 937 |
+#endif |
|
| 938 |
+ u->wst.ptr -= 2; |
|
| 939 |
+ } |
|
| 940 |
+ break; |
|
| 941 |
+ case 0x3d: /* ORA2 */ |
|
| 942 |
+ __asm__( "evaluxn_3d_ORA2:" ); |
|
| 943 |
+ {
|
|
| 944 |
+ 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]; |
|
| 945 |
+ u->wst.dat[u->wst.ptr - 4] = d | b; |
|
| 946 |
+ u->wst.dat[u->wst.ptr - 3] = c | a; |
|
| 947 |
+#ifndef NO_STACK_CHECKS |
|
| 948 |
+ if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 949 |
+ u->wst.error = 1; |
|
| 950 |
+ goto error; |
|
| 951 |
+ } |
|
| 952 |
+#endif |
|
| 953 |
+ u->wst.ptr -= 2; |
|
| 954 |
+ } |
|
| 955 |
+ break; |
|
| 956 |
+ case 0x3e: /* EOR2 */ |
|
| 957 |
+ __asm__( "evaluxn_3e_EOR2:" ); |
|
| 958 |
+ {
|
|
| 959 |
+ 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]; |
|
| 960 |
+ u->wst.dat[u->wst.ptr - 4] = d ^ b; |
|
| 961 |
+ u->wst.dat[u->wst.ptr - 3] = c ^ a; |
|
| 962 |
+#ifndef NO_STACK_CHECKS |
|
| 963 |
+ if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 964 |
+ u->wst.error = 1; |
|
| 965 |
+ goto error; |
|
| 966 |
+ } |
|
| 967 |
+#endif |
|
| 968 |
+ u->wst.ptr -= 2; |
|
| 969 |
+ } |
|
| 970 |
+ break; |
|
| 971 |
+ case 0x3f: /* SFT2 */ |
|
| 972 |
+ __asm__( "evaluxn_3f_SFT2:" ); |
|
| 973 |
+ {
|
|
| 974 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 975 |
+ Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); |
|
| 976 |
+ u->wst.dat[u->wst.ptr - 3] = (b >> (a & 0x0f) << ((a & 0xf0) >> 4)) >> 8; |
|
| 977 |
+ u->wst.dat[u->wst.ptr - 2] = (b >> (a & 0x0f) << ((a & 0xf0) >> 4)) & 0xff; |
|
| 978 |
+#ifndef NO_STACK_CHECKS |
|
| 979 |
+ if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
| 980 |
+ u->wst.error = 1; |
|
| 981 |
+ goto error; |
|
| 982 |
+ } |
|
| 983 |
+#endif |
|
| 984 |
+ u->wst.ptr -= 1; |
|
| 985 |
+ } |
|
| 986 |
+ break; |
|
| 987 |
+ case 0x41: /* LITr */ |
|
| 988 |
+ case 0xc1: /* LITkr */ |
|
| 989 |
+ __asm__( "evaluxn_41_LITr:" ); |
|
| 990 |
+ {
|
|
| 991 |
+ u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, u->ram.ptr++); |
|
| 992 |
+#ifndef NO_STACK_CHECKS |
|
| 993 |
+ if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 994 |
+ u->rst.error = 2; |
|
| 995 |
+ goto error; |
|
| 996 |
+ } |
|
| 997 |
+#endif |
|
| 998 |
+ u->rst.ptr += 1; |
|
| 999 |
+ } |
|
| 1000 |
+ break; |
|
| 1001 |
+ case 0x43: /* POPr */ |
|
| 1002 |
+ __asm__( "evaluxn_43_POPr:" ); |
|
| 1003 |
+ {
|
|
| 1004 |
+ u->rst.dat[u->rst.ptr - 1]; |
|
| 1005 |
+#ifndef NO_STACK_CHECKS |
|
| 1006 |
+ if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 1007 |
+ u->rst.error = 1; |
|
| 1008 |
+ goto error; |
|
| 1009 |
+ } |
|
| 1010 |
+#endif |
|
| 1011 |
+ u->rst.ptr -= 1; |
|
| 1012 |
+ } |
|
| 1013 |
+ break; |
|
| 1014 |
+ case 0x44: /* DUPr */ |
|
| 1015 |
+ __asm__( "evaluxn_44_DUPr:" ); |
|
| 1016 |
+ {
|
|
| 1017 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1018 |
+ u->rst.dat[u->rst.ptr] = a; |
|
| 1019 |
+#ifndef NO_STACK_CHECKS |
|
| 1020 |
+ if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 1021 |
+ u->rst.error = 1; |
|
| 1022 |
+ goto error; |
|
| 1023 |
+ } |
|
| 1024 |
+ if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 1025 |
+ u->rst.error = 2; |
|
| 1026 |
+ goto error; |
|
| 1027 |
+ } |
|
| 1028 |
+#endif |
|
| 1029 |
+ u->rst.ptr += 1; |
|
| 1030 |
+ } |
|
| 1031 |
+ break; |
|
| 1032 |
+ case 0x45: /* SWPr */ |
|
| 1033 |
+ __asm__( "evaluxn_45_SWPr:" ); |
|
| 1034 |
+ {
|
|
| 1035 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1036 |
+ u->rst.dat[u->rst.ptr - 2] = a; |
|
| 1037 |
+ u->rst.dat[u->rst.ptr - 1] = b; |
|
| 1038 |
+#ifndef NO_STACK_CHECKS |
|
| 1039 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1040 |
+ u->rst.error = 1; |
|
| 1041 |
+ goto error; |
|
| 1042 |
+ } |
|
| 1043 |
+#endif |
|
| 1044 |
+ } |
|
| 1045 |
+ break; |
|
| 1046 |
+ case 0x46: /* OVRr */ |
|
| 1047 |
+ __asm__( "evaluxn_46_OVRr:" ); |
|
| 1048 |
+ {
|
|
| 1049 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1050 |
+ u->rst.dat[u->rst.ptr] = b; |
|
| 1051 |
+#ifndef NO_STACK_CHECKS |
|
| 1052 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1053 |
+ u->rst.error = 1; |
|
| 1054 |
+ goto error; |
|
| 1055 |
+ } |
|
| 1056 |
+ if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 1057 |
+ u->rst.error = 2; |
|
| 1058 |
+ goto error; |
|
| 1059 |
+ } |
|
| 1060 |
+#endif |
|
| 1061 |
+ u->rst.ptr += 1; |
|
| 1062 |
+ } |
|
| 1063 |
+ break; |
|
| 1064 |
+ case 0x47: /* ROTr */ |
|
| 1065 |
+ __asm__( "evaluxn_47_ROTr:" ); |
|
| 1066 |
+ {
|
|
| 1067 |
+ 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]; |
|
| 1068 |
+ u->rst.dat[u->rst.ptr - 3] = b; |
|
| 1069 |
+ u->rst.dat[u->rst.ptr - 2] = a; |
|
| 1070 |
+ u->rst.dat[u->rst.ptr - 1] = c; |
|
| 1071 |
+#ifndef NO_STACK_CHECKS |
|
| 1072 |
+ if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
| 1073 |
+ u->rst.error = 1; |
|
| 1074 |
+ goto error; |
|
| 1075 |
+ } |
|
| 1076 |
+#endif |
|
| 1077 |
+ } |
|
| 1078 |
+ break; |
|
| 1079 |
+ case 0x48: /* EQUr */ |
|
| 1080 |
+ __asm__( "evaluxn_48_EQUr:" ); |
|
| 1081 |
+ {
|
|
| 1082 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1083 |
+ u->rst.dat[u->rst.ptr - 2] = b == a; |
|
| 1084 |
+#ifndef NO_STACK_CHECKS |
|
| 1085 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1086 |
+ u->rst.error = 1; |
|
| 1087 |
+ goto error; |
|
| 1088 |
+ } |
|
| 1089 |
+#endif |
|
| 1090 |
+ u->rst.ptr -= 1; |
|
| 1091 |
+ } |
|
| 1092 |
+ break; |
|
| 1093 |
+ case 0x49: /* NEQr */ |
|
| 1094 |
+ __asm__( "evaluxn_49_NEQr:" ); |
|
| 1095 |
+ {
|
|
| 1096 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1097 |
+ u->rst.dat[u->rst.ptr - 2] = b != a; |
|
| 1098 |
+#ifndef NO_STACK_CHECKS |
|
| 1099 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1100 |
+ u->rst.error = 1; |
|
| 1101 |
+ goto error; |
|
| 1102 |
+ } |
|
| 1103 |
+#endif |
|
| 1104 |
+ u->rst.ptr -= 1; |
|
| 1105 |
+ } |
|
| 1106 |
+ break; |
|
| 1107 |
+ case 0x4a: /* GTHr */ |
|
| 1108 |
+ __asm__( "evaluxn_4a_GTHr:" ); |
|
| 1109 |
+ {
|
|
| 1110 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1111 |
+ u->rst.dat[u->rst.ptr - 2] = b > a; |
|
| 1112 |
+#ifndef NO_STACK_CHECKS |
|
| 1113 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1114 |
+ u->rst.error = 1; |
|
| 1115 |
+ goto error; |
|
| 1116 |
+ } |
|
| 1117 |
+#endif |
|
| 1118 |
+ u->rst.ptr -= 1; |
|
| 1119 |
+ } |
|
| 1120 |
+ break; |
|
| 1121 |
+ case 0x4b: /* LTHr */ |
|
| 1122 |
+ __asm__( "evaluxn_4b_LTHr:" ); |
|
| 1123 |
+ {
|
|
| 1124 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1125 |
+ u->rst.dat[u->rst.ptr - 2] = b < a; |
|
| 1126 |
+#ifndef NO_STACK_CHECKS |
|
| 1127 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1128 |
+ u->rst.error = 1; |
|
| 1129 |
+ goto error; |
|
| 1130 |
+ } |
|
| 1131 |
+#endif |
|
| 1132 |
+ u->rst.ptr -= 1; |
|
| 1133 |
+ } |
|
| 1134 |
+ break; |
|
| 1135 |
+ case 0x4c: /* JMPr */ |
|
| 1136 |
+ __asm__( "evaluxn_4c_JMPr:" ); |
|
| 1137 |
+ {
|
|
| 1138 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1139 |
+ u->ram.ptr += (Sint8)a; |
|
| 1140 |
+#ifndef NO_STACK_CHECKS |
|
| 1141 |
+ if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 1142 |
+ u->rst.error = 1; |
|
| 1143 |
+ goto error; |
|
| 1144 |
+ } |
|
| 1145 |
+#endif |
|
| 1146 |
+ u->rst.ptr -= 1; |
|
| 1147 |
+ } |
|
| 1148 |
+ break; |
|
| 1149 |
+ case 0x4d: /* JCNr */ |
|
| 1150 |
+ __asm__( "evaluxn_4d_JCNr:" ); |
|
| 1151 |
+ {
|
|
| 1152 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1153 |
+ if(u->rst.dat[u->rst.ptr - 2]) u->ram.ptr += (Sint8)a; |
|
| 1154 |
+#ifndef NO_STACK_CHECKS |
|
| 1155 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1156 |
+ u->rst.error = 1; |
|
| 1157 |
+ goto error; |
|
| 1158 |
+ } |
|
| 1159 |
+#endif |
|
| 1160 |
+ u->rst.ptr -= 2; |
|
| 1161 |
+ } |
|
| 1162 |
+ break; |
|
| 1163 |
+ case 0x4e: /* JSRr */ |
|
| 1164 |
+ __asm__( "evaluxn_4e_JSRr:" ); |
|
| 1165 |
+ {
|
|
| 1166 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1167 |
+ u->wst.dat[u->wst.ptr] = u->ram.ptr >> 8; |
|
| 1168 |
+ u->wst.dat[u->wst.ptr + 1] = u->ram.ptr & 0xff; |
|
| 1169 |
+ u->ram.ptr += (Sint8)a; |
|
| 1170 |
+#ifndef NO_STACK_CHECKS |
|
| 1171 |
+ if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 1172 |
+ u->rst.error = 1; |
|
| 1173 |
+ goto error; |
|
| 1174 |
+ } |
|
| 1175 |
+#endif |
|
| 1176 |
+ u->rst.ptr -= 1; |
|
| 1177 |
+#ifndef NO_STACK_CHECKS |
|
| 1178 |
+ if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 1179 |
+ u->wst.error = 2; |
|
| 1180 |
+ goto error; |
|
| 1181 |
+ } |
|
| 1182 |
+#endif |
|
| 1183 |
+ u->wst.ptr += 2; |
|
| 1184 |
+ } |
|
| 1185 |
+ break; |
|
| 1186 |
+ case 0x4f: /* STHr */ |
|
| 1187 |
+ __asm__( "evaluxn_4f_STHr:" ); |
|
| 1188 |
+ {
|
|
| 1189 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1190 |
+ u->wst.dat[u->wst.ptr] = a; |
|
| 1191 |
+#ifndef NO_STACK_CHECKS |
|
| 1192 |
+ if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 1193 |
+ u->rst.error = 1; |
|
| 1194 |
+ goto error; |
|
| 1195 |
+ } |
|
| 1196 |
+#endif |
|
| 1197 |
+ u->rst.ptr -= 1; |
|
| 1198 |
+#ifndef NO_STACK_CHECKS |
|
| 1199 |
+ if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 1200 |
+ u->wst.error = 2; |
|
| 1201 |
+ goto error; |
|
| 1202 |
+ } |
|
| 1203 |
+#endif |
|
| 1204 |
+ u->wst.ptr += 1; |
|
| 1205 |
+ } |
|
| 1206 |
+ break; |
|
| 1207 |
+ case 0x50: /* LDZr */ |
|
| 1208 |
+ __asm__( "evaluxn_50_LDZr:" ); |
|
| 1209 |
+ {
|
|
| 1210 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1211 |
+ u->rst.dat[u->rst.ptr - 1] = mempeek8(u->ram.dat, a); |
|
| 1212 |
+#ifndef NO_STACK_CHECKS |
|
| 1213 |
+ if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 1214 |
+ u->rst.error = 1; |
|
| 1215 |
+ goto error; |
|
| 1216 |
+ } |
|
| 1217 |
+#endif |
|
| 1218 |
+ } |
|
| 1219 |
+ break; |
|
| 1220 |
+ case 0x51: /* STZr */ |
|
| 1221 |
+ __asm__( "evaluxn_51_STZr:" ); |
|
| 1222 |
+ {
|
|
| 1223 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1224 |
+ Uint8 b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1225 |
+ mempoke8(u->ram.dat, a, b); |
|
| 1226 |
+#ifndef NO_STACK_CHECKS |
|
| 1227 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1228 |
+ u->rst.error = 1; |
|
| 1229 |
+ goto error; |
|
| 1230 |
+ } |
|
| 1231 |
+#endif |
|
| 1232 |
+ u->rst.ptr -= 2; |
|
| 1233 |
+ } |
|
| 1234 |
+ break; |
|
| 1235 |
+ case 0x52: /* LDRr */ |
|
| 1236 |
+ __asm__( "evaluxn_52_LDRr:" ); |
|
| 1237 |
+ {
|
|
| 1238 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1239 |
+ u->rst.dat[u->rst.ptr - 1] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a); |
|
| 1240 |
+#ifndef NO_STACK_CHECKS |
|
| 1241 |
+ if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 1242 |
+ u->rst.error = 1; |
|
| 1243 |
+ goto error; |
|
| 1244 |
+ } |
|
| 1245 |
+#endif |
|
| 1246 |
+ } |
|
| 1247 |
+ break; |
|
| 1248 |
+ case 0x53: /* STRr */ |
|
| 1249 |
+ __asm__( "evaluxn_53_STRr:" ); |
|
| 1250 |
+ {
|
|
| 1251 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1252 |
+ Uint8 b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1253 |
+ mempoke8(u->ram.dat, u->ram.ptr + (Sint8)a, b); |
|
| 1254 |
+#ifndef NO_STACK_CHECKS |
|
| 1255 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1256 |
+ u->rst.error = 1; |
|
| 1257 |
+ goto error; |
|
| 1258 |
+ } |
|
| 1259 |
+#endif |
|
| 1260 |
+ u->rst.ptr -= 2; |
|
| 1261 |
+ } |
|
| 1262 |
+ break; |
|
| 1263 |
+ case 0x54: /* LDAr */ |
|
| 1264 |
+ __asm__( "evaluxn_54_LDAr:" ); |
|
| 1265 |
+ {
|
|
| 1266 |
+ Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 1267 |
+ u->rst.dat[u->rst.ptr - 2] = mempeek8(u->ram.dat, a); |
|
| 1268 |
+#ifndef NO_STACK_CHECKS |
|
| 1269 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1270 |
+ u->rst.error = 1; |
|
| 1271 |
+ goto error; |
|
| 1272 |
+ } |
|
| 1273 |
+#endif |
|
| 1274 |
+ u->rst.ptr -= 1; |
|
| 1275 |
+ } |
|
| 1276 |
+ break; |
|
| 1277 |
+ case 0x55: /* STAr */ |
|
| 1278 |
+ __asm__( "evaluxn_55_STAr:" ); |
|
| 1279 |
+ {
|
|
| 1280 |
+ Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 1281 |
+ Uint8 b = u->rst.dat[u->rst.ptr - 3]; |
|
| 1282 |
+ mempoke8(u->ram.dat, a, b); |
|
| 1283 |
+#ifndef NO_STACK_CHECKS |
|
| 1284 |
+ if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
| 1285 |
+ u->rst.error = 1; |
|
| 1286 |
+ goto error; |
|
| 1287 |
+ } |
|
| 1288 |
+#endif |
|
| 1289 |
+ u->rst.ptr -= 3; |
|
| 1290 |
+ } |
|
| 1291 |
+ break; |
|
| 1292 |
+ case 0x56: /* DEIr */ |
|
| 1293 |
+ __asm__( "evaluxn_56_DEIr:" ); |
|
| 1294 |
+ {
|
|
| 1295 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1296 |
+ u->rst.dat[u->rst.ptr - 1] = devpeek8(&u->dev[a >> 4], a); |
|
| 1297 |
+#ifndef NO_STACK_CHECKS |
|
| 1298 |
+ if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 1299 |
+ u->rst.error = 1; |
|
| 1300 |
+ goto error; |
|
| 1301 |
+ } |
|
| 1302 |
+#endif |
|
| 1303 |
+ } |
|
| 1304 |
+ break; |
|
| 1305 |
+ case 0x57: /* DEOr */ |
|
| 1306 |
+ __asm__( "evaluxn_57_DEOr:" ); |
|
| 1307 |
+ {
|
|
| 1308 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1309 |
+ devpoke8(&u->dev[a >> 4], a, b); |
|
| 1310 |
+#ifndef NO_STACK_CHECKS |
|
| 1311 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1312 |
+ u->rst.error = 1; |
|
| 1313 |
+ goto error; |
|
| 1314 |
+ } |
|
| 1315 |
+#endif |
|
| 1316 |
+ u->rst.ptr -= 2; |
|
| 1317 |
+ } |
|
| 1318 |
+ break; |
|
| 1319 |
+ case 0x58: /* ADDr */ |
|
| 1320 |
+ __asm__( "evaluxn_58_ADDr:" ); |
|
| 1321 |
+ {
|
|
| 1322 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1323 |
+ u->rst.dat[u->rst.ptr - 2] = b + a; |
|
| 1324 |
+#ifndef NO_STACK_CHECKS |
|
| 1325 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1326 |
+ u->rst.error = 1; |
|
| 1327 |
+ goto error; |
|
| 1328 |
+ } |
|
| 1329 |
+#endif |
|
| 1330 |
+ u->rst.ptr -= 1; |
|
| 1331 |
+ } |
|
| 1332 |
+ break; |
|
| 1333 |
+ case 0x59: /* SUBr */ |
|
| 1334 |
+ __asm__( "evaluxn_59_SUBr:" ); |
|
| 1335 |
+ {
|
|
| 1336 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1337 |
+ u->rst.dat[u->rst.ptr - 2] = b - a; |
|
| 1338 |
+#ifndef NO_STACK_CHECKS |
|
| 1339 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1340 |
+ u->rst.error = 1; |
|
| 1341 |
+ goto error; |
|
| 1342 |
+ } |
|
| 1343 |
+#endif |
|
| 1344 |
+ u->rst.ptr -= 1; |
|
| 1345 |
+ } |
|
| 1346 |
+ break; |
|
| 1347 |
+ case 0x5a: /* MULr */ |
|
| 1348 |
+ __asm__( "evaluxn_5a_MULr:" ); |
|
| 1349 |
+ {
|
|
| 1350 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1351 |
+ u->rst.dat[u->rst.ptr - 2] = b * a; |
|
| 1352 |
+#ifndef NO_STACK_CHECKS |
|
| 1353 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1354 |
+ u->rst.error = 1; |
|
| 1355 |
+ goto error; |
|
| 1356 |
+ } |
|
| 1357 |
+#endif |
|
| 1358 |
+ u->rst.ptr -= 1; |
|
| 1359 |
+ } |
|
| 1360 |
+ break; |
|
| 1361 |
+ case 0x5b: /* DIVr */ |
|
| 1362 |
+ __asm__( "evaluxn_5b_DIVr:" ); |
|
| 1363 |
+ {
|
|
| 1364 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1365 |
+ u->rst.dat[u->rst.ptr - 2] = b / a; |
|
| 1366 |
+#ifndef NO_STACK_CHECKS |
|
| 1367 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1368 |
+ u->rst.error = 1; |
|
| 1369 |
+ goto error; |
|
| 1370 |
+ } |
|
| 1371 |
+#endif |
|
| 1372 |
+ u->rst.ptr -= 1; |
|
| 1373 |
+ } |
|
| 1374 |
+ break; |
|
| 1375 |
+ case 0x5c: /* ANDr */ |
|
| 1376 |
+ __asm__( "evaluxn_5c_ANDr:" ); |
|
| 1377 |
+ {
|
|
| 1378 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1379 |
+ u->rst.dat[u->rst.ptr - 2] = b & a; |
|
| 1380 |
+#ifndef NO_STACK_CHECKS |
|
| 1381 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1382 |
+ u->rst.error = 1; |
|
| 1383 |
+ goto error; |
|
| 1384 |
+ } |
|
| 1385 |
+#endif |
|
| 1386 |
+ u->rst.ptr -= 1; |
|
| 1387 |
+ } |
|
| 1388 |
+ break; |
|
| 1389 |
+ case 0x5d: /* ORAr */ |
|
| 1390 |
+ __asm__( "evaluxn_5d_ORAr:" ); |
|
| 1391 |
+ {
|
|
| 1392 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1393 |
+ u->rst.dat[u->rst.ptr - 2] = b | a; |
|
| 1394 |
+#ifndef NO_STACK_CHECKS |
|
| 1395 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1396 |
+ u->rst.error = 1; |
|
| 1397 |
+ goto error; |
|
| 1398 |
+ } |
|
| 1399 |
+#endif |
|
| 1400 |
+ u->rst.ptr -= 1; |
|
| 1401 |
+ } |
|
| 1402 |
+ break; |
|
| 1403 |
+ case 0x5e: /* EORr */ |
|
| 1404 |
+ __asm__( "evaluxn_5e_EORr:" ); |
|
| 1405 |
+ {
|
|
| 1406 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1407 |
+ u->rst.dat[u->rst.ptr - 2] = b ^ a; |
|
| 1408 |
+#ifndef NO_STACK_CHECKS |
|
| 1409 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1410 |
+ u->rst.error = 1; |
|
| 1411 |
+ goto error; |
|
| 1412 |
+ } |
|
| 1413 |
+#endif |
|
| 1414 |
+ u->rst.ptr -= 1; |
|
| 1415 |
+ } |
|
| 1416 |
+ break; |
|
| 1417 |
+ case 0x5f: /* SFTr */ |
|
| 1418 |
+ __asm__( "evaluxn_5f_SFTr:" ); |
|
| 1419 |
+ {
|
|
| 1420 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1421 |
+ u->rst.dat[u->rst.ptr - 2] = b >> (a & 0x07) << ((a & 0x70) >> 4); |
|
| 1422 |
+#ifndef NO_STACK_CHECKS |
|
| 1423 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1424 |
+ u->rst.error = 1; |
|
| 1425 |
+ goto error; |
|
| 1426 |
+ } |
|
| 1427 |
+#endif |
|
| 1428 |
+ u->rst.ptr -= 1; |
|
| 1429 |
+ } |
|
| 1430 |
+ break; |
|
| 1431 |
+ case 0x61: /* LIT2r */ |
|
| 1432 |
+ case 0xe1: /* LIT2kr */ |
|
| 1433 |
+ __asm__( "evaluxn_61_LIT2r:" ); |
|
| 1434 |
+ {
|
|
| 1435 |
+ u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, u->ram.ptr++); |
|
| 1436 |
+ u->rst.dat[u->rst.ptr + 1] = mempeek8(u->ram.dat, u->ram.ptr++); |
|
| 1437 |
+#ifndef NO_STACK_CHECKS |
|
| 1438 |
+ if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 1439 |
+ u->rst.error = 2; |
|
| 1440 |
+ goto error; |
|
| 1441 |
+ } |
|
| 1442 |
+#endif |
|
| 1443 |
+ u->rst.ptr += 2; |
|
| 1444 |
+ } |
|
| 1445 |
+ break; |
|
| 1446 |
+ case 0x63: /* POP2r */ |
|
| 1447 |
+ __asm__( "evaluxn_63_POP2r:" ); |
|
| 1448 |
+ {
|
|
| 1449 |
+ (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 1450 |
+#ifndef NO_STACK_CHECKS |
|
| 1451 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1452 |
+ u->rst.error = 1; |
|
| 1453 |
+ goto error; |
|
| 1454 |
+ } |
|
| 1455 |
+#endif |
|
| 1456 |
+ u->rst.ptr -= 2; |
|
| 1457 |
+ } |
|
| 1458 |
+ break; |
|
| 1459 |
+ case 0x64: /* DUP2r */ |
|
| 1460 |
+ __asm__( "evaluxn_64_DUP2r:" ); |
|
| 1461 |
+ {
|
|
| 1462 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1463 |
+ u->rst.dat[u->rst.ptr] = b; |
|
| 1464 |
+ u->rst.dat[u->rst.ptr + 1] = a; |
|
| 1465 |
+#ifndef NO_STACK_CHECKS |
|
| 1466 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1467 |
+ u->rst.error = 1; |
|
| 1468 |
+ goto error; |
|
| 1469 |
+ } |
|
| 1470 |
+ if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 1471 |
+ u->rst.error = 2; |
|
| 1472 |
+ goto error; |
|
| 1473 |
+ } |
|
| 1474 |
+#endif |
|
| 1475 |
+ u->rst.ptr += 2; |
|
| 1476 |
+ } |
|
| 1477 |
+ break; |
|
| 1478 |
+ case 0x65: /* SWP2r */ |
|
| 1479 |
+ __asm__( "evaluxn_65_SWP2r:" ); |
|
| 1480 |
+ {
|
|
| 1481 |
+ 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]; |
|
| 1482 |
+ u->rst.dat[u->rst.ptr - 4] = b; |
|
| 1483 |
+ u->rst.dat[u->rst.ptr - 3] = a; |
|
| 1484 |
+ u->rst.dat[u->rst.ptr - 2] = d; |
|
| 1485 |
+ u->rst.dat[u->rst.ptr - 1] = c; |
|
| 1486 |
+#ifndef NO_STACK_CHECKS |
|
| 1487 |
+ if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 1488 |
+ u->rst.error = 1; |
|
| 1489 |
+ goto error; |
|
| 1490 |
+ } |
|
| 1491 |
+#endif |
|
| 1492 |
+ } |
|
| 1493 |
+ break; |
|
| 1494 |
+ case 0x66: /* OVR2r */ |
|
| 1495 |
+ __asm__( "evaluxn_66_OVR2r:" ); |
|
| 1496 |
+ {
|
|
| 1497 |
+ 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]; |
|
| 1498 |
+ u->rst.dat[u->rst.ptr] = d; |
|
| 1499 |
+ u->rst.dat[u->rst.ptr + 1] = c; |
|
| 1500 |
+#ifndef NO_STACK_CHECKS |
|
| 1501 |
+ if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 1502 |
+ u->rst.error = 1; |
|
| 1503 |
+ goto error; |
|
| 1504 |
+ } |
|
| 1505 |
+ if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 1506 |
+ u->rst.error = 2; |
|
| 1507 |
+ goto error; |
|
| 1508 |
+ } |
|
| 1509 |
+#endif |
|
| 1510 |
+ u->rst.ptr += 2; |
|
| 1511 |
+ } |
|
| 1512 |
+ break; |
|
| 1513 |
+ case 0x67: /* ROT2r */ |
|
| 1514 |
+ __asm__( "evaluxn_67_ROT2r:" ); |
|
| 1515 |
+ {
|
|
| 1516 |
+ 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]; |
|
| 1517 |
+ u->rst.dat[u->rst.ptr - 6] = d; |
|
| 1518 |
+ u->rst.dat[u->rst.ptr - 5] = c; |
|
| 1519 |
+ u->rst.dat[u->rst.ptr - 4] = b; |
|
| 1520 |
+ u->rst.dat[u->rst.ptr - 3] = a; |
|
| 1521 |
+ u->rst.dat[u->rst.ptr - 2] = f; |
|
| 1522 |
+ u->rst.dat[u->rst.ptr - 1] = e; |
|
| 1523 |
+#ifndef NO_STACK_CHECKS |
|
| 1524 |
+ if(__builtin_expect(u->rst.ptr < 6, 0)) {
|
|
| 1525 |
+ u->rst.error = 1; |
|
| 1526 |
+ goto error; |
|
| 1527 |
+ } |
|
| 1528 |
+#endif |
|
| 1529 |
+ } |
|
| 1530 |
+ break; |
|
| 1531 |
+ case 0x68: /* EQU2r */ |
|
| 1532 |
+ __asm__( "evaluxn_68_EQU2r:" ); |
|
| 1533 |
+ {
|
|
| 1534 |
+ 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)); |
|
| 1535 |
+ u->rst.dat[u->rst.ptr - 4] = b == a; |
|
| 1536 |
+#ifndef NO_STACK_CHECKS |
|
| 1537 |
+ if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 1538 |
+ u->rst.error = 1; |
|
| 1539 |
+ goto error; |
|
| 1540 |
+ } |
|
| 1541 |
+#endif |
|
| 1542 |
+ u->rst.ptr -= 3; |
|
| 1543 |
+ } |
|
| 1544 |
+ break; |
|
| 1545 |
+ case 0x69: /* NEQ2r */ |
|
| 1546 |
+ __asm__( "evaluxn_69_NEQ2r:" ); |
|
| 1547 |
+ {
|
|
| 1548 |
+ 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)); |
|
| 1549 |
+ u->rst.dat[u->rst.ptr - 4] = b != a; |
|
| 1550 |
+#ifndef NO_STACK_CHECKS |
|
| 1551 |
+ if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 1552 |
+ u->rst.error = 1; |
|
| 1553 |
+ goto error; |
|
| 1554 |
+ } |
|
| 1555 |
+#endif |
|
| 1556 |
+ u->rst.ptr -= 3; |
|
| 1557 |
+ } |
|
| 1558 |
+ break; |
|
| 1559 |
+ case 0x6a: /* GTH2r */ |
|
| 1560 |
+ __asm__( "evaluxn_6a_GTH2r:" ); |
|
| 1561 |
+ {
|
|
| 1562 |
+ 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)); |
|
| 1563 |
+ u->rst.dat[u->rst.ptr - 4] = b > a; |
|
| 1564 |
+#ifndef NO_STACK_CHECKS |
|
| 1565 |
+ if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 1566 |
+ u->rst.error = 1; |
|
| 1567 |
+ goto error; |
|
| 1568 |
+ } |
|
| 1569 |
+#endif |
|
| 1570 |
+ u->rst.ptr -= 3; |
|
| 1571 |
+ } |
|
| 1572 |
+ break; |
|
| 1573 |
+ case 0x6b: /* LTH2r */ |
|
| 1574 |
+ __asm__( "evaluxn_6b_LTH2r:" ); |
|
| 1575 |
+ {
|
|
| 1576 |
+ 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)); |
|
| 1577 |
+ u->rst.dat[u->rst.ptr - 4] = b < a; |
|
| 1578 |
+#ifndef NO_STACK_CHECKS |
|
| 1579 |
+ if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 1580 |
+ u->rst.error = 1; |
|
| 1581 |
+ goto error; |
|
| 1582 |
+ } |
|
| 1583 |
+#endif |
|
| 1584 |
+ u->rst.ptr -= 3; |
|
| 1585 |
+ } |
|
| 1586 |
+ break; |
|
| 1587 |
+ case 0x6c: /* JMP2r */ |
|
| 1588 |
+ __asm__( "evaluxn_6c_JMP2r:" ); |
|
| 1589 |
+ {
|
|
| 1590 |
+ u->ram.ptr = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 1591 |
+#ifndef NO_STACK_CHECKS |
|
| 1592 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1593 |
+ u->rst.error = 1; |
|
| 1594 |
+ goto error; |
|
| 1595 |
+ } |
|
| 1596 |
+#endif |
|
| 1597 |
+ u->rst.ptr -= 2; |
|
| 1598 |
+ } |
|
| 1599 |
+ break; |
|
| 1600 |
+ case 0x6d: /* JCN2r */ |
|
| 1601 |
+ __asm__( "evaluxn_6d_JCN2r:" ); |
|
| 1602 |
+ {
|
|
| 1603 |
+ Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 1604 |
+ if(u->rst.dat[u->rst.ptr - 3]) u->ram.ptr = a; |
|
| 1605 |
+#ifndef NO_STACK_CHECKS |
|
| 1606 |
+ if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
| 1607 |
+ u->rst.error = 1; |
|
| 1608 |
+ goto error; |
|
| 1609 |
+ } |
|
| 1610 |
+#endif |
|
| 1611 |
+ u->rst.ptr -= 3; |
|
| 1612 |
+ } |
|
| 1613 |
+ break; |
|
| 1614 |
+ case 0x6e: /* JSR2r */ |
|
| 1615 |
+ __asm__( "evaluxn_6e_JSR2r:" ); |
|
| 1616 |
+ {
|
|
| 1617 |
+ u->wst.dat[u->wst.ptr] = u->ram.ptr >> 8; |
|
| 1618 |
+ u->wst.dat[u->wst.ptr + 1] = u->ram.ptr & 0xff; |
|
| 1619 |
+ u->ram.ptr = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 1620 |
+#ifndef NO_STACK_CHECKS |
|
| 1621 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1622 |
+ u->rst.error = 1; |
|
| 1623 |
+ goto error; |
|
| 1624 |
+ } |
|
| 1625 |
+#endif |
|
| 1626 |
+ u->rst.ptr -= 2; |
|
| 1627 |
+#ifndef NO_STACK_CHECKS |
|
| 1628 |
+ if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 1629 |
+ u->wst.error = 2; |
|
| 1630 |
+ goto error; |
|
| 1631 |
+ } |
|
| 1632 |
+#endif |
|
| 1633 |
+ u->wst.ptr += 2; |
|
| 1634 |
+ } |
|
| 1635 |
+ break; |
|
| 1636 |
+ case 0x6f: /* STH2r */ |
|
| 1637 |
+ __asm__( "evaluxn_6f_STH2r:" ); |
|
| 1638 |
+ {
|
|
| 1639 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 1640 |
+ u->wst.dat[u->wst.ptr] = b; |
|
| 1641 |
+ u->wst.dat[u->wst.ptr + 1] = a; |
|
| 1642 |
+#ifndef NO_STACK_CHECKS |
|
| 1643 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1644 |
+ u->rst.error = 1; |
|
| 1645 |
+ goto error; |
|
| 1646 |
+ } |
|
| 1647 |
+#endif |
|
| 1648 |
+ u->rst.ptr -= 2; |
|
| 1649 |
+#ifndef NO_STACK_CHECKS |
|
| 1650 |
+ if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 1651 |
+ u->wst.error = 2; |
|
| 1652 |
+ goto error; |
|
| 1653 |
+ } |
|
| 1654 |
+#endif |
|
| 1655 |
+ u->wst.ptr += 2; |
|
| 1656 |
+ } |
|
| 1657 |
+ break; |
|
| 1658 |
+ case 0x70: /* LDZ2r */ |
|
| 1659 |
+ __asm__( "evaluxn_70_LDZ2r:" ); |
|
| 1660 |
+ {
|
|
| 1661 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1662 |
+ u->rst.dat[u->rst.ptr - 1] = mempeek8(u->ram.dat, a); |
|
| 1663 |
+ u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, a + 1); |
|
| 1664 |
+#ifndef NO_STACK_CHECKS |
|
| 1665 |
+ if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 1666 |
+ u->rst.error = 1; |
|
| 1667 |
+ goto error; |
|
| 1668 |
+ } |
|
| 1669 |
+ if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 1670 |
+ u->rst.error = 2; |
|
| 1671 |
+ goto error; |
|
| 1672 |
+ } |
|
| 1673 |
+#endif |
|
| 1674 |
+ u->rst.ptr += 1; |
|
| 1675 |
+ } |
|
| 1676 |
+ break; |
|
| 1677 |
+ case 0x71: /* STZ2r */ |
|
| 1678 |
+ __asm__( "evaluxn_71_STZ2r:" ); |
|
| 1679 |
+ {
|
|
| 1680 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1681 |
+ Uint16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8)); |
|
| 1682 |
+ mempoke16(u->ram.dat, a, b); |
|
| 1683 |
+#ifndef NO_STACK_CHECKS |
|
| 1684 |
+ if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
| 1685 |
+ u->rst.error = 1; |
|
| 1686 |
+ goto error; |
|
| 1687 |
+ } |
|
| 1688 |
+#endif |
|
| 1689 |
+ u->rst.ptr -= 3; |
|
| 1690 |
+ } |
|
| 1691 |
+ break; |
|
| 1692 |
+ case 0x72: /* LDR2r */ |
|
| 1693 |
+ __asm__( "evaluxn_72_LDR2r:" ); |
|
| 1694 |
+ {
|
|
| 1695 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1696 |
+ u->rst.dat[u->rst.ptr - 1] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a); |
|
| 1697 |
+ u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a + 1); |
|
| 1698 |
+#ifndef NO_STACK_CHECKS |
|
| 1699 |
+ if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 1700 |
+ u->rst.error = 1; |
|
| 1701 |
+ goto error; |
|
| 1702 |
+ } |
|
| 1703 |
+ if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 1704 |
+ u->rst.error = 2; |
|
| 1705 |
+ goto error; |
|
| 1706 |
+ } |
|
| 1707 |
+#endif |
|
| 1708 |
+ u->rst.ptr += 1; |
|
| 1709 |
+ } |
|
| 1710 |
+ break; |
|
| 1711 |
+ case 0x73: /* STR2r */ |
|
| 1712 |
+ __asm__( "evaluxn_73_STR2r:" ); |
|
| 1713 |
+ {
|
|
| 1714 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1715 |
+ Uint16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8)); |
|
| 1716 |
+ mempoke16(u->ram.dat, u->ram.ptr + (Sint8)a, b); |
|
| 1717 |
+#ifndef NO_STACK_CHECKS |
|
| 1718 |
+ if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
| 1719 |
+ u->rst.error = 1; |
|
| 1720 |
+ goto error; |
|
| 1721 |
+ } |
|
| 1722 |
+#endif |
|
| 1723 |
+ u->rst.ptr -= 3; |
|
| 1724 |
+ } |
|
| 1725 |
+ break; |
|
| 1726 |
+ case 0x74: /* LDA2r */ |
|
| 1727 |
+ __asm__( "evaluxn_74_LDA2r:" ); |
|
| 1728 |
+ {
|
|
| 1729 |
+ Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 1730 |
+ u->rst.dat[u->rst.ptr - 2] = mempeek8(u->ram.dat, a); |
|
| 1731 |
+ u->rst.dat[u->rst.ptr - 1] = mempeek8(u->ram.dat, a + 1); |
|
| 1732 |
+#ifndef NO_STACK_CHECKS |
|
| 1733 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 1734 |
+ u->rst.error = 1; |
|
| 1735 |
+ goto error; |
|
| 1736 |
+ } |
|
| 1737 |
+#endif |
|
| 1738 |
+ } |
|
| 1739 |
+ break; |
|
| 1740 |
+ case 0x75: /* STA2r */ |
|
| 1741 |
+ __asm__( "evaluxn_75_STA2r:" ); |
|
| 1742 |
+ {
|
|
| 1743 |
+ Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 1744 |
+ Uint16 b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
|
| 1745 |
+ mempoke16(u->ram.dat, a, b); |
|
| 1746 |
+#ifndef NO_STACK_CHECKS |
|
| 1747 |
+ if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 1748 |
+ u->rst.error = 1; |
|
| 1749 |
+ goto error; |
|
| 1750 |
+ } |
|
| 1751 |
+#endif |
|
| 1752 |
+ u->rst.ptr -= 4; |
|
| 1753 |
+ } |
|
| 1754 |
+ break; |
|
| 1755 |
+ case 0x76: /* DEI2r */ |
|
| 1756 |
+ __asm__( "evaluxn_76_DEI2r:" ); |
|
| 1757 |
+ {
|
|
| 1758 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1759 |
+ u->rst.dat[u->rst.ptr - 1] = devpeek8(&u->dev[a >> 4], a); |
|
| 1760 |
+ u->rst.dat[u->rst.ptr] = devpeek8(&u->dev[a >> 4], a + 1); |
|
| 1761 |
+#ifndef NO_STACK_CHECKS |
|
| 1762 |
+ if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 1763 |
+ u->rst.error = 1; |
|
| 1764 |
+ goto error; |
|
| 1765 |
+ } |
|
| 1766 |
+ if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 1767 |
+ u->rst.error = 2; |
|
| 1768 |
+ goto error; |
|
| 1769 |
+ } |
|
| 1770 |
+#endif |
|
| 1771 |
+ u->rst.ptr += 1; |
|
| 1772 |
+ } |
|
| 1773 |
+ break; |
|
| 1774 |
+ case 0x77: /* DEO2r */ |
|
| 1775 |
+ __asm__( "evaluxn_77_DEO2r:" ); |
|
| 1776 |
+ {
|
|
| 1777 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1778 |
+ Uint16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8)); |
|
| 1779 |
+ devpoke16(&u->dev[a >> 4], a, b); |
|
| 1780 |
+#ifndef NO_STACK_CHECKS |
|
| 1781 |
+ if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
| 1782 |
+ u->rst.error = 1; |
|
| 1783 |
+ goto error; |
|
| 1784 |
+ } |
|
| 1785 |
+#endif |
|
| 1786 |
+ u->rst.ptr -= 3; |
|
| 1787 |
+ } |
|
| 1788 |
+ break; |
|
| 1789 |
+ case 0x78: /* ADD2r */ |
|
| 1790 |
+ __asm__( "evaluxn_78_ADD2r:" ); |
|
| 1791 |
+ {
|
|
| 1792 |
+ 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)); |
|
| 1793 |
+ u->rst.dat[u->rst.ptr - 4] = (b + a) >> 8; |
|
| 1794 |
+ u->rst.dat[u->rst.ptr - 3] = (b + a) & 0xff; |
|
| 1795 |
+#ifndef NO_STACK_CHECKS |
|
| 1796 |
+ if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 1797 |
+ u->rst.error = 1; |
|
| 1798 |
+ goto error; |
|
| 1799 |
+ } |
|
| 1800 |
+#endif |
|
| 1801 |
+ u->rst.ptr -= 2; |
|
| 1802 |
+ } |
|
| 1803 |
+ break; |
|
| 1804 |
+ case 0x79: /* SUB2r */ |
|
| 1805 |
+ __asm__( "evaluxn_79_SUB2r:" ); |
|
| 1806 |
+ {
|
|
| 1807 |
+ 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)); |
|
| 1808 |
+ u->rst.dat[u->rst.ptr - 4] = (b - a) >> 8; |
|
| 1809 |
+ u->rst.dat[u->rst.ptr - 3] = (b - a) & 0xff; |
|
| 1810 |
+#ifndef NO_STACK_CHECKS |
|
| 1811 |
+ if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 1812 |
+ u->rst.error = 1; |
|
| 1813 |
+ goto error; |
|
| 1814 |
+ } |
|
| 1815 |
+#endif |
|
| 1816 |
+ u->rst.ptr -= 2; |
|
| 1817 |
+ } |
|
| 1818 |
+ break; |
|
| 1819 |
+ case 0x7a: /* MUL2r */ |
|
| 1820 |
+ __asm__( "evaluxn_7a_MUL2r:" ); |
|
| 1821 |
+ {
|
|
| 1822 |
+ 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)); |
|
| 1823 |
+ u->rst.dat[u->rst.ptr - 4] = (b * a) >> 8; |
|
| 1824 |
+ u->rst.dat[u->rst.ptr - 3] = (b * a) & 0xff; |
|
| 1825 |
+#ifndef NO_STACK_CHECKS |
|
| 1826 |
+ if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 1827 |
+ u->rst.error = 1; |
|
| 1828 |
+ goto error; |
|
| 1829 |
+ } |
|
| 1830 |
+#endif |
|
| 1831 |
+ u->rst.ptr -= 2; |
|
| 1832 |
+ } |
|
| 1833 |
+ break; |
|
| 1834 |
+ case 0x7b: /* DIV2r */ |
|
| 1835 |
+ __asm__( "evaluxn_7b_DIV2r:" ); |
|
| 1836 |
+ {
|
|
| 1837 |
+ 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)); |
|
| 1838 |
+ u->rst.dat[u->rst.ptr - 4] = (b / a) >> 8; |
|
| 1839 |
+ u->rst.dat[u->rst.ptr - 3] = (b / a) & 0xff; |
|
| 1840 |
+#ifndef NO_STACK_CHECKS |
|
| 1841 |
+ if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 1842 |
+ u->rst.error = 1; |
|
| 1843 |
+ goto error; |
|
| 1844 |
+ } |
|
| 1845 |
+#endif |
|
| 1846 |
+ u->rst.ptr -= 2; |
|
| 1847 |
+ } |
|
| 1848 |
+ break; |
|
| 1849 |
+ case 0x7c: /* AND2r */ |
|
| 1850 |
+ __asm__( "evaluxn_7c_AND2r:" ); |
|
| 1851 |
+ {
|
|
| 1852 |
+ 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]; |
|
| 1853 |
+ u->rst.dat[u->rst.ptr - 4] = d & b; |
|
| 1854 |
+ u->rst.dat[u->rst.ptr - 3] = c & a; |
|
| 1855 |
+#ifndef NO_STACK_CHECKS |
|
| 1856 |
+ if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 1857 |
+ u->rst.error = 1; |
|
| 1858 |
+ goto error; |
|
| 1859 |
+ } |
|
| 1860 |
+#endif |
|
| 1861 |
+ u->rst.ptr -= 2; |
|
| 1862 |
+ } |
|
| 1863 |
+ break; |
|
| 1864 |
+ case 0x7d: /* ORA2r */ |
|
| 1865 |
+ __asm__( "evaluxn_7d_ORA2r:" ); |
|
| 1866 |
+ {
|
|
| 1867 |
+ 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]; |
|
| 1868 |
+ u->rst.dat[u->rst.ptr - 4] = d | b; |
|
| 1869 |
+ u->rst.dat[u->rst.ptr - 3] = c | a; |
|
| 1870 |
+#ifndef NO_STACK_CHECKS |
|
| 1871 |
+ if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 1872 |
+ u->rst.error = 1; |
|
| 1873 |
+ goto error; |
|
| 1874 |
+ } |
|
| 1875 |
+#endif |
|
| 1876 |
+ u->rst.ptr -= 2; |
|
| 1877 |
+ } |
|
| 1878 |
+ break; |
|
| 1879 |
+ case 0x7e: /* EOR2r */ |
|
| 1880 |
+ __asm__( "evaluxn_7e_EOR2r:" ); |
|
| 1881 |
+ {
|
|
| 1882 |
+ 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]; |
|
| 1883 |
+ u->rst.dat[u->rst.ptr - 4] = d ^ b; |
|
| 1884 |
+ u->rst.dat[u->rst.ptr - 3] = c ^ a; |
|
| 1885 |
+#ifndef NO_STACK_CHECKS |
|
| 1886 |
+ if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 1887 |
+ u->rst.error = 1; |
|
| 1888 |
+ goto error; |
|
| 1889 |
+ } |
|
| 1890 |
+#endif |
|
| 1891 |
+ u->rst.ptr -= 2; |
|
| 1892 |
+ } |
|
| 1893 |
+ break; |
|
| 1894 |
+ case 0x7f: /* SFT2r */ |
|
| 1895 |
+ __asm__( "evaluxn_7f_SFT2r:" ); |
|
| 1896 |
+ {
|
|
| 1897 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 1898 |
+ Uint16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8)); |
|
| 1899 |
+ u->rst.dat[u->rst.ptr - 3] = (b >> (a & 0x0f) << ((a & 0xf0) >> 4)) >> 8; |
|
| 1900 |
+ u->rst.dat[u->rst.ptr - 2] = (b >> (a & 0x0f) << ((a & 0xf0) >> 4)) & 0xff; |
|
| 1901 |
+#ifndef NO_STACK_CHECKS |
|
| 1902 |
+ if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
| 1903 |
+ u->rst.error = 1; |
|
| 1904 |
+ goto error; |
|
| 1905 |
+ } |
|
| 1906 |
+#endif |
|
| 1907 |
+ u->rst.ptr -= 1; |
|
| 1908 |
+ } |
|
| 1909 |
+ break; |
|
| 1910 |
+ case 0x83: /* POPk */ |
|
| 1911 |
+ __asm__( "evaluxn_83_POPk:" ); |
|
| 1912 |
+ {
|
|
| 1913 |
+ u->wst.dat[u->wst.ptr - 1]; |
|
| 1914 |
+#ifndef NO_STACK_CHECKS |
|
| 1915 |
+ if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 1916 |
+ u->wst.error = 1; |
|
| 1917 |
+ goto error; |
|
| 1918 |
+ } |
|
| 1919 |
+#endif |
|
| 1920 |
+ } |
|
| 1921 |
+ break; |
|
| 1922 |
+ case 0x84: /* DUPk */ |
|
| 1923 |
+ __asm__( "evaluxn_84_DUPk:" ); |
|
| 1924 |
+ {
|
|
| 1925 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 1926 |
+ u->wst.dat[u->wst.ptr] = a; |
|
| 1927 |
+ u->wst.dat[u->wst.ptr + 1] = a; |
|
| 1928 |
+#ifndef NO_STACK_CHECKS |
|
| 1929 |
+ if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 1930 |
+ u->wst.error = 1; |
|
| 1931 |
+ goto error; |
|
| 1932 |
+ } |
|
| 1933 |
+ if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 1934 |
+ u->wst.error = 2; |
|
| 1935 |
+ goto error; |
|
| 1936 |
+ } |
|
| 1937 |
+#endif |
|
| 1938 |
+ u->wst.ptr += 2; |
|
| 1939 |
+ } |
|
| 1940 |
+ break; |
|
| 1941 |
+ case 0x85: /* SWPk */ |
|
| 1942 |
+ __asm__( "evaluxn_85_SWPk:" ); |
|
| 1943 |
+ {
|
|
| 1944 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 1945 |
+ u->wst.dat[u->wst.ptr] = a; |
|
| 1946 |
+ u->wst.dat[u->wst.ptr + 1] = b; |
|
| 1947 |
+#ifndef NO_STACK_CHECKS |
|
| 1948 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 1949 |
+ u->wst.error = 1; |
|
| 1950 |
+ goto error; |
|
| 1951 |
+ } |
|
| 1952 |
+ if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 1953 |
+ u->wst.error = 2; |
|
| 1954 |
+ goto error; |
|
| 1955 |
+ } |
|
| 1956 |
+#endif |
|
| 1957 |
+ u->wst.ptr += 2; |
|
| 1958 |
+ } |
|
| 1959 |
+ break; |
|
| 1960 |
+ case 0x86: /* OVRk */ |
|
| 1961 |
+ __asm__( "evaluxn_86_OVRk:" ); |
|
| 1962 |
+ {
|
|
| 1963 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 1964 |
+ u->wst.dat[u->wst.ptr] = b; |
|
| 1965 |
+ u->wst.dat[u->wst.ptr + 1] = a; |
|
| 1966 |
+ u->wst.dat[u->wst.ptr + 2] = b; |
|
| 1967 |
+#ifndef NO_STACK_CHECKS |
|
| 1968 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 1969 |
+ u->wst.error = 1; |
|
| 1970 |
+ goto error; |
|
| 1971 |
+ } |
|
| 1972 |
+ if(__builtin_expect(u->wst.ptr > 252, 0)) {
|
|
| 1973 |
+ u->wst.error = 2; |
|
| 1974 |
+ goto error; |
|
| 1975 |
+ } |
|
| 1976 |
+#endif |
|
| 1977 |
+ u->wst.ptr += 3; |
|
| 1978 |
+ } |
|
| 1979 |
+ break; |
|
| 1980 |
+ case 0x87: /* ROTk */ |
|
| 1981 |
+ __asm__( "evaluxn_87_ROTk:" ); |
|
| 1982 |
+ {
|
|
| 1983 |
+ 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]; |
|
| 1984 |
+ u->wst.dat[u->wst.ptr] = b; |
|
| 1985 |
+ u->wst.dat[u->wst.ptr + 1] = a; |
|
| 1986 |
+ u->wst.dat[u->wst.ptr + 2] = c; |
|
| 1987 |
+#ifndef NO_STACK_CHECKS |
|
| 1988 |
+ if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
| 1989 |
+ u->wst.error = 1; |
|
| 1990 |
+ goto error; |
|
| 1991 |
+ } |
|
| 1992 |
+ if(__builtin_expect(u->wst.ptr > 252, 0)) {
|
|
| 1993 |
+ u->wst.error = 2; |
|
| 1994 |
+ goto error; |
|
| 1995 |
+ } |
|
| 1996 |
+#endif |
|
| 1997 |
+ u->wst.ptr += 3; |
|
| 1998 |
+ } |
|
| 1999 |
+ break; |
|
| 2000 |
+ case 0x88: /* EQUk */ |
|
| 2001 |
+ __asm__( "evaluxn_88_EQUk:" ); |
|
| 2002 |
+ {
|
|
| 2003 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 2004 |
+ u->wst.dat[u->wst.ptr] = b == a; |
|
| 2005 |
+#ifndef NO_STACK_CHECKS |
|
| 2006 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2007 |
+ u->wst.error = 1; |
|
| 2008 |
+ goto error; |
|
| 2009 |
+ } |
|
| 2010 |
+ if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2011 |
+ u->wst.error = 2; |
|
| 2012 |
+ goto error; |
|
| 2013 |
+ } |
|
| 2014 |
+#endif |
|
| 2015 |
+ u->wst.ptr += 1; |
|
| 2016 |
+ } |
|
| 2017 |
+ break; |
|
| 2018 |
+ case 0x89: /* NEQk */ |
|
| 2019 |
+ __asm__( "evaluxn_89_NEQk:" ); |
|
| 2020 |
+ {
|
|
| 2021 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 2022 |
+ u->wst.dat[u->wst.ptr] = b != a; |
|
| 2023 |
+#ifndef NO_STACK_CHECKS |
|
| 2024 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2025 |
+ u->wst.error = 1; |
|
| 2026 |
+ goto error; |
|
| 2027 |
+ } |
|
| 2028 |
+ if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2029 |
+ u->wst.error = 2; |
|
| 2030 |
+ goto error; |
|
| 2031 |
+ } |
|
| 2032 |
+#endif |
|
| 2033 |
+ u->wst.ptr += 1; |
|
| 2034 |
+ } |
|
| 2035 |
+ break; |
|
| 2036 |
+ case 0x8a: /* GTHk */ |
|
| 2037 |
+ __asm__( "evaluxn_8a_GTHk:" ); |
|
| 2038 |
+ {
|
|
| 2039 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 2040 |
+ u->wst.dat[u->wst.ptr] = b > a; |
|
| 2041 |
+#ifndef NO_STACK_CHECKS |
|
| 2042 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2043 |
+ u->wst.error = 1; |
|
| 2044 |
+ goto error; |
|
| 2045 |
+ } |
|
| 2046 |
+ if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2047 |
+ u->wst.error = 2; |
|
| 2048 |
+ goto error; |
|
| 2049 |
+ } |
|
| 2050 |
+#endif |
|
| 2051 |
+ u->wst.ptr += 1; |
|
| 2052 |
+ } |
|
| 2053 |
+ break; |
|
| 2054 |
+ case 0x8b: /* LTHk */ |
|
| 2055 |
+ __asm__( "evaluxn_8b_LTHk:" ); |
|
| 2056 |
+ {
|
|
| 2057 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 2058 |
+ u->wst.dat[u->wst.ptr] = b < a; |
|
| 2059 |
+#ifndef NO_STACK_CHECKS |
|
| 2060 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2061 |
+ u->wst.error = 1; |
|
| 2062 |
+ goto error; |
|
| 2063 |
+ } |
|
| 2064 |
+ if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2065 |
+ u->wst.error = 2; |
|
| 2066 |
+ goto error; |
|
| 2067 |
+ } |
|
| 2068 |
+#endif |
|
| 2069 |
+ u->wst.ptr += 1; |
|
| 2070 |
+ } |
|
| 2071 |
+ break; |
|
| 2072 |
+ case 0x8c: /* JMPk */ |
|
| 2073 |
+ __asm__( "evaluxn_8c_JMPk:" ); |
|
| 2074 |
+ {
|
|
| 2075 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 2076 |
+ u->ram.ptr += (Sint8)a; |
|
| 2077 |
+#ifndef NO_STACK_CHECKS |
|
| 2078 |
+ if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 2079 |
+ u->wst.error = 1; |
|
| 2080 |
+ goto error; |
|
| 2081 |
+ } |
|
| 2082 |
+#endif |
|
| 2083 |
+ } |
|
| 2084 |
+ break; |
|
| 2085 |
+ case 0x8d: /* JCNk */ |
|
| 2086 |
+ __asm__( "evaluxn_8d_JCNk:" ); |
|
| 2087 |
+ {
|
|
| 2088 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 2089 |
+ if(u->wst.dat[u->wst.ptr - 2]) u->ram.ptr += (Sint8)a; |
|
| 2090 |
+#ifndef NO_STACK_CHECKS |
|
| 2091 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2092 |
+ u->wst.error = 1; |
|
| 2093 |
+ goto error; |
|
| 2094 |
+ } |
|
| 2095 |
+#endif |
|
| 2096 |
+ } |
|
| 2097 |
+ break; |
|
| 2098 |
+ case 0x8e: /* JSRk */ |
|
| 2099 |
+ __asm__( "evaluxn_8e_JSRk:" ); |
|
| 2100 |
+ {
|
|
| 2101 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 2102 |
+ u->rst.dat[u->rst.ptr] = u->ram.ptr >> 8; |
|
| 2103 |
+ u->rst.dat[u->rst.ptr + 1] = u->ram.ptr & 0xff; |
|
| 2104 |
+ u->ram.ptr += (Sint8)a; |
|
| 2105 |
+#ifndef NO_STACK_CHECKS |
|
| 2106 |
+ if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 2107 |
+ u->wst.error = 1; |
|
| 2108 |
+ goto error; |
|
| 2109 |
+ } |
|
| 2110 |
+ if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 2111 |
+ u->rst.error = 2; |
|
| 2112 |
+ goto error; |
|
| 2113 |
+ } |
|
| 2114 |
+#endif |
|
| 2115 |
+ u->rst.ptr += 2; |
|
| 2116 |
+ } |
|
| 2117 |
+ break; |
|
| 2118 |
+ case 0x8f: /* STHk */ |
|
| 2119 |
+ __asm__( "evaluxn_8f_STHk:" ); |
|
| 2120 |
+ {
|
|
| 2121 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 2122 |
+ u->rst.dat[u->rst.ptr] = a; |
|
| 2123 |
+#ifndef NO_STACK_CHECKS |
|
| 2124 |
+ if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 2125 |
+ u->wst.error = 1; |
|
| 2126 |
+ goto error; |
|
| 2127 |
+ } |
|
| 2128 |
+ if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 2129 |
+ u->rst.error = 2; |
|
| 2130 |
+ goto error; |
|
| 2131 |
+ } |
|
| 2132 |
+#endif |
|
| 2133 |
+ u->rst.ptr += 1; |
|
| 2134 |
+ } |
|
| 2135 |
+ break; |
|
| 2136 |
+ case 0x90: /* LDZk */ |
|
| 2137 |
+ __asm__( "evaluxn_90_LDZk:" ); |
|
| 2138 |
+ {
|
|
| 2139 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 2140 |
+ u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, a); |
|
| 2141 |
+#ifndef NO_STACK_CHECKS |
|
| 2142 |
+ if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 2143 |
+ u->wst.error = 1; |
|
| 2144 |
+ goto error; |
|
| 2145 |
+ } |
|
| 2146 |
+ if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2147 |
+ u->wst.error = 2; |
|
| 2148 |
+ goto error; |
|
| 2149 |
+ } |
|
| 2150 |
+#endif |
|
| 2151 |
+ u->wst.ptr += 1; |
|
| 2152 |
+ } |
|
| 2153 |
+ break; |
|
| 2154 |
+ case 0x91: /* STZk */ |
|
| 2155 |
+ __asm__( "evaluxn_91_STZk:" ); |
|
| 2156 |
+ {
|
|
| 2157 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 2158 |
+ Uint8 b = u->wst.dat[u->wst.ptr - 2]; |
|
| 2159 |
+ mempoke8(u->ram.dat, a, b); |
|
| 2160 |
+#ifndef NO_STACK_CHECKS |
|
| 2161 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2162 |
+ u->wst.error = 1; |
|
| 2163 |
+ goto error; |
|
| 2164 |
+ } |
|
| 2165 |
+#endif |
|
| 2166 |
+ } |
|
| 2167 |
+ break; |
|
| 2168 |
+ case 0x92: /* LDRk */ |
|
| 2169 |
+ __asm__( "evaluxn_92_LDRk:" ); |
|
| 2170 |
+ {
|
|
| 2171 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 2172 |
+ u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a); |
|
| 2173 |
+#ifndef NO_STACK_CHECKS |
|
| 2174 |
+ if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 2175 |
+ u->wst.error = 1; |
|
| 2176 |
+ goto error; |
|
| 2177 |
+ } |
|
| 2178 |
+ if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2179 |
+ u->wst.error = 2; |
|
| 2180 |
+ goto error; |
|
| 2181 |
+ } |
|
| 2182 |
+#endif |
|
| 2183 |
+ u->wst.ptr += 1; |
|
| 2184 |
+ } |
|
| 2185 |
+ break; |
|
| 2186 |
+ case 0x93: /* STRk */ |
|
| 2187 |
+ __asm__( "evaluxn_93_STRk:" ); |
|
| 2188 |
+ {
|
|
| 2189 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 2190 |
+ Uint8 b = u->wst.dat[u->wst.ptr - 2]; |
|
| 2191 |
+ mempoke8(u->ram.dat, u->ram.ptr + (Sint8)a, b); |
|
| 2192 |
+#ifndef NO_STACK_CHECKS |
|
| 2193 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2194 |
+ u->wst.error = 1; |
|
| 2195 |
+ goto error; |
|
| 2196 |
+ } |
|
| 2197 |
+#endif |
|
| 2198 |
+ } |
|
| 2199 |
+ break; |
|
| 2200 |
+ case 0x94: /* LDAk */ |
|
| 2201 |
+ __asm__( "evaluxn_94_LDAk:" ); |
|
| 2202 |
+ {
|
|
| 2203 |
+ Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 2204 |
+ u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, a); |
|
| 2205 |
+#ifndef NO_STACK_CHECKS |
|
| 2206 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2207 |
+ u->wst.error = 1; |
|
| 2208 |
+ goto error; |
|
| 2209 |
+ } |
|
| 2210 |
+ if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2211 |
+ u->wst.error = 2; |
|
| 2212 |
+ goto error; |
|
| 2213 |
+ } |
|
| 2214 |
+#endif |
|
| 2215 |
+ u->wst.ptr += 1; |
|
| 2216 |
+ } |
|
| 2217 |
+ break; |
|
| 2218 |
+ case 0x95: /* STAk */ |
|
| 2219 |
+ __asm__( "evaluxn_95_STAk:" ); |
|
| 2220 |
+ {
|
|
| 2221 |
+ Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 2222 |
+ Uint8 b = u->wst.dat[u->wst.ptr - 3]; |
|
| 2223 |
+ mempoke8(u->ram.dat, a, b); |
|
| 2224 |
+#ifndef NO_STACK_CHECKS |
|
| 2225 |
+ if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
| 2226 |
+ u->wst.error = 1; |
|
| 2227 |
+ goto error; |
|
| 2228 |
+ } |
|
| 2229 |
+#endif |
|
| 2230 |
+ } |
|
| 2231 |
+ break; |
|
| 2232 |
+ case 0x96: /* DEIk */ |
|
| 2233 |
+ __asm__( "evaluxn_96_DEIk:" ); |
|
| 2234 |
+ {
|
|
| 2235 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 2236 |
+ u->wst.dat[u->wst.ptr] = devpeek8(&u->dev[a >> 4], a); |
|
| 2237 |
+#ifndef NO_STACK_CHECKS |
|
| 2238 |
+ if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 2239 |
+ u->wst.error = 1; |
|
| 2240 |
+ goto error; |
|
| 2241 |
+ } |
|
| 2242 |
+ if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2243 |
+ u->wst.error = 2; |
|
| 2244 |
+ goto error; |
|
| 2245 |
+ } |
|
| 2246 |
+#endif |
|
| 2247 |
+ u->wst.ptr += 1; |
|
| 2248 |
+ } |
|
| 2249 |
+ break; |
|
| 2250 |
+ case 0x97: /* DEOk */ |
|
| 2251 |
+ __asm__( "evaluxn_97_DEOk:" ); |
|
| 2252 |
+ {
|
|
| 2253 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 2254 |
+ devpoke8(&u->dev[a >> 4], a, b); |
|
| 2255 |
+#ifndef NO_STACK_CHECKS |
|
| 2256 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2257 |
+ u->wst.error = 1; |
|
| 2258 |
+ goto error; |
|
| 2259 |
+ } |
|
| 2260 |
+#endif |
|
| 2261 |
+ } |
|
| 2262 |
+ break; |
|
| 2263 |
+ case 0x98: /* ADDk */ |
|
| 2264 |
+ __asm__( "evaluxn_98_ADDk:" ); |
|
| 2265 |
+ {
|
|
| 2266 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 2267 |
+ u->wst.dat[u->wst.ptr] = b + a; |
|
| 2268 |
+#ifndef NO_STACK_CHECKS |
|
| 2269 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2270 |
+ u->wst.error = 1; |
|
| 2271 |
+ goto error; |
|
| 2272 |
+ } |
|
| 2273 |
+ if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2274 |
+ u->wst.error = 2; |
|
| 2275 |
+ goto error; |
|
| 2276 |
+ } |
|
| 2277 |
+#endif |
|
| 2278 |
+ u->wst.ptr += 1; |
|
| 2279 |
+ } |
|
| 2280 |
+ break; |
|
| 2281 |
+ case 0x99: /* SUBk */ |
|
| 2282 |
+ __asm__( "evaluxn_99_SUBk:" ); |
|
| 2283 |
+ {
|
|
| 2284 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 2285 |
+ u->wst.dat[u->wst.ptr] = b - a; |
|
| 2286 |
+#ifndef NO_STACK_CHECKS |
|
| 2287 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2288 |
+ u->wst.error = 1; |
|
| 2289 |
+ goto error; |
|
| 2290 |
+ } |
|
| 2291 |
+ if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2292 |
+ u->wst.error = 2; |
|
| 2293 |
+ goto error; |
|
| 2294 |
+ } |
|
| 2295 |
+#endif |
|
| 2296 |
+ u->wst.ptr += 1; |
|
| 2297 |
+ } |
|
| 2298 |
+ break; |
|
| 2299 |
+ case 0x9a: /* MULk */ |
|
| 2300 |
+ __asm__( "evaluxn_9a_MULk:" ); |
|
| 2301 |
+ {
|
|
| 2302 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 2303 |
+ u->wst.dat[u->wst.ptr] = b * a; |
|
| 2304 |
+#ifndef NO_STACK_CHECKS |
|
| 2305 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2306 |
+ u->wst.error = 1; |
|
| 2307 |
+ goto error; |
|
| 2308 |
+ } |
|
| 2309 |
+ if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2310 |
+ u->wst.error = 2; |
|
| 2311 |
+ goto error; |
|
| 2312 |
+ } |
|
| 2313 |
+#endif |
|
| 2314 |
+ u->wst.ptr += 1; |
|
| 2315 |
+ } |
|
| 2316 |
+ break; |
|
| 2317 |
+ case 0x9b: /* DIVk */ |
|
| 2318 |
+ __asm__( "evaluxn_9b_DIVk:" ); |
|
| 2319 |
+ {
|
|
| 2320 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 2321 |
+ u->wst.dat[u->wst.ptr] = b / a; |
|
| 2322 |
+#ifndef NO_STACK_CHECKS |
|
| 2323 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2324 |
+ u->wst.error = 1; |
|
| 2325 |
+ goto error; |
|
| 2326 |
+ } |
|
| 2327 |
+ if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2328 |
+ u->wst.error = 2; |
|
| 2329 |
+ goto error; |
|
| 2330 |
+ } |
|
| 2331 |
+#endif |
|
| 2332 |
+ u->wst.ptr += 1; |
|
| 2333 |
+ } |
|
| 2334 |
+ break; |
|
| 2335 |
+ case 0x9c: /* ANDk */ |
|
| 2336 |
+ __asm__( "evaluxn_9c_ANDk:" ); |
|
| 2337 |
+ {
|
|
| 2338 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 2339 |
+ u->wst.dat[u->wst.ptr] = b & a; |
|
| 2340 |
+#ifndef NO_STACK_CHECKS |
|
| 2341 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2342 |
+ u->wst.error = 1; |
|
| 2343 |
+ goto error; |
|
| 2344 |
+ } |
|
| 2345 |
+ if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2346 |
+ u->wst.error = 2; |
|
| 2347 |
+ goto error; |
|
| 2348 |
+ } |
|
| 2349 |
+#endif |
|
| 2350 |
+ u->wst.ptr += 1; |
|
| 2351 |
+ } |
|
| 2352 |
+ break; |
|
| 2353 |
+ case 0x9d: /* ORAk */ |
|
| 2354 |
+ __asm__( "evaluxn_9d_ORAk:" ); |
|
| 2355 |
+ {
|
|
| 2356 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 2357 |
+ u->wst.dat[u->wst.ptr] = b | a; |
|
| 2358 |
+#ifndef NO_STACK_CHECKS |
|
| 2359 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2360 |
+ u->wst.error = 1; |
|
| 2361 |
+ goto error; |
|
| 2362 |
+ } |
|
| 2363 |
+ if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2364 |
+ u->wst.error = 2; |
|
| 2365 |
+ goto error; |
|
| 2366 |
+ } |
|
| 2367 |
+#endif |
|
| 2368 |
+ u->wst.ptr += 1; |
|
| 2369 |
+ } |
|
| 2370 |
+ break; |
|
| 2371 |
+ case 0x9e: /* EORk */ |
|
| 2372 |
+ __asm__( "evaluxn_9e_EORk:" ); |
|
| 2373 |
+ {
|
|
| 2374 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 2375 |
+ u->wst.dat[u->wst.ptr] = b ^ a; |
|
| 2376 |
+#ifndef NO_STACK_CHECKS |
|
| 2377 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2378 |
+ u->wst.error = 1; |
|
| 2379 |
+ goto error; |
|
| 2380 |
+ } |
|
| 2381 |
+ if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2382 |
+ u->wst.error = 2; |
|
| 2383 |
+ goto error; |
|
| 2384 |
+ } |
|
| 2385 |
+#endif |
|
| 2386 |
+ u->wst.ptr += 1; |
|
| 2387 |
+ } |
|
| 2388 |
+ break; |
|
| 2389 |
+ case 0x9f: /* SFTk */ |
|
| 2390 |
+ __asm__( "evaluxn_9f_SFTk:" ); |
|
| 2391 |
+ {
|
|
| 2392 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 2393 |
+ u->wst.dat[u->wst.ptr] = b >> (a & 0x07) << ((a & 0x70) >> 4); |
|
| 2394 |
+#ifndef NO_STACK_CHECKS |
|
| 2395 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2396 |
+ u->wst.error = 1; |
|
| 2397 |
+ goto error; |
|
| 2398 |
+ } |
|
| 2399 |
+ if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2400 |
+ u->wst.error = 2; |
|
| 2401 |
+ goto error; |
|
| 2402 |
+ } |
|
| 2403 |
+#endif |
|
| 2404 |
+ u->wst.ptr += 1; |
|
| 2405 |
+ } |
|
| 2406 |
+ break; |
|
| 2407 |
+ case 0xa3: /* POP2k */ |
|
| 2408 |
+ __asm__( "evaluxn_a3_POP2k:" ); |
|
| 2409 |
+ {
|
|
| 2410 |
+ (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 2411 |
+#ifndef NO_STACK_CHECKS |
|
| 2412 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2413 |
+ u->wst.error = 1; |
|
| 2414 |
+ goto error; |
|
| 2415 |
+ } |
|
| 2416 |
+#endif |
|
| 2417 |
+ } |
|
| 2418 |
+ break; |
|
| 2419 |
+ case 0xa4: /* DUP2k */ |
|
| 2420 |
+ __asm__( "evaluxn_a4_DUP2k:" ); |
|
| 2421 |
+ {
|
|
| 2422 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 2423 |
+ u->wst.dat[u->wst.ptr] = b; |
|
| 2424 |
+ u->wst.dat[u->wst.ptr + 1] = a; |
|
| 2425 |
+ u->wst.dat[u->wst.ptr + 2] = b; |
|
| 2426 |
+ u->wst.dat[u->wst.ptr + 3] = a; |
|
| 2427 |
+#ifndef NO_STACK_CHECKS |
|
| 2428 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2429 |
+ u->wst.error = 1; |
|
| 2430 |
+ goto error; |
|
| 2431 |
+ } |
|
| 2432 |
+ if(__builtin_expect(u->wst.ptr > 251, 0)) {
|
|
| 2433 |
+ u->wst.error = 2; |
|
| 2434 |
+ goto error; |
|
| 2435 |
+ } |
|
| 2436 |
+#endif |
|
| 2437 |
+ u->wst.ptr += 4; |
|
| 2438 |
+ } |
|
| 2439 |
+ break; |
|
| 2440 |
+ case 0xa5: /* SWP2k */ |
|
| 2441 |
+ __asm__( "evaluxn_a5_SWP2k:" ); |
|
| 2442 |
+ {
|
|
| 2443 |
+ 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]; |
|
| 2444 |
+ u->wst.dat[u->wst.ptr] = b; |
|
| 2445 |
+ u->wst.dat[u->wst.ptr + 1] = a; |
|
| 2446 |
+ u->wst.dat[u->wst.ptr + 2] = d; |
|
| 2447 |
+ u->wst.dat[u->wst.ptr + 3] = c; |
|
| 2448 |
+#ifndef NO_STACK_CHECKS |
|
| 2449 |
+ if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 2450 |
+ u->wst.error = 1; |
|
| 2451 |
+ goto error; |
|
| 2452 |
+ } |
|
| 2453 |
+ if(__builtin_expect(u->wst.ptr > 251, 0)) {
|
|
| 2454 |
+ u->wst.error = 2; |
|
| 2455 |
+ goto error; |
|
| 2456 |
+ } |
|
| 2457 |
+#endif |
|
| 2458 |
+ u->wst.ptr += 4; |
|
| 2459 |
+ } |
|
| 2460 |
+ break; |
|
| 2461 |
+ case 0xa6: /* OVR2k */ |
|
| 2462 |
+ __asm__( "evaluxn_a6_OVR2k:" ); |
|
| 2463 |
+ {
|
|
| 2464 |
+ 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]; |
|
| 2465 |
+ u->wst.dat[u->wst.ptr] = d; |
|
| 2466 |
+ u->wst.dat[u->wst.ptr + 1] = c; |
|
| 2467 |
+ u->wst.dat[u->wst.ptr + 2] = b; |
|
| 2468 |
+ u->wst.dat[u->wst.ptr + 3] = a; |
|
| 2469 |
+ u->wst.dat[u->wst.ptr + 4] = d; |
|
| 2470 |
+ u->wst.dat[u->wst.ptr + 5] = c; |
|
| 2471 |
+#ifndef NO_STACK_CHECKS |
|
| 2472 |
+ if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 2473 |
+ u->wst.error = 1; |
|
| 2474 |
+ goto error; |
|
| 2475 |
+ } |
|
| 2476 |
+ if(__builtin_expect(u->wst.ptr > 249, 0)) {
|
|
| 2477 |
+ u->wst.error = 2; |
|
| 2478 |
+ goto error; |
|
| 2479 |
+ } |
|
| 2480 |
+#endif |
|
| 2481 |
+ u->wst.ptr += 6; |
|
| 2482 |
+ } |
|
| 2483 |
+ break; |
|
| 2484 |
+ case 0xa7: /* ROT2k */ |
|
| 2485 |
+ __asm__( "evaluxn_a7_ROT2k:" ); |
|
| 2486 |
+ {
|
|
| 2487 |
+ 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]; |
|
| 2488 |
+ u->wst.dat[u->wst.ptr] = d; |
|
| 2489 |
+ u->wst.dat[u->wst.ptr + 1] = c; |
|
| 2490 |
+ u->wst.dat[u->wst.ptr + 2] = b; |
|
| 2491 |
+ u->wst.dat[u->wst.ptr + 3] = a; |
|
| 2492 |
+ u->wst.dat[u->wst.ptr + 4] = f; |
|
| 2493 |
+ u->wst.dat[u->wst.ptr + 5] = e; |
|
| 2494 |
+#ifndef NO_STACK_CHECKS |
|
| 2495 |
+ if(__builtin_expect(u->wst.ptr < 6, 0)) {
|
|
| 2496 |
+ u->wst.error = 1; |
|
| 2497 |
+ goto error; |
|
| 2498 |
+ } |
|
| 2499 |
+ if(__builtin_expect(u->wst.ptr > 249, 0)) {
|
|
| 2500 |
+ u->wst.error = 2; |
|
| 2501 |
+ goto error; |
|
| 2502 |
+ } |
|
| 2503 |
+#endif |
|
| 2504 |
+ u->wst.ptr += 6; |
|
| 2505 |
+ } |
|
| 2506 |
+ break; |
|
| 2507 |
+ case 0xa8: /* EQU2k */ |
|
| 2508 |
+ __asm__( "evaluxn_a8_EQU2k:" ); |
|
| 2509 |
+ {
|
|
| 2510 |
+ 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)); |
|
| 2511 |
+ u->wst.dat[u->wst.ptr] = b == a; |
|
| 2512 |
+#ifndef NO_STACK_CHECKS |
|
| 2513 |
+ if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 2514 |
+ u->wst.error = 1; |
|
| 2515 |
+ goto error; |
|
| 2516 |
+ } |
|
| 2517 |
+ if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2518 |
+ u->wst.error = 2; |
|
| 2519 |
+ goto error; |
|
| 2520 |
+ } |
|
| 2521 |
+#endif |
|
| 2522 |
+ u->wst.ptr += 1; |
|
| 2523 |
+ } |
|
| 2524 |
+ break; |
|
| 2525 |
+ case 0xa9: /* NEQ2k */ |
|
| 2526 |
+ __asm__( "evaluxn_a9_NEQ2k:" ); |
|
| 2527 |
+ {
|
|
| 2528 |
+ 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)); |
|
| 2529 |
+ u->wst.dat[u->wst.ptr] = b != a; |
|
| 2530 |
+#ifndef NO_STACK_CHECKS |
|
| 2531 |
+ if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 2532 |
+ u->wst.error = 1; |
|
| 2533 |
+ goto error; |
|
| 2534 |
+ } |
|
| 2535 |
+ if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2536 |
+ u->wst.error = 2; |
|
| 2537 |
+ goto error; |
|
| 2538 |
+ } |
|
| 2539 |
+#endif |
|
| 2540 |
+ u->wst.ptr += 1; |
|
| 2541 |
+ } |
|
| 2542 |
+ break; |
|
| 2543 |
+ case 0xaa: /* GTH2k */ |
|
| 2544 |
+ __asm__( "evaluxn_aa_GTH2k:" ); |
|
| 2545 |
+ {
|
|
| 2546 |
+ 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)); |
|
| 2547 |
+ u->wst.dat[u->wst.ptr] = b > a; |
|
| 2548 |
+#ifndef NO_STACK_CHECKS |
|
| 2549 |
+ if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 2550 |
+ u->wst.error = 1; |
|
| 2551 |
+ goto error; |
|
| 2552 |
+ } |
|
| 2553 |
+ if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2554 |
+ u->wst.error = 2; |
|
| 2555 |
+ goto error; |
|
| 2556 |
+ } |
|
| 2557 |
+#endif |
|
| 2558 |
+ u->wst.ptr += 1; |
|
| 2559 |
+ } |
|
| 2560 |
+ break; |
|
| 2561 |
+ case 0xab: /* LTH2k */ |
|
| 2562 |
+ __asm__( "evaluxn_ab_LTH2k:" ); |
|
| 2563 |
+ {
|
|
| 2564 |
+ 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)); |
|
| 2565 |
+ u->wst.dat[u->wst.ptr] = b < a; |
|
| 2566 |
+#ifndef NO_STACK_CHECKS |
|
| 2567 |
+ if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 2568 |
+ u->wst.error = 1; |
|
| 2569 |
+ goto error; |
|
| 2570 |
+ } |
|
| 2571 |
+ if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 2572 |
+ u->wst.error = 2; |
|
| 2573 |
+ goto error; |
|
| 2574 |
+ } |
|
| 2575 |
+#endif |
|
| 2576 |
+ u->wst.ptr += 1; |
|
| 2577 |
+ } |
|
| 2578 |
+ break; |
|
| 2579 |
+ case 0xac: /* JMP2k */ |
|
| 2580 |
+ __asm__( "evaluxn_ac_JMP2k:" ); |
|
| 2581 |
+ {
|
|
| 2582 |
+ u->ram.ptr = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 2583 |
+#ifndef NO_STACK_CHECKS |
|
| 2584 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2585 |
+ u->wst.error = 1; |
|
| 2586 |
+ goto error; |
|
| 2587 |
+ } |
|
| 2588 |
+#endif |
|
| 2589 |
+ } |
|
| 2590 |
+ break; |
|
| 2591 |
+ case 0xad: /* JCN2k */ |
|
| 2592 |
+ __asm__( "evaluxn_ad_JCN2k:" ); |
|
| 2593 |
+ {
|
|
| 2594 |
+ Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 2595 |
+ if(u->wst.dat[u->wst.ptr - 3]) u->ram.ptr = a; |
|
| 2596 |
+#ifndef NO_STACK_CHECKS |
|
| 2597 |
+ if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
| 2598 |
+ u->wst.error = 1; |
|
| 2599 |
+ goto error; |
|
| 2600 |
+ } |
|
| 2601 |
+#endif |
|
| 2602 |
+ } |
|
| 2603 |
+ break; |
|
| 2604 |
+ case 0xae: /* JSR2k */ |
|
| 2605 |
+ __asm__( "evaluxn_ae_JSR2k:" ); |
|
| 2606 |
+ {
|
|
| 2607 |
+ u->rst.dat[u->rst.ptr] = u->ram.ptr >> 8; |
|
| 2608 |
+ u->rst.dat[u->rst.ptr + 1] = u->ram.ptr & 0xff; |
|
| 2609 |
+ u->ram.ptr = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 2610 |
+#ifndef NO_STACK_CHECKS |
|
| 2611 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2612 |
+ u->wst.error = 1; |
|
| 2613 |
+ goto error; |
|
| 2614 |
+ } |
|
| 2615 |
+ if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 2616 |
+ u->rst.error = 2; |
|
| 2617 |
+ goto error; |
|
| 2618 |
+ } |
|
| 2619 |
+#endif |
|
| 2620 |
+ u->rst.ptr += 2; |
|
| 2621 |
+ } |
|
| 2622 |
+ break; |
|
| 2623 |
+ case 0xaf: /* STH2k */ |
|
| 2624 |
+ __asm__( "evaluxn_af_STH2k:" ); |
|
| 2625 |
+ {
|
|
| 2626 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1], b = u->wst.dat[u->wst.ptr - 2]; |
|
| 2627 |
+ u->rst.dat[u->rst.ptr] = b; |
|
| 2628 |
+ u->rst.dat[u->rst.ptr + 1] = a; |
|
| 2629 |
+#ifndef NO_STACK_CHECKS |
|
| 2630 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2631 |
+ u->wst.error = 1; |
|
| 2632 |
+ goto error; |
|
| 2633 |
+ } |
|
| 2634 |
+ if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 2635 |
+ u->rst.error = 2; |
|
| 2636 |
+ goto error; |
|
| 2637 |
+ } |
|
| 2638 |
+#endif |
|
| 2639 |
+ u->rst.ptr += 2; |
|
| 2640 |
+ } |
|
| 2641 |
+ break; |
|
| 2642 |
+ case 0xb0: /* LDZ2k */ |
|
| 2643 |
+ __asm__( "evaluxn_b0_LDZ2k:" ); |
|
| 2644 |
+ {
|
|
| 2645 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 2646 |
+ u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, a); |
|
| 2647 |
+ u->wst.dat[u->wst.ptr + 1] = mempeek8(u->ram.dat, a + 1); |
|
| 2648 |
+#ifndef NO_STACK_CHECKS |
|
| 2649 |
+ if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 2650 |
+ u->wst.error = 1; |
|
| 2651 |
+ goto error; |
|
| 2652 |
+ } |
|
| 2653 |
+ if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 2654 |
+ u->wst.error = 2; |
|
| 2655 |
+ goto error; |
|
| 2656 |
+ } |
|
| 2657 |
+#endif |
|
| 2658 |
+ u->wst.ptr += 2; |
|
| 2659 |
+ } |
|
| 2660 |
+ break; |
|
| 2661 |
+ case 0xb1: /* STZ2k */ |
|
| 2662 |
+ __asm__( "evaluxn_b1_STZ2k:" ); |
|
| 2663 |
+ {
|
|
| 2664 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 2665 |
+ Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); |
|
| 2666 |
+ mempoke16(u->ram.dat, a, b); |
|
| 2667 |
+#ifndef NO_STACK_CHECKS |
|
| 2668 |
+ if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
| 2669 |
+ u->wst.error = 1; |
|
| 2670 |
+ goto error; |
|
| 2671 |
+ } |
|
| 2672 |
+#endif |
|
| 2673 |
+ } |
|
| 2674 |
+ break; |
|
| 2675 |
+ case 0xb2: /* LDR2k */ |
|
| 2676 |
+ __asm__( "evaluxn_b2_LDR2k:" ); |
|
| 2677 |
+ {
|
|
| 2678 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 2679 |
+ u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a); |
|
| 2680 |
+ u->wst.dat[u->wst.ptr + 1] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a + 1); |
|
| 2681 |
+#ifndef NO_STACK_CHECKS |
|
| 2682 |
+ if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 2683 |
+ u->wst.error = 1; |
|
| 2684 |
+ goto error; |
|
| 2685 |
+ } |
|
| 2686 |
+ if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 2687 |
+ u->wst.error = 2; |
|
| 2688 |
+ goto error; |
|
| 2689 |
+ } |
|
| 2690 |
+#endif |
|
| 2691 |
+ u->wst.ptr += 2; |
|
| 2692 |
+ } |
|
| 2693 |
+ break; |
|
| 2694 |
+ case 0xb3: /* STR2k */ |
|
| 2695 |
+ __asm__( "evaluxn_b3_STR2k:" ); |
|
| 2696 |
+ {
|
|
| 2697 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 2698 |
+ Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); |
|
| 2699 |
+ mempoke16(u->ram.dat, u->ram.ptr + (Sint8)a, b); |
|
| 2700 |
+#ifndef NO_STACK_CHECKS |
|
| 2701 |
+ if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
| 2702 |
+ u->wst.error = 1; |
|
| 2703 |
+ goto error; |
|
| 2704 |
+ } |
|
| 2705 |
+#endif |
|
| 2706 |
+ } |
|
| 2707 |
+ break; |
|
| 2708 |
+ case 0xb4: /* LDA2k */ |
|
| 2709 |
+ __asm__( "evaluxn_b4_LDA2k:" ); |
|
| 2710 |
+ {
|
|
| 2711 |
+ Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 2712 |
+ u->wst.dat[u->wst.ptr] = mempeek8(u->ram.dat, a); |
|
| 2713 |
+ u->wst.dat[u->wst.ptr + 1] = mempeek8(u->ram.dat, a + 1); |
|
| 2714 |
+#ifndef NO_STACK_CHECKS |
|
| 2715 |
+ if(__builtin_expect(u->wst.ptr < 2, 0)) {
|
|
| 2716 |
+ u->wst.error = 1; |
|
| 2717 |
+ goto error; |
|
| 2718 |
+ } |
|
| 2719 |
+ if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 2720 |
+ u->wst.error = 2; |
|
| 2721 |
+ goto error; |
|
| 2722 |
+ } |
|
| 2723 |
+#endif |
|
| 2724 |
+ u->wst.ptr += 2; |
|
| 2725 |
+ } |
|
| 2726 |
+ break; |
|
| 2727 |
+ case 0xb5: /* STA2k */ |
|
| 2728 |
+ __asm__( "evaluxn_b5_STA2k:" ); |
|
| 2729 |
+ {
|
|
| 2730 |
+ Uint16 a = (u->wst.dat[u->wst.ptr - 1] | (u->wst.dat[u->wst.ptr - 2] << 8)); |
|
| 2731 |
+ Uint16 b = (u->wst.dat[u->wst.ptr - 3] | (u->wst.dat[u->wst.ptr - 4] << 8)); |
|
| 2732 |
+ mempoke16(u->ram.dat, a, b); |
|
| 2733 |
+#ifndef NO_STACK_CHECKS |
|
| 2734 |
+ if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 2735 |
+ u->wst.error = 1; |
|
| 2736 |
+ goto error; |
|
| 2737 |
+ } |
|
| 2738 |
+#endif |
|
| 2739 |
+ } |
|
| 2740 |
+ break; |
|
| 2741 |
+ case 0xb6: /* DEI2k */ |
|
| 2742 |
+ __asm__( "evaluxn_b6_DEI2k:" ); |
|
| 2743 |
+ {
|
|
| 2744 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 2745 |
+ u->wst.dat[u->wst.ptr] = devpeek8(&u->dev[a >> 4], a); |
|
| 2746 |
+ u->wst.dat[u->wst.ptr + 1] = devpeek8(&u->dev[a >> 4], a + 1); |
|
| 2747 |
+#ifndef NO_STACK_CHECKS |
|
| 2748 |
+ if(__builtin_expect(u->wst.ptr < 1, 0)) {
|
|
| 2749 |
+ u->wst.error = 1; |
|
| 2750 |
+ goto error; |
|
| 2751 |
+ } |
|
| 2752 |
+ if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 2753 |
+ u->wst.error = 2; |
|
| 2754 |
+ goto error; |
|
| 2755 |
+ } |
|
| 2756 |
+#endif |
|
| 2757 |
+ u->wst.ptr += 2; |
|
| 2758 |
+ } |
|
| 2759 |
+ break; |
|
| 2760 |
+ case 0xb7: /* DEO2k */ |
|
| 2761 |
+ __asm__( "evaluxn_b7_DEO2k:" ); |
|
| 2762 |
+ {
|
|
| 2763 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 2764 |
+ Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); |
|
| 2765 |
+ devpoke16(&u->dev[a >> 4], a, b); |
|
| 2766 |
+#ifndef NO_STACK_CHECKS |
|
| 2767 |
+ if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
| 2768 |
+ u->wst.error = 1; |
|
| 2769 |
+ goto error; |
|
| 2770 |
+ } |
|
| 2771 |
+#endif |
|
| 2772 |
+ } |
|
| 2773 |
+ break; |
|
| 2774 |
+ case 0xb8: /* ADD2k */ |
|
| 2775 |
+ __asm__( "evaluxn_b8_ADD2k:" ); |
|
| 2776 |
+ {
|
|
| 2777 |
+ 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)); |
|
| 2778 |
+ u->wst.dat[u->wst.ptr] = (b + a) >> 8; |
|
| 2779 |
+ u->wst.dat[u->wst.ptr + 1] = (b + a) & 0xff; |
|
| 2780 |
+#ifndef NO_STACK_CHECKS |
|
| 2781 |
+ if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 2782 |
+ u->wst.error = 1; |
|
| 2783 |
+ goto error; |
|
| 2784 |
+ } |
|
| 2785 |
+ if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 2786 |
+ u->wst.error = 2; |
|
| 2787 |
+ goto error; |
|
| 2788 |
+ } |
|
| 2789 |
+#endif |
|
| 2790 |
+ u->wst.ptr += 2; |
|
| 2791 |
+ } |
|
| 2792 |
+ break; |
|
| 2793 |
+ case 0xb9: /* SUB2k */ |
|
| 2794 |
+ __asm__( "evaluxn_b9_SUB2k:" ); |
|
| 2795 |
+ {
|
|
| 2796 |
+ 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)); |
|
| 2797 |
+ u->wst.dat[u->wst.ptr] = (b - a) >> 8; |
|
| 2798 |
+ u->wst.dat[u->wst.ptr + 1] = (b - a) & 0xff; |
|
| 2799 |
+#ifndef NO_STACK_CHECKS |
|
| 2800 |
+ if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 2801 |
+ u->wst.error = 1; |
|
| 2802 |
+ goto error; |
|
| 2803 |
+ } |
|
| 2804 |
+ if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 2805 |
+ u->wst.error = 2; |
|
| 2806 |
+ goto error; |
|
| 2807 |
+ } |
|
| 2808 |
+#endif |
|
| 2809 |
+ u->wst.ptr += 2; |
|
| 2810 |
+ } |
|
| 2811 |
+ break; |
|
| 2812 |
+ case 0xba: /* MUL2k */ |
|
| 2813 |
+ __asm__( "evaluxn_ba_MUL2k:" ); |
|
| 2814 |
+ {
|
|
| 2815 |
+ 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)); |
|
| 2816 |
+ u->wst.dat[u->wst.ptr] = (b * a) >> 8; |
|
| 2817 |
+ u->wst.dat[u->wst.ptr + 1] = (b * a) & 0xff; |
|
| 2818 |
+#ifndef NO_STACK_CHECKS |
|
| 2819 |
+ if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 2820 |
+ u->wst.error = 1; |
|
| 2821 |
+ goto error; |
|
| 2822 |
+ } |
|
| 2823 |
+ if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 2824 |
+ u->wst.error = 2; |
|
| 2825 |
+ goto error; |
|
| 2826 |
+ } |
|
| 2827 |
+#endif |
|
| 2828 |
+ u->wst.ptr += 2; |
|
| 2829 |
+ } |
|
| 2830 |
+ break; |
|
| 2831 |
+ case 0xbb: /* DIV2k */ |
|
| 2832 |
+ __asm__( "evaluxn_bb_DIV2k:" ); |
|
| 2833 |
+ {
|
|
| 2834 |
+ 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)); |
|
| 2835 |
+ u->wst.dat[u->wst.ptr] = (b / a) >> 8; |
|
| 2836 |
+ u->wst.dat[u->wst.ptr + 1] = (b / a) & 0xff; |
|
| 2837 |
+#ifndef NO_STACK_CHECKS |
|
| 2838 |
+ if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 2839 |
+ u->wst.error = 1; |
|
| 2840 |
+ goto error; |
|
| 2841 |
+ } |
|
| 2842 |
+ if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 2843 |
+ u->wst.error = 2; |
|
| 2844 |
+ goto error; |
|
| 2845 |
+ } |
|
| 2846 |
+#endif |
|
| 2847 |
+ u->wst.ptr += 2; |
|
| 2848 |
+ } |
|
| 2849 |
+ break; |
|
| 2850 |
+ case 0xbc: /* AND2k */ |
|
| 2851 |
+ __asm__( "evaluxn_bc_AND2k:" ); |
|
| 2852 |
+ {
|
|
| 2853 |
+ 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]; |
|
| 2854 |
+ u->wst.dat[u->wst.ptr] = d & b; |
|
| 2855 |
+ u->wst.dat[u->wst.ptr + 1] = c & a; |
|
| 2856 |
+#ifndef NO_STACK_CHECKS |
|
| 2857 |
+ if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 2858 |
+ u->wst.error = 1; |
|
| 2859 |
+ goto error; |
|
| 2860 |
+ } |
|
| 2861 |
+ if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 2862 |
+ u->wst.error = 2; |
|
| 2863 |
+ goto error; |
|
| 2864 |
+ } |
|
| 2865 |
+#endif |
|
| 2866 |
+ u->wst.ptr += 2; |
|
| 2867 |
+ } |
|
| 2868 |
+ break; |
|
| 2869 |
+ case 0xbd: /* ORA2k */ |
|
| 2870 |
+ __asm__( "evaluxn_bd_ORA2k:" ); |
|
| 2871 |
+ {
|
|
| 2872 |
+ 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]; |
|
| 2873 |
+ u->wst.dat[u->wst.ptr] = d | b; |
|
| 2874 |
+ u->wst.dat[u->wst.ptr + 1] = c | a; |
|
| 2875 |
+#ifndef NO_STACK_CHECKS |
|
| 2876 |
+ if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 2877 |
+ u->wst.error = 1; |
|
| 2878 |
+ goto error; |
|
| 2879 |
+ } |
|
| 2880 |
+ if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 2881 |
+ u->wst.error = 2; |
|
| 2882 |
+ goto error; |
|
| 2883 |
+ } |
|
| 2884 |
+#endif |
|
| 2885 |
+ u->wst.ptr += 2; |
|
| 2886 |
+ } |
|
| 2887 |
+ break; |
|
| 2888 |
+ case 0xbe: /* EOR2k */ |
|
| 2889 |
+ __asm__( "evaluxn_be_EOR2k:" ); |
|
| 2890 |
+ {
|
|
| 2891 |
+ 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]; |
|
| 2892 |
+ u->wst.dat[u->wst.ptr] = d ^ b; |
|
| 2893 |
+ u->wst.dat[u->wst.ptr + 1] = c ^ a; |
|
| 2894 |
+#ifndef NO_STACK_CHECKS |
|
| 2895 |
+ if(__builtin_expect(u->wst.ptr < 4, 0)) {
|
|
| 2896 |
+ u->wst.error = 1; |
|
| 2897 |
+ goto error; |
|
| 2898 |
+ } |
|
| 2899 |
+ if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 2900 |
+ u->wst.error = 2; |
|
| 2901 |
+ goto error; |
|
| 2902 |
+ } |
|
| 2903 |
+#endif |
|
| 2904 |
+ u->wst.ptr += 2; |
|
| 2905 |
+ } |
|
| 2906 |
+ break; |
|
| 2907 |
+ case 0xbf: /* SFT2k */ |
|
| 2908 |
+ __asm__( "evaluxn_bf_SFT2k:" ); |
|
| 2909 |
+ {
|
|
| 2910 |
+ Uint8 a = u->wst.dat[u->wst.ptr - 1]; |
|
| 2911 |
+ Uint16 b = (u->wst.dat[u->wst.ptr - 2] | (u->wst.dat[u->wst.ptr - 3] << 8)); |
|
| 2912 |
+ u->wst.dat[u->wst.ptr] = (b >> (a & 0x0f) << ((a & 0xf0) >> 4)) >> 8; |
|
| 2913 |
+ u->wst.dat[u->wst.ptr + 1] = (b >> (a & 0x0f) << ((a & 0xf0) >> 4)) & 0xff; |
|
| 2914 |
+#ifndef NO_STACK_CHECKS |
|
| 2915 |
+ if(__builtin_expect(u->wst.ptr < 3, 0)) {
|
|
| 2916 |
+ u->wst.error = 1; |
|
| 2917 |
+ goto error; |
|
| 2918 |
+ } |
|
| 2919 |
+ if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 2920 |
+ u->wst.error = 2; |
|
| 2921 |
+ goto error; |
|
| 2922 |
+ } |
|
| 2923 |
+#endif |
|
| 2924 |
+ u->wst.ptr += 2; |
|
| 2925 |
+ } |
|
| 2926 |
+ break; |
|
| 2927 |
+ case 0xc3: /* POPkr */ |
|
| 2928 |
+ __asm__( "evaluxn_c3_POPkr:" ); |
|
| 2929 |
+ {
|
|
| 2930 |
+ u->rst.dat[u->rst.ptr - 1]; |
|
| 2931 |
+#ifndef NO_STACK_CHECKS |
|
| 2932 |
+ if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 2933 |
+ u->rst.error = 1; |
|
| 2934 |
+ goto error; |
|
| 2935 |
+ } |
|
| 2936 |
+#endif |
|
| 2937 |
+ } |
|
| 2938 |
+ break; |
|
| 2939 |
+ case 0xc4: /* DUPkr */ |
|
| 2940 |
+ __asm__( "evaluxn_c4_DUPkr:" ); |
|
| 2941 |
+ {
|
|
| 2942 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 2943 |
+ u->rst.dat[u->rst.ptr] = a; |
|
| 2944 |
+ u->rst.dat[u->rst.ptr + 1] = a; |
|
| 2945 |
+#ifndef NO_STACK_CHECKS |
|
| 2946 |
+ if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 2947 |
+ u->rst.error = 1; |
|
| 2948 |
+ goto error; |
|
| 2949 |
+ } |
|
| 2950 |
+ if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 2951 |
+ u->rst.error = 2; |
|
| 2952 |
+ goto error; |
|
| 2953 |
+ } |
|
| 2954 |
+#endif |
|
| 2955 |
+ u->rst.ptr += 2; |
|
| 2956 |
+ } |
|
| 2957 |
+ break; |
|
| 2958 |
+ case 0xc5: /* SWPkr */ |
|
| 2959 |
+ __asm__( "evaluxn_c5_SWPkr:" ); |
|
| 2960 |
+ {
|
|
| 2961 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 2962 |
+ u->rst.dat[u->rst.ptr] = a; |
|
| 2963 |
+ u->rst.dat[u->rst.ptr + 1] = b; |
|
| 2964 |
+#ifndef NO_STACK_CHECKS |
|
| 2965 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 2966 |
+ u->rst.error = 1; |
|
| 2967 |
+ goto error; |
|
| 2968 |
+ } |
|
| 2969 |
+ if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 2970 |
+ u->rst.error = 2; |
|
| 2971 |
+ goto error; |
|
| 2972 |
+ } |
|
| 2973 |
+#endif |
|
| 2974 |
+ u->rst.ptr += 2; |
|
| 2975 |
+ } |
|
| 2976 |
+ break; |
|
| 2977 |
+ case 0xc6: /* OVRkr */ |
|
| 2978 |
+ __asm__( "evaluxn_c6_OVRkr:" ); |
|
| 2979 |
+ {
|
|
| 2980 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 2981 |
+ u->rst.dat[u->rst.ptr] = b; |
|
| 2982 |
+ u->rst.dat[u->rst.ptr + 1] = a; |
|
| 2983 |
+ u->rst.dat[u->rst.ptr + 2] = b; |
|
| 2984 |
+#ifndef NO_STACK_CHECKS |
|
| 2985 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 2986 |
+ u->rst.error = 1; |
|
| 2987 |
+ goto error; |
|
| 2988 |
+ } |
|
| 2989 |
+ if(__builtin_expect(u->rst.ptr > 252, 0)) {
|
|
| 2990 |
+ u->rst.error = 2; |
|
| 2991 |
+ goto error; |
|
| 2992 |
+ } |
|
| 2993 |
+#endif |
|
| 2994 |
+ u->rst.ptr += 3; |
|
| 2995 |
+ } |
|
| 2996 |
+ break; |
|
| 2997 |
+ case 0xc7: /* ROTkr */ |
|
| 2998 |
+ __asm__( "evaluxn_c7_ROTkr:" ); |
|
| 2999 |
+ {
|
|
| 3000 |
+ 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]; |
|
| 3001 |
+ u->rst.dat[u->rst.ptr] = b; |
|
| 3002 |
+ u->rst.dat[u->rst.ptr + 1] = a; |
|
| 3003 |
+ u->rst.dat[u->rst.ptr + 2] = c; |
|
| 3004 |
+#ifndef NO_STACK_CHECKS |
|
| 3005 |
+ if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
| 3006 |
+ u->rst.error = 1; |
|
| 3007 |
+ goto error; |
|
| 3008 |
+ } |
|
| 3009 |
+ if(__builtin_expect(u->rst.ptr > 252, 0)) {
|
|
| 3010 |
+ u->rst.error = 2; |
|
| 3011 |
+ goto error; |
|
| 3012 |
+ } |
|
| 3013 |
+#endif |
|
| 3014 |
+ u->rst.ptr += 3; |
|
| 3015 |
+ } |
|
| 3016 |
+ break; |
|
| 3017 |
+ case 0xc8: /* EQUkr */ |
|
| 3018 |
+ __asm__( "evaluxn_c8_EQUkr:" ); |
|
| 3019 |
+ {
|
|
| 3020 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3021 |
+ u->rst.dat[u->rst.ptr] = b == a; |
|
| 3022 |
+#ifndef NO_STACK_CHECKS |
|
| 3023 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3024 |
+ u->rst.error = 1; |
|
| 3025 |
+ goto error; |
|
| 3026 |
+ } |
|
| 3027 |
+ if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3028 |
+ u->rst.error = 2; |
|
| 3029 |
+ goto error; |
|
| 3030 |
+ } |
|
| 3031 |
+#endif |
|
| 3032 |
+ u->rst.ptr += 1; |
|
| 3033 |
+ } |
|
| 3034 |
+ break; |
|
| 3035 |
+ case 0xc9: /* NEQkr */ |
|
| 3036 |
+ __asm__( "evaluxn_c9_NEQkr:" ); |
|
| 3037 |
+ {
|
|
| 3038 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3039 |
+ u->rst.dat[u->rst.ptr] = b != a; |
|
| 3040 |
+#ifndef NO_STACK_CHECKS |
|
| 3041 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3042 |
+ u->rst.error = 1; |
|
| 3043 |
+ goto error; |
|
| 3044 |
+ } |
|
| 3045 |
+ if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3046 |
+ u->rst.error = 2; |
|
| 3047 |
+ goto error; |
|
| 3048 |
+ } |
|
| 3049 |
+#endif |
|
| 3050 |
+ u->rst.ptr += 1; |
|
| 3051 |
+ } |
|
| 3052 |
+ break; |
|
| 3053 |
+ case 0xca: /* GTHkr */ |
|
| 3054 |
+ __asm__( "evaluxn_ca_GTHkr:" ); |
|
| 3055 |
+ {
|
|
| 3056 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3057 |
+ u->rst.dat[u->rst.ptr] = b > a; |
|
| 3058 |
+#ifndef NO_STACK_CHECKS |
|
| 3059 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3060 |
+ u->rst.error = 1; |
|
| 3061 |
+ goto error; |
|
| 3062 |
+ } |
|
| 3063 |
+ if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3064 |
+ u->rst.error = 2; |
|
| 3065 |
+ goto error; |
|
| 3066 |
+ } |
|
| 3067 |
+#endif |
|
| 3068 |
+ u->rst.ptr += 1; |
|
| 3069 |
+ } |
|
| 3070 |
+ break; |
|
| 3071 |
+ case 0xcb: /* LTHkr */ |
|
| 3072 |
+ __asm__( "evaluxn_cb_LTHkr:" ); |
|
| 3073 |
+ {
|
|
| 3074 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3075 |
+ u->rst.dat[u->rst.ptr] = b < a; |
|
| 3076 |
+#ifndef NO_STACK_CHECKS |
|
| 3077 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3078 |
+ u->rst.error = 1; |
|
| 3079 |
+ goto error; |
|
| 3080 |
+ } |
|
| 3081 |
+ if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3082 |
+ u->rst.error = 2; |
|
| 3083 |
+ goto error; |
|
| 3084 |
+ } |
|
| 3085 |
+#endif |
|
| 3086 |
+ u->rst.ptr += 1; |
|
| 3087 |
+ } |
|
| 3088 |
+ break; |
|
| 3089 |
+ case 0xcc: /* JMPkr */ |
|
| 3090 |
+ __asm__( "evaluxn_cc_JMPkr:" ); |
|
| 3091 |
+ {
|
|
| 3092 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 3093 |
+ u->ram.ptr += (Sint8)a; |
|
| 3094 |
+#ifndef NO_STACK_CHECKS |
|
| 3095 |
+ if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 3096 |
+ u->rst.error = 1; |
|
| 3097 |
+ goto error; |
|
| 3098 |
+ } |
|
| 3099 |
+#endif |
|
| 3100 |
+ } |
|
| 3101 |
+ break; |
|
| 3102 |
+ case 0xcd: /* JCNkr */ |
|
| 3103 |
+ __asm__( "evaluxn_cd_JCNkr:" ); |
|
| 3104 |
+ {
|
|
| 3105 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 3106 |
+ if(u->rst.dat[u->rst.ptr - 2]) u->ram.ptr += (Sint8)a; |
|
| 3107 |
+#ifndef NO_STACK_CHECKS |
|
| 3108 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3109 |
+ u->rst.error = 1; |
|
| 3110 |
+ goto error; |
|
| 3111 |
+ } |
|
| 3112 |
+#endif |
|
| 3113 |
+ } |
|
| 3114 |
+ break; |
|
| 3115 |
+ case 0xce: /* JSRkr */ |
|
| 3116 |
+ __asm__( "evaluxn_ce_JSRkr:" ); |
|
| 3117 |
+ {
|
|
| 3118 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 3119 |
+ u->wst.dat[u->wst.ptr] = u->ram.ptr >> 8; |
|
| 3120 |
+ u->wst.dat[u->wst.ptr + 1] = u->ram.ptr & 0xff; |
|
| 3121 |
+ u->ram.ptr += (Sint8)a; |
|
| 3122 |
+#ifndef NO_STACK_CHECKS |
|
| 3123 |
+ if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 3124 |
+ u->rst.error = 1; |
|
| 3125 |
+ goto error; |
|
| 3126 |
+ } |
|
| 3127 |
+ if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 3128 |
+ u->wst.error = 2; |
|
| 3129 |
+ goto error; |
|
| 3130 |
+ } |
|
| 3131 |
+#endif |
|
| 3132 |
+ u->wst.ptr += 2; |
|
| 3133 |
+ } |
|
| 3134 |
+ break; |
|
| 3135 |
+ case 0xcf: /* STHkr */ |
|
| 3136 |
+ __asm__( "evaluxn_cf_STHkr:" ); |
|
| 3137 |
+ {
|
|
| 3138 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 3139 |
+ u->wst.dat[u->wst.ptr] = a; |
|
| 3140 |
+#ifndef NO_STACK_CHECKS |
|
| 3141 |
+ if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 3142 |
+ u->rst.error = 1; |
|
| 3143 |
+ goto error; |
|
| 3144 |
+ } |
|
| 3145 |
+ if(__builtin_expect(u->wst.ptr > 254, 0)) {
|
|
| 3146 |
+ u->wst.error = 2; |
|
| 3147 |
+ goto error; |
|
| 3148 |
+ } |
|
| 3149 |
+#endif |
|
| 3150 |
+ u->wst.ptr += 1; |
|
| 3151 |
+ } |
|
| 3152 |
+ break; |
|
| 3153 |
+ case 0xd0: /* LDZkr */ |
|
| 3154 |
+ __asm__( "evaluxn_d0_LDZkr:" ); |
|
| 3155 |
+ {
|
|
| 3156 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 3157 |
+ u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, a); |
|
| 3158 |
+#ifndef NO_STACK_CHECKS |
|
| 3159 |
+ if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 3160 |
+ u->rst.error = 1; |
|
| 3161 |
+ goto error; |
|
| 3162 |
+ } |
|
| 3163 |
+ if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3164 |
+ u->rst.error = 2; |
|
| 3165 |
+ goto error; |
|
| 3166 |
+ } |
|
| 3167 |
+#endif |
|
| 3168 |
+ u->rst.ptr += 1; |
|
| 3169 |
+ } |
|
| 3170 |
+ break; |
|
| 3171 |
+ case 0xd1: /* STZkr */ |
|
| 3172 |
+ __asm__( "evaluxn_d1_STZkr:" ); |
|
| 3173 |
+ {
|
|
| 3174 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 3175 |
+ Uint8 b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3176 |
+ mempoke8(u->ram.dat, a, b); |
|
| 3177 |
+#ifndef NO_STACK_CHECKS |
|
| 3178 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3179 |
+ u->rst.error = 1; |
|
| 3180 |
+ goto error; |
|
| 3181 |
+ } |
|
| 3182 |
+#endif |
|
| 3183 |
+ } |
|
| 3184 |
+ break; |
|
| 3185 |
+ case 0xd2: /* LDRkr */ |
|
| 3186 |
+ __asm__( "evaluxn_d2_LDRkr:" ); |
|
| 3187 |
+ {
|
|
| 3188 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 3189 |
+ u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a); |
|
| 3190 |
+#ifndef NO_STACK_CHECKS |
|
| 3191 |
+ if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 3192 |
+ u->rst.error = 1; |
|
| 3193 |
+ goto error; |
|
| 3194 |
+ } |
|
| 3195 |
+ if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3196 |
+ u->rst.error = 2; |
|
| 3197 |
+ goto error; |
|
| 3198 |
+ } |
|
| 3199 |
+#endif |
|
| 3200 |
+ u->rst.ptr += 1; |
|
| 3201 |
+ } |
|
| 3202 |
+ break; |
|
| 3203 |
+ case 0xd3: /* STRkr */ |
|
| 3204 |
+ __asm__( "evaluxn_d3_STRkr:" ); |
|
| 3205 |
+ {
|
|
| 3206 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 3207 |
+ Uint8 b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3208 |
+ mempoke8(u->ram.dat, u->ram.ptr + (Sint8)a, b); |
|
| 3209 |
+#ifndef NO_STACK_CHECKS |
|
| 3210 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3211 |
+ u->rst.error = 1; |
|
| 3212 |
+ goto error; |
|
| 3213 |
+ } |
|
| 3214 |
+#endif |
|
| 3215 |
+ } |
|
| 3216 |
+ break; |
|
| 3217 |
+ case 0xd4: /* LDAkr */ |
|
| 3218 |
+ __asm__( "evaluxn_d4_LDAkr:" ); |
|
| 3219 |
+ {
|
|
| 3220 |
+ Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 3221 |
+ u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, a); |
|
| 3222 |
+#ifndef NO_STACK_CHECKS |
|
| 3223 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3224 |
+ u->rst.error = 1; |
|
| 3225 |
+ goto error; |
|
| 3226 |
+ } |
|
| 3227 |
+ if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3228 |
+ u->rst.error = 2; |
|
| 3229 |
+ goto error; |
|
| 3230 |
+ } |
|
| 3231 |
+#endif |
|
| 3232 |
+ u->rst.ptr += 1; |
|
| 3233 |
+ } |
|
| 3234 |
+ break; |
|
| 3235 |
+ case 0xd5: /* STAkr */ |
|
| 3236 |
+ __asm__( "evaluxn_d5_STAkr:" ); |
|
| 3237 |
+ {
|
|
| 3238 |
+ Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 3239 |
+ Uint8 b = u->rst.dat[u->rst.ptr - 3]; |
|
| 3240 |
+ mempoke8(u->ram.dat, a, b); |
|
| 3241 |
+#ifndef NO_STACK_CHECKS |
|
| 3242 |
+ if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
| 3243 |
+ u->rst.error = 1; |
|
| 3244 |
+ goto error; |
|
| 3245 |
+ } |
|
| 3246 |
+#endif |
|
| 3247 |
+ } |
|
| 3248 |
+ break; |
|
| 3249 |
+ case 0xd6: /* DEIkr */ |
|
| 3250 |
+ __asm__( "evaluxn_d6_DEIkr:" ); |
|
| 3251 |
+ {
|
|
| 3252 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 3253 |
+ u->rst.dat[u->rst.ptr] = devpeek8(&u->dev[a >> 4], a); |
|
| 3254 |
+#ifndef NO_STACK_CHECKS |
|
| 3255 |
+ if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 3256 |
+ u->rst.error = 1; |
|
| 3257 |
+ goto error; |
|
| 3258 |
+ } |
|
| 3259 |
+ if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3260 |
+ u->rst.error = 2; |
|
| 3261 |
+ goto error; |
|
| 3262 |
+ } |
|
| 3263 |
+#endif |
|
| 3264 |
+ u->rst.ptr += 1; |
|
| 3265 |
+ } |
|
| 3266 |
+ break; |
|
| 3267 |
+ case 0xd7: /* DEOkr */ |
|
| 3268 |
+ __asm__( "evaluxn_d7_DEOkr:" ); |
|
| 3269 |
+ {
|
|
| 3270 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3271 |
+ devpoke8(&u->dev[a >> 4], a, b); |
|
| 3272 |
+#ifndef NO_STACK_CHECKS |
|
| 3273 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3274 |
+ u->rst.error = 1; |
|
| 3275 |
+ goto error; |
|
| 3276 |
+ } |
|
| 3277 |
+#endif |
|
| 3278 |
+ } |
|
| 3279 |
+ break; |
|
| 3280 |
+ case 0xd8: /* ADDkr */ |
|
| 3281 |
+ __asm__( "evaluxn_d8_ADDkr:" ); |
|
| 3282 |
+ {
|
|
| 3283 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3284 |
+ u->rst.dat[u->rst.ptr] = b + a; |
|
| 3285 |
+#ifndef NO_STACK_CHECKS |
|
| 3286 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3287 |
+ u->rst.error = 1; |
|
| 3288 |
+ goto error; |
|
| 3289 |
+ } |
|
| 3290 |
+ if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3291 |
+ u->rst.error = 2; |
|
| 3292 |
+ goto error; |
|
| 3293 |
+ } |
|
| 3294 |
+#endif |
|
| 3295 |
+ u->rst.ptr += 1; |
|
| 3296 |
+ } |
|
| 3297 |
+ break; |
|
| 3298 |
+ case 0xd9: /* SUBkr */ |
|
| 3299 |
+ __asm__( "evaluxn_d9_SUBkr:" ); |
|
| 3300 |
+ {
|
|
| 3301 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3302 |
+ u->rst.dat[u->rst.ptr] = b - a; |
|
| 3303 |
+#ifndef NO_STACK_CHECKS |
|
| 3304 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3305 |
+ u->rst.error = 1; |
|
| 3306 |
+ goto error; |
|
| 3307 |
+ } |
|
| 3308 |
+ if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3309 |
+ u->rst.error = 2; |
|
| 3310 |
+ goto error; |
|
| 3311 |
+ } |
|
| 3312 |
+#endif |
|
| 3313 |
+ u->rst.ptr += 1; |
|
| 3314 |
+ } |
|
| 3315 |
+ break; |
|
| 3316 |
+ case 0xda: /* MULkr */ |
|
| 3317 |
+ __asm__( "evaluxn_da_MULkr:" ); |
|
| 3318 |
+ {
|
|
| 3319 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3320 |
+ u->rst.dat[u->rst.ptr] = b * a; |
|
| 3321 |
+#ifndef NO_STACK_CHECKS |
|
| 3322 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3323 |
+ u->rst.error = 1; |
|
| 3324 |
+ goto error; |
|
| 3325 |
+ } |
|
| 3326 |
+ if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3327 |
+ u->rst.error = 2; |
|
| 3328 |
+ goto error; |
|
| 3329 |
+ } |
|
| 3330 |
+#endif |
|
| 3331 |
+ u->rst.ptr += 1; |
|
| 3332 |
+ } |
|
| 3333 |
+ break; |
|
| 3334 |
+ case 0xdb: /* DIVkr */ |
|
| 3335 |
+ __asm__( "evaluxn_db_DIVkr:" ); |
|
| 3336 |
+ {
|
|
| 3337 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3338 |
+ u->rst.dat[u->rst.ptr] = b / a; |
|
| 3339 |
+#ifndef NO_STACK_CHECKS |
|
| 3340 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3341 |
+ u->rst.error = 1; |
|
| 3342 |
+ goto error; |
|
| 3343 |
+ } |
|
| 3344 |
+ if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3345 |
+ u->rst.error = 2; |
|
| 3346 |
+ goto error; |
|
| 3347 |
+ } |
|
| 3348 |
+#endif |
|
| 3349 |
+ u->rst.ptr += 1; |
|
| 3350 |
+ } |
|
| 3351 |
+ break; |
|
| 3352 |
+ case 0xdc: /* ANDkr */ |
|
| 3353 |
+ __asm__( "evaluxn_dc_ANDkr:" ); |
|
| 3354 |
+ {
|
|
| 3355 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3356 |
+ u->rst.dat[u->rst.ptr] = b & a; |
|
| 3357 |
+#ifndef NO_STACK_CHECKS |
|
| 3358 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3359 |
+ u->rst.error = 1; |
|
| 3360 |
+ goto error; |
|
| 3361 |
+ } |
|
| 3362 |
+ if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3363 |
+ u->rst.error = 2; |
|
| 3364 |
+ goto error; |
|
| 3365 |
+ } |
|
| 3366 |
+#endif |
|
| 3367 |
+ u->rst.ptr += 1; |
|
| 3368 |
+ } |
|
| 3369 |
+ break; |
|
| 3370 |
+ case 0xdd: /* ORAkr */ |
|
| 3371 |
+ __asm__( "evaluxn_dd_ORAkr:" ); |
|
| 3372 |
+ {
|
|
| 3373 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3374 |
+ u->rst.dat[u->rst.ptr] = b | a; |
|
| 3375 |
+#ifndef NO_STACK_CHECKS |
|
| 3376 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3377 |
+ u->rst.error = 1; |
|
| 3378 |
+ goto error; |
|
| 3379 |
+ } |
|
| 3380 |
+ if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3381 |
+ u->rst.error = 2; |
|
| 3382 |
+ goto error; |
|
| 3383 |
+ } |
|
| 3384 |
+#endif |
|
| 3385 |
+ u->rst.ptr += 1; |
|
| 3386 |
+ } |
|
| 3387 |
+ break; |
|
| 3388 |
+ case 0xde: /* EORkr */ |
|
| 3389 |
+ __asm__( "evaluxn_de_EORkr:" ); |
|
| 3390 |
+ {
|
|
| 3391 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3392 |
+ u->rst.dat[u->rst.ptr] = b ^ a; |
|
| 3393 |
+#ifndef NO_STACK_CHECKS |
|
| 3394 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3395 |
+ u->rst.error = 1; |
|
| 3396 |
+ goto error; |
|
| 3397 |
+ } |
|
| 3398 |
+ if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3399 |
+ u->rst.error = 2; |
|
| 3400 |
+ goto error; |
|
| 3401 |
+ } |
|
| 3402 |
+#endif |
|
| 3403 |
+ u->rst.ptr += 1; |
|
| 3404 |
+ } |
|
| 3405 |
+ break; |
|
| 3406 |
+ case 0xdf: /* SFTkr */ |
|
| 3407 |
+ __asm__( "evaluxn_df_SFTkr:" ); |
|
| 3408 |
+ {
|
|
| 3409 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3410 |
+ u->rst.dat[u->rst.ptr] = b >> (a & 0x07) << ((a & 0x70) >> 4); |
|
| 3411 |
+#ifndef NO_STACK_CHECKS |
|
| 3412 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3413 |
+ u->rst.error = 1; |
|
| 3414 |
+ goto error; |
|
| 3415 |
+ } |
|
| 3416 |
+ if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3417 |
+ u->rst.error = 2; |
|
| 3418 |
+ goto error; |
|
| 3419 |
+ } |
|
| 3420 |
+#endif |
|
| 3421 |
+ u->rst.ptr += 1; |
|
| 3422 |
+ } |
|
| 3423 |
+ break; |
|
| 3424 |
+ case 0xe3: /* POP2kr */ |
|
| 3425 |
+ __asm__( "evaluxn_e3_POP2kr:" ); |
|
| 3426 |
+ {
|
|
| 3427 |
+ (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 3428 |
+#ifndef NO_STACK_CHECKS |
|
| 3429 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3430 |
+ u->rst.error = 1; |
|
| 3431 |
+ goto error; |
|
| 3432 |
+ } |
|
| 3433 |
+#endif |
|
| 3434 |
+ } |
|
| 3435 |
+ break; |
|
| 3436 |
+ case 0xe4: /* DUP2kr */ |
|
| 3437 |
+ __asm__( "evaluxn_e4_DUP2kr:" ); |
|
| 3438 |
+ {
|
|
| 3439 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3440 |
+ u->rst.dat[u->rst.ptr] = b; |
|
| 3441 |
+ u->rst.dat[u->rst.ptr + 1] = a; |
|
| 3442 |
+ u->rst.dat[u->rst.ptr + 2] = b; |
|
| 3443 |
+ u->rst.dat[u->rst.ptr + 3] = a; |
|
| 3444 |
+#ifndef NO_STACK_CHECKS |
|
| 3445 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3446 |
+ u->rst.error = 1; |
|
| 3447 |
+ goto error; |
|
| 3448 |
+ } |
|
| 3449 |
+ if(__builtin_expect(u->rst.ptr > 251, 0)) {
|
|
| 3450 |
+ u->rst.error = 2; |
|
| 3451 |
+ goto error; |
|
| 3452 |
+ } |
|
| 3453 |
+#endif |
|
| 3454 |
+ u->rst.ptr += 4; |
|
| 3455 |
+ } |
|
| 3456 |
+ break; |
|
| 3457 |
+ case 0xe5: /* SWP2kr */ |
|
| 3458 |
+ __asm__( "evaluxn_e5_SWP2kr:" ); |
|
| 3459 |
+ {
|
|
| 3460 |
+ 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]; |
|
| 3461 |
+ u->rst.dat[u->rst.ptr] = b; |
|
| 3462 |
+ u->rst.dat[u->rst.ptr + 1] = a; |
|
| 3463 |
+ u->rst.dat[u->rst.ptr + 2] = d; |
|
| 3464 |
+ u->rst.dat[u->rst.ptr + 3] = c; |
|
| 3465 |
+#ifndef NO_STACK_CHECKS |
|
| 3466 |
+ if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 3467 |
+ u->rst.error = 1; |
|
| 3468 |
+ goto error; |
|
| 3469 |
+ } |
|
| 3470 |
+ if(__builtin_expect(u->rst.ptr > 251, 0)) {
|
|
| 3471 |
+ u->rst.error = 2; |
|
| 3472 |
+ goto error; |
|
| 3473 |
+ } |
|
| 3474 |
+#endif |
|
| 3475 |
+ u->rst.ptr += 4; |
|
| 3476 |
+ } |
|
| 3477 |
+ break; |
|
| 3478 |
+ case 0xe6: /* OVR2kr */ |
|
| 3479 |
+ __asm__( "evaluxn_e6_OVR2kr:" ); |
|
| 3480 |
+ {
|
|
| 3481 |
+ 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]; |
|
| 3482 |
+ u->rst.dat[u->rst.ptr] = d; |
|
| 3483 |
+ u->rst.dat[u->rst.ptr + 1] = c; |
|
| 3484 |
+ u->rst.dat[u->rst.ptr + 2] = b; |
|
| 3485 |
+ u->rst.dat[u->rst.ptr + 3] = a; |
|
| 3486 |
+ u->rst.dat[u->rst.ptr + 4] = d; |
|
| 3487 |
+ u->rst.dat[u->rst.ptr + 5] = c; |
|
| 3488 |
+#ifndef NO_STACK_CHECKS |
|
| 3489 |
+ if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 3490 |
+ u->rst.error = 1; |
|
| 3491 |
+ goto error; |
|
| 3492 |
+ } |
|
| 3493 |
+ if(__builtin_expect(u->rst.ptr > 249, 0)) {
|
|
| 3494 |
+ u->rst.error = 2; |
|
| 3495 |
+ goto error; |
|
| 3496 |
+ } |
|
| 3497 |
+#endif |
|
| 3498 |
+ u->rst.ptr += 6; |
|
| 3499 |
+ } |
|
| 3500 |
+ break; |
|
| 3501 |
+ case 0xe7: /* ROT2kr */ |
|
| 3502 |
+ __asm__( "evaluxn_e7_ROT2kr:" ); |
|
| 3503 |
+ {
|
|
| 3504 |
+ 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]; |
|
| 3505 |
+ u->rst.dat[u->rst.ptr] = d; |
|
| 3506 |
+ u->rst.dat[u->rst.ptr + 1] = c; |
|
| 3507 |
+ u->rst.dat[u->rst.ptr + 2] = b; |
|
| 3508 |
+ u->rst.dat[u->rst.ptr + 3] = a; |
|
| 3509 |
+ u->rst.dat[u->rst.ptr + 4] = f; |
|
| 3510 |
+ u->rst.dat[u->rst.ptr + 5] = e; |
|
| 3511 |
+#ifndef NO_STACK_CHECKS |
|
| 3512 |
+ if(__builtin_expect(u->rst.ptr < 6, 0)) {
|
|
| 3513 |
+ u->rst.error = 1; |
|
| 3514 |
+ goto error; |
|
| 3515 |
+ } |
|
| 3516 |
+ if(__builtin_expect(u->rst.ptr > 249, 0)) {
|
|
| 3517 |
+ u->rst.error = 2; |
|
| 3518 |
+ goto error; |
|
| 3519 |
+ } |
|
| 3520 |
+#endif |
|
| 3521 |
+ u->rst.ptr += 6; |
|
| 3522 |
+ } |
|
| 3523 |
+ break; |
|
| 3524 |
+ case 0xe8: /* EQU2kr */ |
|
| 3525 |
+ __asm__( "evaluxn_e8_EQU2kr:" ); |
|
| 3526 |
+ {
|
|
| 3527 |
+ 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)); |
|
| 3528 |
+ u->rst.dat[u->rst.ptr] = b == a; |
|
| 3529 |
+#ifndef NO_STACK_CHECKS |
|
| 3530 |
+ if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 3531 |
+ u->rst.error = 1; |
|
| 3532 |
+ goto error; |
|
| 3533 |
+ } |
|
| 3534 |
+ if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3535 |
+ u->rst.error = 2; |
|
| 3536 |
+ goto error; |
|
| 3537 |
+ } |
|
| 3538 |
+#endif |
|
| 3539 |
+ u->rst.ptr += 1; |
|
| 3540 |
+ } |
|
| 3541 |
+ break; |
|
| 3542 |
+ case 0xe9: /* NEQ2kr */ |
|
| 3543 |
+ __asm__( "evaluxn_e9_NEQ2kr:" ); |
|
| 3544 |
+ {
|
|
| 3545 |
+ 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)); |
|
| 3546 |
+ u->rst.dat[u->rst.ptr] = b != a; |
|
| 3547 |
+#ifndef NO_STACK_CHECKS |
|
| 3548 |
+ if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 3549 |
+ u->rst.error = 1; |
|
| 3550 |
+ goto error; |
|
| 3551 |
+ } |
|
| 3552 |
+ if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3553 |
+ u->rst.error = 2; |
|
| 3554 |
+ goto error; |
|
| 3555 |
+ } |
|
| 3556 |
+#endif |
|
| 3557 |
+ u->rst.ptr += 1; |
|
| 3558 |
+ } |
|
| 3559 |
+ break; |
|
| 3560 |
+ case 0xea: /* GTH2kr */ |
|
| 3561 |
+ __asm__( "evaluxn_ea_GTH2kr:" ); |
|
| 3562 |
+ {
|
|
| 3563 |
+ 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)); |
|
| 3564 |
+ u->rst.dat[u->rst.ptr] = b > a; |
|
| 3565 |
+#ifndef NO_STACK_CHECKS |
|
| 3566 |
+ if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 3567 |
+ u->rst.error = 1; |
|
| 3568 |
+ goto error; |
|
| 3569 |
+ } |
|
| 3570 |
+ if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3571 |
+ u->rst.error = 2; |
|
| 3572 |
+ goto error; |
|
| 3573 |
+ } |
|
| 3574 |
+#endif |
|
| 3575 |
+ u->rst.ptr += 1; |
|
| 3576 |
+ } |
|
| 3577 |
+ break; |
|
| 3578 |
+ case 0xeb: /* LTH2kr */ |
|
| 3579 |
+ __asm__( "evaluxn_eb_LTH2kr:" ); |
|
| 3580 |
+ {
|
|
| 3581 |
+ 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)); |
|
| 3582 |
+ u->rst.dat[u->rst.ptr] = b < a; |
|
| 3583 |
+#ifndef NO_STACK_CHECKS |
|
| 3584 |
+ if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 3585 |
+ u->rst.error = 1; |
|
| 3586 |
+ goto error; |
|
| 3587 |
+ } |
|
| 3588 |
+ if(__builtin_expect(u->rst.ptr > 254, 0)) {
|
|
| 3589 |
+ u->rst.error = 2; |
|
| 3590 |
+ goto error; |
|
| 3591 |
+ } |
|
| 3592 |
+#endif |
|
| 3593 |
+ u->rst.ptr += 1; |
|
| 3594 |
+ } |
|
| 3595 |
+ break; |
|
| 3596 |
+ case 0xec: /* JMP2kr */ |
|
| 3597 |
+ __asm__( "evaluxn_ec_JMP2kr:" ); |
|
| 3598 |
+ {
|
|
| 3599 |
+ u->ram.ptr = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 3600 |
+#ifndef NO_STACK_CHECKS |
|
| 3601 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3602 |
+ u->rst.error = 1; |
|
| 3603 |
+ goto error; |
|
| 3604 |
+ } |
|
| 3605 |
+#endif |
|
| 3606 |
+ } |
|
| 3607 |
+ break; |
|
| 3608 |
+ case 0xed: /* JCN2kr */ |
|
| 3609 |
+ __asm__( "evaluxn_ed_JCN2kr:" ); |
|
| 3610 |
+ {
|
|
| 3611 |
+ Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 3612 |
+ if(u->rst.dat[u->rst.ptr - 3]) u->ram.ptr = a; |
|
| 3613 |
+#ifndef NO_STACK_CHECKS |
|
| 3614 |
+ if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
| 3615 |
+ u->rst.error = 1; |
|
| 3616 |
+ goto error; |
|
| 3617 |
+ } |
|
| 3618 |
+#endif |
|
| 3619 |
+ } |
|
| 3620 |
+ break; |
|
| 3621 |
+ case 0xee: /* JSR2kr */ |
|
| 3622 |
+ __asm__( "evaluxn_ee_JSR2kr:" ); |
|
| 3623 |
+ {
|
|
| 3624 |
+ u->wst.dat[u->wst.ptr] = u->ram.ptr >> 8; |
|
| 3625 |
+ u->wst.dat[u->wst.ptr + 1] = u->ram.ptr & 0xff; |
|
| 3626 |
+ u->ram.ptr = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 3627 |
+#ifndef NO_STACK_CHECKS |
|
| 3628 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3629 |
+ u->rst.error = 1; |
|
| 3630 |
+ goto error; |
|
| 3631 |
+ } |
|
| 3632 |
+ if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 3633 |
+ u->wst.error = 2; |
|
| 3634 |
+ goto error; |
|
| 3635 |
+ } |
|
| 3636 |
+#endif |
|
| 3637 |
+ u->wst.ptr += 2; |
|
| 3638 |
+ } |
|
| 3639 |
+ break; |
|
| 3640 |
+ case 0xef: /* STH2kr */ |
|
| 3641 |
+ __asm__( "evaluxn_ef_STH2kr:" ); |
|
| 3642 |
+ {
|
|
| 3643 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1], b = u->rst.dat[u->rst.ptr - 2]; |
|
| 3644 |
+ u->wst.dat[u->wst.ptr] = b; |
|
| 3645 |
+ u->wst.dat[u->wst.ptr + 1] = a; |
|
| 3646 |
+#ifndef NO_STACK_CHECKS |
|
| 3647 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3648 |
+ u->rst.error = 1; |
|
| 3649 |
+ goto error; |
|
| 3650 |
+ } |
|
| 3651 |
+ if(__builtin_expect(u->wst.ptr > 253, 0)) {
|
|
| 3652 |
+ u->wst.error = 2; |
|
| 3653 |
+ goto error; |
|
| 3654 |
+ } |
|
| 3655 |
+#endif |
|
| 3656 |
+ u->wst.ptr += 2; |
|
| 3657 |
+ } |
|
| 3658 |
+ break; |
|
| 3659 |
+ case 0xf0: /* LDZ2kr */ |
|
| 3660 |
+ __asm__( "evaluxn_f0_LDZ2kr:" ); |
|
| 3661 |
+ {
|
|
| 3662 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 3663 |
+ u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, a); |
|
| 3664 |
+ u->rst.dat[u->rst.ptr + 1] = mempeek8(u->ram.dat, a + 1); |
|
| 3665 |
+#ifndef NO_STACK_CHECKS |
|
| 3666 |
+ if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 3667 |
+ u->rst.error = 1; |
|
| 3668 |
+ goto error; |
|
| 3669 |
+ } |
|
| 3670 |
+ if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 3671 |
+ u->rst.error = 2; |
|
| 3672 |
+ goto error; |
|
| 3673 |
+ } |
|
| 3674 |
+#endif |
|
| 3675 |
+ u->rst.ptr += 2; |
|
| 3676 |
+ } |
|
| 3677 |
+ break; |
|
| 3678 |
+ case 0xf1: /* STZ2kr */ |
|
| 3679 |
+ __asm__( "evaluxn_f1_STZ2kr:" ); |
|
| 3680 |
+ {
|
|
| 3681 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 3682 |
+ Uint16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8)); |
|
| 3683 |
+ mempoke16(u->ram.dat, a, b); |
|
| 3684 |
+#ifndef NO_STACK_CHECKS |
|
| 3685 |
+ if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
| 3686 |
+ u->rst.error = 1; |
|
| 3687 |
+ goto error; |
|
| 3688 |
+ } |
|
| 3689 |
+#endif |
|
| 3690 |
+ } |
|
| 3691 |
+ break; |
|
| 3692 |
+ case 0xf2: /* LDR2kr */ |
|
| 3693 |
+ __asm__( "evaluxn_f2_LDR2kr:" ); |
|
| 3694 |
+ {
|
|
| 3695 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 3696 |
+ u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a); |
|
| 3697 |
+ u->rst.dat[u->rst.ptr + 1] = mempeek8(u->ram.dat, u->ram.ptr + (Sint8)a + 1); |
|
| 3698 |
+#ifndef NO_STACK_CHECKS |
|
| 3699 |
+ if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 3700 |
+ u->rst.error = 1; |
|
| 3701 |
+ goto error; |
|
| 3702 |
+ } |
|
| 3703 |
+ if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 3704 |
+ u->rst.error = 2; |
|
| 3705 |
+ goto error; |
|
| 3706 |
+ } |
|
| 3707 |
+#endif |
|
| 3708 |
+ u->rst.ptr += 2; |
|
| 3709 |
+ } |
|
| 3710 |
+ break; |
|
| 3711 |
+ case 0xf3: /* STR2kr */ |
|
| 3712 |
+ __asm__( "evaluxn_f3_STR2kr:" ); |
|
| 3713 |
+ {
|
|
| 3714 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 3715 |
+ Uint16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8)); |
|
| 3716 |
+ mempoke16(u->ram.dat, u->ram.ptr + (Sint8)a, b); |
|
| 3717 |
+#ifndef NO_STACK_CHECKS |
|
| 3718 |
+ if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
| 3719 |
+ u->rst.error = 1; |
|
| 3720 |
+ goto error; |
|
| 3721 |
+ } |
|
| 3722 |
+#endif |
|
| 3723 |
+ } |
|
| 3724 |
+ break; |
|
| 3725 |
+ case 0xf4: /* LDA2kr */ |
|
| 3726 |
+ __asm__( "evaluxn_f4_LDA2kr:" ); |
|
| 3727 |
+ {
|
|
| 3728 |
+ Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 3729 |
+ u->rst.dat[u->rst.ptr] = mempeek8(u->ram.dat, a); |
|
| 3730 |
+ u->rst.dat[u->rst.ptr + 1] = mempeek8(u->ram.dat, a + 1); |
|
| 3731 |
+#ifndef NO_STACK_CHECKS |
|
| 3732 |
+ if(__builtin_expect(u->rst.ptr < 2, 0)) {
|
|
| 3733 |
+ u->rst.error = 1; |
|
| 3734 |
+ goto error; |
|
| 3735 |
+ } |
|
| 3736 |
+ if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 3737 |
+ u->rst.error = 2; |
|
| 3738 |
+ goto error; |
|
| 3739 |
+ } |
|
| 3740 |
+#endif |
|
| 3741 |
+ u->rst.ptr += 2; |
|
| 3742 |
+ } |
|
| 3743 |
+ break; |
|
| 3744 |
+ case 0xf5: /* STA2kr */ |
|
| 3745 |
+ __asm__( "evaluxn_f5_STA2kr:" ); |
|
| 3746 |
+ {
|
|
| 3747 |
+ Uint16 a = (u->rst.dat[u->rst.ptr - 1] | (u->rst.dat[u->rst.ptr - 2] << 8)); |
|
| 3748 |
+ Uint16 b = (u->rst.dat[u->rst.ptr - 3] | (u->rst.dat[u->rst.ptr - 4] << 8)); |
|
| 3749 |
+ mempoke16(u->ram.dat, a, b); |
|
| 3750 |
+#ifndef NO_STACK_CHECKS |
|
| 3751 |
+ if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 3752 |
+ u->rst.error = 1; |
|
| 3753 |
+ goto error; |
|
| 3754 |
+ } |
|
| 3755 |
+#endif |
|
| 3756 |
+ } |
|
| 3757 |
+ break; |
|
| 3758 |
+ case 0xf6: /* DEI2kr */ |
|
| 3759 |
+ __asm__( "evaluxn_f6_DEI2kr:" ); |
|
| 3760 |
+ {
|
|
| 3761 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 3762 |
+ u->rst.dat[u->rst.ptr] = devpeek8(&u->dev[a >> 4], a); |
|
| 3763 |
+ u->rst.dat[u->rst.ptr + 1] = devpeek8(&u->dev[a >> 4], a + 1); |
|
| 3764 |
+#ifndef NO_STACK_CHECKS |
|
| 3765 |
+ if(__builtin_expect(u->rst.ptr < 1, 0)) {
|
|
| 3766 |
+ u->rst.error = 1; |
|
| 3767 |
+ goto error; |
|
| 3768 |
+ } |
|
| 3769 |
+ if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 3770 |
+ u->rst.error = 2; |
|
| 3771 |
+ goto error; |
|
| 3772 |
+ } |
|
| 3773 |
+#endif |
|
| 3774 |
+ u->rst.ptr += 2; |
|
| 3775 |
+ } |
|
| 3776 |
+ break; |
|
| 3777 |
+ case 0xf7: /* DEO2kr */ |
|
| 3778 |
+ __asm__( "evaluxn_f7_DEO2kr:" ); |
|
| 3779 |
+ {
|
|
| 3780 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 3781 |
+ Uint16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8)); |
|
| 3782 |
+ devpoke16(&u->dev[a >> 4], a, b); |
|
| 3783 |
+#ifndef NO_STACK_CHECKS |
|
| 3784 |
+ if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
| 3785 |
+ u->rst.error = 1; |
|
| 3786 |
+ goto error; |
|
| 3787 |
+ } |
|
| 3788 |
+#endif |
|
| 3789 |
+ } |
|
| 3790 |
+ break; |
|
| 3791 |
+ case 0xf8: /* ADD2kr */ |
|
| 3792 |
+ __asm__( "evaluxn_f8_ADD2kr:" ); |
|
| 3793 |
+ {
|
|
| 3794 |
+ 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)); |
|
| 3795 |
+ u->rst.dat[u->rst.ptr] = (b + a) >> 8; |
|
| 3796 |
+ u->rst.dat[u->rst.ptr + 1] = (b + a) & 0xff; |
|
| 3797 |
+#ifndef NO_STACK_CHECKS |
|
| 3798 |
+ if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 3799 |
+ u->rst.error = 1; |
|
| 3800 |
+ goto error; |
|
| 3801 |
+ } |
|
| 3802 |
+ if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 3803 |
+ u->rst.error = 2; |
|
| 3804 |
+ goto error; |
|
| 3805 |
+ } |
|
| 3806 |
+#endif |
|
| 3807 |
+ u->rst.ptr += 2; |
|
| 3808 |
+ } |
|
| 3809 |
+ break; |
|
| 3810 |
+ case 0xf9: /* SUB2kr */ |
|
| 3811 |
+ __asm__( "evaluxn_f9_SUB2kr:" ); |
|
| 3812 |
+ {
|
|
| 3813 |
+ 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)); |
|
| 3814 |
+ u->rst.dat[u->rst.ptr] = (b - a) >> 8; |
|
| 3815 |
+ u->rst.dat[u->rst.ptr + 1] = (b - a) & 0xff; |
|
| 3816 |
+#ifndef NO_STACK_CHECKS |
|
| 3817 |
+ if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 3818 |
+ u->rst.error = 1; |
|
| 3819 |
+ goto error; |
|
| 3820 |
+ } |
|
| 3821 |
+ if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 3822 |
+ u->rst.error = 2; |
|
| 3823 |
+ goto error; |
|
| 3824 |
+ } |
|
| 3825 |
+#endif |
|
| 3826 |
+ u->rst.ptr += 2; |
|
| 3827 |
+ } |
|
| 3828 |
+ break; |
|
| 3829 |
+ case 0xfa: /* MUL2kr */ |
|
| 3830 |
+ __asm__( "evaluxn_fa_MUL2kr:" ); |
|
| 3831 |
+ {
|
|
| 3832 |
+ 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)); |
|
| 3833 |
+ u->rst.dat[u->rst.ptr] = (b * a) >> 8; |
|
| 3834 |
+ u->rst.dat[u->rst.ptr + 1] = (b * a) & 0xff; |
|
| 3835 |
+#ifndef NO_STACK_CHECKS |
|
| 3836 |
+ if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 3837 |
+ u->rst.error = 1; |
|
| 3838 |
+ goto error; |
|
| 3839 |
+ } |
|
| 3840 |
+ if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 3841 |
+ u->rst.error = 2; |
|
| 3842 |
+ goto error; |
|
| 3843 |
+ } |
|
| 3844 |
+#endif |
|
| 3845 |
+ u->rst.ptr += 2; |
|
| 3846 |
+ } |
|
| 3847 |
+ break; |
|
| 3848 |
+ case 0xfb: /* DIV2kr */ |
|
| 3849 |
+ __asm__( "evaluxn_fb_DIV2kr:" ); |
|
| 3850 |
+ {
|
|
| 3851 |
+ 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)); |
|
| 3852 |
+ u->rst.dat[u->rst.ptr] = (b / a) >> 8; |
|
| 3853 |
+ u->rst.dat[u->rst.ptr + 1] = (b / a) & 0xff; |
|
| 3854 |
+#ifndef NO_STACK_CHECKS |
|
| 3855 |
+ if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 3856 |
+ u->rst.error = 1; |
|
| 3857 |
+ goto error; |
|
| 3858 |
+ } |
|
| 3859 |
+ if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 3860 |
+ u->rst.error = 2; |
|
| 3861 |
+ goto error; |
|
| 3862 |
+ } |
|
| 3863 |
+#endif |
|
| 3864 |
+ u->rst.ptr += 2; |
|
| 3865 |
+ } |
|
| 3866 |
+ break; |
|
| 3867 |
+ case 0xfc: /* AND2kr */ |
|
| 3868 |
+ __asm__( "evaluxn_fc_AND2kr:" ); |
|
| 3869 |
+ {
|
|
| 3870 |
+ 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]; |
|
| 3871 |
+ u->rst.dat[u->rst.ptr] = d & b; |
|
| 3872 |
+ u->rst.dat[u->rst.ptr + 1] = c & a; |
|
| 3873 |
+#ifndef NO_STACK_CHECKS |
|
| 3874 |
+ if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 3875 |
+ u->rst.error = 1; |
|
| 3876 |
+ goto error; |
|
| 3877 |
+ } |
|
| 3878 |
+ if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 3879 |
+ u->rst.error = 2; |
|
| 3880 |
+ goto error; |
|
| 3881 |
+ } |
|
| 3882 |
+#endif |
|
| 3883 |
+ u->rst.ptr += 2; |
|
| 3884 |
+ } |
|
| 3885 |
+ break; |
|
| 3886 |
+ case 0xfd: /* ORA2kr */ |
|
| 3887 |
+ __asm__( "evaluxn_fd_ORA2kr:" ); |
|
| 3888 |
+ {
|
|
| 3889 |
+ 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]; |
|
| 3890 |
+ u->rst.dat[u->rst.ptr] = d | b; |
|
| 3891 |
+ u->rst.dat[u->rst.ptr + 1] = c | a; |
|
| 3892 |
+#ifndef NO_STACK_CHECKS |
|
| 3893 |
+ if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 3894 |
+ u->rst.error = 1; |
|
| 3895 |
+ goto error; |
|
| 3896 |
+ } |
|
| 3897 |
+ if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 3898 |
+ u->rst.error = 2; |
|
| 3899 |
+ goto error; |
|
| 3900 |
+ } |
|
| 3901 |
+#endif |
|
| 3902 |
+ u->rst.ptr += 2; |
|
| 3903 |
+ } |
|
| 3904 |
+ break; |
|
| 3905 |
+ case 0xfe: /* EOR2kr */ |
|
| 3906 |
+ __asm__( "evaluxn_fe_EOR2kr:" ); |
|
| 3907 |
+ {
|
|
| 3908 |
+ 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]; |
|
| 3909 |
+ u->rst.dat[u->rst.ptr] = d ^ b; |
|
| 3910 |
+ u->rst.dat[u->rst.ptr + 1] = c ^ a; |
|
| 3911 |
+#ifndef NO_STACK_CHECKS |
|
| 3912 |
+ if(__builtin_expect(u->rst.ptr < 4, 0)) {
|
|
| 3913 |
+ u->rst.error = 1; |
|
| 3914 |
+ goto error; |
|
| 3915 |
+ } |
|
| 3916 |
+ if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 3917 |
+ u->rst.error = 2; |
|
| 3918 |
+ goto error; |
|
| 3919 |
+ } |
|
| 3920 |
+#endif |
|
| 3921 |
+ u->rst.ptr += 2; |
|
| 3922 |
+ } |
|
| 3923 |
+ break; |
|
| 3924 |
+ case 0xff: /* SFT2kr */ |
|
| 3925 |
+ __asm__( "evaluxn_ff_SFT2kr:" ); |
|
| 3926 |
+ {
|
|
| 3927 |
+ Uint8 a = u->rst.dat[u->rst.ptr - 1]; |
|
| 3928 |
+ Uint16 b = (u->rst.dat[u->rst.ptr - 2] | (u->rst.dat[u->rst.ptr - 3] << 8)); |
|
| 3929 |
+ u->rst.dat[u->rst.ptr] = (b >> (a & 0x0f) << ((a & 0xf0) >> 4)) >> 8; |
|
| 3930 |
+ u->rst.dat[u->rst.ptr + 1] = (b >> (a & 0x0f) << ((a & 0xf0) >> 4)) & 0xff; |
|
| 3931 |
+#ifndef NO_STACK_CHECKS |
|
| 3932 |
+ if(__builtin_expect(u->rst.ptr < 3, 0)) {
|
|
| 3933 |
+ u->rst.error = 1; |
|
| 3934 |
+ goto error; |
|
| 3935 |
+ } |
|
| 3936 |
+ if(__builtin_expect(u->rst.ptr > 253, 0)) {
|
|
| 3937 |
+ u->rst.error = 2; |
|
| 3938 |
+ goto error; |
|
| 3939 |
+ } |
|
| 3940 |
+#endif |
|
| 3941 |
+ u->rst.ptr += 2; |
|
| 3942 |
+ } |
|
| 3943 |
+ break; |
|
| 3944 |
+#pragma GCC diagnostic pop |
|
| 3945 |
+ } |
|
| 3946 |
+ } |
|
| 3947 |
+ return 1; |
|
| 3948 |
+#ifndef NO_STACK_CHECKS |
|
| 3949 |
+error: |
|
| 3950 |
+ printf("Halted: %s-stack %sflow#%04x, at 0x%04x\n",
|
|
| 3951 |
+ u->wst.error ? "Working" : "Return", |
|
| 3952 |
+ ((u->wst.error | u->rst.error) & 2) ? "over" : "under", |
|
| 3953 |
+ instr, |
|
| 3954 |
+ u->ram.ptr); |
|
| 3955 |
+ return 0; |
|
| 3956 |
+#endif |
|
| 3957 |
+} |
|
| 3958 |
+ |
|
| 3959 |
+int |
|
| 3960 |
+bootuxn(Uxn *u) |
|
| 3961 |
+{
|
|
| 3962 |
+ size_t i; |
|
| 3963 |
+ char *cptr = (char *)u; |
|
| 3964 |
+ for(i = 0; i < sizeof(*u); i++) |
|
| 3965 |
+ cptr[i] = 0; |
|
| 3966 |
+ return 1; |
|
| 3967 |
+} |
|
| 3968 |
+ |
|
| 3969 |
+int |
|
| 3970 |
+loaduxn(Uxn *u, char *filepath) |
|
| 3971 |
+{
|
|
| 3972 |
+ FILE *f; |
|
| 3973 |
+ if(!(f = fopen(filepath, "rb"))) {
|
|
| 3974 |
+ printf("Halted: Missing input rom.\n");
|
|
| 3975 |
+ return 0; |
|
| 3976 |
+ } |
|
| 3977 |
+ fread(u->ram.dat + PAGE_PROGRAM, sizeof(u->ram.dat) - PAGE_PROGRAM, 1, f); |
|
| 3978 |
+ printf("Uxn loaded[%s].\n", filepath);
|
|
| 3979 |
+ return 1; |
|
| 3980 |
+} |
|
| 3981 |
+ |
|
| 3982 |
+Device * |
|
| 3983 |
+portuxn(Uxn *u, Uint8 id, char *name, void (*talkfn)(Device *d, Uint8 b0, Uint8 w)) |
|
| 3984 |
+{
|
|
| 3985 |
+ Device *d = &u->dev[id]; |
|
| 3986 |
+ d->addr = id * 0x10; |
|
| 3987 |
+ d->u = u; |
|
| 3988 |
+ d->mem = u->ram.dat; |
|
| 3989 |
+ d->talk = talkfn; |
|
| 3990 |
+ printf("Device added #%02x: %s, at 0x%04x \n", id, name, d->addr);
|
|
| 3991 |
+ return d; |
|
| 3992 |
+} |