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