]> cloudbase.mooo.com Git - z180-stamp.git/commitdiff
Merge branch 'test-fboot-support'
authorLeo C <erbl259-lmu@yahoo.de>
Mon, 18 May 2015 08:06:49 +0000 (10:06 +0200)
committerLeo C <erbl259-lmu@yahoo.de>
Mon, 18 May 2015 08:06:49 +0000 (10:06 +0200)
36 files changed:
TODO.md
avr/Tupfile
avr/cli.c
avr/cli_readline.c
avr/cmd_boot.c
avr/cmd_fat.c
avr/cmd_loadcpm3.c [new file with mode: 0644]
avr/cmd_loadihex.c [new file with mode: 0644]
avr/cmd_mem.c
avr/cmd_misc.c
avr/command.c
avr/command_tbl.c
avr/env.c
avr/main.c
avr/z180-serv.c
avr/z80-if.c
include/cmd_mem.h
include/common.h
include/config.h
z180/Makefile
z180/Tupfile
z180/asci-p.180 [new file with mode: 0644]
z180/asci1-i.180 [moved from z180/ser1-i.180 with 84% similarity]
z180/bioscio.180
z180/chario.180
z180/conbuf-a.180
z180/config.inc
z180/console.180
z180/ddtz.180
z180/fifoio.180
z180/init-80.180 [new file with mode: 0644]
z180/init.180 [new file with mode: 0644]
z180/msgbuf-a.180
z180/msgfifo.180
z180/r3init.180 [deleted file]
z180/z180reg.inc

diff --git a/TODO.md b/TODO.md
index b952c9dced76ac153d02a6ce982773251e31383f..75c967914e8a5671cf877ff734f4bf863e106573 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -3,4 +3,8 @@ TODO List
 
 - TODO: eliminate xmalloc
 - TODO: build time directory as lib
-- TODO: command 'help <topic>' should return success
+- TODO: file search path. 'cd' command?
+- TODO: increase __malloc_margin to ? (now 0x20)
+----------------------------------------------------
+- Done:
+       - command 'help <topic>' should return success
index 78e9744ed9ad33235b5724f6130cd51c150f03de..0c35de4cfb94e9d5f38424d40d4c04264315d98e 100644 (file)
@@ -7,7 +7,7 @@ FATFS   = $(TOP)/fatfs/src/ff.c
 SRC            = main.c
 SRC            += cli.c cli_readline.c command.c command_tbl.c
 SRC            += cmd_help.c cmd_date.c cmd_mem.c cmd_boot.c cmd_gpio.c cmd_misc.c
-SRC            += cmd_sd.c cmd_fat.c
+SRC            += cmd_loadihex.c cmd_loadcpm3.c cmd_sd.c cmd_fat.c
 SRC            += env.c xmalloc.c con-utils.c print-utils.c getopt-min.c
 SRC            += timer.c serial.c i2c.c pcf8583.c mmc.c
 SRC            += background.c z180-serv.c z80-if.c gpio.c
index 52c85db1b4b17c1f192f008730e655cb6f986d2c..6b26b6f09cc77d09542271af3eb54999837f9379 100644 (file)
--- a/avr/cli.c
+++ b/avr/cli.c
@@ -27,6 +27,9 @@
 #include "con-utils.h"
 #include "cli.h"
 
+
+/* FIXME: Quoting problems */
+
 #define DEBUG_PARSER   0       /* set to 1 to debug */
 
 #define debug_parser(fmt, args...)             \
@@ -46,7 +49,7 @@ static int cli_parse_line(char *line, char *argv[])
                        inp++) {
 
                switch (state) {
-               case 0:
+               case 0:                                         /* before arg string, waiting for arg start */
                        if (isblank(c))
                                continue;
 
@@ -55,7 +58,7 @@ static int cli_parse_line(char *line, char *argv[])
                        state = 1;
                        /* fall thru */
 
-               case 1:
+               case 1:                                         /* in arg string, waiting for end of arg string */
                        if (c == '\\') {
                                ++state;
                                continue;
@@ -71,7 +74,7 @@ static int cli_parse_line(char *line, char *argv[])
                        }
                        break;
 
-               case 3:
+               case 3:                                         /* in quote */
                        if (c == '\\' && quote == '\"') {
                                ++state;
                                continue;
@@ -82,7 +85,7 @@ static int cli_parse_line(char *line, char *argv[])
                        }
                        break;
 
-               case 2:
+               case 2:                                         /* waiting for next char */
                case 4:
                        --state;
                        break;
@@ -252,12 +255,13 @@ static int cli_run_command(const char *cmd, int flag)
                 */
                for (inquotes = 0, sep = str; *sep; sep++) {
                        if ((*sep == '\'') &&
-                           (*(sep - 1) != '\\'))
+                           (sep != str) &&                             /* past string start */
+                           (*(sep - 1) != '\\'))               /* and NOT escaped */
                                inquotes = !inquotes;
 
                        if (!inquotes &&
-                           (*sep == ';' || *sep == '\n') &&    /* separator            */
-                           (sep != str) &&                     /* past string start    */
+                           (*sep == ';' || *sep == '\n') &&    /* separator */
+                           (sep != str) &&                             /* past string start */
                            (*(sep - 1) != '\\'))               /* and NOT escaped */
                                break;
                }
index 04d32b126eae45efde86017e347e2d62f0decb25..93a03551e6e376eed90c4e1ed2348f0c24418f4e 100644 (file)
@@ -12,7 +12,6 @@
  */
 
 #include "common.h"
-
 #include <string.h>
 #include <stdio.h>
 
@@ -562,16 +561,8 @@ static int cli_readline_into_buffer(const FLASH char *const prompt, char *buffer
                                        my_puts_P(tab_seq + (col & 07));
                                        col += 8 - (col & 07);
                                } else {
-                                       char buf[2];
-
-                                       /*
-                                        * Echo input using puts() to force an
-                                        * LCD flush if we are using an LCD
-                                        */
                                        ++col;
-                                       buf[0] = c;
-                                       buf[1] = '\0';
-                                       my_puts(buf);
+                                       putchar(c);
                                }
                                *p++ = c;
                                ++n;
index 301f4f583d4e02a8015b481edbed1d02064058b6..f9f8f90f15cc26a15862cb20bb33e4fc2856c4f1 100644 (file)
@@ -194,9 +194,11 @@ command_ret_t do_console(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv
                        pending = (Stat & S_CON_PENDING) != 0;
                        Stat &= ~S_CON_PENDING;
                }
-               if (pending)
-                       while ((ch = z80_memfifo_getc(fifo_conout)) >= 0)
+               if (pending) {
+                       uint8_t count = 100;
+                       while ((ch = z80_memfifo_getc(fifo_conout)) >= 0 && --count)
                                putchar(ch);
+               }
 
                if ((ch = my_getchar(0)) >= 0) {
                        switch (state) {
index 8ed7ae36952bf0238545db3f904c72b37d3d2f6c..af2f77253092198d04dfe74b0b0267a9937158bf 100644 (file)
@@ -22,8 +22,8 @@
 #include "timer.h"
 #include "debug.h"
 
-
-#define MAX_MEMORY     (1ul << 20)
+/* TODO: use memory size test function (cmd_mem.c) */
+#define MAX_MEMORY     (1ul << 19)
 #define BUFFER_SIZE    512
 
 
@@ -157,7 +157,7 @@ FRESULT scan_files (
  */
 command_ret_t do_fat_stat(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-       FATFS *FatFs, *fs;
+       FATFS *fs;
        DWORD nfreeclst;
        FRESULT res;
        char *path;
@@ -165,64 +165,57 @@ command_ret_t do_fat_stat(cmd_tbl_t *cmdtp, int flag, int argc, char * const arg
 
        (void) cmdtp; (void) flag; (void) argc;
 
-       FatFs = (FATFS *) malloc(sizeof (FATFS));
        path = (char *) malloc(BUFFER_SIZE);
-       if (FatFs == NULL || path == NULL) {
+       if (path == NULL) {
                printf_P(PSTR("fatstat: Out of Memory!\n"));
                free(path);
-               free(FatFs);
                return CMD_RET_FAILURE;
        }
 
-       res = f_mount(FatFs, argv[1], 0);
+       res = f_getfree(argv[1], &nfreeclst, &fs);
        if (!res) {
-               res = f_getfree(argv[1], &nfreeclst, &fs);
-               if (!res) {
-                       printf_P(PSTR(
-                                               "FAT type:                %u\n"
-                                               "Bytes/Cluster:           %lu\n"
-                                               "Number of FATs:          %u\n"
-                                               "Root DIR entries:        %u\n"
-                                               "Sectors/FAT:             %lu\n"
-                                               "Number of clusters:      %lu\n"
-                                               "FAT start (lba):         %lu\n"
-                                               "DIR start (lba,cluster): %lu\n"
-                                               "Data start (lba):        %lu\n"),
-                                       fs->fs_type, (DWORD)fs->csize * 512, fs->n_fats,
-                                       fs->n_rootdir, fs->fsize, fs->n_fatent - 2,
-                                       fs->fatbase, fs->dirbase, fs->database);
+               printf_P(PSTR(
+                                       "FAT type:                %u\n"
+                                       "Bytes/Cluster:           %lu\n"
+                                       "Number of FATs:          %u\n"
+                                       "Root DIR entries:        %u\n"
+                                       "Sectors/FAT:             %lu\n"
+                                       "Number of clusters:      %lu\n"
+                                       "FAT start (lba):         %lu\n"
+                                       "DIR start (lba,cluster): %lu\n"
+                                       "Data start (lba):        %lu\n"),
+                               fs->fs_type, (DWORD)fs->csize * 512, fs->n_fats,
+                               fs->n_rootdir, fs->fsize, fs->n_fatent - 2,
+                               fs->fatbase, fs->dirbase, fs->database);
 
 #if _USE_LABEL
-                       TCHAR label[12];
-                       DWORD serial;
-                       res = f_getlabel(argv[1], label, &serial);
-                       if (!res) {
-                               printf_P(PSTR(
-                                                       "Volume name:             %s\n"
-                                                       "Volume S/N:              %04X-%04X\n"),
-                                               label, (WORD)(serial >> 16), (WORD)(serial & 0xFFFF));
-                       }
+               TCHAR label[12];
+               DWORD serial;
+               res = f_getlabel(argv[1], label, &serial);
+               if (!res) {
+                       printf_P(PSTR(
+                                               "Volume name:             %s\n"
+                                               "Volume S/N:              %04X-%04X\n"),
+                                       label, (WORD)(serial >> 16), (WORD)(serial & 0xFFFF));
+               }
 #endif
-                       if (!res) {
-                               my_puts_P(PSTR("\nCounting...  "));
-                               statp.AccSize = statp.AccFiles = statp.AccDirs = 0;
-                               strcpy(path, argv[1]);
+               if (!res) {
+                       my_puts_P(PSTR("\nCounting...  "));
+                       statp.AccSize = statp.AccFiles = statp.AccDirs = 0;
+                       strcpy(path, argv[1]);
 
-                               res = scan_files(path, &statp);
-                       }
-                       if (!res) {
-                               printf_P(PSTR("\r%u files, %lu bytes.\n%u folders.\n"
-                                                        "%lu KB total disk space.\n%lu KB available.\n"),
-                                               statp.AccFiles, statp.AccSize, statp.AccDirs,
-                                               (fs->n_fatent - 2) * (fs->csize / 2), nfreeclst * (fs->csize / 2)
-                               );
-                       }
+                       res = scan_files(path, &statp);
+               }
+               if (!res) {
+                       printf_P(PSTR("\r%u files, %lu bytes.\n%u folders.\n"
+                                                "%lu KB total disk space.\n%lu KB available.\n"),
+                                       statp.AccFiles, statp.AccSize, statp.AccDirs,
+                                       (fs->n_fatent - 2) * (fs->csize / 2), nfreeclst * (fs->csize / 2)
+                       );
                }
        }
 
        free(path);
-       free(FatFs);
-       f_mount(NULL, argv[1], 0);
        if (res) {
                put_rc(res);
                return CMD_RET_FAILURE;
@@ -237,7 +230,7 @@ command_ret_t do_fat_stat(cmd_tbl_t *cmdtp, int flag, int argc, char * const arg
  */
 command_ret_t do_fat_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-       FATFS FatFs, *fs;
+       FATFS *fs;
        DIR Dir;                                        /* Directory object */
        FILINFO Finfo;
        unsigned long p1;
@@ -251,9 +244,7 @@ command_ret_t do_fat_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[
 
        (void) cmdtp; (void) flag; (void) argc;
 
-       res = f_mount(&FatFs, argv[1], 0);
-       if (!res)
-               res = f_opendir(&Dir, argv[1]);
+       res = f_opendir(&Dir, argv[1]);
        if (res) {
                put_rc(res);
                return CMD_RET_FAILURE;
@@ -341,7 +332,6 @@ FRESULT mkpath(TCHAR *path)
  */
 command_ret_t do_fat_rw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-       FATFS *FatFs;
        FIL File;
        uint32_t addr;
        unsigned long bytes;
@@ -376,21 +366,15 @@ command_ret_t do_fat_rw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[
        if (addr + bytes > MAX_MEMORY)
                bytes = MAX_MEMORY - addr;
 
-       FatFs = (FATFS *) malloc(sizeof (FATFS));
        buffer = (uint8_t *) malloc(BUFFER_SIZE);
-       if (FatFs == NULL || buffer == NULL) {
+       if (buffer == NULL) {
                printf_P(PSTR("fatstat: Out of Memory!\n"));
-               free(FatFs);
                free(buffer);
                return CMD_RET_FAILURE;
        }
 
-       res = f_mount(FatFs, argv[1], 0);
-
-       if (!res) {
-               if (dowrite) {
-                       res = mkpath(argv[1]);
-               }
+       if (dowrite) {
+               res = mkpath(argv[1]);
        }
        if (!res) {
                res = f_open(&File, argv[1], dowrite ? FA_WRITE | FA_CREATE_ALWAYS
@@ -451,11 +435,9 @@ command_ret_t do_fat_rw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[
                                                        bytes_rw, bytes_rw, timer ? (bytes_rw * 1000 / timer) : 0);
                        }
                }
-               f_mount(NULL, argv[1], 0);
        }
 
        free(buffer);
-       free(FatFs);
 
        if (buserr)
                my_puts_P(PSTR("Bus timeout\n"));
diff --git a/avr/cmd_loadcpm3.c b/avr/cmd_loadcpm3.c
new file mode 100644 (file)
index 0000000..fd685b2
--- /dev/null
@@ -0,0 +1,151 @@
+/*
+ * (C) Copyright 2015 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include "common.h"
+#include <stdlib.h>
+#include <ctype.h>
+#include <string.h>
+#include <stdbool.h>
+
+#include "command.h"
+#include "env.h"
+#include "ff.h"
+#include "con-utils.h"
+#include "z80-if.h"
+#include "debug.h"
+
+
+#define RS             128             /* CP/M record size */
+
+/*
+ *     Load Routine
+ *
+ *     Input:  addr = Page Address of load top
+ *                     len  = Length in pages of module to read
+ *
+ */
+int load(FIL *File, uint16_t addr, uint8_t len)
+{
+       uint8_t buffer[RS];
+       unsigned int br;                                        /* bytes read */
+       int res;
+
+       len *= 2;               /* length in records of module */
+       //debug("## load: addr: 0x%.4X, records: 0x%.4X, (%u)\n", addr, len, len);
+
+       for (; len; len--) {
+               addr -= RS;
+               res = f_read(File, buffer, RS, &br);
+               if (res || br != RS) {
+                       return 1;
+               }
+
+               if (!(z80_bus_cmd(Request) & ZST_ACQUIRED)) {
+                       my_puts_P(PSTR("Bus timeout\n"));
+                       return 2;
+               }
+               z80_write_block(buffer, addr, RS);
+               z80_bus_cmd(Release);
+               //debug("## written: 0x%.4X\n", addr);
+       }
+
+       return 0;
+}
+
+
+command_ret_t do_loadcpm3(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+       uint16_t mem_top;
+       uint8_t res_len;
+       uint16_t bank_top;
+       uint8_t bank_len;
+       uint16_t osentry_adr = 0;
+       long offset = 0;
+       char *fname;
+       FIL File;
+       /* TODO: put CONFIG_PATH_CPM3SYS in flash */
+       char default_fname[] = CONFIG_PATH_CPM3SYS;
+       unsigned int br;                                        /* bytes read */
+       uint8_t buffer[RS];
+       int res;
+
+       (void) cmdtp; (void) flag;
+
+
+       if (argc > 1)
+               offset = strtoul(argv[1], NULL, 16);
+
+       fname = getenv(PSTR(ENV_PATH_CPM3SYS));
+
+       if (argc > 2) {
+               fname = argv[2];
+       }
+
+       if (fname == NULL || *fname == '\0')
+               fname = default_fname;
+
+       res = f_open(&File, fname, FA_READ );
+       if (res) {
+               printf_P(PSTR("Error: failed to open '%s'\n"), fname);
+               return CMD_RET_FAILURE;
+       }
+
+       printf_P(PSTR("Loading: '%s'...\n"), fname);
+
+       /* read the load record */
+       res = f_read(&File, buffer, RS, &br);
+       if (res || br != RS)
+               goto out;
+
+       mem_top = buffer[0] << 8;
+       res_len = buffer[1];
+       bank_top = buffer[2] << 8;
+       bank_len = buffer[3];
+       osentry_adr = buffer[4] + (buffer[5] << 8);
+
+       /* read display info */
+       res = f_read(&File, buffer, RS, &br);
+       if (res || br != RS)
+               goto out;
+
+       /* print the info */
+       buffer[RS-1] = '$';
+       uint8_t *p = memchr(buffer, '$', RS);
+       *p = '\0';
+       my_puts((char *)buffer);
+
+       /* Main System Load     */
+
+       /* Load Common Portion of System */
+       if ((res = load(&File, mem_top, res_len)) != 0)
+               goto out;
+
+       /* Load Banked Portion of System */
+       res = load(&File, bank_top, bank_len);
+
+out:
+       f_close(&File);
+
+       if (res) {
+               printf_P(PSTR("Error: failed to read '%s'\n"), fname);
+               return CMD_RET_FAILURE;
+       } else {
+               if (res_len != 0)
+                       setenv_hex(PSTR(ENV_STARTADDRESS), osentry_adr);
+               printf_P(PSTR("Loaded: Resident: "));
+               if (res_len != 0)
+                       printf_P(PSTR("0x%.4X-0x%.4X, "), mem_top-res_len*256, mem_top-1);
+               else
+                       printf_P(PSTR(" -  "));
+               printf_P(PSTR("Banked: "));
+               if (bank_len != 0)
+                       printf_P(PSTR("0x%.4X-0x%.4X\n"), bank_top-bank_len*256, bank_top-1);
+               else
+                       printf_P(PSTR(" -  \n"));
+
+               return CMD_RET_SUCCESS;
+       }
+}
diff --git a/avr/cmd_loadihex.c b/avr/cmd_loadihex.c
new file mode 100644 (file)
index 0000000..18d5331
--- /dev/null
@@ -0,0 +1,261 @@
+/*
+ * (C) Copyright 2015 Leo C. <erbl259-lmu@yahoo.de>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include "common.h"
+#include <stdlib.h>
+#include <ctype.h>
+#include <stdbool.h>
+
+#include "command.h"
+#include "con-utils.h"
+#include "z80-if.h"
+#include "debug.h"
+
+
+uint32_t detect_ramsize(void)
+{
+       uint32_t addr;
+       uint8_t save_addr, save_0;
+       const uint8_t PATTERN_1 = 0x55;
+       const uint8_t PATTERN_2 = ~PATTERN_1;
+
+       if (!(z80_bus_cmd(Request) & ZST_ACQUIRED)) {
+               my_puts_P(PSTR("Bus timeout\n"));
+               return  0;
+       }
+
+       save_0 = z80_read(0);
+       z80_write(0, PATTERN_1);
+
+       for (addr=1; addr < CONFIG_SYS_RAMSIZE_MAX; addr <<= 1) {
+               save_addr = z80_read(addr);
+               z80_write(addr, PATTERN_2);
+               if (z80_read(0) != PATTERN_1 || z80_read(addr) != PATTERN_2)
+                       break;
+               z80_write(addr, save_addr);
+       }
+       z80_write(0, save_0);
+       z80_bus_cmd(Release);
+
+       return addr;
+}
+
+typedef enum {
+       IHX_OK,
+       IHX_BROKEN,
+       IHX_CHKSUMERR
+} ihx_rstat_t;
+
+typedef struct {
+       ihx_rstat_t status;
+       int8_t type;
+       uint8_t len;
+       uint16_t address;
+       uint8_t data[256];
+} ihex_t;
+
+
+static
+int get_hexdigit(void) {
+
+       int c;
+       c = toupper(my_getchar(1));
+       if (isxdigit(c)) {
+               c -= '0';
+               if (c > 9)
+                       c -= ('A' - '0' - 10);
+               return c;
+       } else
+               return -1;
+}
+
+static
+int get_hexbyte(void) {
+
+       uint8_t i,j;
+
+       if ((i = (uint8_t) get_hexdigit()) < 0x10)
+               if ((j = (uint8_t) get_hexdigit()) < 0x10) {
+                       return (i<<4) + j;
+               }
+
+       return -1;
+}
+
+
+static
+int ihex_get_record(ihex_t *rec) {
+
+       int c;
+       uint8_t sum;
+
+       rec->status = IHX_BROKEN;
+       rec->len = 0;
+       rec->type = 0xff;
+
+       while ((c = my_getchar(0)) != ':') {
+               if (c == 0x03)
+                       return -1;                                      /* Control-C */
+               if (c == 0x04) {
+                       rec->status = IHX_OK;
+                       return 0;                                       /*Control-D, EOF */
+               }
+       }
+
+       if ((c = get_hexbyte()) < 0)            /* Start code */
+                       return -1;
+       sum = c;
+       rec->len = c;
+       if ((c = get_hexbyte()) < 0)            /* Byte Count */
+                       return -1;
+       sum += c;
+       rec->address = c * 256;
+       if ((c = get_hexbyte()) < 0)            /* Address */
+                       return -1;
+       sum += c;
+       rec->address += c;
+       if ((c = get_hexbyte()) < 0)            /* Record type */
+               return -1;
+       sum += c;
+       rec->type = c;
+
+       if (rec->len) {                                         /* Record Data */
+               uint8_t n;
+
+               for (n = 0; n < rec->len; n++) {
+                       if ((c = get_hexbyte()) < 0)
+                               break;
+                       sum += c;
+                       rec->data[n] = c;
+               }
+
+               if (n < rec->len) {
+                       return -1;
+               }
+       }
+
+       c = get_hexbyte();                              /* Check sum */
+
+       if (c >= 0) {
+               sum += c;
+               if (sum == 0)
+                       rec->status = IHX_OK;
+               else
+                       rec->status = IHX_CHKSUMERR;
+       }
+
+       return rec->len;
+}
+
+
+command_ret_t do_loadihex(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+       long offset = 0;
+       uint32_t base_address = 0;
+       uint32_t address_max = detect_ramsize();
+       uint32_t address_high = 0;
+       uint32_t address_low = address_max;
+       command_ret_t rcode = CMD_RET_FAILURE;
+       ihex_t rec;
+       bool firstrec = true;
+
+       (void) cmdtp; (void) flag;
+
+
+       if (argc > 1)
+               offset = strtol(argv[1], NULL, 16);
+
+       printf_P(PSTR("Waiting for Intel Hex Records...\n"));
+
+       while (ihex_get_record(&rec) > 0 &&
+                               rec.status == IHX_OK &&
+                               rec.type != 1 ) {
+
+               switch (rec.type) {
+               case 0: /* Data record */
+                       if (firstrec) {
+                               printf_P(PSTR("Loading: 0x....."));
+                               firstrec = false;
+                       }
+                       if (rec.len) {
+                               uint32_t addr = base_address + rec.address + offset;
+                               if (addr < address_low)
+                                       address_low = addr;
+                               if (addr+rec.len > address_high)
+                                       address_high = addr + rec.len;
+
+//                             debug("low: 0x%.5lX, high: 0x%.5lX, max: 0x%.5lX, addr: 0x%.5lX, len: %d\n",
+//                                     address_low, address_high, address_max, addr, rec.len);
+                               printf_P(PSTR("\b\b\b\b\b%.5lX"), addr);
+                               if (addr < address_max) {
+                                       uint32_t tmplen = address_max - addr;
+                                       if (rec.len > tmplen)
+                                               rec.len = tmplen;
+
+                                       if (!(z80_bus_cmd(Request) & ZST_ACQUIRED)) {
+                                               my_puts_P(PSTR("Bus timeout\n"));
+                                               return  CMD_RET_FAILURE;
+                                       }
+                                       z80_write_block(rec.data,               /* src */
+                                                       addr,                                   /* dest */
+                                                       rec.len);                               /* len */
+                                       z80_bus_cmd(Release);
+                               }
+                       }
+                       break;
+
+#if 0
+               case 1: /* EOF record */
+                       break;
+#endif
+               case 2: /* Extended Segment Address Record */
+                       base_address = (uint32_t)((rec.data[0] << 8) + rec.data[1]) << 4;
+                       break;
+
+               case 4: /* Extended Linear Address Record */
+                       base_address = (uint32_t)((rec.data[0] << 8) + rec.data[1]) << 16;
+                       break;
+
+               case 3: /* Start Segment Address Record (ignored)*/
+               case 5: /* Start Linear Address Record (ignored)*/
+                       break;
+
+               }
+       }
+
+       switch (rec.status) {
+       case IHX_OK:
+               rcode = CMD_RET_SUCCESS;
+               break;
+
+       case IHX_BROKEN:
+       case IHX_CHKSUMERR:
+               printf_P(PSTR("Broken Hex Record or loading interrupted!\n"));
+               break;
+       }
+
+
+       for (uint_fast8_t i=0; i<100; ++i) {
+               /* flush input buffer */
+               while (my_getchar(0) > 0)
+                       ;
+               udelay(1000);
+       }
+
+
+       printf_P(PSTR("\nData loaded: "));
+       if (address_low >= MIN(address_high, address_max))
+               printf_P(PSTR("None.\n"));
+       else
+               printf_P(PSTR("low: 0x%.5lX high: 0x%.5lX\n"), address_low,
+                               MIN(address_high, address_max) - 1);
+
+       if (address_high > address_max)
+               printf_P(PSTR("Data above highest RAM address "
+                       "(in range 0x%.5lX - 0x%.5lX) ignored!\n"), address_max, address_high - 1);
+
+       return rcode;
+}
index 20a4412a0b2e770e8b8cc232c628057771b73bff..53b18426fbcc1400718ab88f1b2581ab43cf3ed0 100644 (file)
 #include "common.h"
 #include <stdlib.h>
 #include <ctype.h>
+#include <avr/interrupt.h>
 
 #include "command.h"
 #include "cli_readline.h"
 #include "print-utils.h"
 #include "con-utils.h"
+#include "timer.h"
 #include "z80-if.h"
-//#include "debug.h"
+#include "debug.h"
 
 
 #ifndef CONFIG_SYS_MEMTEST_SCRATCH
@@ -222,55 +224,35 @@ command_ret_t do_mem_mw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[
 #ifdef CONFIG_MX_CYCLIC
 command_ret_t do_mem_mdc ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-       int i;
        uint32_t count;
+       uint32_t ts;
+
+       (void) cmdtp;
+       (void) flag;
 
        if (argc < 4)
                return CMD_RET_USAGE;
 
        count = strtoul(argv[3], NULL, 10);
 
+       clear_ctrlc();          /* forget any previous Control C */
        for (;;) {
-               do_mem_md (NULL, 0, 3, argv);
-
-               /* delay for <count> ms... */
-/* TODO: use timer */
-               for (i=0; i<count; i++)
-                       udelay (1000);
-
-               /* check for ctrl-c to abort... */
-               if (ctrlc()) {
-                       my_puts_P(PSTR("Abort\n"));
-                       return CMD_RET_SUCCESS;
-               }
-       }
-
-       return CMD_RET_SUCCESS;
-}
-
-command_ret_t do_mem_mwc ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
-{
-       int i;
-       uint32_t count;
-
-       if (argc < 4)
-               return CMD_RET_USAGE;
 
-       count = strtoul(argv[3], NULL, 10);
+               if (argv[0][1] == 'd')
+                       do_mem_md (NULL, 0, 3, argv);
+               else
+                       do_mem_mw (NULL, 0, 3, argv);
 
-       for (;;) {
-               do_mem_mw (NULL, 0, 3, argv);
 
                /* delay for <count> ms... */
-/* TODO: use timer */
-               for (i=0; i<count; i++)
-                       udelay (1000);
-
-               /* check for ctrl-c to abort... */
-               if (ctrlc()) {
-                       my_puts_P(PSTR("Abort\n"));
-                       return CMD_RET_SUCCESS;
-               }
+               ts = get_timer(0);
+               do {
+                       /* check for ctrl-c to abort... */
+                       if (had_ctrlc() || ctrlc()) {
+                               my_puts_P(PSTR("Abort\n"));
+                               return CMD_RET_SUCCESS;
+                       }
+               } while (get_timer(ts) < count);
        }
 
        return CMD_RET_SUCCESS;
@@ -417,27 +399,26 @@ command_ret_t do_mem_loop(cmd_tbl_t *cmdtp, int flag, int argc,
                        my_puts_P(PSTR("Bus timeout\n"));
                        return  CMD_RET_FAILURE;
                }
+               cli();
                for (;;)
                        z80_read(addr);
-               z80_bus_cmd(Release);
        }
 
        if (!(z80_bus_cmd(Request) & ZST_ACQUIRED)) {
                my_puts_P(PSTR("Bus timeout\n"));
                return  CMD_RET_FAILURE;
        }
+       cli();
        for (;;) {
                uint32_t i = length;
                uint32_t p = addr;
                while (i-- > 0)
                        z80_read(p++);
        }
-       z80_bus_cmd(Release);
 
        return CMD_RET_SUCCESS;
 }
 
-#ifdef CONFIG_LOOPW
 command_ret_t do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        uint32_t addr, length;
@@ -457,7 +438,8 @@ command_ret_t do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char * const a
 
        data = strtoul(argv[3], NULL, 16);
 
-       /* We want to optimize the loops to run as fast as possible.
+       /*
+        * We want to optimize the loops to run as fast as possible.
         * If we have only one object, just run infinite loops.
         */
        if (length == 1) {
@@ -465,6 +447,7 @@ command_ret_t do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char * const a
                        my_puts_P(PSTR("Bus timeout\n"));
                        return  CMD_RET_FAILURE;
                }
+               cli();
                for (;;)
                        z80_write(addr, data);
        }
@@ -473,6 +456,7 @@ command_ret_t do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char * const a
                my_puts_P(PSTR("Bus timeout\n"));
                return  CMD_RET_FAILURE;
        }
+       cli();
        for (;;) {
                uint32_t i = length;
                uint32_t p = addr;
@@ -480,35 +464,33 @@ command_ret_t do_mem_loopw (cmd_tbl_t *cmdtp, int flag, int argc, char * const a
                        z80_write(p++, data);
        }
 }
-#endif /* CONFIG_LOOPW */
+
+//#define CONFIG_SYS_ALT_MEMTEST
 
 #ifdef CONFIG_CMD_MEMTEST
-static uint32_t mem_test_alt(vu_long *buf, uint32_t start_addr, uint32_t end_addr,
-                         vu_long *dummy)
+static uint32_t mem_test_alt(uint32_t start_addr, uint32_t end_addr)
 {
-       vu_long *addr;
+       uint32_t addr;
+       uint32_t dummy;
        uint32_t errs = 0;
-       uint32_t val, readback;
-       int j;
-       vu_long offset;
-       vu_long test_offset;
-       vu_long pattern;
-       vu_long temp;
-       vu_long anti_pattern;
-       vu_long num_words;
-       static const FLASH uint32_t bitpattern[] = {
-               0x00000001,     /* single bit */
-               0x00000003,     /* two adjacent bits */
-               0x00000007,     /* three adjacent bits */
-               0x0000000F,     /* four adjacent bits */
-               0x00000005,     /* two non-adjacent bits */
-               0x00000015,     /* three non-adjacent bits */
-               0x00000055,     /* four non-adjacent bits */
-               0xaaaaaaaa,     /* alternating 1/0 */
+       uint32_t offset;
+       uint32_t test_offset;
+       uint8_t pattern;
+       uint8_t anti_pattern;
+       uint8_t temp;
+       uint32_t num_bytes;
+
+       static const FLASH uint8_t bitpattern[] = {
+               0x01,   /* single bit */
+               0x03,   /* two adjacent bits */
+               0x07,   /* three adjacent bits */
+               0x0F,   /* four adjacent bits */
+               0x05,   /* two non-adjacent bits */
+               0x15,   /* three non-adjacent bits */
+               0x55,   /* four non-adjacent bits */
+               0xaa,   /* alternating 1/0 */
        };
 
-       num_words = (end_addr - start_addr) / sizeof(vu_long);
-
        /*
         * Data line test: write a pattern to the first
         * location, write the 1's complement to a 'parking'
@@ -526,35 +508,39 @@ static uint32_t mem_test_alt(vu_long *buf, uint32_t start_addr, uint32_t end_add
         * '0's and '0' bits through a field of '1's (i.e.
         * pattern and ~pattern).
         */
-       addr = buf;
-       for (j = 0; j < sizeof(bitpattern) / sizeof(bitpattern[0]); j++) {
-               val = bitpattern[j];
-               for (; val != 0; val <<= 1) {
-                       *addr = val;
-                       *dummy  = ~val; /* clear the test data off the bus */
-                       readback = *addr;
-                       if (readback != val) {
+       addr = start_addr;
+       dummy = start_addr+1;
+       for (unsigned int j = 0; j < ARRAY_SIZE(bitpattern); j++) {
+               pattern = bitpattern[j];
+               for (; pattern != 0; pattern <<= 1) {
+                       anti_pattern = ~pattern;
+                       z80_write(addr, pattern);
+                       z80_write(dummy, anti_pattern); /* clear the test data off the bus */
+                       temp = z80_read(addr);
+                       if (temp != pattern) {
                                printf_P(PSTR("FAILURE (data line): "
-                                       "expected %05lx, actual %05lx\n"),
-                                               val, readback);
+                                       "expected %02x, actual %02x\n"),
+                                               pattern, temp);
                                errs++;
-                               if (ctrlc())
-                                       return -1;
                        }
-                       *addr  = ~val;
-                       *dummy  = val;
-                       readback = *addr;
-                       if (readback != ~val) {
+                       z80_write(addr, anti_pattern);
+                       z80_write(dummy, pattern); /* clear the test data off the bus */
+                       temp = z80_read(addr);
+                       if (temp != anti_pattern) {
                                printf_P(PSTR("FAILURE (data line): "
-                                       "Is %05lx, should be %05lx\n"),
-                                               readback, ~val);
+                                       "Is %02x, should be %02x\n"),
+                                               temp, anti_pattern);
                                errs++;
-                               if (ctrlc())
-                                       return -1;
                        }
                }
+
+               if (ctrlc())
+                       return -1;
        }
 
+       if (errs)
+               return errs;
+
        /*
         * Based on code whose Original Author and Copyright
         * information follows: Copyright (c) 1998 by Michael
@@ -589,59 +575,61 @@ static uint32_t mem_test_alt(vu_long *buf, uint32_t start_addr, uint32_t end_add
         *
         * Returns:     0 if the test succeeds, 1 if the test fails.
         */
-       pattern = (vu_long) 0xaaaaaaaa;
-       anti_pattern = (vu_long) 0x55555555;
 
-       debug("%s:%d: length = 0x%.5lx\n", __func__, __LINE__, num_words);
+       num_bytes = (end_addr - start_addr) / sizeof(uint8_t);
+
+       pattern = 0xaa;
+       anti_pattern = 0x55;
+
+//     debug("## %s:%d: length = 0x%.5lx\n", __func__, __LINE__, num_bytes);
        /*
         * Write the default pattern at each of the
         * power-of-two offsets.
         */
-       for (offset = 1; offset < num_words; offset <<= 1)
-               addr[offset] = pattern;
+       for (offset = 1; offset < num_bytes; offset <<= 1)
+               z80_write(addr+offset, pattern);
 
        /*
         * Check for address bits stuck high.
         */
-       test_offset = 0;
-       addr[test_offset] = anti_pattern;
+       z80_write(start_addr, anti_pattern);
 
-       for (offset = 1; offset < num_words; offset <<= 1) {
-               temp = addr[offset];
+       for (offset = 1; offset < num_bytes; offset <<= 1) {
+               temp = z80_read(start_addr + offset);
                if (temp != pattern) {
-                       printf_P(PSTR("\nFAILURE: Address bit stuck high @ 0x%.5lx:"
-                               " expected 0x%.5lx, actual 0x%.5lx\n"),
-                               start_addr + offset*sizeof(vu_long),
-                               pattern, temp);
+                       printf_P(PSTR("FAILURE: Address bit stuck high @ 0x%.5lx:"
+                               " expected 0x%.2x, actual 0x%.2x\n"),
+                               start_addr + offset, pattern, temp);
                        errs++;
                        if (ctrlc())
                                return -1;
                }
        }
-       addr[test_offset] = pattern;
+       z80_write(start_addr, pattern);
 
        /*
         * Check for addr bits stuck low or shorted.
         */
-       for (test_offset = 1; test_offset < num_words; test_offset <<= 1) {
-               addr[test_offset] = anti_pattern;
+       for (test_offset = 1; test_offset < num_bytes; test_offset <<= 1) {
+               z80_write(start_addr + test_offset, anti_pattern);
 
-               for (offset = 1; offset < num_words; offset <<= 1) {
-                       temp = addr[offset];
+               for (offset = 1; offset < num_bytes; offset <<= 1) {
+                       temp = z80_read(start_addr + offset);
                        if ((temp != pattern) && (offset != test_offset)) {
-                               printf_P(PSTR("\nFAILURE: Address bit stuck low or"
-                                       " shorted @ 0x%.5lx: expected 0x%.5lx,"
-                                       " actual 0x%.5lx\n"),
-                                       start_addr + offset*sizeof(vu_long),
-                                       pattern, temp);
+                               printf_P(PSTR("FAILURE: Address bit stuck low or shorted"
+                                       " @ 0x%.5lx: expected 0x%.2x, actual 0x%.2x\n"),
+                                       start_addr + offset, pattern, temp);
                                errs++;
                                if (ctrlc())
                                        return -1;
                        }
                }
-               addr[test_offset] = pattern;
+               z80_write(start_addr + test_offset, pattern);
        }
 
+       if (errs)
+               return errs;
+
        /*
         * Description: Test the integrity of a physical
         *              memory device by performing an
@@ -654,111 +642,50 @@ static uint32_t mem_test_alt(vu_long *buf, uint32_t start_addr, uint32_t end_add
         *
         * Returns:     0 if the test succeeds, 1 if the test fails.
         */
-       num_words++;
+       num_bytes++;
 
        /*
         * Fill memory with a known pattern.
         */
-       for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
-               addr[offset] = pattern;
-       }
+       for (pattern = 1, addr = start_addr; addr <= end_addr; pattern++, addr++)
+               z80_write(addr, pattern);
 
        /*
         * Check each location and invert it for the second pass.
         */
-       for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
-               temp = addr[offset];
+       for (pattern = 1, addr = start_addr; addr <= end_addr; pattern++, addr++) {
+               temp = z80_read(addr);
                if (temp != pattern) {
-                       printf_P(PSTR("\nFAILURE (read/write) @ 0x%.5lx:"
-                               " expected 0x%.5lx, actual 0x%.5lx)\n"),
-                               start_addr + offset*sizeof(vu_long),
-                               pattern, temp);
+                       printf_P(PSTR("FAILURE (read/write) @ 0x%.5lx:"
+                               " expected 0x%.2x, actual 0x%.2x)\n"),
+                               addr, pattern, temp);
                        errs++;
                        if (ctrlc())
                                return -1;
                }
 
                anti_pattern = ~pattern;
-               addr[offset] = anti_pattern;
+               z80_write(addr, anti_pattern);
        }
 
        /*
         * Check each location for the inverted pattern and zero it.
         */
-       for (pattern = 1, offset = 0; offset < num_words; pattern++, offset++) {
-               WATCHDOG_RESET();
+       for (pattern = 1, addr = start_addr; addr <= end_addr; pattern++, addr++) {
                anti_pattern = ~pattern;
-               temp = addr[offset];
+               temp = z80_read(addr);
                if (temp != anti_pattern) {
-                       printf_P(PSTR("\nFAILURE (read/write): @ 0x%.5lx:"
-                               " expected 0x%.5lx, actual 0x%.5lx)\n"),
-                               start_addr + offset*sizeof(vu_long),
-                               anti_pattern, temp);
+                       printf_P(PSTR("FAILURE (read/write) @ 0x%.5lx:"
+                               " expected 0x%.2x, actual 0x%.2x)\n"),
+                               start_addr,     anti_pattern, temp);
                        errs++;
                        if (ctrlc())
                                return -1;
                }
-               addr[offset] = 0;
+               z80_write(addr, 0);
        }
 
-       return 0;
-}
-
-static uint32_t mem_test_quick(vu_long *buf, uint32_t start_addr, uint32_t end_addr,
-                           vu_long pattern, int iteration)
-{
-       vu_long *end;
-       vu_long *addr;
-       uint32_t errs = 0;
-       uint32_t incr, length;
-       uint32_t val, readback;
-
-       /* Alternate the pattern */
-       incr = 1;
-       if (iteration & 1) {
-               incr = -incr;
-               /*
-                * Flip the pattern each time to make lots of zeros and
-                * then, the next time, lots of ones.  We decrement
-                * the "negative" patterns and increment the "positive"
-                * patterns to preserve this feature.
-                */
-               if (pattern & 0x80000000)
-                       pattern = -pattern;     /* complement & increment */
-               else
-                       pattern = ~pattern;
-       }
-       length = (end_addr - start_addr) / sizeof(uint32_t);
-       end = buf + length;
-       printf_P(PSTR("\rPattern %08lX  Writing..."
-               "%12s"
-               "\b\b\b\b\b\b\b\b\b\b"),
-               pattern, "");
-
-       for (addr = buf, val = pattern; addr < end; addr++) {
-               *addr = val;
-               val += incr;
-       }
-
-       my_puts_P(PSTR("Reading..."));
-
-       for (addr = buf, val = pattern; addr < end; addr++) {
-               readback = *addr;
-               if (readback != val) {
-                       uint32_t offset = addr - buf;
-
-                       printf_P(PSTR("\nMem error @ 0x%08X: "
-                               "found %08lX, expected %08lX\n"),
-                               (unsigned int)(uintptr_t)(start_addr + offset*sizeof(vu_long)),
-                               readback, val);
-                       errs++;
-                       if (ctrlc())
-                               return -1;
-               }
-               val += incr;
-       }
-
-       return 0;
+       return errs;
 }
 
 /*
@@ -769,77 +696,61 @@ static uint32_t mem_test_quick(vu_long *buf, uint32_t start_addr, uint32_t end_a
 command_ret_t do_mem_mtest(cmd_tbl_t *cmdtp, int flag, int argc,
                        char * const argv[])
 {
-       uint32_t start, end;
-       vu_long *buf, *dummy;
-       int iteration_limit;
-/* TODO: command_ret_t */
+       uint32_t start = 0;
+       uint32_t end;
+       unsigned int iteration_limit = 0;
+       unsigned int iteration;
+       uint32_t errs = 0;      /* number of errors */
        int ret;
-       uint32_t errs = 0;      /* number of errors, or -1 if interrupted */
-       uint32_t pattern;
-       int iteration;
-#if defined(CONFIG_SYS_ALT_MEMTEST)
-       const int alt_test = 1;
-#else
-       const int alt_test = 0;
-#endif
+
+       (void) cmdtp;
+       (void) flag;
 
        if (argc > 1)
                start = strtoul(argv[1], NULL, 16);
-       else
-               start = CONFIG_SYS_MEMTEST_START;
 
        if (argc > 2)
                end = strtoul(argv[2], NULL, 16);
        else
-               end = CONFIG_SYS_MEMTEST_END;
+               end = CONFIG_SYS_RAMSIZE_MAX - 1;
 
        if (argc > 3)
-               pattern = (uint32_t)strtoul(argv[3], NULL, 16);
-       else
-               pattern = 0;
+               iteration_limit = (unsigned int) strtoul(argv[3], NULL, 16);
 
-       if (argc > 4)
-               iteration_limit = (uint32_t)strtoul(argv[4], NULL, 16);
-       else
-               iteration_limit = 0;
+       printf_P(PSTR("Testing %05lx ... %05lx:\n"), start, end);
+//     debug("## %s:%d: start %#05lx end %#05lx\n", __func__, __LINE__, start, end);
 
-       printf_P(PSTR("Testing %08x ... %08x:\n"), (unsigned int)start, (unsigned int)end);
-       debug("%s:%d: start %#05lx end %#05lx\n", __func__, __LINE__,
-             start, end);
+       clear_ctrlc();          /* forget any previous Control C */
 
-/* TODO: */
-//     buf = map_sysmem(start, end - start);
-//     dummy = map_sysmem(CONFIG_SYS_MEMTEST_SCRATCH, sizeof(vu_long));
        for (iteration = 0;
                        !iteration_limit || iteration < iteration_limit;
                        iteration++) {
-               if (ctrlc()) {
-                       errs = -1UL;
-                       break;
-               }
 
                printf_P(PSTR("Iteration: %6d\r"), iteration + 1);
-               debug("\n");
-               if (alt_test) {
-                       errs = mem_test_alt(buf, start, end, dummy);
-               } else {
-                       errs = mem_test_quick(buf, start, end, pattern,
-                                             iteration);
+//             debug("\n");
+
+               if (!(z80_bus_cmd(Request) & ZST_ACQUIRED)) {
+                       my_puts_P(PSTR("Bus timeout\n"));
+                       return  CMD_RET_FAILURE;
                }
-               if (errs == -1UL)
+               errs += mem_test_alt(start, end);
+               z80_bus_cmd(Release);
+
+               if (had_ctrlc() || ctrlc()) {
                        break;
+               }
        }
 
-       if (errs == -1UL) {
+       if (had_ctrlc()) {
                /* Memory test was aborted - write a newline to finish off */
-               putc('\n');
-               ret = 1;
+               putchar('\n');
+               ret = CMD_RET_FAILURE;
        } else {
                printf_P(PSTR("Tested %d iteration(s) with %lu errors.\n"),
                        iteration, errs);
-               ret = errs != 0;
+               ret = errs ? CMD_RET_FAILURE : CMD_RET_SUCCESS;
        }
 
-       return ret;     /* not reached */
+       return ret;
 }
 #endif /* CONFIG_CMD_MEMTEST */
index b29aedddce4c3dee0bd39db617ad822e802127fe..c9a3c4529e255957940bb9f699237d25c1838004 100644 (file)
@@ -9,46 +9,43 @@
 
 #include "common.h"
 #include <stdlib.h>
+#include <stdbool.h>
 
 #include "command.h"
 #include "timer.h"
 #include "con-utils.h"
+#include "getopt-min.h"
 
 
 command_ret_t do_echo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-       uint_fast8_t putnl = 1;
+       bool put_newline = true;
 
        (void) cmdtp; (void) flag;
 
-       for (uint_fast8_t i = 1; i < argc; i++) {
+       /* reset getopt() */
+       optind = 1;
+
+       int opt;
+       while ((opt = getopt(argc, argv, PSTR("n"))) != -1) {
+               switch (opt) {
+               case 'n':
+                       put_newline = false;
+                       break;
+               default: /* '?' */
+                       return CMD_RET_USAGE;
+               }
+       }
 
-               uint_fast8_t backslash = 0;
-               char *p = argv[i];
-               char c;
+       for (uint_fast8_t i = optind; i < argc; i++) {
 
-               if (i != 1)
+               if (i != optind)
                        putchar(' ');
-               while ((c = *p++) != '\0') {
-
-                       if(backslash) {
-                               backslash = 0;
-                               if (c == 'c') {
-                                       putnl = 0;
-                                       continue;
-                               } else
-                                       putchar('\\');
-                       } else {
-                               if (c == '\\') {
-                                       backslash = 1;
-                                       continue;
-                               }
-                       }
-                       putchar(c);
-               }
+
+               my_puts(argv[i]);
        }
 
-       if (putnl)
+       if (put_newline)
                putchar('\n');
 
        return CMD_RET_SUCCESS;
index b6fa41864f6fba3b87e410e4381ff98fc4d1c81b..ed25dee4f82876ee61915eeb2f1b4f21cd335691 100644 (file)
@@ -120,7 +120,7 @@ command_ret_t _do_help(cmd_tbl_t *cmd_start, int cmd_items, cmd_tbl_t * cmdtp,
         */
        for (i = 1; i < argc; ++i) {
                if ((cmdtp = find_cmd_tbl (argv[i], cmd_start, cmd_items )) != NULL) {
-                       rcode = cmd_usage(cmdtp);
+                       cmd_usage(cmdtp);
                } else {
                        printf_P(PSTR("Unknown command '%s' - try 'help'"
                                " without arguments.\n\n"), argv[i]
@@ -149,8 +149,8 @@ cmd_tbl_t *find_cmd_tbl (const char *cmd, cmd_tbl_t *table, int table_len)
        for (cmdtp = table;
             cmdtp != table + table_len;
             cmdtp++) {
-               if (strncmp_P (cmd, cmdtp->name, len) == 0) {
-                       if (len == strlen (cmdtp->name))
+               if (strncmp_P(cmd, cmdtp->name, len) == 0) {
+                       if (len == strlen_P(cmdtp->name))
                                return cmdtp;   /* full match */
 
                        cmdtp_temp = cmdtp;     /* abbreviated command ? */
index cbd23821bfbfb33ca63f88d74a970b7655f95088..32730930dbb73f88b7b7f0634c48706a1383b872 100644 (file)
@@ -16,6 +16,8 @@ extern command_ret_t do_env_default(cmd_tbl_t *, int, int, char * const []);
 extern command_ret_t do_env_set(cmd_tbl_t *, int, int, char * const []);
 extern command_ret_t do_env_save(cmd_tbl_t *, int, int, char * const []);
 extern command_ret_t do_loadf(cmd_tbl_t *, int, int, char * const []);
+extern command_ret_t do_loadcpm3(cmd_tbl_t *, int, int, char * const []);
+extern command_ret_t do_loadihex(cmd_tbl_t *, int, int, char * const []);
 extern command_ret_t do_go(cmd_tbl_t *, int, int, char * const []);
 extern command_ret_t do_restart(cmd_tbl_t *, int, int, char * const []);
 extern command_ret_t do_console(cmd_tbl_t *, int, int, char * const []);
@@ -79,9 +81,10 @@ CMD_TBL_ITEM(
 ),
 CMD_TBL_ITEM(
        echo,   CONFIG_SYS_MAXARGS,     1,      do_echo,
-       "echo args to console",
-       "[args..]\n"
-       "     - echo args to console; \\c suppresses newline"
+       "display a line of text",
+       "[-n] [argument ...]\n"
+       "     - echo the argument(s) to console.\n"
+       "       -n  do not output the trailing newline"
 ),
 CMD_TBL_ITEM(
        sleep ,    2,    1,     do_sleep,
@@ -130,6 +133,20 @@ CMD_TBL_ITEM(
        "load srec_cat prepared image from controller flash",
        ""
 ),
+CMD_TBL_ITEM(
+       loadcpm3, 3,    0,      do_loadcpm3,
+       "load CPM3.SYS file",
+       "[offset] [filename]\n"
+       "    - Load CP/M 3 system file from FAT filesystem. This command makes\n"
+       "      CPMLDR superfluous. Default filename is '"CONFIG_PATH_CPM3SYS"', but\n"
+       "      uses environment variable '"ENV_PATH_CPM3SYS"', if set."
+),
+CMD_TBL_ITEM(
+       loadi,  2,      0,      do_loadihex,
+       "load intel hex file over serial line",
+       "[[-]offset]\n"
+       "    - load Intel-Hex-Record file over serial line with offset 'offset'"
+),
 CMD_TBL_ITEM(
        go,     2,      0,      do_go,
        "start application at address 'addr'",
@@ -149,7 +166,7 @@ CMD_TBL_ITEM(
        ""
 ),
 CMD_TBL_ITEM(
-       connect, 1, 1,  do_console,
+       connect, 1, 0,  do_console,
        "Connect to CPU console i/o",
        ""
 ),
@@ -211,23 +228,21 @@ CMD_TBL_ITEM(
        "    - set address offset for memory commands to 'offset'"
 ),
 CMD_TBL_ITEM(
-       loop,   3,      1,      do_mem_loop,
+       mloop,  3,      1,      do_mem_loop,
        "infinite loop on address range",
        "address number_of_bytes"
 ),
-#ifdef CONFIG_LOOPW
 CMD_TBL_ITEM(
-       loopw,  4,      1,      do_mem_loopw,
+       mloopw, 4,      1,      do_mem_loopw,
        "infinite write loop on address range",
        "address number_of_bytes data_to_write"
 ),
-#endif /* CONFIG_LOOPW */
 
 #ifdef CONFIG_CMD_MEMTEST
 CMD_TBL_ITEM(
-       mtest,  5,      1,      do_mem_mtest,
+       mtest,  4,      1,      do_mem_mtest,
        "simple RAM read/write test",
-       "[start [end [pattern [iterations]]]]"
+       "[start [end [iterations]]]"
 ),
 #endif /* CONFIG_CMD_MEMTEST */
 
@@ -238,7 +253,7 @@ CMD_TBL_ITEM(
        "address count delay(ms)"
 ),
 CMD_TBL_ITEM(
-       mwc,    4,      1,      do_mem_mwc,
+       mwc,    4,      1,      do_mem_mdc,
        "memory write cyclic",
        "address value delay(ms)"
 ),
index 7be7d03501f102a7fbed6367262272859d3f8ead..a947583a6fe273ce4b3710c5b642e616fb216534 100644 (file)
--- a/avr/env.c
+++ b/avr/env.c
 #define DELIM          "\0"
 
 const FLASH char default_env[] = {
-       "bootdelay="    "3"             DELIM
-       "bootcmd="      "reset; loadf; go ${startaddr}" DELIM
-       "baudrate="     "115200"        DELIM
-       "startaddr="    "0"             DELIM
+       ENV_BAUDRATE      "=" "115200" DELIM
+       ENV_BOOTDELAY     "=" "3" DELIM
+       ENV_BOOTCMD               "=" "reset; loadf; go ${startaddr}" DELIM
+       ENV_PATH_CPM3SYS  "=" CONFIG_PATH_CPM3SYS DELIM
+       ENV_PINALIAS      "=" "0:PG5,1:PG4,2:PB4,3:PB5,4:PB6,5:PB7,"
+                                                 "6:PG3,7:PG2,8:PG1,9:PG0,10:PE7" DELIM
+       ENV_STARTADDRESS  "=" "0" DELIM
        DELIM
 };
 
+
 /* EEPROM storage */
 typedef struct environment_s {
        uint16_t        crc;            /* CRC16 over data bytes        */
@@ -452,7 +456,6 @@ command_ret_t _do_env_set(int flag, int argc, char * const argv[])
        env_item_t e, *ep;
 
        (void) flag;
-       debug("Initial value for argc=%d\n", argc);
 
        name = argv[1];
        value = argv[2];
@@ -519,15 +522,35 @@ command_ret_t _do_env_set(int flag, int argc, char * const argv[])
  * @return 0 if ok, 1 on error
  */
 static
-int setenv(const char *varname, const char *varvalue)
+int setenv(const MEMX char *varname, const char *varvalue)
 {
-       const char * const argv[3] = { NULL, varname, varvalue };
+       int rc;
+
+#ifdef __MEMX
+       char *tmpname = NULL;
+       if (__builtin_avr_flash_segment(varname) != -1) {
+               tmpname = malloc(strlen_P(varname)+1);
+               if (tmpname == NULL) {
+                       printf_P(PSTR("setenv: Out of Memory!\n"));
+                       return 1;
+               }
+               strcpy_P(tmpname, varname);
+       } else
+               tmpname = (char *) varname;
+#endif
+
+       const char * const argv[3] = { NULL, tmpname, varvalue };
        int argc = 3;
 
        if (varvalue == NULL || varvalue[0] == '\0')
                --argc;
 
-       return (int) _do_env_set(0, argc, (char * const *)argv);
+       rc = (int) _do_env_set(0, argc, (char * const *)argv);
+
+#ifdef __MEMX
+       free(tmpname);
+#endif
+       return rc;
 }
 
 /**
index f4d4c6ff0b6b2d484b03b23f4e47cc7517f8139a..3852e754a5ba59477cf813421ebfcc36fea0f3c2 100644 (file)
@@ -12,7 +12,7 @@
 #include <stdio.h>
 
 #include "config.h"
-#include "debug.h"
+#include "ff.h"
 #include "z80-if.h"
 #include "i2c.h"
 #include "con-utils.h"
@@ -24,6 +24,7 @@
 #include "gpio.h"
 #include "time.h"
 #include "rtc.h"
+#include "debug.h"
 
 uint8_t mcusr __attribute__ ((section (".noinit")));
 
@@ -145,6 +146,17 @@ void setup_system_time(void)
        set_system_time(mk_gmtime(&rtc_time) );
 }
 
+
+
+static void setup_fatfs(void)
+{
+       static FATFS FatFs0;
+       static FATFS FatFs1;
+
+       f_mount(&FatFs0, "0:", 0);
+       f_mount(&FatFs1, "1:", 0);
+}
+
 /*--------------------------------------------------------------------------*/
 
 /* Stored value of bootdelay, used by autoboot_command() */
@@ -261,14 +273,9 @@ int main(void)
        print_reset_reason();
 #endif
 
-#if DEBUG
-       unsigned long i_speed = getenv_ulong(PSTR("i2c_clock"), 10, CONFIG_SYS_I2C_CLOCK);
-       debug("### Setting I2C clock Frequency to %lu Hz.\n", i_speed);
-       i2c_init(i_speed);
-#else
        i2c_init(CONFIG_SYS_I2C_CLOCK);
-#endif
        setup_system_time();
+       setup_fatfs();
 
        printf_P(PSTR("\nATMEGA1281+Z8S180 Stamp Monitor\n\n"));
 
index e0b763fa210934b17a1fe8b7db98ae1a6bf3e82d..9b4228a1b68be76336e8bf8caab7ec4f90905588 100644 (file)
@@ -5,13 +5,28 @@
  */
 
 #include "common.h"
+#include <stdlib.h>
+#include <string.h>
+#include <stdbool.h>
 #include <util/atomic.h>
 
 #include "background.h"
+#include "env.h"
+#include "ff.h"
 #include "serial.h"
 #include "z80-if.h"
 #include "debug.h"
+#include "print-utils.h"
 #include "z180-serv.h"
+#include "timer.h"
+
+
+#define DEBUG_CPM_SDIO 0       /* set to 1 to debug */
+
+#define debug_cpmsd(fmt, args...)                                                          \
+       debug_cond(DEBUG_CPM_SDIO, fmt, ##args)
+
+
 
 /*--------------------------------------------------------------------------*/
 
@@ -52,6 +67,25 @@ uint32_t msg_to_addr(uint8_t *msg)
 }
 
 
+static int msg_xmit_header(uint8_t func, uint8_t subf, int len)
+{
+       z80_memfifo_putc(fifo_msgout, 0xAE);
+       z80_memfifo_putc(fifo_msgout, len+2);
+       z80_memfifo_putc(fifo_msgout, func);
+       z80_memfifo_putc(fifo_msgout, subf);
+
+       return 0;
+}
+
+int msg_xmit(uint8_t func, uint8_t subf, int len, uint8_t *msg)
+{
+       msg_xmit_header(func, subf, len);
+       while (len--)
+               z80_memfifo_putc(fifo_msgout, *msg++);
+
+       return 0;
+}
+
 void do_msg_ini_memfifo(uint8_t subf, int len, uint8_t * msg)
 {
        (void)len;
@@ -68,6 +102,241 @@ void do_msg_char_out(uint8_t subf, int len, uint8_t * msg)
                putchar(*msg++);
 }
 
+/* echo message */
+void do_msg_echo(uint8_t subf, int len, uint8_t * msg)
+{
+       (void)subf;
+
+       /* send re-echo */
+       msg_xmit(1, 3, len, msg);
+}
+
+/* ---------------------------------------------------------------------------*/
+
+#define MAX_DRIVE      4
+#define BLOCK_SIZE     512
+#define TPA_BASE       0x10000
+#define COMMON_BASE    0xC000
+
+struct cpm_drive_s {
+       uint8_t drv;
+       uint8_t device;
+       char *img_name;
+       FIL fd;
+};
+
+static uint8_t disk_buffer[BLOCK_SIZE];
+static struct cpm_drive_s drv_table[MAX_DRIVE];
+
+/*
+       db      2       ; disk command
+       ds      1       ; subcommand (login/read/write)
+       ds      1       ; @adrv (8 bits)        +0
+       ds      1       ; @rdrv (8 bits)        +1
+       ds      3       ; @xdph (24 bits)       +2
+*/
+
+void do_msg_cpm_login(uint8_t subf, int len, uint8_t * msg)
+{
+
+       FRESULT res = 0;
+       uint8_t rc = 0;
+       uint8_t drv;
+       char *np;
+       uint8_t result_msg[3];
+
+       (void)subf;
+
+       if (len != 5) {     /* TODO: check adrv, rdrv */
+               rc = 0x01;
+               goto out;
+       }
+
+       debug_cpmsd("\n## %7lu  login: %c:\n", get_timer(0), msg[0]+'A');
+
+
+       drv = msg[0];
+       if ( drv>= MAX_DRIVE) {
+               rc = 0x02;
+               goto out;
+       }
+
+/*
+       uint32_t dph = ((uint32_t)msg[4] << 16) + ((uint16_t)msg[3] << 8) + msg[2];
+*/
+
+       if (drv_table[drv].img_name != NULL) {
+               debug_cpmsd("## %7lu  close: '%s'\n", get_timer(0), drv_table[drv].img_name);
+               f_close(&drv_table[drv].fd);
+               free(drv_table[drv].img_name);
+               drv_table[drv].img_name = NULL;
+       }
+
+       strcpy_P((char *)disk_buffer, PSTR("dsk0"));
+       disk_buffer[3] = msg[0] + '0';
+       if (((np = getenv((char*)disk_buffer)) == NULL) ||
+                       ((drv_table[drv].img_name = strdup(np)) == NULL)) {
+               rc = 0x03;
+               goto out;
+       }
+
+
+       res = f_open(&drv_table[drv].fd, drv_table[drv].img_name,
+                       FA_WRITE | FA_READ);
+
+    debug_cpmsd("## %7lu   open: '%s', (env: '%s'), res: %d\n", get_timer(0),
+                       drv_table[drv].img_name, disk_buffer, res);
+
+out:
+
+       if (res)
+               rc |= 0x80;
+
+       result_msg[0] = rc;
+       result_msg[1] = res;
+       result_msg[2] = res >> 8;
+
+       if (rc) {
+               debug_cpmsd("## %7lu   error    rc: %.02x, res: %d\n", get_timer(0), rc, res);
+       };
+
+       /* send  result*/
+       msg_xmit(2, subf, sizeof(result_msg), result_msg);
+}
+
+
+/*
+       db      2       ; disk command
+       ds      1       ; subcommand (login/read/write)
+       ds      1       ; @adrv (8 bits)                +0
+       ds      1       ; @rdrv (8 bits)                +1
+       ds      2       ; @trk (16 bits)                +2
+       ds      2       ; @sect(16 bits)                +4
+       ds      1       ; @cnt  (8 bits)                +6
+       ds      3       ; phys. transfer addr   +7
+*/
+
+#define ADRV   0
+#define RDRV   1
+#define TRK            2
+#define SEC            4
+#define CNT            6
+#define ADDR   7
+
+void do_msg_cpm_rw(uint8_t subf, int len, uint8_t * msg)
+{
+       uint8_t drv;
+       uint32_t addr;
+       uint32_t pos;
+       uint8_t secs;
+       bool dowrite = (subf == 2);
+       FRESULT res = 0;
+       uint8_t rc = 0;
+       bool buserr = 0;
+       uint8_t result_msg[3];
+
+       if (len != 10) {     /* TODO: check adrv, rdrv */
+               rc = 0x01;
+               goto out;
+       }
+
+       drv = msg[ADRV];
+       if ( drv>= MAX_DRIVE) {
+               rc = 0x02;
+               goto out;
+       }
+
+       secs = msg[CNT];
+       addr = ((uint32_t)msg[ADDR+2] << 16) + ((uint16_t)msg[ADDR+1] << 8) + msg[ADDR];
+
+
+       /* TODO: tracks per sector from dpb */
+       pos = (((uint16_t)(msg[TRK+1] << 8) + msg[TRK]) * 8
+                       + ((uint32_t)(msg[SEC+1] << 8) + msg[SEC])) * BLOCK_SIZE;
+
+       debug_cpmsd("## %7lu cpm_rw: %s %c: trk:%4d, sec: %d, pos: %.8lx, secs: %2d, "
+                       "addr: %.5lx\n", get_timer(0), dowrite ? "write" : " read",
+                       msg[ADRV]+'A', ((uint16_t)(msg[TRK+1] << 8) + msg[TRK]), msg[SEC],
+                       pos, msg[CNT], addr);
+
+       res = f_lseek(&drv_table[drv].fd, pos);
+       while (!res && secs--) {
+               unsigned int cnt, br;
+
+               /* check bank boundary crossing */
+               cnt = 0;
+               if (addr < (TPA_BASE + COMMON_BASE) &&
+                                       (addr + BLOCK_SIZE) > (TPA_BASE + COMMON_BASE)) {
+                       cnt = (TPA_BASE + COMMON_BASE) - addr;
+               }
+
+               if (cnt) {
+                       debug_cpmsd("## %67c addr: %.5lx, cnt: %3d\n", ' ', addr, cnt);
+                       debug_cpmsd("## %67c addr: %.5lx, cnt: %3d\n", ' ', addr+cnt-TPA_BASE, BLOCK_SIZE-cnt);
+               }
+
+               if (dowrite) {
+                       if (!(z80_bus_cmd(Request) & ZST_ACQUIRED)) {
+                               buserr = 1;
+                               break;
+                       } else {
+                               if (cnt) {
+                                       z80_read_block(disk_buffer, addr, cnt);
+                                       addr = addr + cnt - TPA_BASE;
+                               }
+                               z80_read_block(disk_buffer+cnt, addr, BLOCK_SIZE - cnt);
+                               z80_bus_cmd(Release);
+                       }
+                       res = f_write(&drv_table[drv].fd, disk_buffer, BLOCK_SIZE, &br);
+               } else {
+                       res = f_read(&drv_table[drv].fd, disk_buffer, BLOCK_SIZE, &br);
+                       if (res == FR_OK && br == BLOCK_SIZE) {
+                               if (!(z80_bus_cmd(Request) & ZST_ACQUIRED)) {
+                                       buserr = 1;
+                                       break;
+                               } else {
+                                       if (cnt) {
+                                               z80_write_block(disk_buffer, addr, cnt);
+                                               addr = addr + cnt - TPA_BASE;
+                                       }
+                                       z80_write_block(disk_buffer+cnt, addr, BLOCK_SIZE - cnt);
+                                       z80_bus_cmd(Release);
+                               }
+                       }
+               }
+
+               if (br != BLOCK_SIZE) {
+                       debug_cpmsd("## %7lu f_read res: %d, bytes rd/wr: %u\n", get_timer(0), res, br);
+                       dump_ram(disk_buffer, 0, 64, "Read Data");
+                       res = -1;
+               }
+
+               addr += BLOCK_SIZE;
+       }
+
+       if (dowrite && !res)
+               res = f_sync(&drv_table[drv].fd);
+
+out:
+       if (buserr) {
+               debug_cpmsd("Bus timeout\n");
+               rc = 0x03;
+       }
+       if (res)
+               rc |= 0x80;
+
+       result_msg[0] = rc;
+       result_msg[1] = res;
+       result_msg[2] = res >> 8;
+
+       if (rc) {
+               debug_cpmsd("###%7lu  error rc: %.02x, res: %d\n", get_timer(0), rc, res);
+       }
+
+       /* send  result*/
+       msg_xmit(2, subf, sizeof(result_msg), result_msg);
+}
+
 
 const FLASH struct msg_item z80_messages[] =
 {
@@ -77,6 +346,15 @@ const FLASH struct msg_item z80_messages[] =
        { 1,
          1, 1,
          do_msg_char_out},
+       { 1,
+         2, 2,
+         do_msg_echo},
+       { 2,
+         0, 0,
+         do_msg_cpm_login},
+       { 2,
+         1, 2,
+         do_msg_cpm_rw},
        { 0xff,                         /* end mark */
          0, 0,
          0},
@@ -178,18 +456,27 @@ int msg_handling(int state)
 
        if (pending) {
                switch (state) {
-               case 0:
+               case 0:                 /* need init */
+                       /* Get address of fifo_list */
                        z80_bus_cmd(Request);
-                       uint32_t addr = z80_read(0x40) +
+                       uint32_t fifo_list = z80_read(0x40) +
                                ((uint16_t) z80_read(0x41) << 8) +
                                ((uint32_t) z80_read(0x42) << 16);
                        z80_bus_cmd(Release);
-                       if (addr != 0) {
-                               z80_memfifo_init(fifo_msgin, addr);
-                               state = 1;
+                       if (fifo_list != 0) {
+                               /* Get address of fifo 0 */
+                               z80_bus_cmd(Request);
+                               uint32_t fifo_addr = z80_read(fifo_list) +
+                                       ((uint16_t) z80_read(fifo_list+1) << 8) +
+                                       ((uint32_t) z80_read(fifo_list+2) << 16);
+                               z80_bus_cmd(Release);
+                               if (fifo_addr != 0) {
+                                       z80_memfifo_init(fifo_msgin, fifo_addr);
+                                       state = 1;
+                               }
                        }
                        break;
-               case 1:
+               case 1:                 /* awaiting messages */
                        check_msg_fifo();
                        break;
                }
@@ -218,6 +505,7 @@ void restart_z180_serv(void)
        for (int i = 0; i < NUM_FIFOS; i++)
                z80_memfifo_init(i, 0);
        bg_setstat(handle_msg_handling, 0);
+
 }
 
 /*--------------------------------------------------------------------------*/
index d5dc2d75c8a0cfe78b6f75f8d67ac2c9d877e979..21ffeac87e054da19880689744560ae12628a514 100644 (file)
@@ -560,10 +560,9 @@ void z80_memfifo_init(const fifo_t f, uint32_t addr)
 {
        fifo_dsc[f].base = addr;
 
-       if (addr != 0) {
-
 DBG_P(2, "z80_memfifo_init: %i, %lx\n", f, addr);
 
+       if (addr != 0) {
                z80_bus_cmd(Request);
                fifo_dsc[f].mask = z80_read(addr + FIFO_BUFSIZE_MASK);
                fifo_dsc[f].idx_in = z80_read(addr + FIFO_INDEX_IN);
index 05227cc4554b7782f5396ce1ba6a36e87cdf4eb8..782c10a94e679fa379ec35e06e7019418b930f0d 100644 (file)
@@ -19,15 +19,12 @@ extern command_ret_t do_mem_cp(cmd_tbl_t *, int, int, char * const []);
 extern command_ret_t do_mem_cmp(cmd_tbl_t *, int, int, char * const []);
 extern command_ret_t do_mem_base(cmd_tbl_t *, int, int, char * const []);
 extern command_ret_t do_mem_loop(cmd_tbl_t *, int, int, char * const []);
-#ifdef CONFIG_LOOPW
 extern command_ret_t do_mem_loopw(cmd_tbl_t *, int, int, char * const []);
-#endif
 #ifdef CONFIG_CMD_MEMTEST
 extern command_ret_t do_mem_mtest(cmd_tbl_t *, int, int, char * const []);
 #endif
 #ifdef CONFIG_MX_CYCLIC
 extern command_ret_t do_mem_mdc(cmd_tbl_t *, int, int, char * const []);
-extern command_ret_t do_mem_mwc(cmd_tbl_t *, int, int, char * const []);
 #endif /* CONFIG_MX_CYCLIC */
 
 #endif /* CMD_MEM_H */
index cfbbae5c1fc1cf3185f18e67bb9983667d7f9080..10c4417d8b0c147de15a20e142a81fb93265a9d6 100644 (file)
@@ -52,6 +52,12 @@ struct bits {
 #define FSTR(X) ((const FLASH char[]) { X } )
 #define ARRAY_SIZE(x)  (sizeof(x) / sizeof((x)[0]))
 
+#define MIN(a,b)    ({ typeof (a) _a = (a);                                    \
+                                               typeof (b) _b = (b);                                   \
+                                               _a < _b ? _a : _b; })
+#define MAX(a,b)    ({ typeof (a) _a = (a);                                    \
+                                               typeof (b) _b = (b);                                   \
+                                               _a > _b ? _a : _b; })
 
 #ifdef __AVR__
 #define Stat GPIOR0
index e40d016b017f5adf5bfc6f6b629fbb8c0e3cdc18..99e4e78632bc40253dad558ca692f69d982f9377 100644 (file)
 #define ENV_BAUDRATE   "baudrate"
 #define ENV_BOOTDELAY  "bootdelay"
 #define ENV_BOOTCMD            "bootcmd"
+#define ENV_PATH_CPM3SYS "cpm3_file"
 #define ENV_PINALIAS   "pin_alias"
+#define ENV_STARTADDRESS "startaddress"
+
+#define CONFIG_PATH_CPM3SYS "1:/cpm3.sys"
 
 #define CONFIG_ENV_SIZE                1600
 #define CONFIG_ENV_OFFSET      0
@@ -23,9 +27,9 @@
 #define CONFIG_BOOTDELAY       4
 //#define CONFIG_ZERO_BOOTDELAY_CHECK  1
 
-//#define CONFIG_LOOPW
-//#define CONFIG_CMD_MEMTEST
-//#define CONFIG_MX_CYCLIC
+#define CONFIG_CMD_MEMTEST
+#define CONFIG_MX_CYCLIC
+#define CONFIG_SYS_RAMSIZE_MAX (1l<<19)        /* max. addressable memory */
 
 #define CONFIG_CMD_DATE 1
 
index f676826451554e79175127a0fb0dd7107f3d7eed..c6727b9ba9187420eb51428d866863da4e56b207 100644 (file)
@@ -1,7 +1,9 @@
 
 
-SRC :=  r3init.180 ddtz.180
-SRC += fifoio.180 msgbuf.180 ser1-i.180 console.180
+SRC :=  init.180 ddtz.180
+SRC += console.180
+SRC += msgbuf-a.180 conbuf-a.180
+SRC += asci1-p.180
 SRC += romend.180
 
 INC := config.inc z180reg.inc z180.lib
@@ -11,7 +13,7 @@ OBJ := $(SRC:.180=.rel)
 #CP/M emulator
 CPMEMU = zxcc
 
-#Location of CP/M binaries 
+#Location of CP/M binaries
 CPMBIN = /usr/local/lib/cpm/bin80
 
 #AS = $(CPMEMU) $(CPMBIN)/m80.com
@@ -24,7 +26,7 @@ AS_OPT := MFS
 AS_QUIET = 1
 LN_QUIET = 1
 
-#LNKCMD = 
+#LNKCMD =
 LN_VERB = /V
 LN_PROG = 0
 LN_DATA = C000
@@ -70,7 +72,7 @@ define cpm-link =
 endef
 
 #Use:   MAKESYM Filename[.ext][/PXXXX][/DXXXX][/CXXXX]
-#egrep '^[[:xdigit:]]{4}[[:space:]]+[[:xdigit:]]{4}[[:space:]]+D.*r3init\.rel' hdrom.map
+#egrep '^[[:xdigit:]]{4}[[:space:]]+[[:xdigit:]]{4}[[:space:]]+D.*init\.rel' hdrom.map
 define cpm-mksym =
 COMMAND="$(CPMEMU) makesym -$^ -/P -D"; \
 OUTPUT=$$(mktemp); echo $${COMMAND}; \
@@ -80,7 +82,7 @@ if [ "$${ERROR}" != "0" ]; then cat $${OUTPUT}; rm -f $@; fi ; \
 exit $${ERROR}
 endef
 
-hdrom.c: hdrom.hex     
+hdrom.c: hdrom.hex
        srec_cat -o $@ -c_array $(basename $<) -C_COMpressed -include $< -Intel
 
 hdrom.hex : $(OBJ)
@@ -92,7 +94,7 @@ hdrom.hex : $(OBJ)
 
 hdrom.map: hdrom.hex
 
-%.sym: hdrom.map %.lst 
+%.sym: hdrom.map %.lst
        @$(cpm-mksym)
 
 .phony: clean realclean
@@ -123,4 +125,3 @@ realclean: clean
        if [ "$${ERROR}" != "0" ]; then cat $${OUTPUT}; fi ; \
        rm $${OUTPUT}; \
        exit $${ERROR}
-
index bb88946149b2e6ea0457e259f63af365adc23bfe..50ede98bcb6289c9eed642a4d17e1aef1aa54db3 100644 (file)
@@ -2,12 +2,12 @@ include_rules
 
 PROG   = hdrom
 
-SRC    = r3init.180 
+SRC    = init.180
 SRC    += ddtz.180
-#SRC   += fifoio.180 msgbuf.180 ser1-i.180 console.180
-SRC    += msgbuf-a.180 conbuf-a.180 ser1-i.180 bioscio.180 chario.180
-# serial (asci1) console only:
-#SRC   += ser1-i.180 console.180
+SRC    += msgbuf-a.180 conbuf-a.180
+#SRC   += bioscio.180 chario.180
+SRC    += console.180
+SRC    += asci-p.180
 SRC    += romend.180
 
 
@@ -28,7 +28,7 @@ AS = $(CPMEMU) slr180.com
 
 ###############################################################################
 
-!AS-plain = |> $(AS) -%B/$(AS_OPT) |> %B.rel | %B.lst 
+!AS-plain = |> $(AS) -%B/$(AS_OPT) |> %B.rel | %B.lst
 
 !AS = |> ^ $(AS) -%B/$(AS_OPT)^ set +e; OUTPUT=\$(mktemp);\
 $(AS) -%B/$(AS_OPT) > ${OUTPUT};\
@@ -36,9 +36,10 @@ grep -q '^ 0 Error(s) Detected' ${OUTPUT}; ERROR=$?;\
 [ "${ERROR}" != "0" ] && cat ${OUTPUT};\
 [ "${ERROR}" != "0" ] && rm -f %B.rel;\
 rm -f ${OUTPUT}; exit ${ERROR} \
-|> %B.rel | %B.lst 
+|> %B.rel | %B.lst
 
-!LINK = |> ld80 -o %o -ms %O.map -P $(LN_PROG) -D $(LN_DATA) %f |> | %O.map
+#!LINK = |> ld80 -o %o -ms %O.map -P $(LN_PROG) -D $(LN_DATA) %f |> | %O.map
+!LINK = |> ld80 -o %o -ms %O.map -P $(LN_PROG) %f |> | %O.map
 
 #ifndef DEBUG
 
@@ -51,4 +52,3 @@ rm -f ${OUTPUT}; exit ${ERROR} \
 
 
 #endif
-
diff --git a/z180/asci-p.180 b/z180/asci-p.180
new file mode 100644 (file)
index 0000000..956faf1
--- /dev/null
@@ -0,0 +1,133 @@
+       page    200\r
+\r
+       extrn   ioiniml\r
+\r
+       global  as0init\r
+       global  as0ista,as0inp\r
+       global  as0osta,as0out\r
+       global  as1init\r
+       global  as1ista,as1inp\r
+       global  as1osta,as1out\r
+\r
+       include config.inc\r
+       include z180reg.inc\r
+\r
+\r
+;-----------------------------------------------------\r
+;\r
+;\r
+; TC = (f PHI /(2*baudrate*Clock_mode)) - 2\r
+;\r
+; TC = (f PHI / (32 * baudrate)) - 2\r
+;\r
+\r
+       cseg\r
+;\r
+; Init Serial I/O for console input and output (ASCI1)\r
+;\r
+       \r
+\r
+\r
+as0init:\r
+       ld      hl,initab0\r
+       jp      ioiniml\r
+\r
+as1init:\r
+       ld      hl,initab1\r
+       jp      ioiniml\r
+\r
+               \r
+       ld      a,M_MPBT \r
+       out0    (cntlb1),a\r
+       ld      a,M_RE + M_TE + M_MOD2  ;Rx/Tx enable \r
+       out0    (cntla1),a\r
+       ld      a,M_RIE\r
+       out0    (stat1),a       ;Enable rx interrupts\r
+\r
+       ret                     ;\r
+\r
+\r
+initab0:\r
+       db      1,stat0,0               ;Disable rx/tx interrupts\r
+                                       ;Enable baud rate generator\r
+       db      1,asext0,M_BRGMOD+M_DCD0DIS+M_CTS0DIS\r
+       db      2,astc0l,low 28, high 28\r
+       db      1,cntlb0,M_MPBT         ;No MP Mode, X16\r
+       db      1,cntla0,M_RE+M_TE+M_MOD2 ;Rx/Tx enable, 8N1\r
+       db      0\r
+\r
+initab1:\r
+       db      1,stat1,0               ;Disable rx/tx ints, disable CTS1\r
+       db      1,asext1,M_BRGMOD       ;Enable baud rate generator\r
+       db      2,astc1l,low 3, high 3\r
+       db      1,cntlb1,M_MPBT         ;No MP Mode, X16\r
+       db      1,cntla1,M_RE+M_TE+M_MOD2 ;Rx/Tx enable, 8N1\r
+       db      0\r
+\r
+\r
+\r
+as0ista:\r
+       in0     a,(stat0)\r
+       and     M_RDRF\r
+       ret     z\r
+       or      0ffh\r
+       ret\r
+       \r
+as1ista:\r
+       in0     a,(stat1)\r
+       and     M_RDRF\r
+       ret     z\r
+       or      0ffh\r
+       ret\r
+       \r
+\r
+as0inp:\r
+       in0     a,(stat0)\r
+       rlca\r
+       jr      nc,as0inp\r
+       in0     a,rdr0\r
+       ret\r
+\r
+as1inp:\r
+       in0     a,(stat1)\r
+       rlca\r
+       jr      nc,as1inp\r
+       in0     a,rdr1\r
+       ret\r
+\r
+\r
+\r
+as0osta:\r
+       in0     a,(stat0)\r
+       and     M_TDRE\r
+       ret     z\r
+       or      0ffh\r
+       ret\r
+\r
+as1osta:\r
+       in0     a,(stat1)\r
+       and     M_TDRE\r
+       ret     z\r
+       or      0ffh\r
+       ret\r
+\r
+\r
+as0out:\r
+       in0     a,(stat0)\r
+       and     M_TDRE\r
+       jr      z,as0out\r
+       out0    (tdr0),c\r
+       ld      a,c\r
+       ret\r
+\r
+as1out:\r
+       in0     a,(stat1)\r
+       and     M_TDRE\r
+       jr      z,as1out\r
+       out0    (tdr1),c\r
+       ld      a,c\r
+       ret\r
+\r
+       end\r
+\r
+\r
similarity index 84%
rename from z180/ser1-i.180
rename to z180/asci1-i.180
index 2410e3804ed64b6f0e3126f7a0830fbdea0ab330..15e121a0775d11bc63961b7e129c9ca639230475 100644 (file)
@@ -4,12 +4,12 @@
        extrn   buf.init\r
        extrn   isv_sw\r
 \r
-       \r
+\r
        global  ser.init\r
        global  ser.ist,ser.in\r
        global  ser.ost,ser.out\r
 \r
-;TODO: define a trampoline area somewhere in top ram. \r
+;TODO: define a trampoline area somewhere in top ram.\r
 rtxisvjmp      equ     0FF60h  ;momentan frei...\r
 \r
        include config.inc\r
@@ -19,10 +19,10 @@ rtxisvjmp   equ     0FF60h  ;momentan frei...
 ;-----------------------------------------------------\r
 \r
        dseg\r
-       \r
+\r
 buf_start:\r
-       mkbuf   ser1.inbuf,s1.rx_len\r
-       mkbuf   ser1.outbuf,s1.tx_len\r
+       mkbuf   s1.rx_id, ser1.inbuf, s1.rx_len\r
+       mkbuf   s1.tx_id, ser1.outbuf, s1.tx_len\r
 buf_end:\r
 \r
 \r
@@ -33,7 +33,7 @@ buf_end:
 ;\r
 ; Init Serial I/O for console input and output (ASCI1)\r
 ;\r
-       \r
+\r
 \r
 ser.init:\r
 ;      ld      a,i\r
@@ -42,10 +42,10 @@ ser.init:
 \r
        xor     a               ;\r
        out0    (stat1),a       ;Disable rx/tx interrupts\r
-               \r
+\r
        ld hl,rxtx_src          ;move rx and tx isv to common ram\r
        ld de,rxtx_dst          ;\r
-       ld bc,rxtx_src_e-rxtx_src ;     \r
+       ld bc,rxtx_src_e-rxtx_src ;\r
        ldir                    ;\r
 \r
        ld hl,rtxisvjmp         ;rx/tx int vector\r
@@ -59,7 +59,7 @@ ser.init:
 \r
 ; ASCI1: 8N1, highest baudrate (56700), CTS disabled\r
 \r
-       ld      a,M_MPBT \r
+       ld      a,M_MPBT\r
        out0    (cntlb1),a\r
        ld      a,M_RE + M_TE + M_MOD2\r
        out0    (cntla1),a\r
@@ -89,21 +89,21 @@ buf.empty:
        ret     z\r
        or      0ffh\r
        ret\r
-       \r
+\r
 ser.in:\r
-       push    hl                      ;11     \r
+       push    hl                      ;11\r
        push    de                      ;11\r
-       ld      hl,ser1.inbuf-1         ; 9     hl = &rx.out_idx        \r
+       ld      hl,ser1.inbuf-1         ; 9     hl = &rx.out_idx\r
        ld      a,(hl)                  ; 6     a = rx.out_idx\r
        dec     hl                      ; 4     hl = &rx.in_idx\r
        jr      bg.w1\r
 bg.wait:\r
        halt\r
 bg.w1:\r
-       cp      (hl)                    ; 6     while (out_idx==in_idx) \r
+       cp      (hl)                    ; 6     while (out_idx==in_idx)\r
        jr      z,bg.wait               ; 6 (/8)        ;\r
 \r
-       ld      e,a                     ; 4     \r
+       ld      e,a                     ; 4\r
        ld      d,0                     ; 6\r
        inc     de\r
        inc     de\r
@@ -111,20 +111,20 @@ bg.w1:
        ex      de,hl                   ; 3\r
        add     hl,de                   ;10\r
        ld      l,(hl)                  ; 6\r
-       ex      de,hl                   ; 3     \r
+       ex      de,hl                   ; 3\r
 \r
        inc     a                       ; 4\r
        dec     hl                      ; 4\r
-       and     (hl)                    ; 6     \r
+       and     (hl)                    ; 6\r
        inc     hl                      ; 4\r
        inc     hl                      ; 4\r
        ld      (hl),a                  ; 7\r
-       \r
+\r
        ld      a,e                     ; 4\r
        pop     de                      ; 9\r
        pop     hl                      ; 9\r
        ret                             ; 9\r
-                                       ;   153 \r
+                                       ;   153\r
 \r
 ser.ost:\r
        push    ix\r
@@ -191,7 +191,7 @@ rxtxisv:
        in0     d,(rdr1)                ;todo: break detection\r
        bit     FE,a                    ;framing error?\r
        jr      nz,??ri_1\r
-       \r
+\r
        push    ix\r
        ld      ix,ser1.inbuf           ;\r
        ld      hl,ser1.inbuf           ;\r
@@ -233,7 +233,7 @@ txisv:
 ??ti_1:\r
        ld      l,(hl)\r
        out0    (tdr1),l                ;071b\r
-       \r
+\r
        ld      a,(ix+o.out_idx)        ;\r
        inc     a\r
        and     (ix+o.mask)\r
@@ -254,5 +254,3 @@ rxtx_src_e:
 \r
 \r
        end\r
-\r
-\r
index 5ec55c69b07e44d1eefe8392e2df6e5fe998f6e4..2d8e5e032ac13c86c60f6de9282abb93f69abb14 100644 (file)
@@ -65,7 +65,8 @@ c$init$loop:
        dec     c\r
        jp      p,c$init$loop\r
 \r
-       ld      hl,1000000000000000b    ; assign console to HOST\r
+;      ld      hl,1000000000000000b    ; assign console to HOST\r
+       ld      hl,0010000000000000b    ; assign console to ASCI1\r
        ld      (@civec),hl\r
        ld      (@covec),hl\r
        ld      hl,0000000000000000b    ; assign auxiliary to nothing\r
index 6632690688b0cf4c6f6070b6dfea462b8e1e1c2b..4d37b89a2310afe888d7604e932bbd94bdcdb226 100644 (file)
@@ -2,20 +2,21 @@
        .z80\r
 \r
 \r
-;      CP/M 3  compatible character i/o \r
+;      CP/M 3  compatible character i/o\r
 \r
        public  ?cinit,?ci,?co,?cist,?cost\r
        public  @ctbl\r
 \r
        extrn   ff.init,ff.i.st,ff.in,ff.o.st,ff.out\r
-       extrn   ser.init,ser.ist,ser.in,ser.ost,ser.out\r
-       \r
+       extrn   as0init,as0ista,as0inp,as0osta,as0out\r
+       extrn   as1init,as1ista,as1inp,as1osta,as1out\r
+\r
        include config.inc\r
        include z180reg.inc\r
        include modebaud.inc    ; define mode bits and baud eqautes\r
 \r
 \r
-max$device     equ 2\r
+max$device     equ 3\r
 \r
        cseg\r
 \r
@@ -25,7 +26,8 @@ max$device    equ 2
        ld      b,c\r
        call    vector$io\r
        dw      ff.init\r
-       dw      ser.init\r
+       dw      as0init\r
+       dw      as1init\r
        dw      rret\r
 \r
 ; b = device, c = output char, a = input char\r
@@ -33,25 +35,29 @@ max$device  equ 2
 ?ci:                           ; character input\r
        call    vector$io\r
        dw      ff.in\r
-       dw      ser.in\r
+       dw      as0inp\r
+       dw      as1inp\r
        dw      null$input\r
 \r
 ?cist:                         ; character input status\r
        call    vector$io\r
        dw      ff.i.st\r
-       dw      ser.ist\r
+       dw      as0ista\r
+       dw      as1ista\r
        dw      null$status\r
 \r
 ?co:                           ; character output\r
        call    vector$io\r
        dw      ff.out\r
-       dw      ser.out\r
+       dw      as0out\r
+       dw      as1out\r
        dw      rret\r
 \r
 ?cost:                         ; character output status\r
        call    vector$io\r
        dw      ff.o.st\r
-       dw      ser.ost\r
+       dw      as0osta\r
+       dw      as1osta\r
        dw      ret$true\r
 \r
 vector$io:\r
@@ -89,10 +95,15 @@ null$status:
 \r
 @ctbl:\r
        db      'HOST  '        ; device 0\r
-       db      mb$output\r
+       db      mb$in$out\r
        db      baud$none\r
 \r
-       db      'ASCI1 '        ; device 0\r
+       db      'ASCI0 '        ; device 1\r
+       db      mb$in$out+mb$serial+mb$soft$baud\r
+ser0$baud:\r
+       db      baud$19200\r
+\r
+       db      'ASCI1 '        ; device 2\r
        db      mb$in$out+mb$serial+mb$soft$baud\r
 ser1$baud:\r
        db      baud$19200\r
@@ -100,4 +111,3 @@ ser1$baud:
        db      0               ; table terminator\r
 \r
        end\r
-\r
index 8534f7300441c0af2d99e4cac4bac3447c31d9cf..e86b8b25ea26c374a0ed3bfbca515c2399dc4303 100644 (file)
@@ -1,6 +1,6 @@
        page    255\r
        .z80\r
-       \r
+\r
 ;\r
 ; FIFO channels for communication with avr\r
 ;\r
@@ -9,16 +9,18 @@
        extrn   buf.init\r
 \r
        include config.inc\r
+       if CPU_Z180\r
        include z180reg.inc\r
+       endif\r
 \r
 \r
 ;--------------------------------------------------------------\r
 \r
        dseg\r
-       \r
 \r
-       mkbuf   co.fifo,co.fifo_len\r
-       mkbuf   ci.fifo,ci.fifo_len\r
+\r
+       mkbuf   co.fifo_id, co.fifo, co.fifo_len\r
+       mkbuf   ci.fifo_id, ci.fifo, ci.fifo_len\r
 \r
 \r
 ;--------------------------------------------------------------\r
@@ -48,7 +50,7 @@ buf.empty:
        ret     z\r
        or      0ffh\r
        ret\r
-       \r
+\r
 \r
 ff.in:\r
        push    ix\r
@@ -69,12 +71,12 @@ bg.wait:
        inc     h\r
 bg.nc:\r
        ld      l,(hl)\r
-       \r
+\r
        ld      a,(ix+o.out_idx)        ;\r
        inc     a\r
        and     (ix+o.mask)\r
        ld      (ix+o.out_idx),a\r
-       \r
+\r
        ld      a,l\r
        pop     hl\r
        pop     ix\r
@@ -96,36 +98,68 @@ buf.full:
        ret\r
 \r
 \r
+       if 1\r
 ff.out:\r
-       push    ix\r
-       ld      ix,co.fifo              ;\r
+       push    ix                      ;15\r
+       ld      ix,co.fifo              ;14\r
 \r
 buf.put:\r
-       push    hl                      ;\r
-       push    bc\r
-       push    ix\r
-       pop     hl\r
-       ld      a,c\r
-       ld      c,(ix+o.in_idx)         ;\r
-       ld      b,0\r
-       add     hl,bc\r
-       ld      b,a\r
+       push    hl                      ;11\r
+       push    bc                      ;11\r
+       push    ix                      ;15\r
+       pop     hl                      ;10\r
+       ld      a,c                     ;4\r
+       ld      c,(ix+o.in_idx)         ;19\r
+       ld      b,0                     ;7\r
+       add     hl,bc                   ;11\r
+       ld      (hl),a                  ;7\r
+       ld      b,a                     ;4\r
+\r
+       ld      a,c                     ;4\r
+       inc     a                       ;4\r
+       and     (ix+o.mask)             ;19\r
+bp.wait:\r
+       cp      (ix+o.out_idx)          ;19\r
+       jr      z,bp.wait               ;12/7\r
+       ld      (ix+o.in_idx),a         ;19\r
 \r
-       ld      a,c                     ;\r
-       inc     a\r
-       and     (ix+o.mask)\r
+       out     (AVRINT6),a             ;11\r
+       ld      a,b                     ;4\r
+       pop     bc                      ;10\r
+       pop     hl                      ;10\r
+       pop     ix                      ;14\r
+       ret                             ;10\r
+\r
+       else\r
+\r
+ff.out:\r
+       push    ix                      ;15\r
+       ld      ix,co.fifo              ;14\r
+\r
+buf.put:\r
+       push    hl                      ;11\r
+       push    ix                      ;15\r
+       pop     hl                      ;10\r
+       ld      a,(ix+o.in_idx)         ;19\r
+       add     a,l                     ;4\r
+       ld      l,a                     ;4\r
+       jr      nc,bp.1                 ;12/7\r
+       inc     l                       ;4\r
+       ld      (hl),c                  ;7\r
+       ld      a,(ix+o.in_idx)         ;19\r
+       inc     a                       ;4\r
+       and     (ix+o.mask)             ;19\r
 bp.wait:\r
-       cp      (ix+o.out_idx)          ;\r
-       jr      z,bp.wait\r
-       ld      (hl),b\r
-       ld      (ix+o.in_idx),a\r
-       \r
-       out     (AVRINT6),a\r
-       ld      a,b\r
-       pop     bc\r
-       pop     hl\r
-       pop     ix\r
-       ret\r
+       cp      (ix+o.out_idx)          ;19\r
+       jr      z,bp.wait               ;12/7\r
+       ld      (ix+o.in_idx),a         ;19\r
 \r
-       end\r
+       out     (AVRINT6),a             ;11\r
+       ld      a,c                     ;4\r
+       pop     hl                      ;10\r
+       pop     ix                      ;14\r
+       ret                             ;10             |\r
+\r
+       endif\r
 \r
+       end\r
index 9cef0511f8f72a144c7c351dec2e91c02cd27a75..7b6d7ac11e4e7f308823a704b8a0c930a44e5981 100644 (file)
@@ -1,7 +1,42 @@
 \r
+FALSE  equ     0\r
+TRUE   equ     NOT FALSE\r
+\r
+\r
+DEBUG  equ     true\r
+\r
+banked equ     true\r
+\r
+;-----------------------------------------------------\r
+; CPU and BANKING types\r
+\r
+\r
+CPU_Z180       equ     TRUE\r
+CPU_Z80                equ     FALSE\r
+\r
+ROMSYS         equ     FALSE\r
+\r
+AVRCLK         equ     18432           ;[KHz]\r
+\r
+    if CPU_Z180\r
+\r
+;-----------------------------------------------------\r
+FOSC           equ     AVRCLK/2        ;Oscillator frequency [KHz]\r
+PHI            equ     FOSC*2          ;CPU frequency (clock doubler enabled)\r
+\r
+;----------------------------------------------------------------------\r
+; Baudrate Generator for x16 clock mode:\r
+; TC = (f PHI / (32 * baudrate)) - 2\r
+;\r
+;     PHI [MHz]: 9.216 18.432\r
+;     baudrate     TC     TC\r
+;     ----------------------\r
+;      115200      -      3\r
+;      57600       3      8\r
+;      38400       -     13\r
+;      19200      13     28\r
+;       9600      28     58\r
 \r
-FOSC           equ     9216            ;Oscillator frequency [KHz]\r
-PHI            equ     FOSC*2          ;CPU frequency\r
 \r
 ;-----------------------------------------------------\r
 ; Programmable Reload Timer (PRT)\r
@@ -16,8 +51,21 @@ PRT_TC10MS   equ     PHI / (PRT_PRE/10)
 ;-----------------------------------------------------\r
 ; MMU\r
 \r
-SYS$CBAR       equ     0C8h\r
-USR$CBAR       equ     0F0h\r
+COMMON_SIZE    equ     16*1024         ;Common Area size in bytes\r
+                                       ;must be multiple of 4K\r
+\r
+if (COMMON_SIZE mod 1000h)\r
+       .printx COMMON_SIZE not multiple of 4K!\r
+       end     ;stop assembly\r
+endif\r
+\r
+CSK    equ     COMMON_SIZE/1000h       ;\r
+CA     equ     10h - CSK               ;common area start\r
+BA     equ     0                       ;banked area start\r
+\r
+SYS$CBR                equ     0\r
+SYS$CBAR       equ     CA*16 + CA      ;CBAR in system mode\r
+USR$CBAR       equ     CA*16 + BA      ;CBAR in user mode (CP/M)\r
 \r
 \r
 BANKS          equ     18              ;max nr. of banks\r
@@ -26,36 +74,81 @@ BANKS               equ     18              ;max nr. of banks
 \r
 CREFSH         equ     0               ;Refresh rate register (disable refresh)\r
 CWAITIO                equ     3 shl IWI0      ;Max I/O Wait States, 0 Memory Wait States\r
-\r
-\r
-ROMSYS         equ     0\r
-\r
-       if      ROMSYS\r
+PHI_X2         equ     0               ;set to M_X2CM to enable the clock doubler\r
+\r
+    endif              ;CPU_Z180\r
+    if CPU_Z80\r
+\r
+PHI            equ     AVRCLK/5        ;CPU frequency [KHz]\r
+BAUDCLCK       equ     AVRCLK/10       ;Baudrate clock [KHz]\r
+;BDCLK16               equ\r
+\r
+SIOAD  EQU     0bch\r
+SIOAC  EQU     0bdh\r
+SIOBD  EQU     0beh\r
+SIOBC  EQU     0bfh\r
+\r
+CTC0   EQU     0f4h\r
+CTC1   EQU     0f5h\r
+CTC2   EQU     0f6h\r
+CTC3   EQU     0f7h\r
+\r
+;\r
+; Init Serial I/O for console input and output (SIO-A)\r
+;\r
+; Baudrate clock: 1843200 Hz (Bus connector pin A17)\r
+;\r
+; Baudrate   Divider   SIO     CTC\r
+; ---------------------------------\r
+; 115200         16     16       1\r
+;  57600         32     16       2\r
+;  38400         48     16       3\r
+;  19200         96     16       6\r
+;   9600        192     16      12\r
+;   4800        384     16      24\r
+;   2400        768     16      48\r
+;   1200       1536     16      96\r
+;    600       3072     16     192\r
+;    300       6144     64      92\r
+\r
+    endif      ; CPU_Z80\r
+\r
+    if ROMSYS\r
 c$rom          equ     0a5h\r
 ROM_EN         equ     0C0h\r
 ROM_DIS                equ     ROMEN+1\r
+     if CPU_Z180\r
 CWAITROM       equ     2 shl MWI0\r
-       endif\r
+     endif\r
+    endif\r
 \r
 \r
-DRSTNUM        equ     30h             ;DDTZ Restart vector (breakpoints)\r
+DDTZRSTVEC     equ     030h            ;DDTZ Restart vector (breakpoints)\r
 \r
+INIDONE                equ     03Fh            ;CP/M skip hw init, if this address\r
+INIDONEVAL     equ     080h            ;    is set to this value.\r
 \r
-mrx.fifo_len   equ     256\r
-mtx.fifo_len   equ     256\r
+mtx.fifo_len   equ     32              ;Message transfer fifos\r
+mtx.fifo_id    equ     0               ;    This *must* have #0\r
+mrx.fifo_len   equ     32\r
+mrx.fifo_id    equ     1\r
 \r
-ci.fifo_len    equ     128\r
-co.fifo_len    equ     256\r
+ci.fifo_len    equ     32              ;AVRCON Character I/O via AVR\r
+ci.fifo_id     equ     2\r
+co.fifo_len    equ     32\r
+co.fifo_id     equ     3\r
 \r
-s1.rx_len      equ     256             ;Serial 1 (ASCI1) buffers\r
-s1.tx_len      equ     256             ;\r
+s1.rx_len      equ     128             ;Serial 1 (ASCI1) buffers\r
+s1.rx_id       equ     4               ;\r
+s1.tx_len      equ     128             ;\r
+s1.tx_id       equ     5               ;\r
 \r
-AVRINT5                equ     40h\r
-AVRINT6                equ     50h\r
+AVRINT5                equ     4Fh\r
+AVRINT6                equ     5Fh\r
 ;PMSG          equ     80h\r
 \r
 ;-----------------------------------------------------\r
-; Definition of (locical) top 2 memory pages\r
+; Definition of (logical) top 2 memory pages\r
 \r
 sysram_start   equ     0FE00h\r
 stacksize      equ     80\r
@@ -69,24 +162,26 @@ iv2tab             equ     ivtab + 2*9
 \r
 ;-----------------------------------------------------\r
 \r
-\r
+o.id           equ     -4\r
 o.mask         equ     -3\r
 o.in_idx       equ     -2\r
 o.out_idx      equ     -1\r
 \r
        .lall\r
 \r
-mkbuf  macro   name,size\r
-  if ((size & (size-1)) ne 0) or (size gt 256)\r
+mkbuf  macro   id,name,size\r
+  if ((size AND (size-1)) NE 0) OR (size GT 256)\r
     .printx Error: buffer ^size must be power of 2 and in range 0..256!\r
     name&.mask equ ;wrong size error\r
   else\r
+    db id\r
     ds 3\r
     name:: ds size\r
     name&.mask equ low (size-1)\r
     if size ne 0\r
       name&.end equ $-1\r
       name&.len equ size\r
+      name&.id equ id\r
     endif\r
   endif\r
 endm\r
@@ -103,4 +198,3 @@ inidate     macro
        dseg\r
        ds      ??ps.len\r
        endm\r
-\r
index d4f41305e37c5488e16079977fc14142af903bfb..1241d5a05d901a20f71c7406e26d0b14575785bc 100644 (file)
        .z80\r
        \r
 \r
-       global  $coninit\r
-       global  $cists,$ci\r
-       global  $co\r
+; iobyte:\r
+;              0 = console on AVR-System\r
+;              1 = console on SIO/ASCI\r
 \r
 \r
-       extrn   ser.init,ser.ist,ser.in,ser.ost,ser.out\r
+       extrn   iobyte\r
        extrn   ff.init,ff.i.st,ff.in\r
        extrn   ff.o.st,ff.out\r
+    if CPU_Z180\r
+       extrn   as0init,as0ista,as0inp,as0osta,as0out\r
+       extrn   as1init,as1ista,as1inp,as1osta,as1out\r
+    else\r
+       extrn   ser.init,ser.ist,ser.in,ser.ost,ser.out\r
+    endif\r
        \r
+       public  charini\r
+       public  ?const,?conin\r
+       public  ?conos,?cono\r
 \r
        include config.inc\r
+    if CPU_Z180\r
        include z180reg.inc\r
+    endif\r
 \r
        cseg\r
-;\r
-;\r
 \r
-$coninit:\r
+    if CPU_Z180\r
+charini:\r
+       call    ff.init\r
+       call    as0init\r
+       jp      as1init\r
+\r
+?const:\r
+       ld      a,(iobyte)\r
+       and     03h\r
+       jp      z,ff.i.st\r
+       dec     a\r
+       jp      z,as0ista\r
+       dec     a\r
+       jp      z,as1ista\r
+       jr      nullstatus\r
+\r
+?conin:\r
+       ld      a,(iobyte)\r
+       and     03h\r
+       jp      z,ff.in\r
+       dec     a\r
+       jp      z,as0inp\r
+       dec     a\r
+       jp      z,as1inp\r
+       jr      nullinput\r
+\r
+?conos:\r
+       ld      a,(iobyte)\r
+       and     03h\r
+       jp      z,ff.o.st\r
+       dec     a\r
+       jp      z,as0osta\r
+       dec     a\r
+       jp      z,as1osta\r
+       jr      rettrue\r
+\r
+?cono:\r
+       ld      a,(iobyte)\r
+       and     03h\r
+       jp      z,ff.out\r
+       dec     a\r
+       jp      z,as0out\r
+       dec     a\r
+       jp      z,as1out\r
+       jr      nulloutput\r
+\r
+    else\r
+\r
+charini:\r
        call    ff.init\r
+       ld      c,0\r
        call    ser.init\r
+       ld      c,1\r
+       jp      ser.init\r
+\r
+?const:\r
+       ld      a,(iobyte)\r
+       and     03h\r
+       jp      z,ff.i.st\r
+       dec     a\r
+       ld      b,a\r
+       jp      ser.ist\r
+\r
+?conin:\r
+       ld      a,(iobyte)\r
+       and     03h\r
+       jp      z,ff.in\r
+       dec     a\r
+       ld      b,a\r
+       jp      ser.in\r
+\r
+?conos:\r
+       ld      a,(iobyte)\r
+       and     03h\r
+       jp      z,ff.o.st\r
+       dec     a\r
+       ld      b,a\r
+       jp      ser.ost\r
+\r
+?cono:\r
+       ld      a,(iobyte)\r
+       and     03h\r
+       jp      z,ff.out\r
+       dec     a\r
+       ld      b,a\r
+       jp      ser.out\r
+    endif\r
+\r
+\r
+nullinput:\r
+       ld      a,1Ah\r
        ret\r
-       \r
-$cists:\r
-       call    ff.i.st\r
-       ret     nz\r
-       call    ser.ist\r
+\r
+nulloutput:\r
+       ld      a,c\r
        ret\r
-       \r
-$ci:\r
-       call    ff.i.st\r
-       jp      nz,ff.in\r
-       call    ser.ist\r
-       jp      nz,ser.in\r
-       jr      $ci\r
-       \r
-;$costs:\r
-;      jp      f.o.st\r
-       \r
-$co:\r
-       call    ff.out\r
-       jp      ser.out\r
-       \r
+\r
+rettrue:\r
+       or      0FFh\r
+       ret\r
+\r
+nullstatus:\r
+       xor     a\r
+       ret\r
+\r
        end\r
 \r
index 10fecf8ba9b34e0e5f85ff5d7de26db31a974ddf..e8a26fd44b9fd8674df4177aedd3e94b6204ef9e 100644 (file)
@@ -2,14 +2,18 @@
        .z80\r
 \r
        extrn   ?const,?conin,?cono\r
+       extrn   getiff\r
+       extrn   selbnk,@cbnk\r
 \r
        global  ddtz,bpent\r
        global  $stack\r
 \r
 \r
        include config.inc\r
+       if CPU_Z180\r
        include z180reg.inc\r
        include z180.lib\r
+       endif\r
 \r
 BS     equ     08h\r
 TAB    equ     09h\r
@@ -51,10 +55,6 @@ comend       macro
        endif\r
        endm\r
 \r
-; repeat execution of last common code snippet\r
-comrep macro\r
-       call    ?exclst\r
-       endm\r
 \r
 \r
 \r
@@ -97,7 +97,7 @@ ddtz:
        ld      sp,$stack\r
        ld      a,(wstrtflg)            ;check warm start flag\r
        or      a\r
-       jr      nz,ddtz_w\r
+;;;    jr      nz,ddtz_w\r
 \r
        exx\r
        ld      hl,sysramc\r
@@ -105,97 +105,95 @@ ddtz:
        ld      bc,topcodend-topcodbeg\r
        ldir\r
 \r
-       ld      hl,vartab\r
-       ld      de,ddtram\r
-       ld      bc,vartabe-vartab\r
-       ldir\r
        exx\r
 \r
+       if CPU_Z180\r
        ld      a,e\r
        ld      (ubbr),a\r
+       endif\r
 \r
 ddtz_w:\r
-       ld hl,MSG               ;073c\r
-       call PSTR               ;073f\r
-       call ddtei              ;0742\r
+       ld hl,MSG\r
+       call PSTR\r
+       call ddtei\r
 \r
 ; DDTZ main loop\r
 \r
 DDTZML:\r
-       ld sp,$stack            ;0761\r
-       ld hl,l07eah            ;0764\r
-       ld (CMD_ERR),hl         ;0767\r
-       ld hl,(REG.PC)          ;076a\r
-       ld (OFFS.pc),hl         ;076d\r
-       call sub_0e68h          ;0770\r
-       ld hl,(CMD_RPT)         ;0773\r
-       ld de,DDTZML            ;0776\r
-       call CP.HL.DE           ;0779\r
-       ld a,'>'                ;077c\r
-       call OUTCHAR            ;077e\r
-       call nz,OUTCHAR         ;0781\r
-       call z,OUTBL            ;0784\r
-       call INLINE             ;0787\r
-       call SKIPBL             ;078a\r
-       jr z,exe_hl             ;078d\r
-       ld hl,DDTZML            ;078f\r
-       ld (CMD_RPT),hl         ;0792\r
-       inc de                  ;0795\r
-       sub '?'                 ;0796\r
-       jr c,ERROR              ;0798\r
-       cp 'Z'+1-'?'            ;079a\r
-       jr nc,ERROR             ;079c\r
-       add a,a                 ;079e\r
-       ld hl,CMDTAB            ;079f\r
-       call ADD_HL_A           ;07a2\r
-       ld a,(hl)               ;07a5\r
-       inc hl                  ;07a6\r
-       ld h,(hl)               ;07a7\r
-       ld l,a                  ;07a8\r
-       jr exe_hl               ;07a9\r
+       ld sp,$stack\r
+       ld hl,l07eah\r
+       ld (CMD_ERR),hl\r
+       ld hl,(REG.PC)\r
+       ld (OFFS.pc),hl\r
+       call sub_0e68h\r
+       ld hl,(CMD_RPT)\r
+       ld de,DDTZML\r
+       call CP.HL.DE\r
+       ld a,'>'\r
+       call OUTCHAR\r
+       call nz,OUTCHAR\r
+       call z,OUTBL\r
+       call INLINE\r
+       call SKIPBL\r
+       jr z,exe_hl\r
+       ld hl,DDTZML\r
+       ld (CMD_RPT),hl\r
+       inc de\r
+       sub '?'\r
+       jr c,ERROR\r
+       cp 'Z'+1-'?'\r
+       jr nc,ERROR\r
+       add a,a\r
+       ld hl,CMDTAB\r
+       call ADD_HL_A\r
+       ld a,(hl)\r
+       inc hl\r
+       ld h,(hl)\r
+       ld l,a\r
+       jr exe_hl\r
 ERROR:\r
-       ld hl,(CMD_ERR)         ;07ab\r
+       ld hl,(CMD_ERR)\r
 exe_hl:\r
-       call CALL.HL            ;07ae\r
-       jr DDTZML               ;07b1\r
+       call CALL.HL\r
+       jr DDTZML\r
 \r
 CALL.HL:\r
-       jp (hl)                 ;07b3\r
+       jp (hl)\r
 \r
 \r
 CMDTAB:\r
-       defw CMD.?\r
-       defw CMD.@              ;07b4\r
-       defw CMD.A              ;07b6\r
-       defw CMD.B              ;07b8\r
-       defw CMD.C              ;07ba\r
-       defw CMD.D              ;07bc\r
-       defw ERROR              ;07be\r
-       defw ERROR              ;07c0\r
-       defw CMD.G              ;07c2\r
-       defw CMD.H              ;07c4\r
-       defw CMD.I              ;07c6\r
-       defw ERROR              ;07c8\r
-       defw ERROR              ;07ca\r
-       defw CMD.L              ;07cc\r
-       defw CMD.M              ;07ce\r
-       defw ERROR              ;07d0\r
-       defw CMD.O              ;07d2\r
-       defw ERROR              ;07d4\r
-       defw CMD.Q              ;07d6\r
-       defw CMD.R              ;07d8\r
-       defw CMD.S              ;07da\r
-       defw CMD.T              ;07dc\r
-       defw ERROR              ;07de\r
-       defw CMD.V              ;07e0\r
-       defw ERROR              ;07e2\r
-       defw CMD.X              ;07e4\r
-       defw CMD.Y              ;07e6\r
-       defw CMD.Z              ;07e8\r
+       defw CMD.?              ;Help\r
+       defw CMD.@              ;Offset\r
+       defw CMD.A              ;Assemble\r
+       defw CMD.B              ;Breakpoint\r
+       defw CMD.C              ;Call\r
+       defw CMD.D              ;Display\r
+       defw ERROR              ;\r
+       defw ERROR              ;\r
+       defw CMD.G              ;Go\r
+       defw CMD.H              ;Hex Math\r
+       defw CMD.I              ;In Port\r
+       defw ERROR              ;\r
+       defw ERROR              ;\r
+       defw CMD.L              ;List\r
+       defw CMD.M              ;Move\r
+       defw ERROR              ;\r
+       defw CMD.O              ;Out Port\r
+       defw ERROR              ;\r
+       defw CMD.Q              ;Query\r
+       defw CMD.R              ;Read Intel Hex\r
+       defw CMD.S              ;Substitute\r
+       defw CMD.T              ;Trace\r
+       defw ERROR              ;\r
+       defw CMD.V              ;Verify\r
+       defw ERROR              ;\r
+       defw CMD.X              ;eXamine\r
+       defw CMD.Y              ;eXamine Y Registers\r
+       defw CMD.Z              ;Zap (fill) memory\r
 l07eah:\r
-       ld a,'?'                ;07ea\r
-       call OUTCHAR            ;07ec\r
-       jp CRLF                 ;07ef\r
+       ld a,'?'\r
+       call OUTCHAR\r
+       jp CRLF\r
 \r
 CMD.?:\r
        call    assert_eol\r
@@ -295,7 +293,7 @@ l085ch:
        ld (hl),a               ;\r
        cp ' '                  ;\r
        jr nc,l0869h            ;\r
-       ld a,'^'                ;Controle characters\r
+       ld a,'^'                ;Controll characters\r
        call $co                ;\r
        ld a,(hl)               ;\r
        add a,'@'               ;\r
@@ -427,74 +425,74 @@ l0911h:
 \r
 \r
 sub_0917h:\r
-       dec b                   ;0917\r
-       push de                 ;0918\r
-       ld de,10                ;0919\r
-       call DIV_HL_DE          ;091c\r
-       ld a,h                  ;091f\r
-       or l                    ;0920\r
-       call nz,sub_0917h       ;0921\r
-       ld a,e                  ;0924\r
-       pop de                  ;0925\r
-       jr out.digit            ;0926\r
+       dec b\r
+       push de\r
+       ld de,10\r
+       call DIV_HL_DE\r
+       ld a,h\r
+       or l\r
+       call nz,sub_0917h\r
+       ld a,e\r
+       pop de\r
+       jr out.digit\r
 \r
 sub_0928h:\r
-       push hl                 ;0928\r
-       call sub_08f7h          ;0929\r
-       call out.hl             ;092c\r
-       pop hl                  ;092f\r
-       ret                     ;0930\r
+       push hl\r
+       call sub_08f7h\r
+       call out.hl\r
+       pop hl\r
+       ret\r
 out.hl:\r
-       ld a,h                  ;0931\r
-       call out.hex            ;0932\r
-       ld a,l                  ;0935\r
+       ld a,h\r
+       call out.hex\r
+       ld a,l\r
 out.hex:\r
-       push af                 ;0936\r
-       rra                     ;0937\r
-       rra                     ;0938\r
-       rra                     ;0939\r
-       rra                     ;093a\r
-       call out.digit          ;093b\r
-       pop af                  ;093e\r
+       push af\r
+       rra\r
+       rra\r
+       rra\r
+       rra\r
+       call out.digit\r
+       pop af\r
 out.digit:\r
-       and 00fh                ;093f\r
-       cp 10                   ;0941\r
-       jr c,l0947h             ;0943\r
-       add a,007h              ;0945\r
+       and 00fh\r
+       cp 10\r
+       jr c,l0947h\r
+       add a,007h\r
 l0947h:\r
-       add a,'0'               ;0947\r
-       jr OUTCHAR              ;0949\r
+       add a,'0'\r
+       jr OUTCHAR\r
 l094bh:\r
-       ld a,'-'                ;094b\r
-       call OUTCHAR            ;094d\r
-       ld a,040h               ;0950\r
+       ld a,'-'\r
+       call OUTCHAR\r
+       ld a,040h\r
 out.ascii:\r
-       ex af,af'               ;0952\r
-       call outquote           ;0953\r
-       ex af,af'               ;0956\r
-       push af                 ;0957\r
-       res 7,a                 ;0958\r
-       cp ' '                  ;095a\r
-       jr nc,l0960h            ;095c\r
-       sub 0c0h                ;095e\r
+       ex af,af'\r
+       call outquote\r
+       ex af,af'\r
+       push af\r
+       res 7,a\r
+       cp ' '\r
+       jr nc,l0960h\r
+       sub 0c0h\r
 l0960h:\r
-       call OUTCHAR            ;0960\r
-       push af                 ;0963\r
-       cp ''''                 ;0964\r
-       call z,OUTCHAR          ;0966\r
-       pop af                  ;0969\r
-       ex af,af'               ;096a\r
-       call outquote           ;096b\r
-       pop af                  ;096e\r
-       or a                    ;096f\r
-       ld a,'.'                ;0970\r
-       call m,OUTCHAR          ;0972\r
-       ex af,af'               ;0975\r
-       jr c,l094bh             ;0976\r
-       ret                     ;0978\r
+       call OUTCHAR\r
+       push af\r
+       cp ''''\r
+       call z,OUTCHAR\r
+       pop af\r
+       ex af,af'\r
+       call outquote\r
+       pop af\r
+       or a\r
+       ld a,'.'\r
+       call m,OUTCHAR\r
+       ex af,af'\r
+       jr c,l094bh\r
+       ret\r
 \r
 outquote:\r
-       ld a,''''               ;0979\r
+       ld a,''''\r
 OUTCHAR:\r
        push    hl\r
        push    de\r
@@ -509,7 +507,7 @@ OUTCHAR:
        pop     bc\r
        pop     de\r
        pop     hl\r
-       ret                     ;0988\r
+       ret\r
 \r
 inchar:\r
        push    hl\r
@@ -519,406 +517,407 @@ inchar:
        and     a\r
        jr      z,inch1\r
        call    ?conin\r
-       scf                     ;0991\r
+       scf\r
 inch1:\r
        pop     bc\r
        pop     de\r
        pop     hl\r
-       ret                     ;0992\r
+       ret\r
 \r
 PSTR:\r
-       ld c,000h               ;0993\r
+       ld c,000h\r
 l0995h:\r
-       ld a,(hl)               ;0995\r
-       and a                   ;0996\r
-       ret z                   ;0997\r
-       call OUTCHAR            ;0998\r
-       inc c                   ;099b\r
-       inc hl                  ;099c\r
-       and a                   ;099d\r
-       ret m                   ;099e\r
-       jr l0995h               ;099f\r
+       ld a,(hl)\r
+       and a\r
+       ret z\r
+       call OUTCHAR\r
+       inc c\r
+       inc hl\r
+       and a\r
+       ret m\r
+       jr l0995h\r
 \r
 outbl6:\r
-       call outbl2             ;09a1\r
+       call outbl2\r
 outbl4:\r
-       call outbl2             ;09a4\r
+       call outbl2\r
 outbl2:\r
-       call OUTBL              ;09a7\r
+       call OUTBL\r
 OUTBL:\r
-       ld a,' '                ;09aa\r
-       jr OUTCHAR              ;09ac\r
+       ld a,' '\r
+       jr OUTCHAR\r
 CRLF:\r
-       call inchar             ;09ae\r
-       ld a,CR                 ;09b1\r
-       call OUTCHAR            ;09b3\r
-       ld a,LF                 ;09b6\r
-       call OUTCHAR            ;09b8\r
-       ld a,000h               ;09bb\r
-       ld (CON.COL),a          ;09bd\r
-       jp c,DDTZML             ;09c0\r
-       ret                     ;09c3\r
+       call inchar\r
+       ld a,CR\r
+       call OUTCHAR\r
+       ld a,LF\r
+       call OUTCHAR\r
+       ld a,000h\r
+       ld (CON.COL),a\r
+       jp c,DDTZML\r
+       ret\r
 \r
 ADD_HL_A:\r
-       add a,l                 ;09c4\r
-       ld l,a                  ;09c5\r
-       ret nc                  ;09c6\r
-       inc h                   ;09c7\r
-       ret                     ;09c8\r
+       add a,l\r
+       ld l,a\r
+       ret nc\r
+       inc h\r
+       ret\r
 \r
 SKIPBL0:\r
-       inc de                  ;09c9\r
+       inc de\r
 SKIPBL:\r
-       ld a,(de)               ;09ca\r
-       cp ' '                  ;09cb\r
-       jr z,SKIPBL0            ;09cd\r
-       cp 009h                 ;09cf\r
-       jr z,SKIPBL0            ;09d1\r
-       or a                    ;09d3\r
-       ret                     ;09d4\r
+       ld a,(de)\r
+       cp ' '\r
+       jr z,SKIPBL0\r
+       cp 009h\r
+       jr z,SKIPBL0\r
+       or a\r
+       ret\r
 \r
 skip_to_nextarg:\r
-       call SKIPBL             ;09d5\r
-       cp ','                  ;09d8\r
-       ret nz                  ;09da\r
-       inc de                  ;09db\r
-       call SKIPBL             ;09dc\r
-       cp a                    ;09df\r
-       ret                     ;09e0\r
+       call SKIPBL\r
+       cp ','\r
+       ret nz\r
+       inc de\r
+       call SKIPBL\r
+       cp a\r
+       ret\r
 \r
 assert_eol:\r
-       call SKIPBL             ;09e1\r
-       ret z                   ;09e4\r
+       call SKIPBL\r
+       ret z\r
 l09e5h:\r
-       jp ERROR                ;09e5\r
+       jp ERROR\r
 \r
 chk.sp:\r
-       push hl                 ;09e8\r
-       push de                 ;09e9\r
-       ld hl,0                 ;09ea\r
-       add hl,sp               ;09ed\r
-       ld de,$stack-50         ;09ee\r
-       call CP.HL.DE           ;09f1\r
-       pop de                  ;09f4\r
-       pop hl                  ;09f5\r
-       jr c,l09e5h             ;09f6\r
-       ret                     ;09f8\r
+       push hl\r
+       push de\r
+       ld hl,0\r
+       add hl,sp\r
+       ld de,$stack-50\r
+       call CP.HL.DE\r
+       pop de\r
+       pop hl\r
+       jr c,l09e5h\r
+       ret\r
 \r
 CP.HL.DE:\r
-       and a                   ;09f9\r
-       sbc hl,de               ;09fa\r
-       add hl,de               ;09fc\r
-       ret                     ;09fd\r
+       and a\r
+       sbc hl,de\r
+       add hl,de\r
+       ret\r
 \r
 lookupch:\r
-       ld b,000h               ;09fe\r
+       ld b,000h\r
 l0a00h:\r
-       ld a,(hl)               ;0a00\r
-       and a                   ;0a01\r
-       ret z                   ;0a02\r
-       ld a,(de)               ;0a03\r
-       cp (hl)                 ;0a04\r
-       jr z,l0a0bh             ;0a05\r
-       inc hl                  ;0a07\r
-       inc b                   ;0a08\r
-       jr l0a00h               ;0a09\r
+       ld a,(hl)\r
+       and a\r
+       ret z\r
+       ld a,(de)\r
+       cp (hl)\r
+       jr z,l0a0bh\r
+       inc hl\r
+       inc b\r
+       jr l0a00h\r
 l0a0bh:\r
-       scf                     ;0a0b\r
-       inc de                  ;0a0c\r
-       ret                     ;0a0d\r
+       scf\r
+       inc de\r
+       ret\r
 \r
 sub_0a0eh:\r
-       ld hl,b_0x132A_start    ;0a0e\r
-       ld b,07fh               ;0a11\r
-       jr l0a17h               ;0a13\r
+       ld hl,b_0x132A_start\r
+       ld b,07fh\r
+       jr l0a17h\r
 \r
 sub_0a15h:\r
-       ld b,0ffh               ;0a15\r
+       ld b,0ffh\r
 l0a17h:\r
-       inc b                   ;0a17\r
-       ld a,(hl)               ;0a18\r
-       and a                   ;0a19\r
-       ret z                   ;0a1a\r
-       call l0a27              ;0a1b\r
-       jr nc,l0a17h            ;0a1e\r
-       res 7,b                 ;0a20\r
-       ret                     ;0a22\r
+       inc b\r
+       ld a,(hl)\r
+       and a\r
+       ret z\r
+       call l0a27\r
+       jr nc,l0a17h\r
+       res 7,b\r
+       ret\r
 \r
 sub_0a23h:\r
-       push bc                 ;0a23\r
-       res 7,b                 ;0a24\r
+       push bc\r
+       res 7,b\r
        db      3eh             ;0a26  ld a,0c5h\r
 l0a27:\r
-       push bc                 ;0a27\r
-       push de                 ;0a28\r
+       push bc\r
+       push de\r
 l0a29h:\r
-       ld a,(de)               ;0a29\r
-       xor (hl)                ;0a2a\r
-       and 07fh                ;0a2b\r
-       jr nz,l0a41h            ;0a2d\r
-       bit 7,(hl)              ;0a2f\r
-       inc hl                  ;0a31\r
-       inc de                  ;0a32\r
-       jr z,l0a29h             ;0a33\r
-       scf                     ;0a35\r
-       bit 7,b                 ;0a36\r
-       call z,sub_0d20h        ;0a38\r
-       jr nc,l0a44h            ;0a3b\r
-       pop af                  ;0a3d\r
-       scf                     ;0a3e\r
-       pop bc                  ;0a3f\r
-       ret                     ;0a40\r
+       ld a,(de)\r
+       xor (hl)\r
+       and 07fh\r
+       jr nz,l0a41h\r
+       bit 7,(hl)\r
+       inc hl\r
+       inc de\r
+       jr z,l0a29h\r
+       scf\r
+       bit 7,b\r
+       call z,sub_0d20h\r
+       jr nc,l0a44h\r
+       pop af\r
+       scf\r
+       pop bc\r
+       ret\r
 \r
 l0a41h:\r
-       call sub_0a50h          ;0a41\r
+       call sub_0a50h\r
 l0a44h:\r
-       pop de                  ;0a44\r
-       and a                   ;0a45\r
-       pop bc                  ;0a46\r
-       ret                     ;0a47\r
+       pop de\r
+       and a\r
+       pop bc\r
+       ret\r
 \r
 sub_0a48h:\r
-       inc b                   ;0a48\r
+       inc b\r
 l0a49h:\r
-       dec b                   ;0a49\r
-       ret z                   ;0a4a\r
-       call sub_0a50h          ;0a4b\r
-       jr l0a49h               ;0a4e\r
+       dec b\r
+       ret z\r
+       call sub_0a50h\r
+       jr l0a49h\r
 sub_0a50h:\r
-       ld a,(hl)               ;0a50\r
-       and a                   ;0a51\r
-       ret z                   ;0a52\r
+       ld a,(hl)\r
+       and a\r
+       ret z\r
 l0a53h:\r
-       ld a,(hl)               ;0a53\r
-       inc hl                  ;0a54\r
-       and a                   ;0a55\r
-       ret m                   ;0a56\r
-       jr l0a53h               ;0a57\r
+       ld a,(hl)\r
+       inc hl\r
+       and a\r
+       ret m\r
+       jr l0a53h\r
 \r
 get_arg3:\r
-       call get_arg_range      ;0a59\r
-       push hl                 ;0a5c\r
-       push bc                 ;0a5d\r
-       call skip_to_nextarg    ;0a5e\r
-       call get_arg            ;0a61\r
-       ex de,hl                ;0a64\r
-       pop bc                  ;0a65\r
-       pop hl                  ;0a66\r
-       ret                     ;0a67\r
+       call get_arg_range\r
+       push hl\r
+       push bc\r
+       call skip_to_nextarg\r
+       call get_arg\r
+       ex de,hl\r
+       pop bc\r
+       pop hl\r
+       ret\r
 \r
 sub_0a68h:\r
-       call EXPR               ;0a68\r
-       jr c,error0             ;0a6b\r
-       ret                     ;0a6d\r
+       call EXPR\r
+       jr c,error0\r
+       ret\r
 \r
 get_arg:\r
-       call sub_0a68h          ;0a6e\r
+       call sub_0a68h\r
 l0a71h:\r
-       jp assert_eol           ;0a71\r
+       jp assert_eol\r
 \r
 get_lastarg_def:\r
-       call get_arg_def        ;0a74\r
-       jr l0a71h               ;0a77\r
+       call get_arg_def\r
+       jr l0a71h\r
 \r
 get_arg_def:\r
-       push hl                 ;0a79\r
-       call EXPR               ;0a7a\r
-       jr c,l0a80h             ;0a7d\r
-       ex (sp),hl              ;0a7f\r
+       push hl\r
+       call EXPR\r
+       jr c,l0a80h\r
+       ex (sp),hl\r
 l0a80h:\r
-       pop hl                  ;0a80\r
-       ret                     ;0a81\r
+       pop hl\r
+       ret\r
 \r
 sub_0a82h:\r
-       call sub_0a87h          ;0a82\r
-       jr l0a71h               ;0a85\r
+       call sub_0a87h\r
+       jr l0a71h\r
 \r
 sub_0a87h:\r
        db      0e6h            ;0a87  and 037h (clear carry)\r
 get_arg_range:\r
        scf\r
-       ex af,af'               ;0a89\r
-       push bc                 ;0a8a\r
-       push hl                 ;0a8b\r
-       call EXPR               ;0a8c\r
-       jr nc,l0a97h            ;0a8f\r
-       ex af,af'               ;0a91\r
-       jr c,error0             ;0a92\r
-       ex af,af'               ;0a94\r
-       pop hl                  ;0a95\r
-\r
-       defb 03eh               ;0a96\r
+       ex af,af'\r
+       push bc\r
+       push hl\r
+       call EXPR\r
+       jr nc,l0a97h\r
+       ex af,af'\r
+       jr c,error0\r
+       ex af,af'\r
+       pop hl\r
+\r
+       defb 03eh\r
 l0a97h:\r
-       pop af                  ;0a97\r
-       call sub_0aa5h          ;0a98\r
-       jr nc,l0aa3h            ;0a9b\r
-       ex af,af'               ;0a9d\r
-       pop bc                  ;0a9e\r
-       ret nc                  ;0a9f\r
+       pop af\r
+       call sub_0aa5h\r
+       jr nc,l0aa3h\r
+       ex af,af'\r
+       pop bc\r
+       ret nc\r
 error0:\r
-       jp ERROR                ;0aa0\r
+       jp ERROR\r
 \r
 l0aa3h:\r
-       pop af                  ;0aa3\r
-       ret                     ;0aa4\r
+       pop af\r
+       ret\r
 \r
 sub_0aa5h:\r
-       call skip_to_nextarg    ;0aa5\r
-       cp 'S'                  ;0aa8\r
-       jr nz,l0aadh            ;0aaa\r
-       inc de                  ;0aac\r
+       call skip_to_nextarg\r
+       cp 'S'\r
+       jr nz,l0aadh\r
+       inc de\r
 l0aadh:\r
-       push hl                 ;0aad\r
-       push af                 ;0aae\r
-       call EXPR               ;0aaf\r
-       jr c,l0ac3h             ;0ab2\r
-       ld b,h                  ;0ab4\r
-       ld c,l                  ;0ab5\r
-       pop af                  ;0ab6\r
-       pop hl                  ;0ab7\r
-       jr z,l0ac1h             ;0ab8\r
-       ld a,c                  ;0aba\r
-       sub l                   ;0abb\r
-       ld c,a                  ;0abc\r
-       ld a,b                  ;0abd\r
-       sbc a,h                 ;0abe\r
-       ld b,a                  ;0abf\r
-       inc bc                  ;0ac0\r
+       push hl\r
+       push af\r
+       call EXPR\r
+       jr c,l0ac3h\r
+       ld b,h\r
+       ld c,l\r
+       pop af\r
+       pop hl\r
+       jr z,l0ac1h\r
+       ld a,c\r
+       sub l\r
+       ld c,a\r
+       ld a,b\r
+       sbc a,h\r
+       ld b,a\r
+       inc bc\r
 l0ac1h:\r
-       and a                   ;0ac1\r
-       ret                     ;0ac2\r
+       and a\r
+       ret\r
 \r
 l0ac3h:\r
-       pop af                  ;0ac3\r
-       pop hl                  ;0ac4\r
-       jr z,error0             ;0ac5\r
-       scf                     ;0ac7\r
-       ret                     ;0ac8\r
+       pop af\r
+       pop hl\r
+       jr z,error0\r
+       scf\r
+       ret\r
 \r
 EXPR:\r
-       call SKIPBL             ;0ac9\r
+       call SKIPBL\r
 EXPR1:\r
-       call do_subexpr         ;0acc\r
-       ret c                   ;0acf\r
-       call do_rel_op          ;0ad0\r
-       ret nc                  ;0ad3\r
-       push bc                 ;0ad4\r
-       push hl                 ;0ad5\r
-       call do_subexpr         ;0ad6\r
-       jr c,error0             ;0ad9\r
-       ex de,hl                ;0adb\r
-       ex (sp),hl              ;0adc\r
-       and a                   ;0add\r
-       sbc hl,de               ;0ade\r
-       ld hl,0ffffh            ;0ae0\r
-       pop de                  ;0ae3\r
-       ret                     ;0ae4\r
+       call do_subexpr\r
+       ret c\r
+       call do_rel_op\r
+       ret nc\r
+       push bc\r
+       push hl\r
+       call do_subexpr\r
+       jr c,error0\r
+       ex de,hl\r
+       ex (sp),hl\r
+       and a\r
+       sbc hl,de\r
+       ld hl,0ffffh\r
+       pop de\r
+       ret\r
 \r
 do_op_eq:\r
-       jr z,l0af8h             ;0ae5\r
-       jr l0af7h               ;0ae7\r
+       jr z,l0af8h\r
+       jr l0af7h\r
 do_op_ne:\r
-       jr nz,l0af8h            ;0ae9\r
-       jr l0af7h               ;0aeb\r
+       jr nz,l0af8h\r
+       jr l0af7h\r
 do_op_le:\r
-       jr z,l0af8h             ;0aed\r
+       jr z,l0af8h\r
 do_op_lt:\r
-       jr c,l0af8h             ;0aef\r
-       jr l0af7h               ;0af1\r
+       jr c,l0af8h\r
+       jr l0af7h\r
 do_op_gt:\r
-       jr z,l0af7h             ;0af3\r
+       jr z,l0af7h\r
 do_op_ge:\r
-       jr nc,l0af8h            ;0af5\r
+       jr nc,l0af8h\r
 l0af7h:\r
-       inc hl                  ;0af7\r
+       inc hl\r
 l0af8h:\r
-       and a                   ;0af8\r
-       ret                     ;0af9\r
+       and a\r
+       ret\r
 \r
 do_rel_op:\r
-       push hl                 ;0afa\r
-       ld hl,tab_eq_le_ge      ;0afb\r
-       call lookupch           ;0afe\r
-       jr nc,l0b28h            ;0b01\r
-       ld a,b                  ;0b03\r
-       or a                    ;0b04\r
-       jr z,l0b1ch             ;0b05\r
-       ld a,(de)               ;0b07\r
-       cp '='                  ;0b08\r
-       jr nz,l0b11h            ;0b0a\r
-       inc de                  ;0b0c\r
-       inc b                   ;0b0d\r
-       inc b                   ;0b0e\r
-       jr l0b1ch               ;0b0f\r
+       push hl\r
+       ld hl,tab_eq_le_ge\r
+       call lookupch\r
+       jr nc,l0b28h\r
+       ld a,b\r
+       or a\r
+       jr z,l0b1ch\r
+       ld a,(de)\r
+       cp '='\r
+       jr nz,l0b11h\r
+       inc de\r
+       inc b\r
+       inc b\r
+       jr l0b1ch\r
 \r
 l0b11h:\r
-       bit 0,b                 ;0b11\r
-       jr z,l0b1ch             ;0b13\r
-       cp '>'                  ;0b15\r
-       jr nz,l0b1ch            ;0b17\r
-       inc de                  ;0b19\r
-       ld b,005h               ;0b1a\r
+       bit 0,b\r
+       jr z,l0b1ch\r
+       cp '>'\r
+       jr nz,l0b1ch\r
+       inc de\r
+       ld b,005h\r
 l0b1ch:\r
-       ld hl,tab_func_eqlege   ;0b1c\r
-       ld a,b                  ;0b1f\r
-       add a,a                 ;0b20\r
-       call ADD_HL_A           ;0b21\r
-       ld c,(hl)               ;0b24\r
-       inc hl                  ;0b25\r
-       ld b,(hl)               ;0b26\r
-       scf                     ;0b27\r
+       ld hl,tab_func_eqlege\r
+       ld a,b\r
+       add a,a\r
+       call ADD_HL_A\r
+       ld c,(hl)\r
+       inc hl\r
+       ld b,(hl)\r
+       scf\r
 l0b28h:\r
-       pop hl                  ;0b28\r
-       ret                     ;0b29\r
+       pop hl\r
+       ret\r
 \r
 tab_eq_le_ge:\r
        db      '=<>',0\r
 \r
 tab_func_eqlege:\r
-       defw do_op_eq           ;0b2e\r
-       defw do_op_lt           ;0b30\r
-       defw do_op_gt           ;0b32\r
-       defw do_op_le           ;0b34\r
-       defw do_op_ge           ;0b36\r
-       defw do_op_ne           ;0b38\r
+       defw do_op_eq\r
+       defw do_op_lt\r
+       defw do_op_gt\r
+       defw do_op_le\r
+       defw do_op_ge\r
+       defw do_op_ne\r
 \r
 do_subexpr:\r
-       call do_factor          ;0b3a\r
-       ret c                   ;0b3d\r
+       call do_factor\r
+       ret c\r
 l0b3eh:\r
-       call do_binary_op       ;0b3e\r
-       push hl                 ;0b41\r
-       push bc                 ;0b42\r
-       call do_factor          ;0b43\r
-       pop bc                  ;0b46\r
-       ex de,hl                ;0b47\r
-       ex (sp),hl              ;0b48\r
-       jr nc,l0b52h            ;0b49\r
-       pop de                  ;0b4b\r
-       ld a,b                  ;0b4c\r
-       or c                    ;0b4d\r
-       ret z                   ;0b4e\r
-       jp ERROR                ;0b4f\r
+       call do_binary_op\r
+       push hl\r
+       push bc\r
+       call do_factor\r
+       pop bc\r
+       ex de,hl\r
+       ex (sp),hl\r
+       jr nc,l0b52h\r
+       pop de\r
+       ld a,b\r
+       or c\r
+       ret z\r
+       jp ERROR\r
 \r
 l0b52h:\r
-       ld a,b                  ;0b52\r
-       or c                    ;0b53\r
-       push bc                 ;0b54\r
-       ret nz                  ;0b55\r
-       pop bc                  ;0b56\r
+       ld a,b\r
+       or c\r
+       push bc\r
+       ret nz\r
+       pop bc\r
 do_op_add:\r
-       add hl,de               ;0b57\r
+       add hl,de\r
 l0b58h:\r
-       pop de                  ;0b58\r
-       jr l0b3eh               ;0b59\r
+       pop de\r
+       jr l0b3eh\r
 \r
 do_op_sub:\r
-       and a                   ;0b5b\r
-       sbc hl,de               ;0b5c\r
-       jr l0b58h               ;0b5e\r
+       and a\r
+       sbc hl,de\r
+       jr l0b58h\r
 \r
 do_op_mlt:\r
-       push bc                 ;0b60\r
+       push    bc\r
+       if CPU_Z180\r
        ld      b,h\r
        ld      c,e\r
        ld      h,e\r
@@ -930,462 +929,478 @@ do_op_mlt:
        add     a,c\r
        add     a,e\r
        ld      h,a\r
-       pop bc                  ;0b72\r
-       jr l0b58h               ;0b73\r
+       else\r
+        ld     b,h\r
+        ld     c,l\r
+        ld     hl,0\r
+        ld     a,16\r
+mlt_1:\r
+        add    hl,hl\r
+        ex     de,hl\r
+        add    hl,hl\r
+        ex     de,hl\r
+        jr     nc,mlt_2\r
+        add    hl,bc\r
+mlt_2:\r
+        dec    a\r
+        jr     nz,mlt_1\r
+       endif\r
+       pop     bc\r
+       jr      l0b58h\r
 \r
 do_op_div:\r
-       call DIV_HL_DE          ;0b75\r
-       jr l0b58h               ;0b78\r
+       call DIV_HL_DE\r
+       jr l0b58h\r
 \r
 do_op_mod:\r
-       call DIV_HL_DE          ;0b7a\r
-       ex de,hl                ;0b7d\r
-       jr l0b58h               ;0b7e\r
+       call DIV_HL_DE\r
+       ex de,hl\r
+       jr l0b58h\r
 \r
 DIV_HL_DE:\r
-       push bc                 ;0b80\r
-       ex de,hl                ;0b81\r
-       ld b,h                  ;0b82\r
-       ld c,l                  ;0b83\r
-       ld hl,0                 ;0b84\r
-       ld a,16                 ;0b87\r
+       push bc\r
+       ex de,hl\r
+       ld b,h\r
+       ld c,l\r
+       ld hl,0\r
+       ld a,16\r
 l0b89h:\r
-       push af                 ;0b89\r
-       add hl,hl               ;0b8a\r
-       ex de,hl                ;0b8b\r
-       xor a                   ;0b8c\r
-       add hl,hl               ;0b8d\r
-       ex de,hl                ;0b8e\r
-       adc a,l                 ;0b8f\r
-       sub c                   ;0b90\r
-       ld l,a                  ;0b91\r
-       ld a,h                  ;0b92\r
-       sbc a,b                 ;0b93\r
-       ld h,a                  ;0b94\r
-       inc de                  ;0b95\r
-       jr nc,l0b9ah            ;0b96\r
-       add hl,bc               ;0b98\r
-       dec de                  ;0b99\r
+       push af\r
+       add hl,hl\r
+       ex de,hl\r
+       xor a\r
+       add hl,hl\r
+       ex de,hl\r
+       adc a,l\r
+       sub c\r
+       ld l,a\r
+       ld a,h\r
+       sbc a,b\r
+       ld h,a\r
+       inc de\r
+       jr nc,l0b9ah\r
+       add hl,bc\r
+       dec de\r
 l0b9ah:\r
-       pop af                  ;0b9a\r
-       dec a                   ;0b9b\r
-       jr nz,l0b89h            ;0b9c\r
-       ex de,hl                ;0b9e\r
-       pop bc                  ;0b9f\r
-       ret                     ;0ba0\r
+       pop af\r
+       dec a\r
+       jr nz,l0b89h\r
+       ex de,hl\r
+       pop bc\r
+       ret\r
 \r
 do_op_and:\r
-       ld a,h                  ;0ba1\r
-       and d                   ;0ba2\r
-       ld h,a                  ;0ba3\r
-       ld a,l                  ;0ba4\r
-       and e                   ;0ba5\r
-       ld l,a                  ;0ba6\r
-       jr l0b58h               ;0ba7\r
+       ld a,h\r
+       and d\r
+       ld h,a\r
+       ld a,l\r
+       and e\r
+       ld l,a\r
+       jr l0b58h\r
 \r
 do_op_or:\r
-       ld a,h                  ;0ba9\r
-       or d                    ;0baa\r
-       ld h,a                  ;0bab\r
-       ld a,l                  ;0bac\r
-       or e                    ;0bad\r
-       ld l,a                  ;0bae\r
-       jr l0b58h               ;0baf\r
+       ld a,h\r
+       or d\r
+       ld h,a\r
+       ld a,l\r
+       or e\r
+       ld l,a\r
+       jr l0b58h\r
 \r
 do_op_xor:\r
-       ld a,h                  ;0bb1\r
-       xor d                   ;0bb2\r
-       ld h,a                  ;0bb3\r
-       ld a,l                  ;0bb4\r
-       xor e                   ;0bb5\r
-       ld l,a                  ;0bb6\r
-       jr l0b58h               ;0bb7\r
+       ld a,h\r
+       xor d\r
+       ld h,a\r
+       ld a,l\r
+       xor e\r
+       ld l,a\r
+       jr l0b58h\r
 \r
 do_binary_op:\r
-       push hl                 ;0bb9\r
-       ld hl,tab_op_a          ;0bba\r
-       call lookupch           ;0bbd\r
-       ld a,b                  ;0bc0\r
-       ld hl,tab_func_opa      ;0bc1\r
-       add a,a                 ;0bc4\r
-       call ADD_HL_A           ;0bc5\r
-       ld c,(hl)               ;0bc8\r
-       inc hl                  ;0bc9\r
-       ld b,(hl)               ;0bca\r
-       pop hl                  ;0bcb\r
-       ret                     ;0bcc\r
+       push hl\r
+       ld hl,tab_op_a\r
+       call lookupch\r
+       ld a,b\r
+       ld hl,tab_func_opa\r
+       add a,a\r
+       call ADD_HL_A\r
+       ld c,(hl)\r
+       inc hl\r
+       ld b,(hl)\r
+       pop hl\r
+       ret\r
 \r
 tab_op_a:\r
        DB      '+-*/%&!#',0\r
 tab_func_opa:\r
-       defw do_op_add          ;0bd6\r
-       defw do_op_sub          ;0bd8\r
-       defw do_op_mlt          ;0bda\r
-       defw do_op_div          ;0bdc\r
-       defw do_op_mod          ;0bde\r
-       defw do_op_and          ;0be0\r
-       defw do_op_or           ;0be2\r
-       defw do_op_xor          ;0be4\r
-       defw 0                  ;0be6\r
+       defw do_op_add\r
+       defw do_op_sub\r
+       defw do_op_mlt\r
+       defw do_op_div\r
+       defw do_op_mod\r
+       defw do_op_and\r
+       defw do_op_or\r
+       defw do_op_xor\r
+       defw 0\r
 \r
 fact_factor:\r
-       call do_factor          ;0be8\r
-       ret nc                  ;0beb\r
-       jp ERROR                ;0bec\r
+       call do_factor\r
+       ret nc\r
+       jp ERROR\r
 \r
 do_factor:\r
-       call chk.sp             ;0bef\r
-       call get.number         ;0bf2\r
-       ret nc                  ;0bf5\r
-       inc de                  ;0bf6\r
-       ld hl,TOPRAM            ;0bf7\r
-       cp 'T'                  ;0bfa\r
-       ret z                   ;0bfc\r
-       ld hl,(HILOD)           ;0bfd\r
-       cp 'H'                  ;0c00\r
-       ret z                   ;0c02\r
-       ld hl,(MAXLOD)          ;0c03\r
-       cp 'M'                  ;0c06\r
-       ret z                   ;0c08\r
-       ld hl,TPA               ;0c09\r
-       cp 'L'                  ;0c0c\r
-       ret z                   ;0c0e\r
-       ld hl,(offs.@)          ;0c0f\r
-       cp '@'                  ;0c12\r
-       ret z                   ;0c14\r
-       ld hl,(OFFS.pc)         ;0c15\r
-       cp '$'                  ;0c18\r
-       ret z                   ;0c1a\r
-       cp '-'                  ;0c1b\r
-       jr z,fact_factneg       ;0c1d\r
-       cp '~'                  ;0c1f\r
-       jr z,fact_factinv               ;0c21\r
-       cp '+'                  ;0c23\r
-       jr z,fact_factor        ;0c25\r
-       cp '^'                  ;0c27\r
-       jr z,fact_reg.CPU       ;0c29\r
-       cp 'Y'                  ;0c2b\r
-       jr z,fact_reg.Y         ;0c2d\r
-       cp '('                  ;0c2f\r
-       jr z,fact_mem           ;0c31\r
-       cp '['                  ;0c33\r
+       call chk.sp\r
+       call get.number\r
+       ret nc\r
+       inc de\r
+       ld hl,TOPRAM\r
+       cp 'T'\r
+       ret z\r
+       ld hl,(HILOD)\r
+       cp 'H'\r
+       ret z\r
+       ld hl,(MAXLOD)\r
+       cp 'M'\r
+       ret z\r
+       ld hl,TPA\r
+       cp 'L'\r
+       ret z\r
+       ld hl,(offs.@)\r
+       cp '@'\r
+       ret z\r
+       ld hl,(OFFS.pc)\r
+       cp '$'\r
+       ret z\r
+       cp '-'\r
+       jr z,fact_factneg\r
+       cp '~'\r
+       jr z,fact_factinv\r
+       cp '+'\r
+       jr z,fact_factor\r
+       cp '^'\r
+       jr z,fact_reg.CPU\r
+       cp 'Y'\r
+       jr z,fact_reg.Y\r
+       cp '('\r
+       jr z,fact_mem\r
+       cp '['\r
        jp z,EXPR_BRCKT         ;0c35   [ expression ]\r
-       cp ''''                 ;0c38\r
-       jr z,fact_factstring    ;0c3a\r
-       dec de                  ;0c3c\r
-       scf                     ;0c3d\r
-       ret                     ;0c3e\r
+       cp ''''\r
+       jr z,fact_factstring\r
+       dec de\r
+       scf\r
+       ret\r
 \r
 fact_reg.Y:\r
-       call get.decdigit       ;0c3f\r
-       jp c,ERROR              ;0c42\r
-       inc de                  ;0c45\r
-       add a,a                 ;0c46\r
-       ld hl,reg.Y             ;0c47\r
-       call ADD_HL_A           ;0c4a\r
-       ld a,(hl)               ;0c4d\r
-       inc hl                  ;0c4e\r
-       ld h,(hl)               ;0c4f\r
-       ld l,a                  ;0c50\r
-       and a                   ;0c51\r
-       ret                     ;0c52\r
+       call get.decdigit\r
+       jp c,ERROR\r
+       inc de\r
+       add a,a\r
+       ld hl,reg.Y\r
+       call ADD_HL_A\r
+       ld a,(hl)\r
+       inc hl\r
+       ld h,(hl)\r
+       ld l,a\r
+       and a\r
+       ret\r
 fact_factstring:\r
-       ld hl,0                 ;0c53\r
+       ld hl,0\r
 l0c56h:\r
-       ld a,(de)               ;0c56\r
-       cp ''''                 ;0c57\r
-       jr z,l0c62h             ;0c59\r
-       and a                   ;0c5b\r
-       ret z                   ;0c5c\r
+       ld a,(de)\r
+       cp ''''\r
+       jr z,l0c62h\r
+       and a\r
+       ret z\r
 l0c5dh:\r
-       ld h,l                  ;0c5d\r
-       ld l,a                  ;0c5e\r
-       inc de                  ;0c5f\r
-       jr l0c56h               ;0c60\r
+       ld h,l\r
+       ld l,a\r
+       inc de\r
+       jr l0c56h\r
 \r
 l0c62h:\r
-       inc de                  ;0c62\r
-       ld a,(de)               ;0c63\r
-       cp ''''                 ;0c64\r
-       jr z,l0c5dh             ;0c66\r
-       sub '.'                 ;0c68\r
-       or a                    ;0c6a\r
-       ret nz                  ;0c6b\r
-       inc de                  ;0c6c\r
-       set 7,l                 ;0c6d\r
-       ret                     ;0c6f\r
+       inc de\r
+       ld a,(de)\r
+       cp ''''\r
+       jr z,l0c5dh\r
+       sub '.'\r
+       or a\r
+       ret nz\r
+       inc de\r
+       set 7,l\r
+       ret\r
 \r
 fact_reg.CPU:\r
-       call sub_1315h          ;0c70\r
-       jr nc,l0cbbh            ;0c73\r
-       ld a,(hl)               ;0c75\r
-       inc hl                  ;0c76\r
-       ld h,(hl)               ;0c77\r
-       ld l,a                  ;0c78\r
-       and a                   ;0c79\r
-       bit 0,c                 ;0c7a\r
-       ret nz                  ;0c7c\r
-       ld h,000h               ;0c7d\r
-       ret                     ;0c7f\r
+       call sub_1315h\r
+       jr nc,l0cbbh\r
+       ld a,(hl)\r
+       inc hl\r
+       ld h,(hl)\r
+       ld l,a\r
+       and a\r
+       bit 0,c\r
+       ret nz\r
+       ld h,000h\r
+       ret\r
 \r
 fact_factneg:\r
-       call fact_factor        ;0c80\r
-       dec hl                  ;0c83\r
+       call fact_factor\r
+       dec hl\r
 cpl.hl:\r
-       ld a,h                  ;0c84\r
-       cpl                     ;0c85\r
-       ld h,a                  ;0c86\r
-       ld a,l                  ;0c87\r
-       cpl                     ;0c88\r
-       ld l,a                  ;0c89\r
-       ret                     ;0c8a\r
+       ld a,h\r
+       cpl\r
+       ld h,a\r
+       ld a,l\r
+       cpl\r
+       ld l,a\r
+       ret\r
 fact_factinv:\r
-       call fact_factor        ;0c8b\r
-       jr cpl.hl               ;0c8e\r
+       call fact_factor\r
+       jr cpl.hl\r
 \r
 fact_mem:\r
-       call EXPR1              ;0c90\r
-       jr c,l0cbbh             ;0c93\r
-       ld a,(de)               ;0c95\r
-       cp ')'                  ;0c96\r
-       jr nz,l0cbbh            ;0c98\r
-       inc de                  ;0c9a\r
+       call EXPR1\r
+       jr c,l0cbbh\r
+       ld a,(de)\r
+       cp ')'\r
+       jr nz,l0cbbh\r
+       inc de\r
        comst\r
-        ld a,(hl)              ;0c9f\r
+        ld a,(hl)\r
         inc hl                 ;\r
         ld h,(hl)              ;\r
        comend\r
-       ld l,a                  ;0ca7\r
-       ld a,(de)               ;0ca8\r
-       inc de                  ;0ca9\r
-       cp '.'                  ;0caa\r
-       ret z                   ;0cac\r
-       dec de                  ;0cad\r
-       xor a                   ;0cae\r
-       ld h,a                  ;0caf\r
-       ret                     ;0cb0\r
+       ld l,a\r
+       ld a,(de)\r
+       inc de\r
+       cp '.'\r
+       ret z\r
+       dec de\r
+       xor a\r
+       ld h,a\r
+       ret\r
 \r
 EXPR_BRCKT:\r
-       call EXPR1              ;0cb1\r
-       jr c,l0cbbh             ;0cb4\r
-       ld a,(de)               ;0cb6\r
-       cp ']'                  ;0cb7\r
-       inc de                  ;0cb9\r
-       ret z                   ;0cba\r
+       call EXPR1\r
+       jr c,l0cbbh\r
+       ld a,(de)\r
+       cp ']'\r
+       inc de\r
+       ret z\r
 l0cbbh:\r
-       jp ERROR                ;0cbb\r
+       jp ERROR\r
 \r
 get.number:\r
-       call get.hexdigit       ;0cbe\r
-       ret c                   ;0cc1\r
-       push de                 ;0cc2\r
+       call get.hexdigit\r
+       ret c\r
+       push de\r
 l0cc3h:\r
-       inc de                  ;0cc3\r
-       call get.hexdigit       ;0cc4\r
-       jr nc,l0cc3h            ;0cc7\r
-       pop de                  ;0cc9\r
-       cp '.'                  ;0cca\r
-       jr z,l0d04h             ;0ccc\r
-       cp '"'                  ;0cce\r
-       jr z,l0ce9h             ;0cd0\r
-       ld hl,0                 ;0cd2\r
+       inc de\r
+       call get.hexdigit\r
+       jr nc,l0cc3h\r
+       pop de\r
+       cp '.'\r
+       jr z,l0d04h\r
+       cp '"'\r
+       jr z,l0ce9h\r
+       ld hl,0\r
 l0cd5h:\r
-       call get.hexdigit       ;0cd5\r
-       jr c,l0ce4h             ;0cd8\r
-       add hl,hl               ;0cda\r
-       add hl,hl               ;0cdb\r
-       add hl,hl               ;0cdc\r
-       add hl,hl               ;0cdd\r
-       call ADD_HL_A           ;0cde\r
-       inc de                  ;0ce1\r
-       jr l0cd5h               ;0ce2\r
+       call get.hexdigit\r
+       jr c,l0ce4h\r
+       add hl,hl\r
+       add hl,hl\r
+       add hl,hl\r
+       add hl,hl\r
+       call ADD_HL_A\r
+       inc de\r
+       jr l0cd5h\r
 l0ce4h:\r
-       xor 'H'                 ;0ce4\r
-       ret nz                  ;0ce6\r
-       inc de                  ;0ce7\r
-       ret                     ;0ce8\r
+       xor 'H'\r
+       ret nz\r
+       inc de\r
+       ret\r
 \r
 l0ce9h:\r
-       ld hl,0                 ;0ce9\r
+       ld hl,0\r
 l0cech:\r
-       call get.decdigit       ;0cec\r
+       call get.decdigit\r
 l0cefh:\r
-       inc de                  ;0cef\r
-       jr c,l0cf8h             ;0cf0\r
-       add hl,hl               ;0cf2\r
-       call ADD_HL_A           ;0cf3\r
-       jr l0cech               ;0cf6\r
+       inc de\r
+       jr c,l0cf8h\r
+       add hl,hl\r
+       call ADD_HL_A\r
+       jr l0cech\r
 l0cf8h:\r
-       cp '"'                  ;0cf8\r
-       jp nz,ERROR             ;0cfa\r
-       call get.decdigit       ;0cfd\r
-       jr nc,l0cefh            ;0d00\r
-       or a                    ;0d02\r
-       ret                     ;0d03\r
+       cp '"'\r
+       jp nz,ERROR\r
+       call get.decdigit\r
+       jr nc,l0cefh\r
+       or a\r
+       ret\r
 l0d04h:\r
-       ld hl,0                 ;0d04\r
+       ld hl,0\r
 l0d07h:\r
-       call get.decdigit       ;0d07\r
-       inc de                  ;0d0a\r
-       jr c,l0d1ah             ;0d0b\r
-       push bc                 ;0d0d\r
+       call get.decdigit\r
+       inc de\r
+       jr c,l0d1ah\r
+       push bc\r
        add hl,hl               ;0d0e   hl *= 10\r
-       ld b,h                  ;0d0f\r
-       ld c,l                  ;0d10\r
-       add hl,hl               ;0d11\r
-       add hl,hl               ;0d12\r
-       add hl,bc               ;0d13\r
-       pop bc                  ;0d14\r
-       call ADD_HL_A           ;0d15\r
-       jr l0d07h               ;0d18\r
+       ld b,h\r
+       ld c,l\r
+       add hl,hl\r
+       add hl,hl\r
+       add hl,bc\r
+       pop bc\r
+       call ADD_HL_A\r
+       jr l0d07h\r
 l0d1ah:\r
-       cp '.'                  ;0d1a\r
-       ret z                   ;0d1c\r
-       jp ERROR                ;0d1d\r
+       cp '.'\r
+       ret z\r
+       jp ERROR\r
 \r
 sub_0d20h:\r
-       ld a,(de)               ;0d20\r
-       cp 05bh                 ;0d21\r
-       jr l0d28h               ;0d23\r
+       ld a,(de)\r
+       cp 05bh\r
+       jr l0d28h\r
 \r
 get.hexdigit:\r
-       ld a,(de)               ;0d25\r
+       ld a,(de)\r
 sub_0d26h:\r
-       cp 'F'+1                ;0d26\r
+       cp 'F'+1\r
 l0d28h:\r
-       ccf                     ;0d28\r
-       ret c                   ;0d29\r
-       cp 'A'                  ;0d2a\r
-       jr c,l0d32h             ;0d2c\r
-       sub 'A'-10              ;0d2e\r
-       ret                     ;0d30\r
+       ccf\r
+       ret c\r
+       cp 'A'\r
+       jr c,l0d32h\r
+       sub 'A'-10\r
+       ret\r
 \r
 get.decdigit:\r
-       ld a,(de)               ;0d31\r
+       ld a,(de)\r
 l0d32h:\r
-       cp '9'+1                ;0d32\r
-       jr l0d39h               ;0d34\r
+       cp '9'+1\r
+       jr l0d39h\r
 get.bindigit:\r
-       ld a,(de)               ;0d36\r
-       cp '1'+1                ;0d37\r
+       ld a,(de)\r
+       cp '1'+1\r
 l0d39h:\r
-       ccf                     ;0d39\r
-       ret c                   ;0d3a\r
-       cp '0'                  ;0d3b\r
-       ret c                   ;0d3d\r
-       sub '0'                 ;0d3e\r
-       ret                     ;0d40\r
+       ccf\r
+       ret c\r
+       cp '0'\r
+       ret c\r
+       sub '0'\r
+       ret\r
 \r
 l0d41h:\r
-       call assert_eol         ;0d41\r
+       call assert_eol\r
 \r
 prnt_cpustat:\r
-       call prnt_f             ;0d44\r
-       call outbl2             ;0d47\r
-       ld hl,b_0x0DFD_start    ;0d4a\r
-       ld de,b_0x0E1D_start    ;0d4d\r
-       ld b,006h               ;0d50\r
+       call prnt_f\r
+       call outbl2\r
+       ld hl,b_0x0DFD_start\r
+       ld de,b_0x0E1D_start\r
+       ld b,006h\r
 l0d52h:\r
-       call prnt_regs          ;0d52\r
-       djnz l0d52h             ;0d55\r
-       push hl                 ;0d57\r
-       push de                 ;0d58\r
-       ld iy,(REG.PC)          ;0d59\r
-       call sub_1f77h          ;0d5d\r
-       exx                     ;0d60\r
-       ex af,af'               ;0d61\r
-       call CRLF               ;0d62\r
-       call prnt_f2            ;0d65\r
-       call outbl2             ;0d68\r
-       pop de                  ;0d6b\r
-       pop hl                  ;0d6c\r
-       ld b,007h               ;0d6d\r
+       call prnt_regs\r
+       djnz l0d52h\r
+       push hl\r
+       push de\r
+       ld iy,(REG.PC)\r
+       call sub_1f77h\r
+       exx\r
+       ex af,af'\r
+       call CRLF\r
+       call prnt_f2\r
+       call outbl2\r
+       pop de\r
+       pop hl\r
+       ld b,007h\r
 l0d6fh:\r
-       call prnt_regs          ;0d6f\r
-       djnz l0d6fh             ;0d72\r
-       exx                     ;0d74\r
-       ex af,af'               ;0d75\r
-       and a                   ;0d76\r
-       jr z,l0d7fh             ;0d77\r
-       call outbl6             ;0d79\r
-       call sub_1f5bh          ;0d7c\r
+       call prnt_regs\r
+       djnz l0d6fh\r
+       exx\r
+       ex af,af'\r
+       and a\r
+       jr z,l0d7fh\r
+       call outbl6\r
+       call sub_1f5bh\r
 l0d7fh:\r
-       jp crlf                 ;0d7f\r
+       jp crlf\r
 \r
 prnt_f:\r
-       ld a,(reg.f)            ;0d82\r
-       call prnt_flags         ;0d85\r
-       ld a,(reg.iff)          ;0d88\r
-       cp 0f3h                 ;0d8b\r
-       jp z,outbl              ;0d8d\r
-       ld a,'E'                ;0d90\r
-       jp outchar              ;0d92\r
+       ld a,(reg.f)\r
+       call prnt_flags\r
+       ld a,(reg.iff)\r
+       cp 0f3h\r
+       jp z,outbl\r
+       ld a,'E'\r
+       jp outchar\r
 \r
 prnt_f2:\r
-       ld a,(reg.f2)           ;0d95\r
-       call prnt_flags         ;0d98\r
-       jp outbl                ;0d9b\r
+       ld a,(reg.f2)\r
+       call prnt_flags\r
+       jp outbl\r
 \r
 prnt_flags:\r
-       ld b,a                  ;0d9e\r
-       ld a,'S'                ;0d9f\r
-       call sub_0dbeh          ;0da1\r
-       ld a,'Z'                ;0da4\r
-       call sub_0dbeh          ;0da6\r
-       rl b                    ;0da9\r
-       ld a,'H'                ;0dab\r
-       call sub_0dbeh          ;0dad\r
-       rl b                    ;0db0\r
-       ld a,'V'                ;0db2\r
-       call sub_0dbeh          ;0db4\r
-       ld a,'N'                ;0db7\r
-       call sub_0dbeh          ;0db9\r
-       ld a,'C'                ;0dbc\r
+       ld b,a\r
+       ld a,'S'\r
+       call sub_0dbeh\r
+       ld a,'Z'\r
+       call sub_0dbeh\r
+       rl b\r
+       ld a,'H'\r
+       call sub_0dbeh\r
+       rl b\r
+       ld a,'V'\r
+       call sub_0dbeh\r
+       ld a,'N'\r
+       call sub_0dbeh\r
+       ld a,'C'\r
 sub_0dbeh:\r
-       rl b                    ;0dbe\r
-       jp c,OUTCHAR            ;0dc0\r
-       jp OUTBL                ;0dc3\r
+       rl b\r
+       jp c,OUTCHAR\r
+       jp OUTBL\r
 \r
 prnt_regs:\r
-       push bc                 ;0dc6\r
-       push de                 ;0dc7\r
-       call PSTR               ;0dc8\r
-       ld a,'='                ;0dcb\r
-       call OUTCHAR            ;0dcd\r
-       ex (sp),hl              ;0dd0\r
-       ld e,(hl)               ;0dd1\r
-       inc hl                  ;0dd2\r
-       ld d,(hl)               ;0dd3\r
-       inc hl                  ;0dd4\r
-       ld a,(hl)               ;0dd5\r
-       inc hl                  ;0dd6\r
-       push hl                 ;0dd7\r
-       and a                   ;0dd8\r
-       jr z,l0df2h             ;0dd9\r
-       push af                 ;0ddb\r
-       ld a,(de)               ;0ddc\r
-       ld l,a                  ;0ddd\r
-       inc de                  ;0dde\r
-       ld a,(de)               ;0ddf\r
-       ld h,a                  ;0de0\r
-       pop af                  ;0de1\r
-       dec a                   ;0de2\r
-       jr z,l0dedh             ;0de3\r
-       call out.hl.@           ;0de5\r
-       call z,outbl6           ;0de8\r
-       jr l0df6h               ;0deb\r
+       push bc\r
+       push de\r
+       call PSTR\r
+       ld a,'='\r
+       call OUTCHAR\r
+       ex (sp),hl\r
+       ld e,(hl)\r
+       inc hl\r
+       ld d,(hl)\r
+       inc hl\r
+       ld a,(hl)\r
+       inc hl\r
+       push hl\r
+       and a\r
+       jr z,l0df2h\r
+       push af\r
+       ld a,(de)\r
+       ld l,a\r
+       inc de\r
+       ld a,(de)\r
+       ld h,a\r
+       pop af\r
+       dec a\r
+       jr z,l0dedh\r
+       call out.hl.@\r
+       call z,outbl6\r
+       jr l0df6h\r
 l0dedh:\r
-       call out.hl             ;0ded\r
-       jr l0df6h               ;0df0\r
+       call out.hl\r
+       jr l0df6h\r
 l0df2h:\r
-       ld a,(de)               ;0df2\r
-       call out.hex            ;0df3\r
+       ld a,(de)\r
+       call out.hex\r
 l0df6h:\r
-       call OUTBL              ;0df6\r
-       pop de                  ;0df9\r
-       pop hl                  ;0dfa\r
-       pop bc                  ;0dfb\r
-       ret                     ;0dfc\r
+       call OUTBL\r
+       pop de\r
+       pop hl\r
+       pop bc\r
+       ret\r
 \r
 b_0x0DFD_start:\r
        DC      'A '\r
@@ -1404,522 +1419,510 @@ b_0x0DFD_start:
        DB      0\r
 \r
 b_0x0E1D_start:\r
-       defw reg.a              ;0e1d\r
-       defb 000h               ;0e1f\r
-       defw reg.c              ;0e20\r
-       defb 001h               ;0e22\r
-       defw reg.e              ;0e23\r
-       defb 001h               ;0e25\r
-       defw reg.l              ;0e26\r
-       defb 001h               ;0e28\r
-       defw reg.sp             ;0e29\r
-       defb 001h               ;0e2b\r
-       defw reg.pc             ;0e2c\r
-       defb 002h               ;0e2e\r
-       defw reg.a2             ;0e2f\r
-       defb 000h               ;0e31\r
-       defw reg.c2             ;0e32\r
-       defb 001h               ;0e34\r
-       defw reg.e2             ;0e35\r
-       defb 001h               ;0e37\r
-       defw reg.l2             ;0e38\r
-       defb 001h               ;0e3a\r
-       defw reg.ix             ;0e3b\r
-       defb 001h               ;0e3d\r
-       defw reg.iy             ;0e3e\r
-       defb 001h               ;0e40\r
-       defw reg.i              ;0e41\r
-       dw      0               ;0e43\r
+       defw reg.a\r
+       defb 000h\r
+       defw reg.c\r
+       defb 001h\r
+       defw reg.e\r
+       defb 001h\r
+       defw reg.l\r
+       defb 001h\r
+       defw reg.sp\r
+       defb 001h\r
+       defw reg.pc\r
+       defb 002h\r
+       defw reg.a2\r
+       defb 000h\r
+       defw reg.c2\r
+       defb 001h\r
+       defw reg.e2\r
+       defb 001h\r
+       defw reg.l2\r
+       defb 001h\r
+       defw reg.ix\r
+       defb 001h\r
+       defw reg.iy\r
+       defb 001h\r
+       defw reg.i\r
+       dw      0\r
 \r
 CMD.G:\r
-       sub a                   ;0e45\r
-       ld (TCFLG),a            ;0e46\r
-       ld (XA747),a            ;0e49\r
-       call EXPR               ;0e4c\r
-       jr c,l0e54h             ;0e4f\r
-       ld (REG.PC),hl          ;0e51\r
+       sub a\r
+       ld (TCFLG),a\r
+       ld (XA747),a\r
+       call EXPR\r
+       jr c,l0e54h\r
+       ld (REG.PC),hl\r
 l0e54h:\r
-       call SKIPBL             ;0e54\r
-       jp z,l1183h             ;0e57\r
-       cp ';'                  ;0e5a\r
-       jp nz,ERROR             ;0e5c\r
-       inc de                  ;0e5f\r
-       ld a,002h               ;0e60\r
-       call sub_0f24h          ;0e62\r
-       jp l1183h               ;0e65\r
+       call SKIPBL\r
+       jp z,l1183h\r
+       cp ';'\r
+       jp nz,ERROR\r
+       inc de\r
+       ld a,002h\r
+       call sub_0f24h\r
+       jp l1183h\r
 \r
 sub_0e68h:\r
-       ld b,BP_CNT             ;0e68\r
-       ld ix,bp_tab            ;0e6a\r
+       ld b,BP_CNT\r
+       ld ix,bp_tab\r
 l0e6eh:\r
-       ld a,(ix+000h)          ;0e6e\r
-       and 0f1h                ;0e71\r
-       ld (ix+000h),a          ;0e73\r
-       call sub_11c5h          ;0e76\r
-       ld de,BP_SIZE           ;0e79\r
-       add ix,de               ;0e7c\r
-       djnz l0e6eh             ;0e7e\r
-       ret                     ;0e80\r
+       ld a,(ix+000h)\r
+       and 0f1h\r
+       ld (ix+000h),a\r
+       call sub_11c5h\r
+       ld de,BP_SIZE\r
+       add ix,de\r
+       djnz l0e6eh\r
+       ret\r
 \r
 CMD.B:\r
-       call SKIPBL             ;0e81\r
-       jr z,l0ecbh             ;0e84\r
-       inc de                  ;0e86\r
-       cp 'X'                  ;0e87\r
-       jr z,l0e91h             ;0e89\r
-       dec de                  ;0e8b\r
-       ld a,001h               ;0e8c\r
-       jp sub_0f24h            ;0e8e\r
+       call SKIPBL\r
+       jr z,l0ecbh\r
+       inc de\r
+       cp 'X'\r
+       jr z,l0e91h\r
+       dec de\r
+       ld a,001h\r
+       jp sub_0f24h\r
 l0e91h:\r
-       call SKIPBL             ;0e91\r
-       jr z,l0ea6h             ;0e94\r
+       call SKIPBL\r
+       jr z,l0ea6h\r
 l0e96h:\r
-       call EXPR               ;0e96\r
-       jp c,assert_eol         ;0e99\r
-       push de                 ;0e9c\r
-       call sub_0ea7h          ;0e9d\r
-       pop de                  ;0ea0\r
-       call skip_to_nextarg    ;0ea1\r
-       jr l0e96h               ;0ea4\r
+       call EXPR\r
+       jp c,assert_eol\r
+       push de\r
+       call sub_0ea7h\r
+       pop de\r
+       call skip_to_nextarg\r
+       jr l0e96h\r
 l0ea6h:\r
-       scf                     ;0ea6\r
+       scf\r
 sub_0ea7h:\r
-       ld b,BP_CNT             ;0ea7\r
-       ld ix,bp_tab            ;0ea9\r
+       ld b,BP_CNT\r
+       ld ix,bp_tab\r
 l0eadh:\r
-       push af                 ;0ead\r
-       jr c,l0ebbh             ;0eae\r
-       ld e,(ix+002h)          ;0eb0\r
-       ld d,(ix+003h)          ;0eb3\r
-       call CP.HL.DE           ;0eb6\r
-       jr nz,l0ec2h            ;0eb9\r
+       push af\r
+       jr c,l0ebbh\r
+       ld e,(ix+002h)\r
+       ld d,(ix+003h)\r
+       call CP.HL.DE\r
+       jr nz,l0ec2h\r
 l0ebbh:\r
-       ld (ix+000h),000h       ;0ebb\r
-       call sub_11c5h          ;0ebf\r
+       ld (ix+000h),000h\r
+       call sub_11c5h\r
 l0ec2h:\r
-       ld de,BP_SIZE           ;0ec2\r
-       add ix,de               ;0ec5\r
-       pop af                  ;0ec7\r
-       djnz l0eadh             ;0ec8\r
-       ret                     ;0eca\r
+       ld de,BP_SIZE\r
+       add ix,de\r
+       pop af\r
+       djnz l0eadh\r
+       ret\r
 l0ecbh:\r
-       ld b,BP_CNT             ;0ecb\r
-       ld ix,bp_tab            ;0ecd\r
+       ld b,BP_CNT\r
+       ld ix,bp_tab\r
 l0ed1h:\r
-       bit 0,(ix+000h)         ;0ed1\r
-       jr z,l0f1ch             ;0ed5\r
-       ld a,'R'                ;0ed7\r
-       bit 4,(ix+000h)         ;0ed9\r
-       jr nz,l0ee1h            ;0edd\r
-       ld a,' '                ;0edf\r
+       bit 0,(ix+000h)\r
+       jr z,l0f1ch\r
+       ld a,'R'\r
+       bit 4,(ix+000h)\r
+       jr nz,l0ee1h\r
+       ld a,' '\r
 l0ee1h:\r
-       call OUTCHAR            ;0ee1\r
-       call OUTBL              ;0ee4\r
-       ld l,(ix+002h)          ;0ee7\r
-       ld h,(ix+003h)          ;0eea\r
-       call out.hl.@           ;0eed\r
-       call outbl2             ;0ef0\r
-       ld a,':'                ;0ef3\r
-       call OUTCHAR            ;0ef5\r
-       ld l,(ix+004h)          ;0ef8\r
-       ld h,(ix+005h)          ;0efb\r
-       call out.hl             ;0efe\r
-       ld l,(ix+006h)          ;0f01\r
-       ld h,(ix+007h)          ;0f04\r
-       ld a,h                  ;0f07\r
-       or l                    ;0f08\r
-       jr z,l0f19h             ;0f09\r
-       call outbl4             ;0f0b\r
-       ld a,'I'                ;0f0e\r
-       call OUTCHAR            ;0f10\r
-       call outbl2             ;0f13\r
-       call PSTR               ;0f16\r
+       call OUTCHAR\r
+       call OUTBL\r
+       ld l,(ix+002h)\r
+       ld h,(ix+003h)\r
+       call out.hl.@\r
+       call outbl2\r
+       ld a,':'\r
+       call OUTCHAR\r
+       ld l,(ix+004h)\r
+       ld h,(ix+005h)\r
+       call out.hl\r
+       ld l,(ix+006h)\r
+       ld h,(ix+007h)\r
+       ld a,h\r
+       or l\r
+       jr z,l0f19h\r
+       call outbl4\r
+       ld a,'I'\r
+       call OUTCHAR\r
+       call outbl2\r
+       call PSTR\r
 l0f19h:\r
-       call CRLF               ;0f19\r
+       call CRLF\r
 l0f1ch:\r
-       ld de,BP_SIZE           ;0f1c\r
-       add ix,de               ;0f1f\r
-       djnz l0ed1h             ;0f21\r
-       ret                     ;0f23\r
+       ld de,BP_SIZE\r
+       add ix,de\r
+       djnz l0ed1h\r
+       ret\r
 \r
 sub_0f24h:\r
-       ld b,a                  ;0f24\r
-       call SKIPBL             ;0f25\r
-       ret z                   ;0f28\r
-       cp 'R'                  ;0f29\r
-       jr nz,l0f30h            ;0f2b\r
-       inc de                  ;0f2d\r
-       set 4,b                 ;0f2e\r
+       ld b,a\r
+       call SKIPBL\r
+       ret z\r
+       cp 'R'\r
+       jr nz,l0f30h\r
+       inc de\r
+       set 4,b\r
 l0f30h:\r
-       push bc                 ;0f30\r
-       call EXPR               ;0f31\r
-       jp c,ERROR              ;0f34\r
-       pop bc                  ;0f37\r
-       bit 0,b                 ;0f38\r
-       push bc                 ;0f3a\r
-       push de                 ;0f3b\r
-       push hl                 ;0f3c\r
-       call nz,sub_0ea7h       ;0f3d\r
-       pop hl                  ;0f40\r
-       call sub_0f68h          ;0f41\r
-       pop de                  ;0f44\r
-       ld (ix+002h),l          ;0f45\r
-       ld (ix+003h),h          ;0f48\r
-       call sub_0f80h          ;0f4b\r
-       ld (ix+004h),l          ;0f4e\r
-       ld (ix+005h),h          ;0f51\r
-       call sub_0f91h          ;0f54\r
-       ld (ix+006h),l          ;0f57\r
-       ld (ix+007h),h          ;0f5a\r
-       call skip_to_nextarg    ;0f5d\r
-       pop af                  ;0f60\r
-       ld (ix+000h),a          ;0f61\r
-       and 00fh                ;0f64\r
-       jr sub_0f24h            ;0f66\r
+       push bc\r
+       call EXPR\r
+       jp c,ERROR\r
+       pop bc\r
+       bit 0,b\r
+       push bc\r
+       push de\r
+       push hl\r
+       call nz,sub_0ea7h\r
+       pop hl\r
+       call sub_0f68h\r
+       pop de\r
+       ld (ix+002h),l\r
+       ld (ix+003h),h\r
+       call sub_0f80h\r
+       ld (ix+004h),l\r
+       ld (ix+005h),h\r
+       call sub_0f91h\r
+       ld (ix+006h),l\r
+       ld (ix+007h),h\r
+       call skip_to_nextarg\r
+       pop af\r
+       ld (ix+000h),a\r
+       and 00fh\r
+       jr sub_0f24h\r
 sub_0f68h:\r
-       ld b,BP_CNT             ;0f68\r
-       ld ix,bp_tab            ;0f6a\r
+       ld b,BP_CNT\r
+       ld ix,bp_tab\r
 l0f6eh:\r
-       ld a,(ix+000h)          ;0f6e\r
-       and 00fh                ;0f71\r
-       ret z                   ;0f73\r
-       push bc                 ;0f74\r
-       ld bc,BP_SIZE           ;0f75\r
-       add ix,bc               ;0f78\r
-       pop bc                  ;0f7a\r
-       djnz l0f6eh             ;0f7b\r
-       jp ERROR                ;0f7d\r
+       ld a,(ix+000h)\r
+       and 00fh\r
+       ret z\r
+       push bc\r
+       ld bc,BP_SIZE\r
+       add ix,bc\r
+       pop bc\r
+       djnz l0f6eh\r
+       jp ERROR\r
 \r
 sub_0f80h:\r
-       call SKIPBL             ;0f80\r
-       ld hl,1                 ;0f83\r
-       cp 03ah                 ;0f86\r
-       ret nz                  ;0f88\r
-       inc de                  ;0f89\r
-       call EXPR               ;0f8a\r
-       jp c,ERROR              ;0f8d\r
-       ret                     ;0f90\r
+       call SKIPBL\r
+       ld hl,1\r
+       cp 03ah\r
+       ret nz\r
+       inc de\r
+       call EXPR\r
+       jp c,ERROR\r
+       ret\r
 sub_0f91h:\r
-       call SKIPBL             ;0f91\r
-       cp 049h                 ;0f94\r
-       ld hl,0                 ;0f96\r
-       ret nz                  ;0f99\r
-       inc de                  ;0f9a\r
-       call SKIPBL             ;0f9b\r
-       push de                 ;0f9e\r
-       call EXPR               ;0f9f\r
-       jp c,ERROR              ;0fa2\r
-       ex de,hl                ;0fa5\r
-       pop de                  ;0fa6\r
-       push de                 ;0fa7\r
-       sbc hl,de               ;0fa8\r
-       ld b,h                  ;0faa\r
-       ld c,l                  ;0fab\r
-       ld hl,(sexp1)           ;0fac\r
-       push hl                 ;0faf\r
-       add hl,bc               ;0fb0\r
-       ld de,sexpbufe          ;0fb1\r
-       call CP.HL.DE           ;0fb4\r
-       jp nc,ERROR             ;0fb7\r
-       pop hl                  ;0fba\r
-       ld (sexp2),hl           ;0fbb\r
-       pop de                  ;0fbe\r
-       ex de,hl                ;0fbf\r
-       ldir                    ;0fc0\r
-       xor a                   ;0fc2\r
-       ld (de),a               ;0fc3\r
-       inc de                  ;0fc4\r
-       ex de,hl                ;0fc5\r
-       ld (sexp1),hl           ;0fc6\r
-       ld hl,(sexp2)           ;0fc9\r
-       ret                     ;0fcc\r
+       call SKIPBL\r
+       cp 049h\r
+       ld hl,0\r
+       ret nz\r
+       inc de\r
+       call SKIPBL\r
+       push de\r
+       call EXPR\r
+       jp c,ERROR\r
+       ex de,hl\r
+       pop de\r
+       push de\r
+       sbc hl,de\r
+       ld b,h\r
+       ld c,l\r
+       ld hl,(sexp1)\r
+       push hl\r
+       add hl,bc\r
+       ld de,sexpbufe\r
+       call CP.HL.DE\r
+       jp nc,ERROR\r
+       pop hl\r
+       ld (sexp2),hl\r
+       pop de\r
+       ex de,hl\r
+       ldir\r
+       xor a\r
+       ld (de),a\r
+       inc de\r
+       ex de,hl\r
+       ld (sexp1),hl\r
+       ld hl,(sexp2)\r
+       ret\r
 \r
 bpddtz:\r
        if ROMSYS\r
-        ld h,ROMEN             ;0fcd\r
-        jr z,l0fd2h            ;0fcf\r
-        inc h                  ;0fd1\r
+        ld     h,ROMEN\r
+        jr     z,l0fd2h\r
+        inc    h\r
 l0fd2h:\r
-        push hl                ;0fd2   save rom enable stat\r
+        push   hl              ;save rom enable stat\r
+       endif\r
+       push    bc\r
+       push    de\r
+       push    ix\r
+       push    iy\r
+       ld      a,i\r
+       ld      h,a\r
+       ld      l,000h\r
+       push    hl              ;save I register\r
+\r
+       if CPU_Z180\r
+        ld     a,0f3h          ;DI\r
+        jp     po,l0fe6h\r
+        ld     a,0fbh          ;EI\r
+       else                    ;NMOS Z80 design flaw\r
+        call   getiff          ;return Carry set, if INTs are disabled.\r
+        ld     a,0f3h          ;DI\r
+        jr     c,l0fe6h\r
+        ld     a,0fbh          ;EI\r
        endif\r
-       push bc                 ;0fd3\r
-       push de                 ;0fd4\r
-       push ix                 ;0fd5\r
-       push iy                 ;0fd7\r
-       ld a,i                  ;0fd9\r
-       ld h,a                  ;0fdb\r
-       ld l,000h               ;0fdc\r
-       push hl                 ;0fde\r
-       ld a,0f3h               ;0fdf   DI\r
-       jp po,l0fe6h            ;0fe1\r
-       ld a,0fbh               ;0fe4   EI\r
 l0fe6h:\r
-       ld (reg.iff),a          ;0fe6\r
-       ld hl,ivtab             ;0fe9\r
-       ld a,h                  ;0fec\r
-       ld i,a                  ;0fed\r
-       call ddtei              ;0fef\r
-       ex af,af'               ;0ff2\r
-       push af                 ;0ff3\r
-       exx                     ;0ff4\r
-       push bc                 ;0ff5\r
-       push de                 ;0ff6\r
-       push hl                 ;0ff7\r
-       call bp.unset           ;0ff8\r
-       in0 a,(itc)             ;0ffb\r
-       jp p,l1017h             ;0ffe\r
-       res TRAP,a              ;1001\r
-       out0 (itc),a            ;1003\r
-       bit UFO,a               ;1006\r
-       jr z,l1011h             ;1008\r
-       ld hl,(REG.PC)          ;100a\r
-       dec hl                  ;100d\r
-       ld (REG.PC),hl          ;100e\r
+       ld      (reg.iff),a\r
+       ld      hl,ivtab\r
+       ld      a,h\r
+       ld      i,a\r
+       call    ddtei\r
+       ex      af,af'\r
+       push    af\r
+       exx\r
+       push    bc\r
+       push    de\r
+       push    hl\r
+       call    bp.unset\r
+       if CPU_Z180\r
+        in0    a,(itc)\r
+        jp     p,l1017h\r
+        res    TRAP,a\r
+        out0   (itc),a\r
+        bit    UFO,a\r
+        jr     z,l1011h\r
+        ld     hl,(REG.PC)\r
+        dec    hl\r
+        ld     (REG.PC),hl\r
 l1011h:\r
-       ld hl,MSG_trap          ;1011\r
-       call PSTR               ;1014\r
+        ld     hl,MSG_trap\r
+        call   PSTR\r
 l1017h:\r
-       ld a,(XBFE8)            ;1017\r
-       dec a                   ;101a\r
-       jr z,l1051h             ;101b\r
-       call inchar             ;101d\r
-       jr c,l102eh             ;1020\r
-       call sub_1059h          ;1022\r
-       and a                   ;1025\r
-       jp z,l1183h             ;1026\r
-       and 083h                ;1029\r
-       jp z,l284ah             ;102b\r
+       endif\r
+\r
+       ld      a,(XBFE8)\r
+       dec     a\r
+       jr      z,l1051h\r
+       call    inchar\r
+       jr      c,l102eh\r
+       call    sub_1059h\r
+       and     a\r
+       jp      z,l1183h\r
+       and     083h\r
+       jp      z,l284ah\r
 l102eh:\r
-       call sub_0e68h          ;102e\r
-       call prnt_cpustat       ;1031\r
-       jp DDTZML               ;1034\r
+       call    sub_0e68h\r
+       call prnt_cpustat\r
+       jp      DDTZML\r
 \r
+       if CPU_Z180\r
 MSG_trap:\r
        DB      CR,LF,'Undefined opcode trap'\r
        DB      CR,LF,0\r
+       endif\r
 \r
 l1051h:\r
-       ld (XBFE8),a            ;1051\r
-       ld c,007h               ;1054\r
-       jp l119fh               ;1056\r
+       ld (XBFE8),a\r
+       ld c,007h\r
+       jp l119fh\r
 sub_1059h:\r
-       ld a,080h               ;1059\r
-       ex af,af'               ;105b\r
-       sub a                   ;105c\r
-       ld (XA747),a            ;105d\r
-       ld b,BP_CNT             ;1060\r
-       ld ix,bp_tab            ;1062\r
+       ld a,080h\r
+       ex af,af'\r
+       sub a\r
+       ld (XA747),a\r
+       ld b,BP_CNT\r
+       ld ix,bp_tab\r
 l1066h:\r
-       ld a,(ix+000h)          ;1066\r
-       and 007h                ;1069\r
-       jr z,l107eh             ;106b\r
-       ld e,(ix+002h)          ;106d\r
-       ld d,(ix+003h)          ;1070\r
-       ld hl,(REG.PC)          ;1073\r
-       call CP.HL.DE           ;1076\r
-       push bc                 ;1079\r
-       call z,sub_1087h        ;107a\r
-       pop bc                  ;107d\r
+       ld a,(ix+000h)\r
+       and 007h\r
+       jr z,l107eh\r
+       ld e,(ix+002h)\r
+       ld d,(ix+003h)\r
+       ld hl,(REG.PC)\r
+       call CP.HL.DE\r
+       push bc\r
+       call z,sub_1087h\r
+       pop bc\r
 l107eh:\r
-       ld de,BP_SIZE           ;107e\r
-       add ix,de               ;1081\r
-       djnz l1066h             ;1083\r
-       ex af,af'               ;1085\r
-       ret                     ;1086\r
+       ld de,BP_SIZE\r
+       add ix,de\r
+       djnz l1066h\r
+       ex af,af'\r
+       ret\r
 sub_1087h:\r
-       ex af,af'               ;1087\r
-       res 7,a                 ;1088\r
-       ex af,af'               ;108a\r
-       ld e,(ix+006h)          ;108b\r
-       ld d,(ix+007h)          ;108e\r
-       ld a,d                  ;1091\r
-       or e                    ;1092\r
-       ld hl,0ffffh            ;1093\r
-       call nz,EXPR            ;1096\r
-       ld a,h                  ;1099\r
-       or l                    ;109a\r
-       jr z,l10aeh             ;109b\r
-       ld e,(ix+004h)          ;109d\r
-       ld d,(ix+005h)          ;10a0\r
-       dec de                  ;10a3\r
-       ld a,d                  ;10a4\r
-       or e                    ;10a5\r
-       jr z,l10b9h             ;10a6\r
-       ld (ix+004h),e          ;10a8\r
-       ld (ix+005h),d          ;10ab\r
+       ex af,af'\r
+       res 7,a\r
+       ex af,af'\r
+       ld e,(ix+006h)\r
+       ld d,(ix+007h)\r
+       ld a,d\r
+       or e\r
+       ld hl,0ffffh\r
+       call nz,EXPR\r
+       ld a,h\r
+       or l\r
+       jr z,l10aeh\r
+       ld e,(ix+004h)\r
+       ld d,(ix+005h)\r
+       dec de\r
+       ld a,d\r
+       or e\r
+       jr z,l10b9h\r
+       ld (ix+004h),e\r
+       ld (ix+005h),d\r
 l10aeh:\r
-       bit 4,(ix+000h)         ;10ae\r
-       ret z                   ;10b2\r
-       ld a,001h               ;10b3\r
-       ld (XA747),a            ;10b5\r
-       ret                     ;10b8\r
+       bit 4,(ix+000h)\r
+       ret z\r
+       ld a,001h\r
+       ld (XA747),a\r
+       ret\r
 l10b9h:\r
-       ex af,af'               ;10b9\r
-       or (ix+000h)            ;10ba\r
-       ex af,af'               ;10bd\r
+       ex af,af'\r
+       or (ix+000h)\r
+       ex af,af'\r
        ret\r
 \r
 bp.unset:\r
-       ld b,BP_CNT             ;10bf\r
-       ld ix,bp_tab            ;10c1\r
+       ld b,BP_CNT\r
+       ld ix,bp_tab\r
 l10c5h:\r
-       bit 5,(ix+000h)         ;10c5\r
-       res 5,(ix+000h)         ;10c9\r
-       jr z,l10e7h             ;10cd\r
-       ld l,(ix+002h)          ;10cf\r
-       ld h,(ix+003h)          ;10d2\r
-       ld a,(ddtrst)           ;10d5\r
-       comst                   ;10e2\r
-       cp (hl)                 ;10dc\r
+       bit 5,(ix+000h)\r
+       res 5,(ix+000h)\r
+       jr z,l10e7h\r
+       ld l,(ix+002h)\r
+       ld h,(ix+003h)\r
+       ld a,(ddtzrst)\r
+       comst\r
+       cp (hl)\r
        comend\r
-       jr nz,l10e7h            ;10dd\r
-       ld a,(ix+001h)          ;10df\r
-       comst                   ;10e2\r
-        ld (hl),a              ;10e6\r
+       jr nz,l10e7h\r
+       ld a,(ix+001h)\r
+       comst\r
+        ld (hl),a\r
        comend\r
 l10e7h:\r
-       res 3,(ix+000h)         ;10e7\r
-       ld de,BP_SIZE           ;10eb\r
-       add ix,de               ;10ee\r
-       djnz l10c5h             ;10f0\r
-       ret                     ;10f2\r
+       res 3,(ix+000h)\r
+       ld de,BP_SIZE\r
+       add ix,de\r
+       djnz l10c5h\r
+       ret\r
 sub_10f3h:\r
-       ld b,BP_CNT             ;10f3\r
-       ld ix,bp_tab            ;10f5\r
+       ld b,BP_CNT\r
+       ld ix,bp_tab\r
 l10f9h:\r
-       ld a,(ix+000h)          ;10f9\r
-       and 003h                ;10fc\r
-       jr z,l110dh             ;10fe\r
-       ld e,(ix+002h)          ;1100\r
-       ld d,(ix+003h)          ;1103\r
-       ld hl,(REG.PC)          ;1106\r
-       call CP.HL.DE           ;1109\r
-       ret z                   ;110c\r
+       ld a,(ix+000h)\r
+       and 003h\r
+       jr z,l110dh\r
+       ld e,(ix+002h)\r
+       ld d,(ix+003h)\r
+       ld hl,(REG.PC)\r
+       call CP.HL.DE\r
+       ret z\r
 l110dh:\r
-       ld de,BP_SIZE           ;110d\r
-       add ix,de               ;1110\r
-       djnz l10f9h             ;1112\r
-       sub a                   ;1114\r
-       inc a                   ;1115\r
-       ret                     ;1116\r
+       ld de,BP_SIZE\r
+       add ix,de\r
+       djnz l10f9h\r
+       sub a\r
+       inc a\r
+       ret\r
 sub_1117h:\r
-       call sub_0f68h          ;1117\r
-       ld (ix+004h),001h       ;111a\r
-       ld (ix+005h),000h       ;111e\r
-       ld (ix+002h),l          ;1122\r
-       ld (ix+003h),h          ;1125\r
-       ld (ix+006h),000h       ;1128\r
-       ld (ix+007h),000h       ;112c\r
-       ld a,(XBFE8)            ;1130\r
-       and a                   ;1133\r
-       ld a,008h               ;1134\r
-       jr nz,l113ah            ;1136\r
-       ld a,004h               ;1138\r
+       call sub_0f68h\r
+       ld (ix+004h),001h\r
+       ld (ix+005h),000h\r
+       ld (ix+002h),l\r
+       ld (ix+003h),h\r
+       ld (ix+006h),000h\r
+       ld (ix+007h),000h\r
+       ld a,(XBFE8)\r
+       and a\r
+       ld a,008h\r
+       jr nz,l113ah\r
+       ld a,004h\r
 l113ah:\r
-       ld (ix+000h),a          ;113a\r
-       ret                     ;113d\r
+       ld (ix+000h),a\r
+       ret\r
 \r
 bp.set:\r
-       ld b,BP_CNT             ;113e\r
-       ld ix,bp_tab            ;1140\r
+       ld b,BP_CNT\r
+       ld ix,bp_tab\r
 l1144h:\r
-       ld a,(ix+000h)          ;1144\r
-       and c                   ;1147\r
-       jr z,l117bh             ;1148\r
-       set 5,(ix+000h)         ;114a\r
-       ld l,(ix+002h)          ;114e\r
-       ld h,(ix+003h)          ;1151\r
+       ld a,(ix+000h)\r
+       and c\r
+       jr z,l117bh\r
+       set 5,(ix+000h)\r
+       ld l,(ix+002h)\r
+       ld h,(ix+003h)\r
 \r
-       if 0\r
 \r
-       comst                   ;1154\r
-        ld a,(hl)              ;1158\r
-       comend\r
-       ld (ix+001h),a          ;1159\r
-       ld a,(ddtrst)           ;115c\r
-       comst                   ;115f\r
-       ld (hl),a               ;1163\r
-       comend\r
-       and 038h                ;1164\r
-       ld h,000h               ;1166\r
-       ld l,a                  ;1168\r
-       ld a,0c3h               ;1169\r
-       comrep                  ;116b\r
-       inc hl                  ;116e\r
-       ld de,bpent             ;116f\r
-       ld a,e                  ;1172\r
-       comrep                  ;1173\r
-       inc hl                  ;1176\r
-       ld a,d                  ;1177\r
-       comrep                  ;1178\r
-\r
-       else\r
-\r
-       ld a,(ddtrst)           ;115c\r
-       comst                   ;115f\r
-       ld e,(hl)               ;1158\r
-       ld (hl),a               ;1163\r
+       ld a,(ddtzrst)\r
+       comst\r
+       ld e,(hl)\r
+       ld (hl),a\r
        comend\r
-       ld (ix+001h),e          ;1159\r
-       and 038h                ;1164\r
-       ld h,0                  ;1166\r
-       ld l,a                  ;1168\r
-       ld de,bpent             ;116f\r
+       ld (ix+001h),e\r
+       and 038h\r
+       ld h,0\r
+       ld l,a\r
+       ld de,bpent\r
        comst                   ;\r
-       ld (hl),0c3h            ;1169\r
-       inc hl                  ;116e\r
-       ld (hl),e               ;1172\r
-       inc hl                  ;1176\r
-       ld (hl),d               ;1177\r
+       ld (hl),0c3h\r
+       inc hl\r
+       ld (hl),e\r
+       inc hl\r
+       ld (hl),d\r
        comend\r
 \r
-       endif\r
-       \r
+\r
 l117bh:\r
-       ld de,BP_SIZE           ;117b\r
-       add ix,de               ;117e\r
-       djnz l1144h             ;1180\r
+       ld de,BP_SIZE\r
+       add ix,de\r
+       djnz l1144h\r
        ret\r
-                               ;1182\r
+\r
 l1183h:\r
-       sub a                   ;1183\r
-       ld (XBFE8),a            ;1184\r
-       ld a,(XA747)            ;1187\r
-       and a                   ;118a\r
-       call nz,prnt_cpustat    ;118b\r
-       call sub_10f3h          ;118e\r
-       ld c,007h               ;1191\r
-       jr nz,l119fh            ;1193\r
-       ld a,001h               ;1195\r
-       ld (XBFE8),a            ;1197\r
-       call sub_26e7h          ;119a\r
-       ld c,008h               ;119d\r
+       sub a\r
+       ld (XBFE8),a\r
+       ld a,(XA747)\r
+       and a\r
+       call nz,prnt_cpustat\r
+       call sub_10f3h\r
+       ld c,007h\r
+       jr nz,l119fh\r
+       ld a,001h\r
+       ld (XBFE8),a\r
+       call sub_26e7h\r
+       ld c,008h\r
 l119fh:\r
-       call bp.set             ;119f\r
+       call bp.set\r
        ld sp,$stack            ;11a2   set/restore user cpu state\r
-       pop hl                  ;11a5\r
-       pop de                  ;11a6\r
-       pop bc                  ;11a7\r
-       pop af                  ;11a8\r
-       exx                     ;11a9\r
-       ex af,af'               ;11aa\r
-       pop af                  ;11ab\r
-       ld i,a                  ;11ac\r
-       pop iy                  ;11ae\r
-       pop ix                  ;11b0\r
-       pop de                  ;11b2\r
-       pop bc                  ;11b3\r
+       pop hl\r
+       pop de\r
+       pop bc\r
+       pop af\r
+       exx\r
+       ex af,af'\r
+       pop af\r
+       ld i,a\r
+       pop iy\r
+       pop ix\r
+       pop de\r
+       pop bc\r
        if ROMSYS\r
-        pop hl                 ;11b4\r
-        ld a,l                 ;11b5\r
-        and M_MWI              ;11b6\r
-        ld l,a                 ;11b8\r
-        di                     ;11b9\r
-        in0 a,(dcntl)          ;11ba\r
-        and ~M_MWI             ;11bd\r
-        or l                   ;11bf\r
-        ld l,a                 ;11c0\r
-        ld a,h                 ;11c1\r
+        pop hl\r
+        ld a,l\r
+        and M_MWI\r
+        ld l,a\r
+        di\r
+        in0 a,(dcntl)\r
+        and ~M_MWI\r
+        or l\r
+        ld l,a\r
+        ld a,h\r
        else\r
         pop hl\r
         di\r
@@ -1927,227 +1930,234 @@ l119fh:
        jp $go                  ;11c2   common ram, switch banks and go to user prog\r
 \r
 sub_11c5h:\r
-       ld a,(ix+000h)          ;11c5\r
-       and 003h                ;11c8\r
-       ret nz                  ;11ca\r
-       ld e,(ix+006h)          ;11cb\r
-       ld d,(ix+007h)          ;11ce\r
-       ld a,d                  ;11d1\r
-       or e                    ;11d2\r
-       ret z                   ;11d3\r
-       push bc                 ;11d4\r
-       ld h,d                  ;11d5\r
-       ld l,e                  ;11d6\r
-       sub a                   ;11d7\r
-       ld (ix+006h),a          ;11d8\r
-       ld (ix+007h),a          ;11db\r
-       ld bc,0ffffh            ;11de\r
-       cpir                    ;11e1\r
+       ld a,(ix+000h)\r
+       and 003h\r
+       ret nz\r
+       ld e,(ix+006h)\r
+       ld d,(ix+007h)\r
+       ld a,d\r
+       or e\r
+       ret z\r
+       push bc\r
+       ld h,d\r
+       ld l,e\r
+       sub a\r
+       ld (ix+006h),a\r
+       ld (ix+007h),a\r
+       ld bc,0ffffh\r
+       cpir\r
 l11e3h:\r
-       push de                 ;11e3\r
-       ld de,(sexp1)           ;11e4\r
-       call CP.HL.DE           ;11e8\r
-       pop de                  ;11eb\r
-       jr nc,l11f9h            ;11ec\r
-       call sub_11ffh          ;11ee\r
+       push de\r
+       ld de,(sexp1)\r
+       call CP.HL.DE\r
+       pop de\r
+       jr nc,l11f9h\r
+       call sub_11ffh\r
 l11f1h:\r
-       ld a,(hl)               ;11f1\r
-       ldi                     ;11f2\r
-       and a                   ;11f4\r
-       jr nz,l11f1h            ;11f5\r
-       jr l11e3h               ;11f7\r
+       ld a,(hl)\r
+       ldi\r
+       and a\r
+       jr nz,l11f1h\r
+       jr l11e3h\r
 l11f9h:\r
-       ld (sexp1),de           ;11f9\r
-       pop bc                  ;11fd\r
-       ret                     ;11fe\r
+       ld (sexp1),de\r
+       pop bc\r
+       ret\r
 sub_11ffh:\r
-       ld iy,bp_tab            ;11ff\r
-       push de                 ;1203\r
+       ld iy,bp_tab\r
+       push de\r
 l1204h:\r
-       ld e,(iy+006h)          ;1204\r
-       ld d,(iy+007h)          ;1207\r
-       call CP.HL.DE           ;120a\r
-       jr z,l1216h             ;120d\r
-       ld de,BP_SIZE           ;120f\r
-       add iy,de               ;1212\r
-       jr l1204h               ;1214\r
+       ld e,(iy+006h)\r
+       ld d,(iy+007h)\r
+       call CP.HL.DE\r
+       jr z,l1216h\r
+       ld de,BP_SIZE\r
+       add iy,de\r
+       jr l1204h\r
 l1216h:\r
-       pop de                  ;1216\r
-       ld (iy+006h),e          ;1217\r
-       ld (iy+007h),d          ;121a\r
-       ret                     ;121d\r
+       pop de\r
+       ld (iy+006h),e\r
+       ld (iy+007h),d\r
+       ret\r
 \r
 CMD.Y:\r
-       call get.decdigit               ;121e\r
-       jr c,l122fh             ;1221\r
-       inc de                  ;1223\r
-       push af                 ;1224\r
-       call assert_eol         ;1225\r
-       pop af                  ;1228\r
-       call sub_1248h          ;1229\r
-       jp l127ch               ;122c\r
+       call get.decdigit\r
+       jr c,l122fh\r
+       inc de\r
+       push af\r
+       call assert_eol\r
+       pop af\r
+       call sub_1248h\r
+       jp l127ch\r
 l122fh:\r
-       call assert_eol         ;122f\r
-       xor a                   ;1232\r
+       call assert_eol\r
+       xor a\r
 l1233h:\r
-       push af                 ;1233\r
-       call sub_1248h          ;1234\r
-       call outbl4             ;1237\r
-       pop af                  ;123a\r
-       inc a                   ;123b\r
-       bit 0,a                 ;123c\r
-       push af                 ;123e\r
-       call z,CRLF             ;123f\r
-       pop af                  ;1242\r
-       cp LF                   ;1243\r
-       jr c,l1233h             ;1245\r
-       ret                     ;1247\r
+       push af\r
+       call sub_1248h\r
+       call outbl4\r
+       pop af\r
+       inc a\r
+       bit 0,a\r
+       push af\r
+       call z,CRLF\r
+       pop af\r
+       cp LF\r
+       jr c,l1233h\r
+       ret\r
 \r
 sub_1248h:\r
-       ld c,a                  ;1248\r
-       ld b,0                  ;1249\r
-       add a,'0'+080h          ;124b\r
-       ld de,msg.Y+1           ;124d\r
-       ld (de),a               ;1250\r
-       dec de                  ;1251\r
-       ld hl,reg.Y             ;1252\r
-       add hl,bc               ;1255\r
-       add hl,bc               ;1256\r
-       ex de,hl                ;1257\r
-       ld c,003h               ;1258\r
-       jp l129ah               ;125a\r
+       ld c,a\r
+       ld b,0\r
+       add a,'0'+080h\r
+       ld de,msg.Y+1\r
+       ld (de),a\r
+       dec de\r
+       ld hl,reg.Y\r
+       add hl,bc\r
+       add hl,bc\r
+       ex de,hl\r
+       ld c,003h\r
+       jp l129ah\r
 \r
 CMD.X:\r
-       call SKIPBL             ;125d\r
-       call sub_1315h          ;1260\r
-       jp nc,l0d41h            ;1263\r
-       call assert_eol         ;1266\r
-       ld a,b                  ;1269\r
-       cp 01fh                 ;126a\r
-       jr z,l12c6h             ;126c\r
-       cp 020h                 ;126e\r
-       jr z,l12b6h             ;1270\r
-       ex de,hl                ;1272\r
-       ld hl,b_0x132A_start    ;1273\r
-       call sub_0a48h          ;1276\r
+       call SKIPBL\r
+       call sub_1315h\r
+       jp nc,l0d41h\r
+       call assert_eol\r
+       ld a,b\r
+       cp 01fh\r
+       jr z,l12c6h\r
+       cp 020h\r
+       jr z,l12b6h\r
+       ex de,hl\r
+       ld hl,b_0x132A_start\r
+       call sub_0a48h\r
 l1279h:\r
-       call l129ah             ;1279\r
+       call l129ah\r
 l127ch:\r
-       call OUTBL              ;127c\r
-       push de                 ;127f\r
-       push bc                 ;1280\r
-       call INLINE             ;1281\r
-       call SKIPBL             ;1284\r
-       jr z,l1297h             ;1287\r
-       call get_arg            ;1289\r
-       ld b,h                  ;128c\r
-       ld c,l                  ;128d\r
-       pop af                  ;128e\r
-       pop hl                  ;128f\r
-       ld (hl),c               ;1290\r
-       bit 0,a                 ;1291\r
-       ret z                   ;1293\r
-       inc hl                  ;1294\r
-       ld (hl),b               ;1295\r
-       ret                     ;1296\r
+       call OUTBL\r
+       push de\r
+       push bc\r
+       call INLINE\r
+       call SKIPBL\r
+       jr z,l1297h\r
+       call get_arg\r
+       ld b,h\r
+       ld c,l\r
+       pop af\r
+       pop hl\r
+       ld (hl),c\r
+       bit 0,a\r
+       ret z\r
+       inc hl\r
+       ld (hl),b\r
+       ret\r
 l1297h:\r
-       pop af                  ;1297\r
-       pop hl                  ;1298\r
-       ret                     ;1299\r
+       pop af\r
+       pop hl\r
+       ret\r
 l129ah:\r
-       ld b,c                  ;129a\r
-       call PSTR               ;129b\r
-       ld a,'='                ;129e\r
-       call OUTCHAR            ;12a0\r
-       ld a,(de)               ;12a3\r
-       bit 0,b                 ;12a4\r
-       jp z,out.hex            ;12a6\r
-       ld l,a                  ;12a9\r
-       inc de                  ;12aa\r
-       ld a,(de)               ;12ab\r
-       dec de                  ;12ac\r
-       ld h,a                  ;12ad\r
-       bit 1,b                 ;12ae\r
-       jp z,out.hl             ;12b0\r
-       jp out.hl.@             ;12b3\r
+       ld b,c\r
+       call PSTR\r
+       ld a,'='\r
+       call OUTCHAR\r
+       ld a,(de)\r
+       bit 0,b\r
+       jp z,out.hex\r
+       ld l,a\r
+       inc de\r
+       ld a,(de)\r
+       dec de\r
+       ld h,a\r
+       bit 1,b\r
+       jp z,out.hl\r
+       jp out.hl.@\r
 \r
 l12b6h:\r
-       call prnt_f             ;12b6\r
-       ld a,0f3h               ;12b9\r
-       ld (reg.iff),a          ;12bb\r
-       scf                     ;12be\r
-       call sub_12d1h          ;12bf\r
-       ld (reg.f),a            ;12c2\r
-       ret                     ;12c5\r
+       call prnt_f\r
+       ld a,0f3h\r
+       ld (reg.iff),a\r
+       scf\r
+       call sub_12d1h\r
+       ld (reg.f),a\r
+       ret\r
 \r
 l12c6h:\r
-       call prnt_f2            ;12c6\r
-       and a                   ;12c9\r
-       call sub_12d1h          ;12ca\r
-       ld (reg.f2),a           ;12cd\r
-       ret                     ;12d0\r
+       call prnt_f2\r
+       and a\r
+       call sub_12d1h\r
+       ld (reg.f2),a\r
+       ret\r
 \r
 sub_12d1h:\r
-       ex af,af'               ;12d1\r
-       ld b,000h               ;12d2\r
-       call outbl              ;12d4\r
-       call assert_eol         ;12d7\r
-       call inline             ;12da\r
+       ex af,af'\r
+       ld b,000h\r
+       call outbl\r
+       call assert_eol\r
+       call inline\r
 l12ddh:\r
-       call skipbl             ;12dd\r
-       ld a,b                  ;12e0\r
-       ret z                   ;12e1\r
-       push bc                 ;12e2\r
-       ld hl,tab_pr_flags      ;12e3\r
-       call lookupch           ;12e6\r
-       jp nc,error             ;12e9\r
-       ld a,b                  ;12ec\r
-       cp 008h                 ;12ed\r
-       jr z,l12feh             ;12ef\r
-       inc b                   ;12f1\r
-       ld a,001h               ;12f2\r
-       jr l12f7h               ;12f4\r
+       call skipbl\r
+       ld a,b\r
+       ret z\r
+       push bc\r
+       ld hl,tab_pr_flags\r
+       call lookupch\r
+       jp nc,error\r
+       ld a,b\r
+       cp 008h\r
+       jr z,l12feh\r
+       inc b\r
+       ld a,001h\r
+       jr l12f7h\r
 l12f6h:\r
-       rlca                    ;12f6\r
+       rlca\r
 l12f7h:\r
-       djnz l12f6h             ;12f7\r
-       pop bc                  ;12f9\r
-       or b                    ;12fa\r
-       ld b,a                  ;12fb\r
-       jr l12ddh               ;12fc\r
+       djnz l12f6h\r
+       pop bc\r
+       or b\r
+       ld b,a\r
+       jr l12ddh\r
 l12feh:\r
-       ex af,af'               ;12fe\r
-       jp nc,ERROR             ;12ff\r
-       ex af,af'               ;1302\r
-       ld a,0FBh               ;1303\r
-       ld (reg.iff),a          ;1305\r
-       pop bc                  ;1308\r
-       jr l12ddh               ;1309\r
+       ex af,af'\r
+       jp nc,ERROR\r
+       ex af,af'\r
+       ld a,0FBh\r
+       ld (reg.iff),a\r
+       pop bc\r
+       jr l12ddh\r
 \r
 tab_pr_flags:\r
        db      'CNV H ZSE'\r
        db      0\r
 \r
 sub_1315h:\r
-       call sub_0a0eh          ;1315\r
-       ret nc                  ;1318\r
-       ld a,b                  ;1319\r
-       add a,b                 ;131a\r
-       add a,b                 ;131b\r
-       ld hl,b_0x136C_start    ;131c\r
-       call ADD_HL_A           ;131f\r
-       ld c,(hl)               ;1322\r
-       inc hl                  ;1323\r
-       ld a,(hl)               ;1324\r
-       inc hl                  ;1325\r
-       ld h,(hl)               ;1326\r
-       ld l,a                  ;1327\r
-       scf                     ;1328\r
-       ret                     ;1329\r
+       call sub_0a0eh\r
+       ret nc\r
+       ld a,b\r
+       add a,b\r
+       add a,b\r
+       ld hl,b_0x136C_start\r
+       call ADD_HL_A\r
+       ld c,(hl)\r
+       inc hl\r
+       ld a,(hl)\r
+       inc hl\r
+       ld h,(hl)\r
+       ld l,a\r
+       scf\r
+       ret\r
 \r
 b_0x132A_start:\r
+       if ROMSYS\r
+        DC     'ROMSEL'\r
+       endif\r
+       if CPU_Z180\r
        DC      'CBAR'\r
        DC      'BBR'\r
+       else\r
+        DC     'BNK'\r
+       endif\r
        DC      'BC'''\r
        DC      'DE'''\r
        DC      'HL'''\r
@@ -2179,659 +2189,667 @@ b_0x132A_start:
        DC      'I'\r
        DC      'F'''\r
        DC      'F'\r
-       if ROMSYS\r
-        DC     'ROMSEL'\r
-       endif\r
        DB      0\r
 b_0x136C_start:\r
-       defb 000h               ;136c\r
-       defw ucbar              ;136d\r
-       defb 000h               ;136f\r
-       defw ubbr               ;1370\r
-       defb 003h               ;1372\r
-       defw reg.c2             ;1373\r
-       defb 003h               ;1375\r
-       defw reg.e2             ;1376\r
-       defb 003h               ;1378\r
-       defw reg.l2             ;1379\r
-       defb 003h               ;137b\r
-       defw reg.c              ;137c\r
-       defb 003h               ;137e\r
-       defw reg.e              ;137f\r
-       defb 003h               ;1381\r
-       defw reg.l              ;1382\r
-       defb 000h               ;1384\r
-       defw reg.a2             ;1385\r
-       defb 000h               ;1387\r
-       defw reg.b2             ;1388\r
-       defb 000h               ;138a\r
-       defw reg.c2             ;138b\r
-       defb 000h               ;138d\r
-       defw reg.d2             ;138e\r
-       defb 000h               ;1390\r
-       defw reg.e2             ;1391\r
-       defb 000h               ;1393\r
-       defw reg.h2             ;1394\r
-       defb 000h               ;1396\r
-       defw reg.l2             ;1397\r
-       defb 000h               ;1399\r
-       defw reg.a              ;139a\r
-       defb 000h               ;139c\r
-       defw reg.b              ;139d\r
-       defb 000h               ;139f\r
-       defw reg.c              ;13a0\r
-       defb 000h               ;13a2\r
-       defw reg.d              ;13a3\r
-       defb 000h               ;13a5\r
-       defw reg.e              ;13a6\r
-       defb 000h               ;13a8\r
-       defw reg.h              ;13a9\r
-       defb 000h               ;13ab\r
-       defw reg.l              ;13ac\r
-       defb 003h               ;13ae\r
-       defw reg.ix             ;13af\r
-       defb 003h               ;13b1\r
-       defw reg.iy             ;13b2\r
-       defb 003h               ;13b4\r
-       defw reg.sp             ;13b5\r
-       defb 003h               ;13b7\r
-       defw reg.pc             ;13b8\r
-       defb 003h               ;13ba\r
-       defw reg.ix             ;13bb\r
-       defb 003h               ;13bd\r
-       defw reg.iy             ;13be\r
-       defb 003h               ;13c0\r
-       defw reg.sp             ;13c1\r
-       defb 003h               ;13c3\r
-       defw reg.pc             ;13c4\r
-       defb 000h               ;13c6\r
-       defw reg.i              ;13c7\r
-       defb 000h               ;13c9\r
-       defw reg.f2             ;13ca\r
-       defb 000h               ;13cc\r
-       defw reg.f              ;13cd\r
        if ROMSYS\r
-        defb 000h              ;13cf\r
-        defw uromen            ;13d0\r
+        defb 000h\r
+        defw uromen\r
+       endif\r
+       if CPU_Z180\r
+       defb 000h\r
+       defw ucbar\r
+       defb 000h\r
+       defw ubbr\r
+       else\r
+        defb 000h\r
+        defw ubnk\r
        endif\r
+       defb 003h\r
+       defw reg.c2\r
+       defb 003h\r
+       defw reg.e2\r
+       defb 003h\r
+       defw reg.l2\r
+       defb 003h\r
+       defw reg.c\r
+       defb 003h\r
+       defw reg.e\r
+       defb 003h\r
+       defw reg.l\r
+       defb 000h\r
+       defw reg.a2\r
+       defb 000h\r
+       defw reg.b2\r
+       defb 000h\r
+       defw reg.c2\r
+       defb 000h\r
+       defw reg.d2\r
+       defb 000h\r
+       defw reg.e2\r
+       defb 000h\r
+       defw reg.h2\r
+       defb 000h\r
+       defw reg.l2\r
+       defb 000h\r
+       defw reg.a\r
+       defb 000h\r
+       defw reg.b\r
+       defb 000h\r
+       defw reg.c\r
+       defb 000h\r
+       defw reg.d\r
+       defb 000h\r
+       defw reg.e\r
+       defb 000h\r
+       defw reg.h\r
+       defb 000h\r
+       defw reg.l\r
+       defb 003h\r
+       defw reg.ix\r
+       defb 003h\r
+       defw reg.iy\r
+       defb 003h\r
+       defw reg.sp\r
+       defb 003h\r
+       defw reg.pc\r
+       defb 003h\r
+       defw reg.ix\r
+       defb 003h\r
+       defw reg.iy\r
+       defb 003h\r
+       defw reg.sp\r
+       defb 003h\r
+       defw reg.pc\r
+       defb 000h\r
+       defw reg.i\r
+       defb 000h\r
+       defw reg.f2\r
+       defb 000h\r
+       defw reg.f\r
 CMD.S:\r
-       ld hl,(lst.S)           ;13d2\r
-       call get_lastarg_def    ;13d5\r
+       ld hl,(lst.S)\r
+       call get_lastarg_def\r
 l13d8h:\r
-       ld (lst.S),hl           ;13d8\r
-       call out.hl.@           ;13db\r
-       call OUTBL              ;13de\r
-       comst                   ;13e1\r
-       ld a,(hl)               ;13e5\r
+       ld (lst.S),hl\r
+       call out.hl.@\r
+       call OUTBL\r
+       comst\r
+       ld a,(hl)\r
        comend\r
-       call out.hex            ;13e6\r
-       call outbl2             ;13e9\r
-       call INLINE             ;13ec\r
-       call SKIPBL             ;13ef\r
-       inc hl                  ;13f2\r
-       jr z,l13d8h             ;13f3\r
-       dec hl                  ;13f5\r
-       inc de                  ;13f6\r
-       cp '.'                  ;13f7\r
-       jp z,assert_eol         ;13f9\r
-       cp '-'                  ;13fc\r
-       jr nz,l1406h            ;13fe\r
-       ld a,(de)               ;1400\r
-       or a                    ;1401\r
-       dec hl                  ;1402\r
-       jr z,l13d8h             ;1403\r
-       inc hl                  ;1405\r
+       call out.hex\r
+       call outbl2\r
+       call INLINE\r
+       call SKIPBL\r
+       inc hl\r
+       jr z,l13d8h\r
+       dec hl\r
+       inc de\r
+       cp '.'\r
+       jp z,assert_eol\r
+       cp '-'\r
+       jr nz,l1406h\r
+       ld a,(de)\r
+       or a\r
+       dec hl\r
+       jr z,l13d8h\r
+       inc hl\r
 l1406h:\r
-       dec de                  ;1406\r
-       call get_bytes_m        ;1407\r
-       jr l13d8h               ;140a\r
+       dec de\r
+       call get_bytes_m\r
+       jr l13d8h\r
 \r
 CMD.@:\r
-       call assert_eol         ;140c\r
-       ld hl,MSG_at            ;140f\r
-       ld de,offs.@            ;1412\r
-       ld c,001h               ;1415\r
-       jp l1279h               ;1417\r
+       call assert_eol\r
+       ld hl,MSG_at\r
+       ld de,offs.@\r
+       ld c,001h\r
+       jp l1279h\r
 MSG_at:\r
        dc      '@'\r
 \r
 CMD.I:\r
-       ld hl,CMD.I             ;141b\r
-       ld (CMD_RPT),hl         ;141e\r
-       ld hl,(lst.IP)          ;1421\r
-       call get_lastarg_def    ;1424\r
-       ld (lst.IP),hl          ;1427\r
-       ld b,h                  ;142a\r
-       ld c,l                  ;142b\r
-       ld a,b                  ;142c\r
-       or a                    ;142d\r
-       jr nz,l1442h            ;142e\r
-       ld a,c                  ;1430\r
-       ld hl,ucbar             ;1431\r
-       cp cbar                 ;1434\r
-       jr z,l143fh             ;1436\r
-       ld hl,ubbr              ;1438\r
-       cp bbr                  ;143b\r
-       jr nz,l1442h            ;143d\r
+       ld hl,CMD.I\r
+       ld (CMD_RPT),hl\r
+       ld hl,(lst.IP)\r
+       call get_lastarg_def\r
+       ld (lst.IP),hl\r
+       ld b,h\r
+       ld c,l\r
+       if CPU_Z180\r
+       ld a,b\r
+       or a\r
+       jr nz,l1442h\r
+       ld a,c\r
+       ld hl,ucbar\r
+       cp cbar\r
+       jr z,l143fh\r
+       ld hl,ubbr\r
+       cp bbr\r
+       jr nz,l1442h\r
 l143fh:\r
-       ld a,(hl)               ;143f\r
-       jr l1444h               ;1440\r
+       ld a,(hl)\r
+       jr l1444h\r
 l1442h:\r
-       in a,(c)                ;1442\r
+       endif\r
+       in a,(c)\r
 l1444h:\r
-       push af                 ;1444\r
-       call out.hex            ;1445\r
-       call outbl4             ;1448\r
-       pop af                  ;144b\r
-       call out.bin.b          ;144c\r
-       jp CRLF                 ;144f\r
+       push af\r
+       call out.hex\r
+       call outbl4\r
+       pop af\r
+       call out.bin.b\r
+       jp CRLF\r
 CMD.O:\r
-       ld hl,CMD.O             ;1452\r
-       ld (CMD_RPT),hl         ;1455\r
-       ld hl,(lst.OD)          ;1458\r
-       call get_arg_def        ;145b\r
-       ld a,l                  ;145e\r
-       ld (lst.OD),a           ;145f\r
-       push af                 ;1462\r
-       call skip_to_nextarg    ;1463\r
-       ld hl,(lst.OP)          ;1466\r
-       call get_lastarg_def    ;1469\r
-       ld (lst.OP),hl          ;146c\r
-       ld b,h                  ;146f\r
-       ld c,l                  ;1470\r
-       ld a,b                  ;1471\r
-       or a                    ;1472\r
-       jr nz,l1489h            ;1473\r
-       ld a,c                  ;1475\r
-       ld hl,ucbar             ;1476\r
-       cp cbar                 ;1479\r
-       jr z,l148dh             ;147b\r
-       ld hl,ubbr              ;147d\r
-       cp bbr                  ;1480\r
-       jr z,l148dh             ;1482\r
-       cp cbr                  ;1484\r
-       jp z,ERROR              ;1486\r
+       ld hl,CMD.O\r
+       ld (CMD_RPT),hl\r
+       ld hl,(lst.OD)\r
+       call get_arg_def\r
+       ld a,l\r
+       ld (lst.OD),a\r
+       push af\r
+       call skip_to_nextarg\r
+       ld hl,(lst.OP)\r
+       call get_lastarg_def\r
+       ld (lst.OP),hl\r
+       ld b,h\r
+       ld c,l\r
+       if CPU_Z180\r
+       ld a,b\r
+       or a\r
+       jr nz,l1489h\r
+       ld a,c\r
+       ld hl,ucbar\r
+       cp cbar\r
+       jr z,l148dh\r
+       ld hl,ubbr\r
+       cp bbr\r
+       jr z,l148dh\r
+       cp cbr\r
+       jp z,ERROR\r
 l1489h:\r
-       pop af                  ;1489\r
-       out (c),a               ;148a\r
-       ret                     ;148c\r
+       endif\r
+       pop af\r
+       out (c),a\r
+       ret\r
+       if CPU_Z180\r
 l148dh:\r
-       pop af                  ;148d\r
-       ld (hl),a               ;148e\r
-       ret                     ;148f\r
+       pop af\r
+       ld (hl),a\r
+       ret\r
+       endif\r
 \r
 CMD.V:\r
        call get_arg3           ;1490   get from, size, to\r
 cmp_mem:\r
-       push bc                 ;1493\r
-       comst                   ;1494\r
-       ld a,(de)               ;1498\r
-       ld b,(hl)               ;1499\r
+       push bc\r
+       comst\r
+       ld a,(de)\r
+       ld b,(hl)\r
        comend\r
-       cp b                    ;149a\r
-       jr z,l14bah             ;149b\r
-       ld c,a                  ;149d\r
-       call out.hl.@           ;149e\r
-       call OUTBL              ;14a1\r
-       ld a,b                  ;14a4\r
-       call out.hex            ;14a5\r
-       call outbl2             ;14a8\r
-       ld a,c                  ;14ab\r
-       call out.hex            ;14ac\r
-       call OUTBL              ;14af\r
-       ex de,hl                ;14b2\r
-       call out.hl.@           ;14b3\r
-       ex de,hl                ;14b6\r
-       call CRLF               ;14b7\r
+       cp b\r
+       jr z,l14bah\r
+       ld c,a\r
+       call out.hl.@\r
+       call OUTBL\r
+       ld a,b\r
+       call out.hex\r
+       call outbl2\r
+       ld a,c\r
+       call out.hex\r
+       call OUTBL\r
+       ex de,hl\r
+       call out.hl.@\r
+       ex de,hl\r
+       call CRLF\r
 l14bah:\r
-       pop bc                  ;14ba\r
-       inc hl                  ;14bb\r
-       inc de                  ;14bc\r
-       dec bc                  ;14bd\r
-       ld a,b                  ;14be\r
-       or c                    ;14bf\r
-       jr nz,cmp_mem           ;14c0\r
-       ret                     ;14c2\r
+       pop bc\r
+       inc hl\r
+       inc de\r
+       dec bc\r
+       ld a,b\r
+       or c\r
+       jr nz,cmp_mem\r
+       ret\r
 \r
 CMD.M:\r
-       ld a,(de)               ;14c3\r
-       cp 'V'                  ;14c4\r
-       jr nz,bm_nv             ;14c6\r
-       inc de                  ;14c8\r
+       ld a,(de)\r
+       cp 'V'\r
+       jr nz,bm_nv\r
+       inc de\r
 bm_nv:\r
        push af                 ;14c9   save 'V' flag\r
-       call get_arg3           ;14ca\r
-       push hl                 ;14cd\r
-       push de                 ;14ce\r
-       push bc                 ;14cf\r
-       call CP.HL.DE           ;14d0\r
-       jr nc,bm_mvdown         ;14d3\r
-       add hl,bc               ;14d5\r
-       ex de,hl                ;14d6\r
-       add hl,bc               ;14d7\r
-       ex de,hl                ;14d8\r
-       dec hl                  ;14d9\r
-       dec de                  ;14da\r
-       comst                   ;14db\r
-       lddr                    ;14df\r
+       call get_arg3\r
+       push hl\r
+       push de\r
+       push bc\r
+       call CP.HL.DE\r
+       jr nc,bm_mvdown\r
+       add hl,bc\r
+       ex de,hl\r
+       add hl,bc\r
+       ex de,hl\r
+       dec hl\r
+       dec de\r
+       comst\r
+       lddr\r
        comend\r
-       jr bm_done              ;14e1\r
+       jr bm_done\r
 bm_mvdown:\r
-       comst                   ;14e3\r
-       ldir                    ;14e7\r
+       comst\r
+       ldir\r
        comend\r
 bm_done:\r
-       pop bc                  ;14e9\r
-       pop de                  ;14ea\r
-       pop hl                  ;14eb\r
-       pop af                  ;14ec\r
+       pop bc\r
+       pop de\r
+       pop hl\r
+       pop af\r
        jr z,cmp_mem            ;14ed   validate?\r
-       ret                     ;14ef\r
+       ret\r
 CMD.H:\r
-       call EXPR               ;14f0\r
-       jp c,l173ch             ;14f3\r
-       call skip_to_nextarg    ;14f6\r
-       push hl                 ;14f9\r
-       call EXPR               ;14fa\r
-       push af                 ;14fd\r
-       call assert_eol         ;14fe\r
-       pop af                  ;1501\r
-       ex de,hl                        ;1502\r
-       pop hl                  ;1503\r
-       jr c,l1511h             ;1504\r
-       push hl                 ;1506\r
-       push de                 ;1507\r
-       add hl,de                       ;1508\r
-       call l1511h             ;1509\r
-       pop de                  ;150c\r
-       pop hl                  ;150d\r
-       and a                   ;150e\r
-       sbc hl,de               ;150f\r
+       call EXPR\r
+       jp c,l173ch\r
+       call skip_to_nextarg\r
+       push hl\r
+       call EXPR\r
+       push af\r
+       call assert_eol\r
+       pop af\r
+       ex de,hl\r
+       pop hl\r
+       jr c,l1511h\r
+       push hl\r
+       push de\r
+       add hl,de\r
+       call l1511h\r
+       pop de\r
+       pop hl\r
+       and a\r
+       sbc hl,de\r
 l1511h:\r
        call out.hl             ;1511   val\r
-       call outbl2             ;1514\r
+       call outbl2\r
        call sub_0928h          ;1517   -val\r
-       call outbl4             ;151a\r
+       call outbl4\r
        call out.hl.dec         ;151d   dec\r
-       call outbl2             ;1520\r
+       call outbl2\r
        call out.hl.decm        ;1523   -dec\r
-       call outbl4             ;1526\r
+       call outbl4\r
        call out.bin.w          ;1529   bin\r
-       call outbl2             ;152c\r
-       ld a,l                  ;152f\r
-       call out.ascii          ;1530\r
-       jp CRLF                 ;1533\r
+       call outbl2\r
+       ld a,l\r
+       call out.ascii\r
+       jp CRLF\r
 \r
 CMD.Q:\r
-       ld a,(de)               ;1536\r
-       sub 'J'                 ;1537\r
-       ld (lst.Qj),a           ;1539\r
-       jr nz,l153fh            ;153c\r
-       inc de                  ;153e\r
+       ld a,(de)\r
+       sub 'J'\r
+       ld (lst.Qj),a\r
+       jr nz,l153fh\r
+       inc de\r
 l153fh:\r
-       call get_arg_range      ;153f\r
-       push bc                 ;1542\r
-       push hl                 ;1543\r
-       call sub_15a7h          ;1544\r
-       pop hl                  ;1547\r
+       call get_arg_range\r
+       push bc\r
+       push hl\r
+       call sub_15a7h\r
+       pop hl\r
 l1548h:\r
-       call sub_1594h          ;1548\r
-       jr nz,l1562h            ;154b\r
-       push bc                 ;154d\r
-       push hl                 ;154e\r
-       ld a,(lst.Qj)           ;154f\r
-       or a                    ;1552\r
-       jr nz,l1559h            ;1553\r
-       ld bc,-8                ;1555\r
-       add hl,bc               ;1558\r
+       call sub_1594h\r
+       jr nz,l1562h\r
+       push bc\r
+       push hl\r
+       ld a,(lst.Qj)\r
+       or a\r
+       jr nz,l1559h\r
+       ld bc,-8\r
+       add hl,bc\r
 l1559h:\r
-       ld bc,MEMDUMP_CNT       ;1559\r
-       and a                   ;155c\r
-       call memdump            ;155d\r
-       pop hl                  ;1560\r
-       pop bc                  ;1561\r
+       ld bc,MEMDUMP_CNT\r
+       and a\r
+       call memdump\r
+       pop hl\r
+       pop bc\r
 l1562h:\r
-       inc hl                  ;1562\r
-       ex (sp),hl              ;1563\r
-       dec hl                  ;1564\r
-       ld a,h                  ;1565\r
-       or l                    ;1566\r
-       ex (sp),hl              ;1567\r
-       jr nz,l1548h            ;1568\r
-       pop bc                  ;156a\r
-       ret                     ;156b\r
+       inc hl\r
+       ex (sp),hl\r
+       dec hl\r
+       ld a,h\r
+       or l\r
+       ex (sp),hl\r
+       jr nz,l1548h\r
+       pop bc\r
+       ret\r
 \r
 CMD.Z:\r
-       call get_arg_range      ;156c\r
-       push bc                 ;156f\r
-       push hl                 ;1570\r
-       call sub_15a7h          ;1571\r
-       ld a,b                  ;1574\r
-       pop hl                  ;1575\r
-       pop bc                  ;1576\r
-       push hl                 ;1577\r
-       ex de,hl                ;1578\r
+       call get_arg_range\r
+       push bc\r
+       push hl\r
+       call sub_15a7h\r
+       ld a,b\r
+       pop hl\r
+       pop bc\r
+       push hl\r
+       ex de,hl\r
 l1579h:\r
-       push af                 ;1579\r
-       ld a,(hl)               ;157a\r
-       comst                   ;157b\r
-       ld (de),a               ;157f\r
+       push af\r
+       ld a,(hl)\r
+       comst\r
+       ld (de),a\r
        comend\r
-       pop af                  ;1580\r
-       inc de                  ;1581\r
-       cpi                     ;1582\r
-       jp po,l1592h            ;1584\r
-       dec a                   ;1587\r
-       jr nz,l1579h            ;1588\r
-       pop hl                  ;158a\r
-       comst                   ;158b\r
-       ldir                    ;158f\r
+       pop af\r
+       inc de\r
+       cpi\r
+       jp po,l1592h\r
+       dec a\r
+       jr nz,l1579h\r
+       pop hl\r
+       comst\r
+       ldir\r
        comend\r
-       ret                     ;1591\r
+       ret\r
 l1592h:\r
-       pop hl                  ;1592\r
-       ret                     ;1593\r
+       pop hl\r
+       ret\r
 \r
 sub_1594h:\r
-       push hl                 ;1594\r
-       push de                 ;1595\r
-       push bc                 ;1596\r
+       push hl\r
+       push de\r
+       push bc\r
 l1597h:\r
-       ld a,(de)               ;1597\r
-       comst                   ;1598\r
-       cp (hl)                 ;159c\r
+       ld a,(de)\r
+       comst\r
+       cp (hl)\r
        comend\r
-       jr nz,l15a3h            ;159d\r
-       inc de                  ;159f\r
-       inc hl                  ;15a0\r
-       djnz l1597h             ;15a1\r
+       jr nz,l15a3h\r
+       inc de\r
+       inc hl\r
+       djnz l1597h\r
 l15a3h:\r
-       pop bc                  ;15a3\r
-       pop de                  ;15a4\r
-       pop hl                  ;15a5\r
-       ret                     ;15a6\r
+       pop bc\r
+       pop de\r
+       pop hl\r
+       ret\r
 \r
 sub_15a7h:\r
-       ld hl,ci.buf+1          ;15a7\r
-       call get_bytes          ;15aa\r
-       ld de,ci.buf+1          ;15ad\r
-       and a                   ;15b0\r
-       sbc hl,de               ;15b1\r
-       ld b,l                  ;15b3\r
-       ret nz                  ;15b4\r
-       jp ERROR                ;15b5\r
+       ld hl,ci.buf+1\r
+       call get_bytes\r
+       ld de,ci.buf+1\r
+       and a\r
+       sbc hl,de\r
+       ld b,l\r
+       ret nz\r
+       jp ERROR\r
 \r
 get_bytes:\r
        db      0e6h            ;15b8  and 037h (clear carry, skip next opc)\r
 get_bytes_m:\r
        scf\r
 l15bah:\r
-       push af                 ;15ba\r
-       call skip_to_nextarg    ;15bb\r
-       cp 'W'                  ;15be\r
-       jr nz,l15d9h            ;15c0\r
-       inc de                  ;15c2\r
-       push hl                 ;15c3\r
-       call sub_0a68h          ;15c4\r
-       ex de,hl                ;15c7\r
-       pop bc                  ;15c8\r
-       pop af                  ;15c9\r
-       push af                 ;15ca\r
-       push bc                 ;15cb\r
-       ex (sp),hl              ;15cc\r
-       jr nc,l15d3h            ;15cd\r
-       comst                   ;15cf\r
+       push af\r
+       call skip_to_nextarg\r
+       cp 'W'\r
+       jr nz,l15d9h\r
+       inc de\r
+       push hl\r
+       call sub_0a68h\r
+       ex de,hl\r
+       pop bc\r
+       pop af\r
+       push af\r
+       push bc\r
+       ex (sp),hl\r
+       jr nc,l15d3h\r
+       comst\r
 l15d3h:\r
-       ld (hl),e               ;15d3\r
+       ld (hl),e\r
        comend\r
-       inc hl                  ;15d4\r
-       ld c,d                  ;15d5\r
-       pop de                  ;15d6\r
-       jr l15e5h               ;15d7\r
+       inc hl\r
+       ld c,d\r
+       pop de\r
+       jr l15e5h\r
 l15d9h:\r
-       cp ''''                 ;15d9\r
-       jr z,l15f1h             ;15db\r
-       push hl                 ;15dd\r
-       call EXPR               ;15de\r
-       ld c,l                  ;15e1\r
-       pop hl                  ;15e2\r
-       jr c,l1626h             ;15e3\r
+       cp ''''\r
+       jr z,l15f1h\r
+       push hl\r
+       call EXPR\r
+       ld c,l\r
+       pop hl\r
+       jr c,l1626h\r
 l15e5h:\r
-       pop af                  ;15e5\r
-       push af                 ;15e6\r
-       jr nc,l15edh            ;15e7\r
-       comst                   ;15e9\r
+       pop af\r
+       push af\r
+       jr nc,l15edh\r
+       comst\r
 l15edh:\r
-       ld (hl),c               ;15ed\r
+       ld (hl),c\r
        comend\r
-       inc hl                  ;15ee\r
-       jr l161eh               ;15ef\r
+       inc hl\r
+       jr l161eh\r
 l15f1h:\r
-       inc de                  ;15f1\r
-       ld a,(de)               ;15f2\r
-       cp ''''                 ;15f3\r
-       jr z,l1607h             ;15f5\r
-       or a                    ;15f7\r
-       jr z,l1626h             ;15f8\r
+       inc de\r
+       ld a,(de)\r
+       cp ''''\r
+       jr z,l1607h\r
+       or a\r
+       jr z,l1626h\r
 l15fah:\r
-       ld c,a                  ;15fa\r
-       pop af                  ;15fb\r
-       push af                 ;15fc\r
-       jr nc,l1603h            ;15fd\r
-       comst                   ;15ff\r
+       ld c,a\r
+       pop af\r
+       push af\r
+       jr nc,l1603h\r
+       comst\r
 l1603h:\r
-       ld (hl),c               ;1603\r
+       ld (hl),c\r
        comend\r
-       inc hl                  ;1604\r
-       jr l15f1h               ;1605\r
+       inc hl\r
+       jr l15f1h\r
 l1607h:\r
-       inc de                  ;1607\r
-       ld a,(de)               ;1608\r
-       cp ''''                 ;1609\r
-       jr z,l15fah             ;160b\r
-       cp '.'                  ;160d\r
-       jr nz,l161eh            ;160f\r
-       inc de                  ;1611\r
-       dec hl                  ;1612\r
-       pop af                  ;1613\r
-       push af                 ;1614\r
-       jr nc,l161bh            ;1615\r
-       comst                   ;1617\r
+       inc de\r
+       ld a,(de)\r
+       cp ''''\r
+       jr z,l15fah\r
+       cp '.'\r
+       jr nz,l161eh\r
+       inc de\r
+       dec hl\r
+       pop af\r
+       push af\r
+       jr nc,l161bh\r
+       comst\r
 l161bh:\r
-       set 7,(hl)              ;161b\r
+       set 7,(hl)\r
        comend\r
-       inc hl                  ;161d\r
+       inc hl\r
 l161eh:\r
-       pop af                  ;161e\r
-       jr nc,l15bah            ;161f\r
-       ld (lst.S),hl           ;1621\r
-       jr l15bah               ;1624\r
+       pop af\r
+       jr nc,l15bah\r
+       ld (lst.S),hl\r
+       jr l15bah\r
 \r
 l1626h:\r
-       pop af                  ;1626\r
-       ret nc                  ;1627\r
-       ld (lst.S),hl           ;1628\r
-       ret                     ;162b\r
+       pop af\r
+       ret nc\r
+       ld (lst.S),hl\r
+       ret\r
 \r
 CMD.D:\r
-       ld hl,CMD.D             ;162c\r
-       ld (CMD_RPT),hl         ;162f\r
-       ld hl,(lst.D)           ;1632\r
-       ld bc,00080h            ;1635\r
-       call sub_0a82h          ;1638\r
-       scf                     ;163b\r
+       ld hl,CMD.D\r
+       ld (CMD_RPT),hl\r
+       ld hl,(lst.D)\r
+       ld bc,00080h\r
+       call sub_0a82h\r
+       scf\r
 memdump:\r
-       push bc                 ;163c\r
-       push de                 ;163d\r
-       push hl                 ;163e\r
-       ex af,af'               ;163f\r
+       push bc\r
+       push de\r
+       push hl\r
+       ex af,af'\r
 l1640h:\r
-       call out.hl.@           ;1640\r
-       call z,outbl2           ;1643\r
-       call OUTBL              ;1646\r
-       ld de,0                 ;1649\r
+       call out.hl.@\r
+       call z,outbl2\r
+       call OUTBL\r
+       ld de,0\r
 l164ch:\r
-       comst                   ;164c\r
-       ld a,(hl)               ;1650\r
+       comst\r
+       ld a,(hl)\r
        comend\r
-       inc hl                  ;1651\r
-       call out.hex            ;1652\r
-       call OUTBL              ;1655\r
-       dec bc                  ;1658\r
-       inc e                   ;1659\r
-       ld a,e                  ;165a\r
-       cp 010h                 ;165b\r
-       jr z,l1668h             ;165d\r
-       and 003h                ;165f\r
-       call z,OUTBL            ;1661\r
-       ld a,b                  ;1664\r
-       or c                    ;1665\r
-       jr nz,l164ch            ;1666\r
+       inc hl\r
+       call out.hex\r
+       call OUTBL\r
+       dec bc\r
+       inc e\r
+       ld a,e\r
+       cp 010h\r
+       jr z,l1668h\r
+       and 003h\r
+       call z,OUTBL\r
+       ld a,b\r
+       or c\r
+       jr nz,l164ch\r
 l1668h:\r
-       call OUTBL              ;1668\r
-       and a                   ;166b\r
-       sbc hl,de               ;166c\r
+       call OUTBL\r
+       and a\r
+       sbc hl,de\r
 l166eh:\r
-       comst                   ;166e\r
-       ld a,(hl)               ;1672\r
+       comst\r
+       ld a,(hl)\r
        comend\r
-       call sub_168fh          ;1673\r
-       call OUTCHAR            ;1676\r
-       inc hl                  ;1679\r
-       dec e                   ;167a\r
-       jr nz,l166eh            ;167b\r
-       ex af,af'               ;167d\r
-       jr nc,l1683h            ;167e\r
-       ld (lst.D),hl           ;1680\r
+       call sub_168fh\r
+       call OUTCHAR\r
+       inc hl\r
+       dec e\r
+       jr nz,l166eh\r
+       ex af,af'\r
+       jr nc,l1683h\r
+       ld (lst.D),hl\r
 l1683h:\r
-       ex af,af'               ;1683\r
-       call CRLF               ;1684\r
-       ld a,b                  ;1687\r
-       or c                    ;1688\r
-       jr nz,l1640h            ;1689\r
-       pop hl                  ;168b\r
-       pop de                  ;168c\r
-       pop bc                  ;168d\r
-       ret                     ;168e\r
+       ex af,af'\r
+       call CRLF\r
+       ld a,b\r
+       or c\r
+       jr nz,l1640h\r
+       pop hl\r
+       pop de\r
+       pop bc\r
+       ret\r
 sub_168fh:\r
-       and 07fh                ;168f\r
-       cp 07fh                 ;1691\r
-       jr z,l1698h             ;1693\r
-       cp 020h                 ;1695\r
-       ret nc                  ;1697\r
+       and 07fh\r
+       cp 07fh\r
+       jr z,l1698h\r
+       cp 020h\r
+       ret nc\r
 l1698h:\r
-       ld a,02eh               ;1698\r
-       ret                     ;169a\r
+       ld a,02eh\r
+       ret\r
 \r
 ;      Read Intel Hex File from console.\r
 CMD.R:\r
-       ld hl,0                 ;169b\r
+       ld hl,0\r
        call get_lastarg_def    ;169e   get offset from command line\r
-       push hl                 ;16a1\r
-       ld hl,0                 ;16a2\r
-       ld (HILOD),hl           ;16a5\r
+       push hl\r
+       ld hl,0\r
+       ld (HILOD),hl\r
 w_recstart:\r
-       call i.getchar          ;16a8\r
-       jr z,l16deh             ;16ab\r
-       cp ':'                  ;16ad\r
-       jr nz,w_recstart        ;16af\r
+       call i.getchar\r
+       jr z,l16deh\r
+       cp ':'\r
+       jr nz,w_recstart\r
        ld c,0                  ;16b1   init checksum\r
        call i.gethexbyte       ;16b3   record len\r
-       ld b,a                  ;16b6\r
+       ld b,a\r
        call i.gethexbyte       ;16b7   address high\r
-       ld h,a                  ;16ba\r
+       ld h,a\r
        call i.gethexbyte       ;16bb   address low\r
-       ld l,a                  ;16be\r
+       ld l,a\r
        call i.gethexbyte       ;16bf   record type (ignored)\r
-       ld a,b                  ;16c2\r
+       ld a,b\r
        and a                   ;16c3   record len == 0?\r
-       jr z,l16deh             ;16c4\r
+       jr z,l16deh\r
 l16c6h:\r
-       call i.gethexbyte       ;16c6\r
+       call i.gethexbyte\r
        pop de                  ;16c9   offset\r
-       push de                 ;16ca\r
-       push hl                 ;16cb\r
-       add hl,de               ;16cc\r
-       call i.storebyte        ;16cd\r
-       pop hl                  ;16d0\r
-       inc hl                  ;16d1\r
+       push de\r
+       push hl\r
+       add hl,de\r
+       call i.storebyte\r
+       pop hl\r
+       inc hl\r
        djnz l16c6h             ;16d2   repeat for record len\r
        call i.gethexbyte       ;16d4   checksum\r
-       ld a,c                  ;16d7\r
-       and a                   ;16d8\r
+       ld a,c\r
+       and a\r
        jp nz,ERROR             ;16d9   exit if checksum error\r
        jr w_recstart           ;16dc   next record\r
 l16deh:\r
-       pop hl                  ;16de\r
-       call i.gethexbyte       ;16df\r
-       jp l173fh               ;16e2\r
+       pop hl\r
+       call i.gethexbyte\r
+       jp l173fh\r
 \r
 i.gethexbyte:\r
-       call sub_16f6h          ;16e5\r
-       rlca                    ;16e8\r
-       rlca                    ;16e9\r
-       rlca                    ;16ea\r
-       rlca                    ;16eb\r
-       ld d,a                  ;16ec\r
-       call sub_16f6h          ;16ed\r
-       add a,d                 ;16f0\r
-       ld d,a                  ;16f1\r
-       add a,c                 ;16f2\r
-       ld c,a                  ;16f3\r
-       ld a,d                  ;16f4\r
-       ret                     ;16f5\r
+       call sub_16f6h\r
+       rlca\r
+       rlca\r
+       rlca\r
+       rlca\r
+       ld d,a\r
+       call sub_16f6h\r
+       add a,d\r
+       ld d,a\r
+       add a,c\r
+       ld c,a\r
+       ld a,d\r
+       ret\r
 \r
 sub_16f6h:\r
-       call i.getchar          ;16f6\r
-       jr z,l16ffh             ;16f9\r
-       call sub_0d26h          ;16fb\r
-       ret nc                  ;16fe\r
+       call i.getchar\r
+       jr z,l16ffh\r
+       call sub_0d26h\r
+       ret nc\r
 l16ffh:\r
-       jp ERROR                ;16ff\r
+       jp ERROR\r
 \r
 i.getchar:\r
-       call $ci                ;1702\r
-       cp 01ah                 ;1705\r
-       ret                     ;1707\r
+       call $ci\r
+       cp 01ah\r
+       ret\r
 \r
 i.storebyte:\r
-       push af                 ;1708\r
-       push de                 ;1709\r
+       push af\r
+       push de\r
        ld de,TPA               ;170a   lowest allowed load address\r
-       call CP.HL.DE           ;170d\r
-       jp c,ERROR              ;1710\r
+       call CP.HL.DE\r
+       jp c,ERROR\r
        ld de,$stcka            ;1713   highest allowed load address\r
-       call CP.HL.DE           ;1716\r
-       jp nc,ERROR             ;1719\r
-       ld de,(HILOD)           ;171c\r
-       call CP.HL.DE           ;1720\r
-       jr c,l1728h             ;1723\r
-       ld (HILOD),hl           ;1725\r
+       call CP.HL.DE\r
+       jp nc,ERROR\r
+       ld de,(HILOD)\r
+       call CP.HL.DE\r
+       jr c,l1728h\r
+       ld (HILOD),hl\r
 l1728h:\r
-       ld de,(MAXLOD)          ;1728\r
-       call CP.HL.DE           ;172c\r
-       jr c,l1734h             ;172f\r
-       ld (MAXLOD),hl          ;1731\r
+       ld de,(MAXLOD)\r
+       call CP.HL.DE\r
+       jr c,l1734h\r
+       ld (MAXLOD),hl\r
 l1734h:\r
-       pop de                  ;1734\r
-       pop af                  ;1735\r
-       comst                   ;1736\r
+       pop de\r
+       pop af\r
+       comst\r
        ld (hl),a               ;173a   store byte\r
        comend\r
-       ret                     ;173b\r
+       ret\r
 \r
 l173ch:\r
-       call assert_eol         ;173c\r
+       call assert_eol\r
 l173fh:\r
-       ld hl,MSG_high          ;173f\r
-       call PSTR               ;1742\r
-       ld hl,(HILOD)           ;1745\r
-       call out.hl             ;1748\r
-       ld hl,MSG_max           ;174b\r
-       call PSTR               ;174e\r
-       ld hl,(MAXLOD)          ;1751\r
-       call out.hl             ;1754\r
-       jp CRLF         ;1757\r
+       ld hl,MSG_high\r
+       call PSTR\r
+       ld hl,(HILOD)\r
+       call out.hl\r
+       ld hl,MSG_max\r
+       call PSTR\r
+       ld hl,(MAXLOD)\r
+       call out.hl\r
+       jp CRLF\r
 \r
 MSG_high:\r
        DC      'High = '\r
@@ -2839,1067 +2857,1067 @@ MSG_max:
        DC      '  Max = '\r
 \r
 CMD.A:\r
-       ld hl,(lst.A)           ;1769\r
-       call get_lastarg_def    ;176c\r
-       push hl                 ;176f\r
-       pop iy                  ;1770\r
-       ld hl,l17c4h            ;1772\r
-       ld (CMD_ERR),hl         ;1775\r
-       ld (XB068),sp           ;1778\r
+       ld hl,(lst.A)\r
+       call get_lastarg_def\r
+       push hl\r
+       pop iy\r
+       ld hl,l17c4h\r
+       ld (CMD_ERR),hl\r
+       ld (XB068),sp\r
 l177ch:\r
-       push iy                 ;177c\r
-       pop hl                  ;177e\r
-       ld (lst.A),hl           ;177f\r
-       ld (OFFS.pc),hl         ;1782\r
-       push hl                 ;1785\r
-       call sub_1f3fh          ;1786\r
-       pop iy                  ;1789\r
-       ld c,b                  ;178b\r
-       ld de,(offs.@)          ;178c\r
-       ld a,d                  ;1790\r
-       or e                    ;1791\r
-       ld b,011h               ;1792\r
-       jr z,l1798h             ;1794\r
-       ld b,019h               ;1796\r
+       push iy\r
+       pop hl\r
+       ld (lst.A),hl\r
+       ld (OFFS.pc),hl\r
+       push hl\r
+       call sub_1f3fh\r
+       pop iy\r
+       ld c,b\r
+       ld de,(offs.@)\r
+       ld a,d\r
+       or e\r
+       ld b,011h\r
+       jr z,l1798h\r
+       ld b,019h\r
 l1798h:\r
-       call OUTBL              ;1798\r
-       ld a,(CON.COL)          ;179b\r
-       cp b                    ;179e\r
-       jr c,l1798h             ;179f\r
-       push bc                 ;17a1\r
-       call INLINE             ;17a2\r
-       pop bc                  ;17a5\r
-       call SKIPBL             ;17a6\r
-       cp '.'                  ;17a9\r
-       ret z                   ;17ab\r
-       cp '-'                  ;17ac\r
-       jr nz,l17b6h            ;17ae\r
-       ld iy,(XB06C)           ;17b0\r
-       jr l177ch               ;17b4\r
+       call OUTBL\r
+       ld a,(CON.COL)\r
+       cp b\r
+       jr c,l1798h\r
+       push bc\r
+       call INLINE\r
+       pop bc\r
+       call SKIPBL\r
+       cp '.'\r
+       ret z\r
+       cp '-'\r
+       jr nz,l17b6h\r
+       ld iy,(XB06C)\r
+       jr l177ch\r
 l17b6h:\r
-       and a                   ;17b6\r
-       call nz,sub_17cdh       ;17b7\r
-       ld (XB06C),iy           ;17ba\r
-       ld b,0                  ;17be\r
-       add iy,bc               ;17c0\r
-       jr l177ch               ;17c2\r
+       and a\r
+       call nz,sub_17cdh\r
+       ld (XB06C),iy\r
+       ld b,0\r
+       add iy,bc\r
+       jr l177ch\r
 l17c4h:\r
-       call l07eah             ;17c4\r
-       ld sp,(XB068)           ;17c7\r
-       jr l177ch               ;17cb\r
+       call l07eah\r
+       ld sp,(XB068)\r
+       jr l177ch\r
 \r
 sub_17cdh:\r
-       call SKIPBL             ;17cd\r
-       ld hl,t_MNEMONICS       ;17d0\r
-       call sub_0a15h          ;17d3\r
-       jp nc,ERROR             ;17d6\r
-       call SKIPBL             ;17d9\r
-       push de                 ;17dc\r
-       ld a,b                  ;17dd\r
-       add a,b                 ;17de\r
-       add a,b                 ;17df\r
-       ld hl,b_0x17EE_start            ;17e0\r
-       call ADD_HL_A           ;17e3\r
-       ld e,(hl)                       ;17e6\r
-       inc hl                  ;17e7\r
-       ld d,(hl)                       ;17e8\r
-       inc hl                  ;17e9\r
-       ld b,(hl)                       ;17ea\r
-       ex de,hl                        ;17eb\r
-       pop de                  ;17ec\r
-       jp (hl)                 ;17ed\r
+       call SKIPBL\r
+       ld hl,t_MNEMONICS\r
+       call sub_0a15h\r
+       jp nc,ERROR\r
+       call SKIPBL\r
+       push de\r
+       ld a,b\r
+       add a,b\r
+       add a,b\r
+       ld hl,b_0x17EE_start\r
+       call ADD_HL_A\r
+       ld e,(hl)\r
+       inc hl\r
+       ld d,(hl)\r
+       inc hl\r
+       ld b,(hl)\r
+       ex de,hl\r
+       pop de\r
+       jp (hl)\r
 \r
 b_0x17EE_start:\r
-       defw l1b54h             ;17ee\r
+       defw l1b54h\r
 \r
 b_0x17F0_start:\r
-       defb 088h               ;17f0\r
+       defb 088h\r
 \r
 b_0x17F1_start:\r
-       defw l1b74h             ;17f1\r
+       defw l1b74h\r
 \r
 b_0x17F3_start:\r
-       defb 080h               ;17f3\r
+       defb 080h\r
 \r
 b_0x17F4_start:\r
-       defw l1babh             ;17f4\r
+       defw l1babh\r
 \r
 b_0x17F6_start:\r
-       defb 0a0h               ;17f6\r
+       defb 0a0h\r
 \r
 b_0x17F7_start:\r
-       defw l1c14h             ;17f7\r
+       defw l1c14h\r
 \r
 b_0x17F9_start:\r
-       defb 040h               ;17f9\r
+       defb 040h\r
 \r
 b_0x17FA_start:\r
-       defw l1c38h             ;17fa\r
+       defw l1c38h\r
 \r
 b_0x17FC_start:\r
-       defb 0c4h               ;17fc\r
+       defb 0c4h\r
 \r
 b_0x17FD_start:\r
-       defw l1b36h             ;17fd\r
+       defw l1b36h\r
 \r
 b_0x17FF_start:\r
-       defb 03fh               ;17ff\r
+       defb 03fh\r
 \r
 b_0x1800_start:\r
-       defw l1babh             ;1800\r
+       defw l1babh\r
 \r
 b_0x1802_start:\r
-       defb 0b8h               ;1802\r
+       defb 0b8h\r
 \r
 b_0x1803_start:\r
-       defw gen.opc.ED2        ;1803\r
+       defw gen.opc.ED2\r
 \r
 b_0x1805_start:\r
-       defb 0a9h               ;1805\r
+       defb 0a9h\r
 \r
 b_0x1806_start:\r
-       defw gen.opc.ED2        ;1806\r
+       defw gen.opc.ED2\r
 \r
 b_0x1808_start:\r
-       defb 0b9h               ;1808\r
+       defb 0b9h\r
 \r
 b_0x1809_start:\r
-       defw gen.opc.ED2        ;1809\r
+       defw gen.opc.ED2\r
 \r
 b_0x180B_start:\r
-       defb 0a1h               ;180b\r
+       defb 0a1h\r
 \r
 b_0x180C_start:\r
-       defw gen.opc.ED2        ;180c\r
+       defw gen.opc.ED2\r
 \r
 b_0x180E_start:\r
-       defb 0b1h               ;180e\r
+       defb 0b1h\r
 \r
 b_0x180F_start:\r
-       defw l1b36h             ;180f\r
+       defw l1b36h\r
 \r
 b_0x1811_start:\r
-       defb 02fh               ;1811\r
+       defb 02fh\r
 \r
 b_0x1812_start:\r
-       defw l1b36h             ;1812\r
+       defw l1b36h\r
 \r
 b_0x1814_start:\r
-       defb 027h               ;1814\r
+       defb 027h\r
 \r
 b_0x1815_start:\r
-       defw l1dabh             ;1815\r
+       defw l1dabh\r
 \r
 b_0x1817_start:\r
-       defb 005h               ;1817\r
+       defb 005h\r
 \r
 b_0x1818_start:\r
-       defw l1b36h             ;1818\r
+       defw l1b36h\r
 \r
 b_0x181A_start:\r
-       defb 0f3h               ;181a\r
+       defb 0f3h\r
 \r
 b_0x181B_start:\r
-       defw l1ca4h             ;181b\r
+       defw l1ca4h\r
 \r
 b_0x181D_start:\r
-       defb 010h               ;181d\r
+       defb 010h\r
 \r
 b_0x181E_start:\r
-       defw l1b36h             ;181e\r
+       defw l1b36h\r
 \r
 b_0x1820_start:\r
-       defb 0fbh               ;1820\r
+       defb 0fbh\r
 \r
 b_0x1821_start:\r
-       defw l1d54h             ;1821\r
+       defw l1d54h\r
 \r
 b_0x1823_start:\r
-       defb 0e3h               ;1823\r
+       defb 0e3h\r
 \r
 b_0x1824_start:\r
-       defw l1b36h             ;1824\r
+       defw l1b36h\r
 \r
 b_0x1826_start:\r
-       defb 0d9h               ;1826\r
+       defb 0d9h\r
 \r
 b_0x1827_start:\r
-       defw l1b36h             ;1827\r
+       defw l1b36h\r
 \r
 b_0x1829_start:\r
-       defb 076h               ;1829\r
+       defb 076h\r
 \r
 b_0x182A_start:\r
-       defw l1cbfh             ;182a\r
+       defw l1cbfh\r
 \r
 b_0x182C_start:\r
-       defb 046h               ;182c\r
+       defb 046h\r
 \r
 b_0x182D_start:\r
-       defw l1cf8h             ;182d\r
+       defw l1cf8h\r
 \r
 b_0x182F_start:\r
-       defb 040h               ;182f\r
+       defb 040h\r
 \r
 b_0x1830_start:\r
-       defw l1dabh             ;1830\r
+       defw l1dabh\r
 \r
 b_0x1832_start:\r
-       defb 004h               ;1832\r
+       defb 004h\r
 \r
 b_0x1833_start:\r
-       defw gen.opc.ED2        ;1833\r
+       defw gen.opc.ED2\r
 \r
 b_0x1835_start:\r
-       defb 0aah               ;1835\r
+       defb 0aah\r
 \r
 b_0x1836_start:\r
-       defw gen.opc.ED2        ;1836\r
+       defw gen.opc.ED2\r
 \r
 b_0x1838_start:\r
-       defb 0bah               ;1838\r
+       defb 0bah\r
 \r
 b_0x1839_start:\r
-       defw gen.opc.ED2        ;1839\r
+       defw gen.opc.ED2\r
 \r
 b_0x183B_start:\r
-       defb 0a2h               ;183b\r
+       defb 0a2h\r
 \r
 b_0x183C_start:\r
-       defw gen.opc.ED2        ;183c\r
+       defw gen.opc.ED2\r
 \r
 b_0x183E_start:\r
-       defb 0b2h               ;183e\r
+       defb 0b2h\r
 \r
 b_0x183F_start:\r
-       defw l1c5eh             ;183f\r
+       defw l1c5eh\r
 \r
 b_0x1841_start:\r
-       defb 0c2h               ;1841\r
+       defb 0c2h\r
 \r
 b_0x1842_start:\r
-       defw l1cabh             ;1842\r
+       defw l1cabh\r
 \r
 b_0x1844_start:\r
-       defb 020h               ;1844\r
+       defb 020h\r
 \r
 b_0x1845_start:\r
-       defw l1934h             ;1845\r
+       defw l1934h\r
 \r
 b_0x1847_start:\r
-       defb 040h               ;1847\r
+       defb 040h\r
 \r
 b_0x1848_start:\r
-       defw gen.opc.ED2        ;1848\r
+       defw gen.opc.ED2\r
 \r
 b_0x184A_start:\r
-       defb 0a8h               ;184a\r
+       defb 0a8h\r
 \r
 b_0x184B_start:\r
-       defw gen.opc.ED2        ;184b\r
+       defw gen.opc.ED2\r
 \r
 b_0x184D_start:\r
-       defb 0b8h               ;184d\r
+       defb 0b8h\r
 \r
 b_0x184E_start:\r
-       defw gen.opc.ED2        ;184e\r
+       defw gen.opc.ED2\r
 \r
 b_0x1850_start:\r
-       defb 0a0h               ;1850\r
+       defb 0a0h\r
 \r
 b_0x1851_start:\r
-       defw gen.opc.ED2        ;1851\r
+       defw gen.opc.ED2\r
 \r
 b_0x1853_start:\r
-       defb 0b0h               ;1853\r
+       defb 0b0h\r
 \r
 b_0x1854_start:\r
-       defw gen.opc.ED2        ;1854\r
+       defw gen.opc.ED2\r
 \r
 b_0x1856_start:\r
-       defb 044h               ;1856\r
+       defb 044h\r
 \r
 b_0x1857_start:\r
-       defw l1b36h             ;1857\r
+       defw l1b36h\r
 \r
 b_0x1859_start:\r
-       defb 000h               ;1859\r
+       defb 000h\r
 \r
 b_0x185A_start:\r
-       defw l1babh             ;185a\r
+       defw l1babh\r
 \r
 b_0x185C_start:\r
-       defb 0b0h               ;185c\r
+       defb 0b0h\r
 \r
 b_0x185D_start:\r
-       defw gen.opc.ED2        ;185d\r
+       defw gen.opc.ED2\r
 \r
 b_0x185F_start:\r
-       defb 0bbh               ;185f\r
+       defb 0bbh\r
 \r
 b_0x1860_start:\r
-       defw gen.opc.ED2        ;1860\r
+       defw gen.opc.ED2\r
 \r
 b_0x1862_start:\r
-       defb 0b3h               ;1862\r
+       defb 0b3h\r
 \r
 b_0x1863_start:\r
-       defw l1d2ch             ;1863\r
+       defw l1d2ch\r
 \r
 b_0x1865_start:\r
-       defb 041h               ;1865\r
+       defb 041h\r
 \r
 b_0x1866_start:\r
-       defw gen.opc.ED2        ;1866\r
+       defw gen.opc.ED2\r
 \r
 b_0x1868_start:\r
-       defb 0abh               ;1868\r
+       defb 0abh\r
 \r
 b_0x1869_start:\r
-       defw gen.opc.ED2        ;1869\r
+       defw gen.opc.ED2\r
 \r
 b_0x186B_start:\r
-       defb 0a3h               ;186b\r
+       defb 0a3h\r
 \r
 b_0x186C_start:\r
-       defw l1ce4h             ;186c\r
+       defw l1ce4h\r
 \r
 b_0x186E_start:\r
-       defb 0c1h               ;186e\r
+       defb 0c1h\r
 \r
 b_0x186F_start:\r
-       defw l1ce4h             ;186f\r
+       defw l1ce4h\r
 \r
 b_0x1871_start:\r
-       defb 0c5h               ;1871\r
+       defb 0c5h\r
 \r
 b_0x1872_start:\r
-       defw l1c14h             ;1872\r
+       defw l1c14h\r
 \r
 b_0x1874_start:\r
-       defb 080h               ;1874\r
+       defb 080h\r
 \r
 b_0x1875_start:\r
-       defw l1c50h             ;1875\r
+       defw l1c50h\r
 \r
 b_0x1877_start:\r
-       defb 0c0h               ;1877\r
+       defb 0c0h\r
 \r
 b_0x1878_start:\r
-       defw gen.opc.ED2        ;1878\r
+       defw gen.opc.ED2\r
 \r
 b_0x187A_start:\r
-       defb 04dh               ;187a\r
+       defb 04dh\r
 \r
 b_0x187B_start:\r
-       defw gen.opc.ED2        ;187b\r
+       defw gen.opc.ED2\r
 \r
 b_0x187D_start:\r
-       defb 045h               ;187d\r
+       defb 045h\r
 \r
 b_0x187E_start:\r
-       defw l1bd8h             ;187e\r
+       defw l1bd8h\r
 \r
 b_0x1880_start:\r
-       defb 010h               ;1880\r
+       defb 010h\r
 \r
 b_0x1881_start:\r
-       defw l1b36h             ;1881\r
+       defw l1b36h\r
 \r
 b_0x1883_start:\r
-       defb 017h               ;1883\r
+       defb 017h\r
 \r
 b_0x1884_start:\r
-       defw l1bd8h             ;1884\r
+       defw l1bd8h\r
 \r
 b_0x1886_start:\r
-       defb 000h               ;1886\r
+       defb 000h\r
 \r
 b_0x1887_start:\r
-       defw l1b36h             ;1887\r
+       defw l1b36h\r
 \r
 b_0x1889_start:\r
-       defb 007h               ;1889\r
+       defb 007h\r
 \r
 b_0x188A_start:\r
-       defw gen.opc.ED2        ;188a\r
+       defw gen.opc.ED2\r
 \r
 b_0x188C_start:\r
-       defb 06fh               ;188c\r
+       defb 06fh\r
 \r
 b_0x188D_start:\r
-       defw l1bd8h             ;188d\r
+       defw l1bd8h\r
 \r
 b_0x188F_start:\r
-       defb 018h               ;188f\r
+       defb 018h\r
 \r
 b_0x1890_start:\r
-       defw l1b36h             ;1890\r
+       defw l1b36h\r
 \r
 b_0x1892_start:\r
-       defb 01fh               ;1892\r
+       defb 01fh\r
 \r
 b_0x1893_start:\r
-       defw l1bd8h             ;1893\r
+       defw l1bd8h\r
 \r
 b_0x1895_start:\r
-       defb 008h               ;1895\r
+       defb 008h\r
 \r
 b_0x1896_start:\r
-       defw l1b36h             ;1896\r
+       defw l1b36h\r
 \r
 b_0x1898_start:\r
-       defb 00fh               ;1898\r
+       defb 00fh\r
 \r
 b_0x1899_start:\r
-       defw gen.opc.ED2        ;1899\r
+       defw gen.opc.ED2\r
 \r
 b_0x189B_start:\r
-       defb 067h               ;189b\r
+       defb 067h\r
 \r
 b_0x189C_start:\r
-       defw l1cd5h             ;189c\r
+       defw l1cd5h\r
 \r
 b_0x189E_start:\r
-       defb 0c7h               ;189e\r
+       defb 0c7h\r
 \r
 b_0x189F_start:\r
-       defw l1b54h             ;189f\r
+       defw l1b54h\r
 \r
 b_0x18A1_start:\r
-       defb 098h               ;18a1\r
+       defb 098h\r
 \r
 b_0x18A2_start:\r
-       defw l1b36h             ;18a2\r
+       defw l1b36h\r
 \r
 b_0x18A4_start:\r
-       defb 037h               ;18a4\r
+       defb 037h\r
 \r
 b_0x18A5_start:\r
-       defw l1c14h             ;18a5\r
+       defw l1c14h\r
 \r
 b_0x18A7_start:\r
-       defb 0c0h               ;18a7\r
+       defb 0c0h\r
 \r
 b_0x18A8_start:\r
-       defw l1bd8h             ;18a8\r
+       defw l1bd8h\r
 \r
 b_0x18AA_start:\r
-       defb 020h               ;18aa\r
+       defb 020h\r
 \r
 b_0x18AB_start:\r
-       defw l1bd8h             ;18ab\r
+       defw l1bd8h\r
 \r
 b_0x18AD_start:\r
-       defb 028h               ;18ad\r
+       defb 028h\r
 \r
 b_0x18AE_start:\r
-       defw l1bd8h             ;18ae\r
+       defw l1bd8h\r
 \r
 b_0x18B0_start:\r
-       defb 038h               ;18b0\r
+       defb 038h\r
 \r
 b_0x18B1_start:\r
-       defw l1babh             ;18b1\r
+       defw l1babh\r
 \r
 b_0x18B3_start:\r
-       defb 090h               ;18b3\r
+       defb 090h\r
 \r
 b_0x18B4_start:\r
-       defw l1babh             ;18b4\r
+       defw l1babh\r
 \r
 b_0x18B6_start:\r
-       defb 0a8h               ;18b6\r
+       defb 0a8h\r
 \r
 b_0x18B7_start:\r
-       defw A.IN0              ;18b7\r
+       defw A.IN0\r
 \r
 b_0x18B9_start:\r
-       defb 000h               ;18b9\r
+       defb 000h\r
 \r
 b_0x18BA_start:\r
-       defw A.MLT              ;18ba\r
+       defw A.MLT\r
 \r
 b_0x18BC_start:\r
-       defb 04ch               ;18bc\r
-       ld b,e                  ;18bd\r
-       dec de                  ;18be\r
+       defb 04ch\r
+       ld b,e\r
+       dec de\r
 \r
 b_0x18BF_start:\r
-       defb 08bh               ;18bf\r
+       defb 08bh\r
 \r
 b_0x18C0_start:\r
-       defw gen.opc.ED2        ;18c0\r
+       defw gen.opc.ED2\r
 \r
 b_0x18C2_start:\r
-       defb 09bh               ;18c2\r
+       defb 09bh\r
 \r
 b_0x18C3_start:\r
-       defw gen.opc.ED2        ;18c3\r
+       defw gen.opc.ED2\r
 \r
 b_0x18C5_start:\r
-       defb 083h               ;18c5\r
+       defb 083h\r
 \r
 b_0x18C6_start:\r
-       defw gen.opc.ED2        ;18c6\r
+       defw gen.opc.ED2\r
 \r
 b_0x18C8_start:\r
-       defb 093h               ;18c8\r
+       defb 093h\r
 \r
 b_0x18C9_start:\r
-       defw l18fdh             ;18c9\r
+       defw l18fdh\r
 \r
 b_0x18CB_start:\r
-       defb 001h               ;18cb\r
+       defb 001h\r
 \r
 b_0x18CC_start:\r
-       defw gen.opc.ED2        ;18cc\r
+       defw gen.opc.ED2\r
 \r
 b_0x18CE_start:\r
-       defb 076h               ;18ce\r
+       defb 076h\r
 \r
 b_0x18CF_start:\r
-       defw l191dh             ;18cf\r
+       defw l191dh\r
 \r
 b_0x18D1_start:\r
-       defb 004h               ;18d1\r
+       defb 004h\r
 \r
 b_0x18D2_start:\r
-       defw l192ch             ;18d2\r
+       defw l192ch\r
 \r
 b_0x18D4_start:\r
-       defb 074h               ;18d4\r
+       defb 074h\r
 A.IN0:\r
-       call sub_1e41h          ;18d5\r
-       jr nc,l1931h            ;18d8\r
-       cp 006h         ;18da\r
-       jr z,l1931h             ;18dc\r
-       rlca                    ;18de\r
-       rlca                    ;18df\r
-       rlca                    ;18e0\r
-       add a,b                 ;18e1\r
-       ld b,a                  ;18e2\r
-       call sub_1ed1h          ;18e3\r
-       call sub_1e06h          ;18e6\r
+       call sub_1e41h\r
+       jr nc,l1931h\r
+       cp 006h\r
+       jr z,l1931h\r
+       rlca\r
+       rlca\r
+       rlca\r
+       add a,b\r
+       ld b,a\r
+       call sub_1ed1h\r
+       call sub_1e06h\r
 l18e9h:\r
-       call assert_eol         ;18e9\r
-       comst                   ;18ec\r
-       ld (iy+000h),0edh       ;18f0\r
-       ld (iy+001h),b          ;18f4\r
-       ld (iy+002h),l          ;18f7\r
+       call assert_eol\r
+       comst\r
+       ld (iy+000h),0edh\r
+       ld (iy+001h),b\r
+       ld (iy+002h),l\r
        comend\r
-       ld c,003h               ;18fa\r
-       ret                     ;18fc\r
+       ld c,003h\r
+       ret\r
 l18fdh:\r
-       call sub_1e06h          ;18fd\r
-       call sub_1ed1h          ;1900\r
-       call sub_1e41h          ;1903\r
-       jr nc,l1931h            ;1906\r
-       cp 006h                 ;1908\r
-       jr z,l1931h             ;190a\r
-       rlca                    ;190c\r
-       rlca                    ;190d\r
-       rlca                    ;190e\r
-       add a,b                 ;190f\r
-       ld b,a                  ;1910\r
-       jr l18e9h               ;1911\r
+       call sub_1e06h\r
+       call sub_1ed1h\r
+       call sub_1e41h\r
+       jr nc,l1931h\r
+       cp 006h\r
+       jr z,l1931h\r
+       rlca\r
+       rlca\r
+       rlca\r
+       add a,b\r
+       ld b,a\r
+       jr l18e9h\r
 A.MLT:\r
-       call sub_1e2eh          ;1913\r
-       jr nc,l1931h            ;1916\r
-       add a,b                 ;1918\r
-       ld b,a                  ;1919\r
-       jp gen.opc.ED2          ;191a\r
+       call sub_1e2eh\r
+       jr nc,l1931h\r
+       add a,b\r
+       ld b,a\r
+       jp gen.opc.ED2\r
 l191dh:\r
-       call sub_1e41h          ;191d\r
-       jr nc,l192ah            ;1920\r
-       rlca                    ;1922\r
-       rlca                    ;1923\r
-       rlca                    ;1924\r
-       add a,b                 ;1925\r
-       ld b,a                  ;1926\r
-       jp gen.opc.ED2          ;1927\r
+       call sub_1e41h\r
+       jr nc,l192ah\r
+       rlca\r
+       rlca\r
+       rlca\r
+       add a,b\r
+       ld b,a\r
+       jp gen.opc.ED2\r
 l192ah:\r
-       ld b,064h               ;192a\r
+       ld b,064h\r
 l192ch:\r
-       call sub_1e12h          ;192c\r
-       jr l18e9h               ;192f\r
+       call sub_1e12h\r
+       jr l18e9h\r
 l1931h:\r
-       jp ERROR                ;1931\r
+       jp ERROR\r
 l1934h:\r
-       call sub_1e41h          ;1934\r
-       jp c,l19bfh             ;1937\r
-       call sub_1e68h          ;193a\r
-       jp c,l1a64h             ;193d\r
-       call sub_1e2eh          ;1940\r
-       jp c,l1a93h             ;1943\r
-       call sub_1e50h          ;1946\r
-       jp c,l1af0h             ;1949\r
-       ld a,(de)               ;194c\r
-       cp 049h                 ;194d\r
-       jp z,l1b0ch             ;194f\r
-       cp 052h                 ;1952\r
-       jp z,l1b14h             ;1954\r
-       cp 028h                 ;1957\r
-       jp nz,ERROR             ;1959\r
-       inc de                  ;195c\r
-       call sub_1e2eh          ;195d\r
-       jp c,l1b23h             ;1960\r
-       call tst_EXPR           ;1963\r
-       call sub_1ed8h          ;1966\r
-       call sub_1ed1h          ;1969\r
-       call sub_1e2eh          ;196c\r
-       jr c,l19adh             ;196f\r
-       call sub_1e50h          ;1971\r
-       jr nc,l1991h            ;1974\r
-       ld b,022h               ;1976\r
+       call sub_1e41h\r
+       jp c,l19bfh\r
+       call sub_1e68h\r
+       jp c,l1a64h\r
+       call sub_1e2eh\r
+       jp c,l1a93h\r
+       call sub_1e50h\r
+       jp c,l1af0h\r
+       ld a,(de)\r
+       cp 049h\r
+       jp z,l1b0ch\r
+       cp 052h\r
+       jp z,l1b14h\r
+       cp 028h\r
+       jp nz,ERROR\r
+       inc de\r
+       call sub_1e2eh\r
+       jp c,l1b23h\r
+       call tst_EXPR\r
+       call sub_1ed8h\r
+       call sub_1ed1h\r
+       call sub_1e2eh\r
+       jr c,l19adh\r
+       call sub_1e50h\r
+       jr nc,l1991h\r
+       ld b,022h\r
 l1978h:\r
-       call assert_eol         ;1978\r
-       ld a,(pfx.IXY)          ;197b\r
+       call assert_eol\r
+       ld a,(pfx.IXY)\r
 l197eh:\r
-       comst                   ;197e\r
-       ld (iy+000h),a          ;1982\r
-       ld (iy+001h),b          ;1985\r
-       ld (iy+002h),l          ;1988\r
-       ld (iy+003h),h          ;198b\r
+       comst\r
+       ld (iy+000h),a\r
+       ld (iy+001h),b\r
+       ld (iy+002h),l\r
+       ld (iy+003h),h\r
        comend\r
-       ld c,004h               ;198e\r
-       ret                     ;1990\r
+       ld c,004h\r
+       ret\r
 l1991h:\r
-       ld a,(de)                       ;1991\r
-       cp 041h         ;1992\r
-       jp nz,ERROR             ;1994\r
-       inc de                  ;1997\r
-       ld b,032h               ;1998\r
+       ld a,(de)\r
+       cp 041h\r
+       jp nz,ERROR\r
+       inc de\r
+       ld b,032h\r
 l199ah:\r
-       call assert_eol         ;199a\r
-       comst                   ;199d\r
-       ld (iy+000h),b          ;19a1\r
-       ld (iy+001h),l          ;19a4\r
-       ld (iy+002h),h          ;19a7\r
+       call assert_eol\r
+       comst\r
+       ld (iy+000h),b\r
+       ld (iy+001h),l\r
+       ld (iy+002h),h\r
        comend\r
-       ld c,003h               ;19aa\r
-       ret                     ;19ac\r
+       ld c,003h\r
+       ret\r
 l19adh:\r
-       cp 020h         ;19ad\r
-       jr z,l19bbh             ;19af\r
-       add a,043h              ;19b1\r
-       ld b,a                  ;19b3\r
+       cp 020h\r
+       jr z,l19bbh\r
+       add a,043h\r
+       ld b,a\r
 l19b4h:\r
-       call assert_eol         ;19b4\r
-       ld a,0edh               ;19b7\r
-       jr l197eh               ;19b9\r
+       call assert_eol\r
+       ld a,0edh\r
+       jr l197eh\r
 l19bbh:\r
-       ld b,022h               ;19bb\r
-       jr l199ah               ;19bd\r
+       ld b,022h\r
+       jr l199ah\r
 l19bfh:\r
-       ld b,a                  ;19bf\r
-       call sub_1ed1h          ;19c0\r
-       call sub_1e41h          ;19c3\r
-       jr nc,l19dbh            ;19c6\r
-       push af                 ;19c8\r
-       ld a,b                  ;19c9\r
-       rlca                    ;19ca\r
-       rlca                    ;19cb\r
-       rlca                    ;19cc\r
-       ld b,a                  ;19cd\r
-       pop af                  ;19ce\r
-       add a,b                 ;19cf\r
-       add a,040h              ;19d0\r
-       cp 076h         ;19d2\r
-       jp z,ERROR              ;19d4\r
+       ld b,a\r
+       call sub_1ed1h\r
+       call sub_1e41h\r
+       jr nc,l19dbh\r
+       push af\r
+       ld a,b\r
+       rlca\r
+       rlca\r
+       rlca\r
+       ld b,a\r
+       pop af\r
+       add a,b\r
+       add a,040h\r
+       cp 076h\r
+       jp z,ERROR\r
 l19d7h:\r
-       ld b,a                  ;19d7\r
-       jp l1b36h               ;19d8\r
+       ld b,a\r
+       jp l1b36h\r
 l19dbh:\r
-       call sub_1e68h          ;19db\r
-       jr nc,l1a02h            ;19de\r
-       ld a,b                  ;19e0\r
-       rlca                    ;19e1\r
-       rlca                    ;19e2\r
-       rlca                    ;19e3\r
-       add a,046h              ;19e4\r
-       cp 076h         ;19e6\r
-       jp z,ERROR              ;19e8\r
+       call sub_1e68h\r
+       jr nc,l1a02h\r
+       ld a,b\r
+       rlca\r
+       rlca\r
+       rlca\r
+       add a,046h\r
+       cp 076h\r
+       jp z,ERROR\r
 l19ebh:\r
-       ld b,a                  ;19eb\r
-       call assert_eol         ;19ec\r
-       ld a,(pfx.IXY)          ;19ef\r
-       comst                   ;19f2\r
-       ld (iy+000h),a          ;19f6\r
-       ld (iy+001h),b          ;19f9\r
-       ld (iy+002h),c          ;19fc\r
+       ld b,a\r
+       call assert_eol\r
+       ld a,(pfx.IXY)\r
+       comst\r
+       ld (iy+000h),a\r
+       ld (iy+001h),b\r
+       ld (iy+002h),c\r
        comend\r
-       ld c,003h               ;19ff\r
-       ret                     ;1a01\r
+       ld c,003h\r
+       ret\r
 l1a02h:\r
-       ld a,(de)               ;1a02\r
-       cp 'I'                  ;1a03\r
-       jr z,l1a15h             ;1a05\r
-       cp 'R'                  ;1a07\r
-       jr nz,l1a21h            ;1a09\r
-       ld a,b                  ;1a0b\r
-       cp 007h                 ;1a0c\r
-       jp nz,ERROR             ;1a0e\r
-       ld b,05fh               ;1a11\r
-       jr l1a1dh               ;1a13\r
+       ld a,(de)\r
+       cp 'I'\r
+       jr z,l1a15h\r
+       cp 'R'\r
+       jr nz,l1a21h\r
+       ld a,b\r
+       cp 007h\r
+       jp nz,ERROR\r
+       ld b,05fh\r
+       jr l1a1dh\r
 l1a15h:\r
-       ld a,b                  ;1a15\r
-       cp 007h                 ;1a16\r
-       jp nz,ERROR             ;1a18\r
-       ld b,057h               ;1a1b\r
+       ld a,b\r
+       cp 007h\r
+       jp nz,ERROR\r
+       ld b,057h\r
 l1a1dh:\r
-       inc de                  ;1a1d\r
-       jp gen.opc.ED2          ;1a1e\r
+       inc de\r
+       jp gen.opc.ED2\r
 l1a21h:\r
-       cp '('                  ;1a21\r
-       jr z,l1a3fh             ;1a23\r
-       call sub_1e12h          ;1a25\r
+       cp '('\r
+       jr z,l1a3fh\r
+       call sub_1e12h\r
        ld a,b                  ;1a28   ld r,nn\r
-       rlca                    ;1a29\r
-       rlca                    ;1a2a\r
-       rlca                    ;1a2b\r
-       add a,006h              ;1a2c\r
+       rlca\r
+       rlca\r
+       rlca\r
+       add a,006h\r
 l1a2eh:\r
-       ld b,a                  ;1a2e\r
+       ld b,a\r
 l1a2fh:\r
-       call assert_eol         ;1a2f\r
-       comst                   ;1a32\r
-       ld (iy+000h),b          ;1a36\r
-       ld (iy+001h),l          ;1a39\r
+       call assert_eol\r
+       comst\r
+       ld (iy+000h),b\r
+       ld (iy+001h),l\r
        comend\r
-       ld c,002h               ;1a3c\r
-       ret                     ;1a3e\r
+       ld c,002h\r
+       ret\r
 l1a3fh:\r
-       inc de                  ;1a3f\r
-       ld a,b                  ;1a40\r
-       cp 007h         ;1a41\r
-       jp nz,ERROR             ;1a43\r
-       call sub_1e2eh          ;1a46\r
-       jr nc,l1a59h            ;1a49\r
-       cp 030h         ;1a4b\r
-       jp nc,ERROR             ;1a4d\r
-       add a,00ah              ;1a50\r
-       ld b,a                  ;1a52\r
-       call sub_1ed8h          ;1a53\r
-       jp l1b36h               ;1a56\r
+       inc de\r
+       ld a,b\r
+       cp 007h\r
+       jp nz,ERROR\r
+       call sub_1e2eh\r
+       jr nc,l1a59h\r
+       cp 030h\r
+       jp nc,ERROR\r
+       add a,00ah\r
+       ld b,a\r
+       call sub_1ed8h\r
+       jp l1b36h\r
 l1a59h:\r
-       call tst_EXPR           ;1a59\r
-       call sub_1ed8h          ;1a5c\r
-       ld b,03ah               ;1a5f\r
-       jp l199ah               ;1a61\r
+       call tst_EXPR\r
+       call sub_1ed8h\r
+       ld b,03ah\r
+       jp l199ah\r
 l1a64h:\r
-       call sub_1ed1h          ;1a64\r
-       call sub_1e41h          ;1a67\r
-       jr nc,l1a76h            ;1a6a\r
-       cp 006h                 ;1a6c\r
-       jp z,ERROR              ;1a6e\r
-       add a,070h              ;1a71\r
-       jp l19ebh               ;1a73\r
+       call sub_1ed1h\r
+       call sub_1e41h\r
+       jr nc,l1a76h\r
+       cp 006h\r
+       jp z,ERROR\r
+       add a,070h\r
+       jp l19ebh\r
 l1a76h:\r
-       call sub_1e12h          ;1a76\r
-       call assert_eol         ;1a79\r
-       ld a,(pfx.IXY)          ;1a7c\r
-       comst                   ;1a7f\r
+       call sub_1e12h\r
+       call assert_eol\r
+       ld a,(pfx.IXY)\r
+       comst\r
        ld (iy+000h),a          ;1a83   dd/fd\r
-       ld (iy+001h),036h       ;1a86\r
+       ld (iy+001h),036h\r
        ld (iy+002h),c          ;1a8a   displacement\r
        ld (iy+003h),l          ;1a8d   nn\r
        comend\r
-       ld c,4                  ;1a90\r
-       ret                     ;1a92\r
+       ld c,4\r
+       ret\r
 l1a93h:\r
-       ld b,a                  ;1a93\r
-       call sub_1ed1h          ;1a94\r
-       ld hl,t_HL.AF           ;1a97\r
-       call sub_0a23h          ;1a9a\r
-       jr c,l1abeh             ;1a9d\r
-       call sub_1e50h          ;1a9f\r
-       jr nc,l1ac7h            ;1aa2\r
-       ld a,b                  ;1aa4\r
-       cp 030h         ;1aa5\r
-       jr nz,l1b20h            ;1aa7\r
-       ld b,0f9h               ;1aa9\r
+       ld b,a\r
+       call sub_1ed1h\r
+       ld hl,t_HL.AF\r
+       call sub_0a23h\r
+       jr c,l1abeh\r
+       call sub_1e50h\r
+       jr nc,l1ac7h\r
+       ld a,b\r
+       cp 030h\r
+       jr nz,l1b20h\r
+       ld b,0f9h\r
 l1aabh:\r
-       call assert_eol         ;1aab\r
-       ld a,(pfx.IXY)          ;1aae\r
-       comst                   ;1ab1\r
-       ld (iy+000h),a          ;1ab5\r
-       ld (iy+001h),b          ;1ab8\r
+       call assert_eol\r
+       ld a,(pfx.IXY)\r
+       comst\r
+       ld (iy+000h),a\r
+       ld (iy+001h),b\r
        comend\r
-       ld c,002h               ;1abb\r
-       ret                     ;1abd\r
+       ld c,002h\r
+       ret\r
 l1abeh:\r
-       ld a,b                  ;1abe\r
-       cp 030h                 ;1abf\r
-       jr nz,l1b20h            ;1ac1\r
-       ld b,0f9h               ;1ac3\r
-       jr l1b36h               ;1ac5\r
+       ld a,b\r
+       cp 030h\r
+       jr nz,l1b20h\r
+       ld b,0f9h\r
+       jr l1b36h\r
 l1ac7h:\r
-       ld a,(de)               ;1ac7\r
-       cp 028h                 ;1ac8\r
-       jr nz,l1ae3h            ;1aca\r
-       inc de                  ;1acc\r
-       call tst_EXPR           ;1acd\r
-       call sub_1ed8h          ;1ad0\r
-       ld a,b                  ;1ad3\r
-       cp 020h                 ;1ad4\r
-       jr z,l1adeh             ;1ad6\r
-       add a,04bh              ;1ad8\r
-       ld b,a                  ;1ada\r
-       jp l19b4h               ;1adb\r
+       ld a,(de)\r
+       cp 028h\r
+       jr nz,l1ae3h\r
+       inc de\r
+       call tst_EXPR\r
+       call sub_1ed8h\r
+       ld a,b\r
+       cp 020h\r
+       jr z,l1adeh\r
+       add a,04bh\r
+       ld b,a\r
+       jp l19b4h\r
 l1adeh:\r
-       ld b,02ah               ;1ade\r
-       jp l199ah               ;1ae0\r
+       ld b,02ah\r
+       jp l199ah\r
 l1ae3h:\r
-       call tst_EXPR           ;1ae3\r
-       call assert_eol         ;1ae6\r
-       ld a,001h               ;1ae9\r
-       add a,b                 ;1aeb\r
-       ld b,a                  ;1aec\r
-       jp l199ah               ;1aed\r
+       call tst_EXPR\r
+       call assert_eol\r
+       ld a,001h\r
+       add a,b\r
+       ld b,a\r
+       jp l199ah\r
 l1af0h:\r
-       call sub_1ed1h          ;1af0\r
-       ld a,(de)               ;1af3\r
-       cp 028h                 ;1af4\r
-       jr nz,l1b04h            ;1af6\r
-       inc de                  ;1af8\r
-       call tst_EXPR           ;1af9\r
-       call sub_1ed8h          ;1afc\r
-       ld b,02ah               ;1aff\r
-       jp l1978h               ;1b01\r
+       call sub_1ed1h\r
+       ld a,(de)\r
+       cp 028h\r
+       jr nz,l1b04h\r
+       inc de\r
+       call tst_EXPR\r
+       call sub_1ed8h\r
+       ld b,02ah\r
+       jp l1978h\r
 l1b04h:\r
-       call tst_EXPR           ;1b04\r
-       ld b,021h               ;1b07\r
-       jp l1978h               ;1b09\r
+       call tst_EXPR\r
+       ld b,021h\r
+       jp l1978h\r
 l1b0ch:\r
-       inc de                  ;1b0c\r
-       call sub_1ed1h          ;1b0d\r
-       ld b,047h               ;1b10\r
-       jr l1b1ah               ;1b12\r
+       inc de\r
+       call sub_1ed1h\r
+       ld b,047h\r
+       jr l1b1ah\r
 l1b14h:\r
-       inc de                  ;1b14\r
-       call sub_1ed1h          ;1b15\r
-       ld b,04fh               ;1b18\r
+       inc de\r
+       call sub_1ed1h\r
+       ld b,04fh\r
 l1b1ah:\r
-       ld a,(de)                       ;1b1a\r
-       inc de                  ;1b1b\r
-       cp 041h         ;1b1c\r
-       jr z,gen.opc.ED2        ;1b1e\r
+       ld a,(de)\r
+       inc de\r
+       cp 041h\r
+       jr z,gen.opc.ED2\r
 l1b20h:\r
-       jp ERROR                ;1b20\r
+       jp ERROR\r
 l1b23h:\r
-       cp 020h         ;1b23\r
-       jr nc,l1b20h            ;1b25\r
-       add a,002h              ;1b27\r
-       ld b,a                  ;1b29\r
-       call sub_1ed8h          ;1b2a\r
-       call sub_1ed1h          ;1b2d\r
-       ld a,(de)                       ;1b30\r
-       cp 041h         ;1b31\r
-       jr nz,l1b20h            ;1b33\r
-       inc de                  ;1b35\r
+       cp 020h\r
+       jr nc,l1b20h\r
+       add a,002h\r
+       ld b,a\r
+       call sub_1ed8h\r
+       call sub_1ed1h\r
+       ld a,(de)\r
+       cp 041h\r
+       jr nz,l1b20h\r
+       inc de\r
 l1b36h:\r
-       call assert_eol         ;1b36\r
-       comst                   ;1b39\r
-       ld (iy+000h),b          ;1b3d\r
+       call assert_eol\r
+       comst\r
+       ld (iy+000h),b\r
        comend\r
-       ld c,001h               ;1b40\r
-       ret                     ;1b42\r
+       ld c,001h\r
+       ret\r
 gen.opc.ED2:\r
-       call assert_eol         ;1b43\r
-       comst                   ;1b46\r
-       ld (iy+000h),0edh               ;1b4a\r
-       ld (iy+001h),b          ;1b4e\r
+       call assert_eol\r
+       comst\r
+       ld (iy+000h),0edh\r
+       ld (iy+001h),b\r
        comend\r
-       ld c,002h               ;1b51\r
-       ret                     ;1b53\r
+       ld c,002h\r
+       ret\r
 l1b54h:\r
-       ld hl,t_HL.AF           ;1b54\r
-       call sub_0a23h          ;1b57\r
-       jr nc,l1babh            ;1b5a\r
-       call sub_1ed1h          ;1b5c\r
-       call sub_1e2eh          ;1b5f\r
-       jp nc,ERROR             ;1b62\r
-       push af                 ;1b65\r
-       ld a,b                  ;1b66\r
-       cp 088h         ;1b67\r
-       ld b,04ah               ;1b69\r
-       jr z,l1b6fh             ;1b6b\r
-       ld b,042h               ;1b6d\r
+       ld hl,t_HL.AF\r
+       call sub_0a23h\r
+       jr nc,l1babh\r
+       call sub_1ed1h\r
+       call sub_1e2eh\r
+       jp nc,ERROR\r
+       push af\r
+       ld a,b\r
+       cp 088h\r
+       ld b,04ah\r
+       jr z,l1b6fh\r
+       ld b,042h\r
 l1b6fh:\r
-       pop af                  ;1b6f\r
-       add a,b                 ;1b70\r
+       pop af\r
+       add a,b\r
 l1b71h:\r
-       ld b,a                  ;1b71\r
-       jr gen.opc.ED2          ;1b72\r
+       ld b,a\r
+       jr gen.opc.ED2\r
 l1b74h:\r
-       ld hl,t_HL.AF           ;1b74\r
-       call sub_0a23h          ;1b77\r
-       jr c,l1b9dh             ;1b7a\r
-       call sub_1e50h          ;1b7c\r
-       jr nc,l1babh            ;1b7f\r
-       call sub_1ed1h          ;1b81\r
-       ld hl,t_BC.DE.IX.SP     ;1b84\r
-       ld a,(pfx.IXY)          ;1b87\r
-       cp 0fdh                 ;1b8a\r
-       jr nz,l1b91h            ;1b8c\r
-       ld hl,t_BC.DE.IY.SP     ;1b8e\r
+       ld hl,t_HL.AF\r
+       call sub_0a23h\r
+       jr c,l1b9dh\r
+       call sub_1e50h\r
+       jr nc,l1babh\r
+       call sub_1ed1h\r
+       ld hl,t_BC.DE.IX.SP\r
+       ld a,(pfx.IXY)\r
+       cp 0fdh\r
+       jr nz,l1b91h\r
+       ld hl,t_BC.DE.IY.SP\r
 l1b91h:\r
-       call sub_1e2bh          ;1b91\r
-       jp nc,ERROR             ;1b94\r
-       add a,009h              ;1b97\r
+       call sub_1e2bh\r
+       jp nc,ERROR\r
+       add a,009h\r
 l1b99h:\r
-       ld b,a                  ;1b99\r
-       jp l1aabh               ;1b9a\r
+       ld b,a\r
+       jp l1aabh\r
 l1b9dh:\r
-       call sub_1ed1h          ;1b9d\r
-       call sub_1e2eh          ;1ba0\r
-       jp nc,ERROR             ;1ba3\r
-       add a,009h              ;1ba6\r
-       jp l19d7h               ;1ba8\r
+       call sub_1ed1h\r
+       call sub_1e2eh\r
+       jp nc,ERROR\r
+       add a,009h\r
+       jp l19d7h\r
 l1babh:\r
-       ld a,(de)               ;1bab\r
-       cp 041h                 ;1bac\r
-       jr nz,l1bbbh            ;1bae\r
-       push de                 ;1bb0\r
-       inc de                  ;1bb1\r
-       call skip_to_nextarg    ;1bb2\r
-       jr z,l1bbah             ;1bb5\r
-       pop de                  ;1bb7\r
-       jr l1bbbh               ;1bb8\r
+       ld a,(de)\r
+       cp 041h\r
+       jr nz,l1bbbh\r
+       push de\r
+       inc de\r
+       call skip_to_nextarg\r
+       jr z,l1bbah\r
+       pop de\r
+       jr l1bbbh\r
 l1bbah:\r
-       pop af                  ;1bba\r
+       pop af\r
 l1bbbh:\r
-       call sub_1e41h          ;1bbb\r
-       jr c,l1bceh             ;1bbe\r
-       call sub_1e68h          ;1bc0\r
-       jr c,l1bd2h             ;1bc3\r
-       call sub_1e12h          ;1bc5\r
-       ld a,b                  ;1bc8\r
-       add a,046h              ;1bc9\r
-       jp l1a2eh               ;1bcb\r
+       call sub_1e41h\r
+       jr c,l1bceh\r
+       call sub_1e68h\r
+       jr c,l1bd2h\r
+       call sub_1e12h\r
+       ld a,b\r
+       add a,046h\r
+       jp l1a2eh\r
 l1bceh:\r
-       add a,b                 ;1bce\r
-       jp l19d7h               ;1bcf\r
+       add a,b\r
+       jp l19d7h\r
 l1bd2h:\r
-       ld a,b                  ;1bd2\r
-       add a,006h              ;1bd3\r
-       jp l19ebh               ;1bd5\r
+       ld a,b\r
+       add a,006h\r
+       jp l19ebh\r
 l1bd8h:\r
-       call sub_1e41h          ;1bd8\r
-       jr c,l1c01h             ;1bdb\r
-       call sub_1e68h          ;1bdd\r
-       jp nc,ERROR             ;1be0\r
-       ld a,b                  ;1be3\r
-       add a,006h              ;1be4\r
-       ld b,a                  ;1be6\r
+       call sub_1e41h\r
+       jr c,l1c01h\r
+       call sub_1e68h\r
+       jp nc,ERROR\r
+       ld a,b\r
+       add a,006h\r
+       ld b,a\r
 l1be7h:\r
-       call assert_eol         ;1be7\r
-       ld a,(pfx.IXY)          ;1bea\r
-       comst                   ;1bed\r
-       ld (iy+000h),a          ;1bf1\r
-       ld (iy+001h),0cbh               ;1bf4\r
-       ld (iy+002h),c          ;1bf8\r
-       ld (iy+003h),b          ;1bfb\r
+       call assert_eol\r
+       ld a,(pfx.IXY)\r
+       comst\r
+       ld (iy+000h),a\r
+       ld (iy+001h),0cbh\r
+       ld (iy+002h),c\r
+       ld (iy+003h),b\r
        comend\r
-       ld c,004h               ;1bfe\r
-       ret                     ;1c00\r
+       ld c,004h\r
+       ret\r
 l1c01h:\r
-       add a,b                 ;1c01\r
+       add a,b\r
 l1c02h:\r
-       ld b,a                  ;1c02\r
-       call assert_eol         ;1c03\r
-       comst                   ;1c06\r
-       ld (iy+000h),0cbh               ;1c0a\r
-       ld (iy+001h),b          ;1c0e\r
+       ld b,a\r
+       call assert_eol\r
+       comst\r
+       ld (iy+000h),0cbh\r
+       ld (iy+001h),b\r
        comend\r
-       ld c,002h               ;1c11\r
-       ret                     ;1c13\r
+       ld c,002h\r
+       ret\r
 l1c14h:\r
-       call sub_1de6h          ;1c14\r
-       call sub_1ed1h          ;1c17\r
-       call sub_1e41h          ;1c1a\r
-       jr c,l1c2fh             ;1c1d\r
-       call sub_1e68h          ;1c1f\r
-       jp nc,ERROR             ;1c22\r
-       ld a,l                  ;1c25\r
-       rlca                    ;1c26\r
-       rlca                    ;1c27\r
-       rlca                    ;1c28\r
-       add a,006h              ;1c29\r
-       add a,b                 ;1c2b\r
-       ld b,a                  ;1c2c\r
-       jr l1be7h               ;1c2d\r
+       call sub_1de6h\r
+       call sub_1ed1h\r
+       call sub_1e41h\r
+       jr c,l1c2fh\r
+       call sub_1e68h\r
+       jp nc,ERROR\r
+       ld a,l\r
+       rlca\r
+       rlca\r
+       rlca\r
+       add a,006h\r
+       add a,b\r
+       ld b,a\r
+       jr l1be7h\r
 l1c2fh:\r
-       add a,b                 ;1c2f\r
-       ld b,a                  ;1c30\r
-       ld a,l                  ;1c31\r
-       rlca                    ;1c32\r
-       rlca                    ;1c33\r
-       rlca                    ;1c34\r
-       add a,b                 ;1c35\r
-       jr l1c02h               ;1c36\r
+       add a,b\r
+       ld b,a\r
+       ld a,l\r
+       rlca\r
+       rlca\r
+       rlca\r
+       add a,b\r
+       jr l1c02h\r
 l1c38h:\r
-       push de                 ;1c38\r
-       call sub_1eb8h          ;1c39\r
-       jr nc,l1c47h            ;1c3c\r
-       add a,b                 ;1c3e\r
-       ld b,a                  ;1c3f\r
-       call skip_to_nextarg    ;1c40\r
-       jr z,l1c49h             ;1c43\r
-       pop de                  ;1c45\r
-       push de                 ;1c46\r
+       push de\r
+       call sub_1eb8h\r
+       jr nc,l1c47h\r
+       add a,b\r
+       ld b,a\r
+       call skip_to_nextarg\r
+       jr z,l1c49h\r
+       pop de\r
+       push de\r
 l1c47h:\r
-       ld b,0cdh               ;1c47\r
+       ld b,0cdh\r
 l1c49h:\r
-       pop af                  ;1c49\r
-       call tst_EXPR           ;1c4a\r
-       jp l199ah               ;1c4d\r
+       pop af\r
+       call tst_EXPR\r
+       jp l199ah\r
 l1c50h:\r
-       call sub_1eb8h          ;1c50\r
-       jr nc,l1c59h            ;1c53\r
-       add a,b                 ;1c55\r
-       ld b,a                  ;1c56\r
-       jr l1c5bh               ;1c57\r
+       call sub_1eb8h\r
+       jr nc,l1c59h\r
+       add a,b\r
+       ld b,a\r
+       jr l1c5bh\r
 l1c59h:\r
-       ld b,0c9h               ;1c59\r
+       ld b,0c9h\r
 l1c5bh:\r
-       jp l1b36h               ;1c5b\r
+       jp l1b36h\r
 l1c5eh:\r
-       push de                 ;1c5e\r
-       call sub_1eb8h          ;1c5f\r
-       jr c,l1c71h             ;1c62\r
+       push de\r
+       call sub_1eb8h\r
+       jr c,l1c71h\r
 l1c64h:\r
-       pop de                  ;1c64\r
-       ld hl,b_0x1C97_start    ;1c65\r
-       call sub_0a15h          ;1c68\r
-       jr c,l1c7fh             ;1c6b\r
-       ld b,0c3h               ;1c6d\r
-       jr l1c79h               ;1c6f\r
+       pop de\r
+       ld hl,b_0x1C97_start\r
+       call sub_0a15h\r
+       jr c,l1c7fh\r
+       ld b,0c3h\r
+       jr l1c79h\r
 l1c71h:\r
-       add a,b                 ;1c71\r
-       ld b,a                  ;1c72\r
-       call skip_to_nextarg    ;1c73\r
-       jr nz,l1c64h            ;1c76\r
-       pop af                  ;1c78\r
+       add a,b\r
+       ld b,a\r
+       call skip_to_nextarg\r
+       jr nz,l1c64h\r
+       pop af\r
 l1c79h:\r
-       call tst_EXPR           ;1c79\r
-       jp l199ah               ;1c7c\r
+       call tst_EXPR\r
+       jp l199ah\r
 l1c7fh:\r
-       call assert_eol         ;1c7f\r
-       ld a,b                  ;1c82\r
-       and a                   ;1c83\r
-       jr nz,l1c8bh            ;1c84\r
-       ld b,0e9h               ;1c86\r
-       jp l1b36h               ;1c88\r
+       call assert_eol\r
+       ld a,b\r
+       and a\r
+       jr nz,l1c8bh\r
+       ld b,0e9h\r
+       jp l1b36h\r
 l1c8bh:\r
-       ld b,0ddh               ;1c8b\r
-       dec a                   ;1c8d\r
-       jr z,l1c92h             ;1c8e\r
-       ld b,0fdh               ;1c90\r
+       ld b,0ddh\r
+       dec a\r
+       jr z,l1c92h\r
+       ld b,0fdh\r
 l1c92h:\r
-       ld l,0e9h               ;1c92\r
-       jp l1a2fh               ;1c94\r
+       ld l,0e9h\r
+       jp l1a2fh\r
 \r
 b_0x1C97_start:\r
        DC      '(HL)'\r
@@ -3908,128 +3926,128 @@ b_0x1C97_start:
        DB      0\r
 \r
 l1ca4h:\r
-       call skip_to_nextarg    ;1ca4\r
-       ld b,010h               ;1ca7\r
-       jr l1cb9h               ;1ca9\r
+       call skip_to_nextarg\r
+       ld b,010h\r
+       jr l1cb9h\r
 l1cabh:\r
-       call sub_1ebfh          ;1cab\r
-       jr c,l1cb4h             ;1cae\r
-       ld b,018h               ;1cb0\r
-       jr l1cb9h               ;1cb2\r
+       call sub_1ebfh\r
+       jr c,l1cb4h\r
+       ld b,018h\r
+       jr l1cb9h\r
 l1cb4h:\r
-       add a,b                 ;1cb4\r
-       ld b,a                  ;1cb5\r
-       call sub_1ed1h          ;1cb6\r
+       add a,b\r
+       ld b,a\r
+       call sub_1ed1h\r
 l1cb9h:\r
-       call sub_1defh          ;1cb9\r
-       jp l1a2fh               ;1cbc\r
+       call sub_1defh\r
+       jp l1a2fh\r
 l1cbfh:\r
-       call sub_1e12h          ;1cbf\r
-       ld a,l                  ;1cc2\r
-       cp 003h                 ;1cc3\r
-       jr nc,l1d23h            ;1cc5\r
-       and a                   ;1cc7\r
-       jr z,l1cd2h             ;1cc8\r
-       ld b,056h               ;1cca\r
-       cp 001h                 ;1ccc\r
-       jr z,l1cd2h             ;1cce\r
-       ld b,05eh               ;1cd0\r
+       call sub_1e12h\r
+       ld a,l\r
+       cp 003h\r
+       jr nc,l1d23h\r
+       and a\r
+       jr z,l1cd2h\r
+       ld b,056h\r
+       cp 001h\r
+       jr z,l1cd2h\r
+       ld b,05eh\r
 l1cd2h:\r
-       jp gen.opc.ED2          ;1cd2\r
+       jp gen.opc.ED2\r
 l1cd5h:\r
-       call sub_1e12h          ;1cd5\r
-       ld a,l                  ;1cd8\r
-       push af                 ;1cd9\r
-       add a,b                 ;1cda\r
-       ld b,a                  ;1cdb\r
-       pop af                  ;1cdc\r
-       and 0c7h                ;1cdd\r
-       jr nz,l1d23h            ;1cdf\r
-       jp l1b36h               ;1ce1\r
+       call sub_1e12h\r
+       ld a,l\r
+       push af\r
+       add a,b\r
+       ld b,a\r
+       pop af\r
+       and 0c7h\r
+       jr nz,l1d23h\r
+       jp l1b36h\r
 l1ce4h:\r
-       call sub_1e50h          ;1ce4\r
-       jr c,l1cf2h             ;1ce7\r
-       call sub_1e25h          ;1ce9\r
-       jr nc,l1d23h            ;1cec\r
-       add a,b                 ;1cee\r
-       jp l19d7h               ;1cef\r
+       call sub_1e50h\r
+       jr c,l1cf2h\r
+       call sub_1e25h\r
+       jr nc,l1d23h\r
+       add a,b\r
+       jp l19d7h\r
 l1cf2h:\r
-       ld a,b                  ;1cf2\r
-       add a,020h              ;1cf3\r
-       jp l1b99h               ;1cf5\r
+       ld a,b\r
+       add a,020h\r
+       jp l1b99h\r
 l1cf8h:\r
-       call sub_1e41h          ;1cf8\r
-       jr nc,l1d23h            ;1cfb\r
-       cp 006h         ;1cfd\r
-       jr z,l1d23h             ;1cff\r
-       rlca                    ;1d01\r
-       rlca                    ;1d02\r
-       rlca                    ;1d03\r
-       add a,b                 ;1d04\r
-       ld b,a                  ;1d05\r
-       cp 078h         ;1d06\r
-       jr nz,l1d1ah            ;1d08\r
-       call sub_1ed1h          ;1d0a\r
-       call sub_1d26h          ;1d0d\r
-       jr c,l1d20h             ;1d10\r
-       call sub_1e06h          ;1d12\r
-       ld b,0dbh               ;1d15\r
-       jp l1a2fh               ;1d17\r
+       call sub_1e41h\r
+       jr nc,l1d23h\r
+       cp 006h\r
+       jr z,l1d23h\r
+       rlca\r
+       rlca\r
+       rlca\r
+       add a,b\r
+       ld b,a\r
+       cp 078h\r
+       jr nz,l1d1ah\r
+       call sub_1ed1h\r
+       call sub_1d26h\r
+       jr c,l1d20h\r
+       call sub_1e06h\r
+       ld b,0dbh\r
+       jp l1a2fh\r
 l1d1ah:\r
-       call sub_1ed1h          ;1d1a\r
-       call sub_1d26h          ;1d1d\r
+       call sub_1ed1h\r
+       call sub_1d26h\r
 l1d20h:\r
-       jp c,gen.opc.ED2        ;1d20\r
+       jp c,gen.opc.ED2\r
 l1d23h:\r
-       jp ERROR                ;1d23\r
+       jp ERROR\r
 sub_1d26h:\r
-       ld hl,t__C_             ;1d26\r
-       jp sub_0a23h            ;1d29\r
+       ld hl,t__C_\r
+       jp sub_0a23h\r
 l1d2ch:\r
-       call sub_1d26h          ;1d2c\r
-       jr nc,l1d44h            ;1d2f\r
-       call sub_1ed1h          ;1d31\r
-       call sub_1e41h          ;1d34\r
-       jr nc,l1d23h            ;1d37\r
-       cp 006h         ;1d39\r
-       jr z,l1d23h             ;1d3b\r
-       rlca                    ;1d3d\r
-       rlca                    ;1d3e\r
-       rlca                    ;1d3f\r
-       add a,b                 ;1d40\r
-       jp l1b71h               ;1d41\r
+       call sub_1d26h\r
+       jr nc,l1d44h\r
+       call sub_1ed1h\r
+       call sub_1e41h\r
+       jr nc,l1d23h\r
+       cp 006h\r
+       jr z,l1d23h\r
+       rlca\r
+       rlca\r
+       rlca\r
+       add a,b\r
+       jp l1b71h\r
 l1d44h:\r
-       call sub_1e06h          ;1d44\r
-       call sub_1ed1h          ;1d47\r
-       cp 041h         ;1d4a\r
-       jr nz,l1d23h            ;1d4c\r
-       inc de                  ;1d4e\r
-       ld b,0d3h               ;1d4f\r
-       jp l1a2fh               ;1d51\r
+       call sub_1e06h\r
+       call sub_1ed1h\r
+       cp 041h\r
+       jr nz,l1d23h\r
+       inc de\r
+       ld b,0d3h\r
+       jp l1a2fh\r
 l1d54h:\r
-       ld hl,b_0x1D80_start    ;1d54\r
-       call sub_0a15h          ;1d57\r
-       jp nc,ERROR             ;1d5a\r
-       ld c,b                  ;1d5d\r
-       call assert_eol         ;1d5e\r
-       ld b,000h               ;1d61\r
-       ld hl,b_0x1DA1_start    ;1d63\r
-       add hl,bc               ;1d66\r
-       add hl,bc               ;1d67\r
-       ld a,(hl)               ;1d68\r
-       comst                   ;1d69\r
-       ld (iy+000h),a          ;1d6d\r
+       ld hl,b_0x1D80_start\r
+       call sub_0a15h\r
+       jp nc,ERROR\r
+       ld c,b\r
+       call assert_eol\r
+       ld b,000h\r
+       ld hl,b_0x1DA1_start\r
+       add hl,bc\r
+       add hl,bc\r
+       ld a,(hl)\r
+       comst\r
+       ld (iy+000h),a\r
        comend\r
-       ld c,001h               ;1d70\r
-       inc hl                  ;1d72\r
-       ld a,(hl)               ;1d73\r
-       and a                   ;1d74\r
-       ret z                   ;1d75\r
-       comst                   ;1d76\r
-       ld (iy+001h),a          ;1d7a\r
+       ld c,001h\r
+       inc hl\r
+       ld a,(hl)\r
+       and a\r
+       ret z\r
+       comst\r
+       ld (iy+001h),a\r
        comend\r
-       ld c,002h               ;1d7d\r
-       ret                     ;1d7f\r
+       ld c,002h\r
+       ret\r
 \r
 b_0x1D80_start:\r
        DC      'AF,AF'''\r
@@ -4038,1359 +4056,1359 @@ l1d86h:
        DC      '(SP),HL'\r
        DC      '(SP),IX'\r
        DC      '(SP),IY'\r
-       db      000h            ;1da0\r
+       db      000h\r
 \r
 b_0x1DA1_start:\r
-       db      008h            ;1da1\r
-       db      000h            ;1da2\r
-       db      0ebh            ;1da3\r
-       db      000h            ;1da4\r
-       db      0e3h            ;1da5\r
-       db      000h            ;1da6\r
-       db      0ddh            ;1da7\r
-       db      0e3h            ;1da8\r
-       db      0fdh            ;1da9\r
-       db      0e3h            ;1daa\r
+       db      008h\r
+       db      000h\r
+       db      0ebh\r
+       db      000h\r
+       db      0e3h\r
+       db      000h\r
+       db      0ddh\r
+       db      0e3h\r
+       db      0fdh\r
+       db      0e3h\r
 l1dabh:\r
-       call sub_1e50h          ;1dab\r
-       jr c,l1dc6h             ;1dae\r
-       call sub_1e2eh          ;1db0\r
-       jr c,l1dd2h             ;1db3\r
-       call sub_1e41h          ;1db5\r
-       jr c,l1ddfh             ;1db8\r
-       call sub_1e68h          ;1dba\r
-       jp nc,ERROR             ;1dbd\r
-       ld a,b                  ;1dc0\r
-       add a,030h              ;1dc1\r
-       jp l19ebh               ;1dc3\r
+       call sub_1e50h\r
+       jr c,l1dc6h\r
+       call sub_1e2eh\r
+       jr c,l1dd2h\r
+       call sub_1e41h\r
+       jr c,l1ddfh\r
+       call sub_1e68h\r
+       jp nc,ERROR\r
+       ld a,b\r
+       add a,030h\r
+       jp l19ebh\r
 l1dc6h:\r
-       ld a,b                  ;1dc6\r
-       ld b,023h               ;1dc7\r
-       cp 004h                 ;1dc9\r
-       jr z,l1dcfh             ;1dcb\r
-       ld b,02bh               ;1dcd\r
+       ld a,b\r
+       ld b,023h\r
+       cp 004h\r
+       jr z,l1dcfh\r
+       ld b,02bh\r
 l1dcfh:\r
-       jp l1aabh               ;1dcf\r
+       jp l1aabh\r
 l1dd2h:\r
-       push af                 ;1dd2\r
-       ld a,b                  ;1dd3\r
-       ld b,003h               ;1dd4\r
-       cp 004h                 ;1dd6\r
-       jr z,l1ddch             ;1dd8\r
-       ld b,00bh               ;1dda\r
+       push af\r
+       ld a,b\r
+       ld b,003h\r
+       cp 004h\r
+       jr z,l1ddch\r
+       ld b,00bh\r
 l1ddch:\r
-       pop af                  ;1ddc\r
-       jr l1de2h               ;1ddd\r
+       pop af\r
+       jr l1de2h\r
 l1ddfh:\r
-       rlca                    ;1ddf\r
-       rlca                    ;1de0\r
-       rlca                    ;1de1\r
+       rlca\r
+       rlca\r
+       rlca\r
 l1de2h:\r
-       add a,b                 ;1de2\r
-       jp l19d7h               ;1de3\r
+       add a,b\r
+       jp l19d7h\r
 sub_1de6h:\r
-       call sub_1e12h          ;1de6\r
-       ld a,l                  ;1de9\r
-       cp 008h                 ;1dea\r
-       jr nc,error1            ;1dec\r
-       ret                     ;1dee\r
+       call sub_1e12h\r
+       ld a,l\r
+       cp 008h\r
+       jr nc,error1\r
+       ret\r
 sub_1defh:\r
-       call tst_EXPR           ;1def\r
-       push bc                 ;1df2\r
-       push iy                 ;1df3\r
-       pop bc                  ;1df5\r
-       and a                   ;1df6\r
-       sbc hl,bc               ;1df7\r
-       dec hl                  ;1df9\r
-       dec hl                  ;1dfa\r
-       pop bc                  ;1dfb\r
-       call sub_1e15h          ;1dfc\r
-       ld a,h                  ;1dff\r
-       xor l                   ;1e00\r
-       bit 7,a         ;1e01\r
-       jr nz,error1            ;1e03\r
-       ret                     ;1e05\r
+       call tst_EXPR\r
+       push bc\r
+       push iy\r
+       pop bc\r
+       and a\r
+       sbc hl,bc\r
+       dec hl\r
+       dec hl\r
+       pop bc\r
+       call sub_1e15h\r
+       ld a,h\r
+       xor l\r
+       bit 7,a\r
+       jr nz,error1\r
+       ret\r
 sub_1e06h:\r
-       ld a,(de)                       ;1e06\r
-       cp 028h         ;1e07\r
-       jr nz,sub_1e12h         ;1e09\r
-       inc de                  ;1e0b\r
-       call sub_1e12h          ;1e0c\r
-       jp sub_1ed8h            ;1e0f\r
+       ld a,(de)\r
+       cp 028h\r
+       jr nz,sub_1e12h\r
+       inc de\r
+       call sub_1e12h\r
+       jp sub_1ed8h\r
 \r
 sub_1e12h:\r
-       call tst_EXPR           ;1e12\r
+       call tst_EXPR\r
 sub_1e15h:\r
-       ld a,h                  ;1e15\r
-       and a                   ;1e16\r
-       ret z                   ;1e17\r
-       inc a                   ;1e18\r
-       ret z                   ;1e19\r
-       jr error1               ;1e1a\r
+       ld a,h\r
+       and a\r
+       ret z\r
+       inc a\r
+       ret z\r
+       jr error1\r
 \r
 tst_EXPR:\r
-       push bc                 ;1e1c\r
-       call EXPR               ;1e1d\r
-       pop bc                  ;1e20\r
-       ret nc                  ;1e21\r
+       push bc\r
+       call EXPR\r
+       pop bc\r
+       ret nc\r
 error1:\r
-       jp ERROR                ;1e22\r
+       jp ERROR\r
 sub_1e25h:\r
-       push hl                 ;1e25\r
-       ld hl,t_BC.DE.HL.AF     ;1e26\r
-       jr l1e32h               ;1e29\r
+       push hl\r
+       ld hl,t_BC.DE.HL.AF\r
+       jr l1e32h\r
 sub_1e2bh:\r
-       push hl                 ;1e2b\r
-       jr l1e32h               ;1e2c\r
+       push hl\r
+       jr l1e32h\r
 sub_1e2eh:\r
-       push hl                 ;1e2e\r
-       ld hl,t_BC.DE.HL.SP     ;1e2f\r
+       push hl\r
+       ld hl,t_BC.DE.HL.SP\r
 l1e32h:\r
-       push bc                 ;1e32\r
-       call sub_0a15h          ;1e33\r
-       jr nc,l1e3eh            ;1e36\r
-       ld a,b                  ;1e38\r
-       rlca                    ;1e39\r
-       rlca                    ;1e3a\r
-       rlca                    ;1e3b\r
-       rlca                    ;1e3c\r
-       scf                     ;1e3d\r
+       push bc\r
+       call sub_0a15h\r
+       jr nc,l1e3eh\r
+       ld a,b\r
+       rlca\r
+       rlca\r
+       rlca\r
+       rlca\r
+       scf\r
 l1e3eh:\r
-       pop bc                  ;1e3e\r
-       pop hl                  ;1e3f\r
-       ret                     ;1e40\r
+       pop bc\r
+       pop hl\r
+       ret\r
 sub_1e41h:\r
-       call SKIPBL             ;1e41\r
-       push bc                 ;1e44\r
-       push hl                 ;1e45\r
-       ld hl,t_BCDEHL_HL_A     ;1e46\r
-       call sub_0a15h          ;1e49\r
-       ld a,b                  ;1e4c\r
-       pop hl                  ;1e4d\r
-       pop bc                  ;1e4e\r
-       ret                     ;1e4f\r
+       call SKIPBL\r
+       push bc\r
+       push hl\r
+       ld hl,t_BCDEHL_HL_A\r
+       call sub_0a15h\r
+       ld a,b\r
+       pop hl\r
+       pop bc\r
+       ret\r
 sub_1e50h:\r
-       push hl                 ;1e50\r
-       push bc                 ;1e51\r
-       ld hl,t_IX.IY           ;1e52\r
-       call sub_0a15h          ;1e55\r
-       jr nc,l1e65h            ;1e58\r
-       ld a,0ddh               ;1e5a\r
-       dec b                   ;1e5c\r
-       jr nz,l1e61h            ;1e5d\r
-       ld a,0fdh               ;1e5f\r
+       push hl\r
+       push bc\r
+       ld hl,t_IX.IY\r
+       call sub_0a15h\r
+       jr nc,l1e65h\r
+       ld a,0ddh\r
+       dec b\r
+       jr nz,l1e61h\r
+       ld a,0fdh\r
 l1e61h:\r
-       ld (pfx.IXY),a          ;1e61\r
-       scf                     ;1e64\r
+       ld (pfx.IXY),a\r
+       scf\r
 l1e65h:\r
-       pop bc                  ;1e65\r
-       pop hl                  ;1e66\r
-       ret                     ;1e67\r
+       pop bc\r
+       pop hl\r
+       ret\r
 sub_1e68h:\r
-       push hl                 ;1e68\r
-       push bc                 ;1e69\r
-       ld a,(de)               ;1e6a\r
-       cp '('                  ;1e6b\r
-       jr nz,l1eb4h            ;1e6d\r
-       push de                 ;1e6f\r
-       inc de                  ;1e70\r
-       ld hl,t_IX.IY           ;1e71\r
-       call sub_0a15h          ;1e74\r
-       jr nc,l1eb3h            ;1e77\r
-       pop af                  ;1e79\r
-       ld a,0ddh               ;1e7a\r
-       dec b                   ;1e7c\r
-       jr nz,l1e81h            ;1e7d\r
-       ld a,0fdh               ;1e7f\r
+       push hl\r
+       push bc\r
+       ld a,(de)\r
+       cp '('\r
+       jr nz,l1eb4h\r
+       push de\r
+       inc de\r
+       ld hl,t_IX.IY\r
+       call sub_0a15h\r
+       jr nc,l1eb3h\r
+       pop af\r
+       ld a,0ddh\r
+       dec b\r
+       jr nz,l1e81h\r
+       ld a,0fdh\r
 l1e81h:\r
-       ld (pfx.IXY),a          ;1e81\r
-       ld a,(de)               ;1e84\r
-       cp '+'                  ;1e85\r
-       jr z,l1e95h             ;1e87\r
-       cp ')'                  ;1e89\r
-       ld hl,0                 ;1e8b\r
-       jr z,l1eadh             ;1e8e\r
-       cp '-'                  ;1e90\r
-       jp nz,ERROR             ;1e92\r
+       ld (pfx.IXY),a\r
+       ld a,(de)\r
+       cp '+'\r
+       jr z,l1e95h\r
+       cp ')'\r
+       ld hl,0\r
+       jr z,l1eadh\r
+       cp '-'\r
+       jp nz,ERROR\r
 l1e95h:\r
-       push af                 ;1e95\r
-       inc de                  ;1e96\r
+       push af\r
+       inc de\r
        call sub_1e12h          ;1e97   get displacement\r
-       pop af                  ;1e9a\r
-       cp '+'                  ;1e9b\r
-       jr z,l1ea7h             ;1e9d\r
-       ld b,h                  ;1e9f\r
-       ld c,l                  ;1ea0\r
-       ld hl,0                 ;1ea1\r
-       and a                   ;1ea4\r
-       sbc hl,bc               ;1ea5\r
+       pop af\r
+       cp '+'\r
+       jr z,l1ea7h\r
+       ld b,h\r
+       ld c,l\r
+       ld hl,0\r
+       and a\r
+       sbc hl,bc\r
 l1ea7h:\r
-       ld a,(de)               ;1ea7\r
-       cp ')'                  ;1ea8\r
-       jp nz,ERROR             ;1eaa\r
+       ld a,(de)\r
+       cp ')'\r
+       jp nz,ERROR\r
 l1eadh:\r
-       inc de                  ;1ead\r
-       pop bc                  ;1eae\r
-       ld c,l                  ;1eaf\r
-       pop hl                  ;1eb0\r
-       scf                     ;1eb1\r
-       ret                     ;1eb2\r
+       inc de\r
+       pop bc\r
+       ld c,l\r
+       pop hl\r
+       scf\r
+       ret\r
 l1eb3h:\r
-       pop de                  ;1eb3\r
+       pop de\r
 l1eb4h:\r
-       pop bc                  ;1eb4\r
-       pop hl                  ;1eb5\r
-       and a                   ;1eb6\r
-       ret                     ;1eb7\r
+       pop bc\r
+       pop hl\r
+       and a\r
+       ret\r
 sub_1eb8h:\r
-       ld hl,t_tstfl_ZCPS      ;1eb8\r
-       ld c,007h               ;1ebb\r
-       jr l1ec4h               ;1ebd\r
+       ld hl,t_tstfl_ZCPS\r
+       ld c,007h\r
+       jr l1ec4h\r
 sub_1ebfh:\r
-       ld hl,t_tstfl_ZC        ;1ebf\r
-       ld c,003h               ;1ec2\r
+       ld hl,t_tstfl_ZC\r
+       ld c,003h\r
 l1ec4h:\r
-       push bc                 ;1ec4\r
-       call sub_0a15h          ;1ec5\r
-       ld a,b                  ;1ec8\r
-       pop bc                  ;1ec9\r
-       ret nc                  ;1eca\r
-       and c                   ;1ecb\r
-       rlca                    ;1ecc\r
-       rlca                    ;1ecd\r
-       rlca                    ;1ece\r
-       scf                     ;1ecf\r
-       ret                     ;1ed0\r
+       push bc\r
+       call sub_0a15h\r
+       ld a,b\r
+       pop bc\r
+       ret nc\r
+       and c\r
+       rlca\r
+       rlca\r
+       rlca\r
+       scf\r
+       ret\r
 sub_1ed1h:\r
-       call skip_to_nextarg    ;1ed1\r
-       ret z                   ;1ed4\r
+       call skip_to_nextarg\r
+       ret z\r
 l1ed5h:\r
-       jp ERROR                ;1ed5\r
+       jp ERROR\r
 sub_1ed8h:\r
-       ld a,(de)                       ;1ed8\r
-       cp 029h         ;1ed9\r
-       jr nz,l1ed5h            ;1edb\r
-       inc de                  ;1edd\r
-       ret                     ;1ede\r
+       ld a,(de)\r
+       cp 029h\r
+       jr nz,l1ed5h\r
+       inc de\r
+       ret\r
 CMD.L:\r
-       ld hl,CMD.L             ;1edf\r
-       ld (CMD_RPT),hl         ;1ee2\r
-       call EXPR               ;1ee5\r
-       jr nc,l1eedh            ;1ee8\r
-       ld hl,(lst.L)           ;1eea\r
+       ld hl,CMD.L\r
+       ld (CMD_RPT),hl\r
+       call EXPR\r
+       jr nc,l1eedh\r
+       ld hl,(lst.L)\r
 l1eedh:\r
-       push hl                 ;1eed\r
-       pop iy                  ;1eee\r
-       call skip_to_nextarg    ;1ef0\r
-       call sub_0aa5h          ;1ef3\r
-       jr nc,l1f17h            ;1ef6\r
-       call assert_eol         ;1ef8\r
-       ld b,010h               ;1efb\r
+       push hl\r
+       pop iy\r
+       call skip_to_nextarg\r
+       call sub_0aa5h\r
+       jr nc,l1f17h\r
+       call assert_eol\r
+       ld b,010h\r
 l1efdh:\r
-       push bc                 ;1efd\r
-       push iy         ;1efe\r
-       pop hl                  ;1f00\r
-       push hl                 ;1f01\r
-       call sub_1f3fh          ;1f02\r
-       call CRLF               ;1f05\r
-       pop iy          ;1f08\r
-       ld c,b                  ;1f0a\r
-       ld b,000h               ;1f0b\r
-       add iy,bc               ;1f0d\r
-       ld (lst.L),iy           ;1f0f\r
-       pop bc                  ;1f13\r
-       djnz l1efdh             ;1f14\r
-       ret                     ;1f16\r
+       push bc\r
+       push iy\r
+       pop hl\r
+       push hl\r
+       call sub_1f3fh\r
+       call CRLF\r
+       pop iy\r
+       ld c,b\r
+       ld b,000h\r
+       add iy,bc\r
+       ld (lst.L),iy\r
+       pop bc\r
+       djnz l1efdh\r
+       ret\r
 l1f17h:\r
-       call assert_eol         ;1f17\r
-       ld h,b                  ;1f1a\r
-       ld l,c                  ;1f1b\r
-       ld a,b                  ;1f1c\r
-       or c                    ;1f1d\r
-       jr nz,l1f21h            ;1f1e\r
-       dec hl                  ;1f20\r
+       call assert_eol\r
+       ld h,b\r
+       ld l,c\r
+       ld a,b\r
+       or c\r
+       jr nz,l1f21h\r
+       dec hl\r
 l1f21h:\r
-       push hl                 ;1f21\r
-       push iy         ;1f22\r
-       pop hl                  ;1f24\r
-       push hl                 ;1f25\r
-       call sub_1f3fh          ;1f26\r
-       call CRLF               ;1f29\r
-       pop iy          ;1f2c\r
-       ld e,b                  ;1f2e\r
-       ld d,000h               ;1f2f\r
-       add iy,de               ;1f31\r
-       ld (lst.L),iy           ;1f33\r
-       pop hl                  ;1f37\r
-       and a                   ;1f38\r
-       sbc hl,de               ;1f39\r
-       ret z                   ;1f3b\r
-       ret c                   ;1f3c\r
-       jr l1f21h               ;1f3d\r
+       push hl\r
+       push iy\r
+       pop hl\r
+       push hl\r
+       call sub_1f3fh\r
+       call CRLF\r
+       pop iy\r
+       ld e,b\r
+       ld d,000h\r
+       add iy,de\r
+       ld (lst.L),iy\r
+       pop hl\r
+       and a\r
+       sbc hl,de\r
+       ret z\r
+       ret c\r
+       jr l1f21h\r
 sub_1f3fh:\r
-       call out.hl.@           ;1f3f\r
-       call z,OUTBL            ;1f42\r
-       call OUTBL              ;1f45\r
-       sub a                   ;1f48\r
-       ld (CON.COL),a          ;1f49\r
-       call sub_1f77h          ;1f4c\r
-       and a                   ;1f4f\r
-       ret z                   ;1f50\r
+       call out.hl.@\r
+       call z,OUTBL\r
+       call OUTBL\r
+       sub a\r
+       ld (CON.COL),a\r
+       call sub_1f77h\r
+       and a\r
+       ret z\r
 l1f51h:\r
-       call OUTBL              ;1f51\r
-       ld a,(CON.COL)          ;1f54\r
-       cp 010h         ;1f57\r
-       jr c,l1f51h             ;1f59\r
+       call OUTBL\r
+       ld a,(CON.COL)\r
+       cp 010h\r
+       jr c,l1f51h\r
 sub_1f5bh:\r
-       ld de,(offs.@)          ;1f5b\r
-       ld a,d                  ;1f5f\r
-       or e                    ;1f60\r
-       ret z                   ;1f61\r
-       ld a,'('                ;1f62\r
-       call OUTCHAR            ;1f64\r
-       ld a,'@'                ;1f67\r
-       call OUTCHAR            ;1f69\r
-       and a                   ;1f6c\r
-       sbc hl,de               ;1f6d\r
-       call out.hl             ;1f6f\r
-       ld a,')'                ;1f72\r
-       jp OUTCHAR              ;1f74\r
+       ld de,(offs.@)\r
+       ld a,d\r
+       or e\r
+       ret z\r
+       ld a,'('\r
+       call OUTCHAR\r
+       ld a,'@'\r
+       call OUTCHAR\r
+       and a\r
+       sbc hl,de\r
+       call out.hl\r
+       ld a,')'\r
+       jp OUTCHAR\r
 sub_1f77h:\r
-       sub a                   ;1f77\r
-       ld (XBE03),a            ;1f78\r
-       call sub_1f9eh          ;1f7b\r
-       jr nc,l1f91h            ;1f7e\r
-       push bc                 ;1f80\r
-       call sub_2581h          ;1f81\r
-       ex de,hl                        ;1f84\r
-       call sub_1fdbh          ;1f85\r
-       pop bc                  ;1f88\r
-       ld a,(XBE03)            ;1f89\r
-       ld hl,(XBE01)           ;1f8c\r
-       scf                     ;1f8f\r
-       ret                     ;1f90\r
+       sub a\r
+       ld (XBE03),a\r
+       call sub_1f9eh\r
+       jr nc,l1f91h\r
+       push bc\r
+       call sub_2581h\r
+       ex de,hl\r
+       call sub_1fdbh\r
+       pop bc\r
+       ld a,(XBE03)\r
+       ld hl,(XBE01)\r
+       scf\r
+       ret\r
 l1f91h:\r
-       ld hl,b_0x1F9B_start            ;1f91\r
-       call PSTR               ;1f94\r
-       ld b,001h               ;1f97\r
-       sub a                   ;1f99\r
-       ret                     ;1f9a\r
+       ld hl,b_0x1F9B_start\r
+       call PSTR\r
+       ld b,001h\r
+       sub a\r
+       ret\r
 \r
 b_0x1F9B_start:\r
        DC      '???'\r
-       \r
+\r
 sub_1f9eh:\r
-       sub a                   ;1f9e\r
-       ld (is.pfx.IXY),a       ;1f9f\r
-       comst                   ;1fa2\r
-       ld a,(iy+000h)          ;1fa6\r
+       sub a\r
+       ld (is.pfx.IXY),a\r
+       comst\r
+       ld a,(iy+000h)\r
        comend\r
-       cp 0edh                 ;1fa9\r
-       jp z,disas_pfx.ED               ;1fab\r
-       cp 0ddh                 ;1fae\r
-       jr z,l1fc5h             ;1fb0\r
-       cp 0fdh                 ;1fb2\r
-       jr z,l1fc9h             ;1fb4\r
+       cp 0edh\r
+       jp z,disas_pfx.ED\r
+       cp 0ddh\r
+       jr z,l1fc5h\r
+       cp 0fdh\r
+       jr z,l1fc9h\r
 sub_1fb6h:\r
-       comst                   ;1fb6\r
-       ld a,(iy+000h)          ;1fba\r
+       comst\r
+       ld a,(iy+000h)\r
        comend\r
-       cp 0cbh                 ;1fbd\r
-       jp z,l2061h             ;1fbf\r
-       jp l2078h               ;1fc2\r
+       cp 0cbh\r
+       jp z,l2061h\r
+       jp l2078h\r
 l1fc5h:\r
-       ld a,001h               ;1fc5\r
-       jr l1fcbh               ;1fc7\r
+       ld a,001h\r
+       jr l1fcbh\r
 l1fc9h:\r
-       ld a,002h               ;1fc9\r
+       ld a,002h\r
 l1fcbh:\r
-       ld (is.pfx.IXY),a               ;1fcb\r
-       call sub_1fdch          ;1fce\r
-       ret nc                  ;1fd1\r
-       push bc                 ;1fd2\r
-       call sub_1fb6h          ;1fd3\r
-       pop af                  ;1fd6\r
-       add a,b                 ;1fd7\r
-       ld b,a                  ;1fd8\r
-       scf                     ;1fd9\r
-       ret                     ;1fda\r
+       ld (is.pfx.IXY),a\r
+       call sub_1fdch\r
+       ret nc\r
+       push bc\r
+       call sub_1fb6h\r
+       pop af\r
+       add a,b\r
+       ld b,a\r
+       scf\r
+       ret\r
 \r
 sub_1fdbh:\r
-       jp (hl)                 ;1fdb\r
+       jp (hl)\r
 \r
 sub_1fdch:\r
-       inc iy                  ;1fdc\r
-       ld hl,b_0x2011_start    ;1fde\r
-       call sub_20bbh          ;1fe1\r
-       ld b,002h               ;1fe4\r
-       ret c                   ;1fe6\r
-       ld hl,l202ch            ;1fe7\r
-       call sub_20bbh          ;1fea\r
-       ld b,001h               ;1fed\r
-       ret c                   ;1fef\r
-       comst                   ;1ff0\r
-       ld a,(iy+000h)          ;1ff4\r
+       inc iy\r
+       ld hl,b_0x2011_start\r
+       call sub_20bbh\r
+       ld b,002h\r
+       ret c\r
+       ld hl,l202ch\r
+       call sub_20bbh\r
+       ld b,001h\r
+       ret c\r
+       comst\r
+       ld a,(iy+000h)\r
        comend\r
-       cp 0cbh                 ;1ff7\r
-       jr nz,l200fh            ;1ff9\r
-       comst                   ;1ffb\r
-       ld a,(iy+002h)          ;1fff\r
+       cp 0cbh\r
+       jr nz,l200fh\r
+       comst\r
+       ld a,(iy+002h)\r
        comend\r
-       cp 036h                 ;2002\r
-       ret z                   ;2004\r
-       and 007h                ;2005\r
-       cp 006h                 ;2007\r
-       jr nz,l200fh            ;2009\r
-       ld b,002h               ;200b\r
-       scf                     ;200d\r
-       ret                     ;200e\r
+       cp 036h\r
+       ret z\r
+       and 007h\r
+       cp 006h\r
+       jr nz,l200fh\r
+       ld b,002h\r
+       scf\r
+       ret\r
 l200fh:\r
-       and a                   ;200f\r
-       ret                     ;2010\r
+       and a\r
+       ret\r
 \r
 b_0x2011_start:\r
-       db      034h            ;2011\r
-       db      035h            ;2012\r
-       db      036h            ;2013\r
-       db      046h            ;2014\r
-       db      04eh            ;2015\r
-       db      056h            ;2016\r
-       db      05eh            ;2017\r
-       db      066h            ;2018\r
-       db      06eh            ;2019\r
-       db      070h            ;201a\r
-       db      071h            ;201b\r
-       db      072h            ;201c\r
-       db      073h            ;201d\r
-       db      074h            ;201e\r
-       db      075h            ;201f\r
-       db      076h            ;2020\r
-       db      077h            ;2021\r
-       db      07eh            ;2022\r
-       db      086h            ;2023\r
-       db      08eh            ;2024\r
-       db      096h            ;2025\r
-       db      09eh            ;2026\r
-       db      0a6h            ;2027\r
-       db      0aeh            ;2028\r
-       db      0b6h            ;2029\r
-       db      0beh            ;202a\r
-       db      000h            ;202b\r
+       db      034h\r
+       db      035h\r
+       db      036h\r
+       db      046h\r
+       db      04eh\r
+       db      056h\r
+       db      05eh\r
+       db      066h\r
+       db      06eh\r
+       db      070h\r
+       db      071h\r
+       db      072h\r
+       db      073h\r
+       db      074h\r
+       db      075h\r
+       db      076h\r
+       db      077h\r
+       db      07eh\r
+       db      086h\r
+       db      08eh\r
+       db      096h\r
+       db      09eh\r
+       db      0a6h\r
+       db      0aeh\r
+       db      0b6h\r
+       db      0beh\r
+       db      000h\r
 l202ch:\r
-       db      009h            ;202c\r
-       db      019h            ;202d\r
-       db      021h            ;202e\r
-       db      022h            ;202f\r
-       db      023h            ;2030\r
-       db      029h            ;2031\r
-       db      02ah            ;2032\r
-       db      02bh            ;2033\r
-       db      039h            ;2034\r
-       db      0e1h            ;2035\r
-       db      0e3h            ;2036\r
-       db      0e5h            ;2037\r
-       db      0e9h            ;2038\r
-       db      0f9h            ;2039\r
-       db      000h            ;203a\r
+       db      009h\r
+       db      019h\r
+       db      021h\r
+       db      022h\r
+       db      023h\r
+       db      029h\r
+       db      02ah\r
+       db      02bh\r
+       db      039h\r
+       db      0e1h\r
+       db      0e3h\r
+       db      0e5h\r
+       db      0e9h\r
+       db      0f9h\r
+       db      000h\r
 \r
 disas_pfx.ED:\r
-       inc iy                  ;203b\r
-       ld hl,b_0x2200_start    ;203d\r
-       call sub_209dh          ;2040\r
-       ld b,002h               ;2043\r
-       ret c                   ;2045\r
-       ld hl,l2235h            ;2046\r
-       call lookup_opc         ;2049\r
-       ld b,002h               ;204c\r
-       ret c                   ;204e\r
-       ld hl,l228bh            ;204f\r
-       call lookup_opc         ;2052\r
-       ld b,003h               ;2055\r
-       ret c                   ;2057\r
-       ld hl,l22b4h            ;2058\r
-       call lookup_opc         ;205b\r
-       ld b,004h               ;205e\r
-       ret                     ;2060\r
+       inc iy\r
+       ld hl,b_0x2200_start\r
+       call sub_209dh\r
+       ld b,002h\r
+       ret c\r
+       ld hl,l2235h\r
+       call lookup_opc\r
+       ld b,002h\r
+       ret c\r
+       ld hl,l228bh\r
+       call lookup_opc\r
+       ld b,003h\r
+       ret c\r
+       ld hl,l22b4h\r
+       call lookup_opc\r
+       ld b,004h\r
+       ret\r
 l2061h:\r
-       push iy                 ;2061\r
-       inc iy                  ;2063\r
-       ld a,(is.pfx.IXY)       ;2065\r
-       and a                   ;2068\r
-       jr z,l206dh             ;2069\r
-       inc iy                  ;206b\r
+       push iy\r
+       inc iy\r
+       ld a,(is.pfx.IXY)\r
+       and a\r
+       jr z,l206dh\r
+       inc iy\r
 l206dh:\r
-       ld hl,l22c9h            ;206d\r
-       call lookup_opc         ;2070\r
-       pop iy                  ;2073\r
-       ld b,002h               ;2075\r
-       ret                     ;2077\r
+       ld hl,l22c9h\r
+       call lookup_opc\r
+       pop iy\r
+       ld b,002h\r
+       ret\r
 l2078h:\r
-       ld hl,b_0x218B_start    ;2078\r
-       call lookup_opc         ;207b\r
-       ld b,002h               ;207e\r
-       ret c                   ;2080\r
-       ld hl,b_0x20ED_start    ;2081\r
-       call sub_209dh          ;2084\r
-       ld b,001h               ;2087\r
-       ret c                   ;2089\r
-       ld hl,b_0x2108_start    ;208a\r
-       call lookup_opc         ;208d\r
-       ld b,001h               ;2090\r
-       ret c                   ;2092\r
-       ld hl,b_0x21D2_start    ;2093\r
-       call lookup_opc         ;2096\r
-       ret nc                  ;2099\r
-       ld b,003h               ;209a\r
-       ret                     ;209c\r
+       ld hl,b_0x218B_start\r
+       call lookup_opc\r
+       ld b,002h\r
+       ret c\r
+       ld hl,b_0x20ED_start\r
+       call sub_209dh\r
+       ld b,001h\r
+       ret c\r
+       ld hl,b_0x2108_start\r
+       call lookup_opc\r
+       ld b,001h\r
+       ret c\r
+       ld hl,b_0x21D2_start\r
+       call lookup_opc\r
+       ret nc\r
+       ld b,003h\r
+       ret\r
 \r
 sub_209dh:\r
-       ld a,(hl)               ;209d\r
-       cp 0ffh                 ;209e\r
-       ret z                   ;20a0\r
-       comst                   ;20a1\r
-       cp (iy+000h)            ;20a5\r
+       ld a,(hl)\r
+       cp 0ffh\r
+       ret z\r
+       comst\r
+       cp (iy+000h)\r
        comend\r
-       jr z,l20aeh             ;20a8\r
-       inc hl                  ;20aa\r
-       inc hl                  ;20ab\r
-       jr sub_209dh            ;20ac\r
+       jr z,l20aeh\r
+       inc hl\r
+       inc hl\r
+       jr sub_209dh\r
 l20aeh:\r
-       inc hl                  ;20ae\r
-       ld c,(hl)               ;20af\r
-       ld hl,t_MNEMONICS       ;20b0\r
-       ld b,000h               ;20b3\r
-       add hl,bc               ;20b5\r
-       ld de,l230bh            ;20b6\r
-       scf                     ;20b9\r
-       ret                     ;20ba\r
+       inc hl\r
+       ld c,(hl)\r
+       ld hl,t_MNEMONICS\r
+       ld b,000h\r
+       add hl,bc\r
+       ld de,l230bh\r
+       scf\r
+       ret\r
 sub_20bbh:\r
-       ld a,(hl)               ;20bb\r
-       and a                   ;20bc\r
-       ret z                   ;20bd\r
-       inc hl                  ;20be\r
-       comst                   ;20bf\r
-       cp (iy+000h)            ;20c3\r
+       ld a,(hl)\r
+       and a\r
+       ret z\r
+       inc hl\r
+       comst\r
+       cp (iy+000h)\r
        comend\r
-       jr nz,sub_20bbh         ;20c6\r
-       scf                     ;20c8\r
-       ret                     ;20c9\r
+       jr nz,sub_20bbh\r
+       scf\r
+       ret\r
 \r
 lookup_opc:\r
-       comst                   ;20ca\r
-       ld a,(iy+000h)          ;20ce\r
+       comst\r
+       ld a,(iy+000h)\r
        comend\r
-       and (hl)                        ;20d1\r
-       inc hl                  ;20d2\r
-       cp (hl)                 ;20d3\r
-       jr z,l20dfh             ;20d4\r
-       inc hl                  ;20d6\r
-       inc hl                  ;20d7\r
-       inc hl                  ;20d8\r
-       inc hl                  ;20d9\r
-       ld a,(hl)               ;20da\r
-       and a                   ;20db\r
-       jr nz,lookup_opc        ;20dc\r
-       ret                     ;20de\r
+       and (hl)\r
+       inc hl\r
+       cp (hl)\r
+       jr z,l20dfh\r
+       inc hl\r
+       inc hl\r
+       inc hl\r
+       inc hl\r
+       ld a,(hl)\r
+       and a\r
+       jr nz,lookup_opc\r
+       ret\r
 l20dfh:\r
-       inc hl                  ;20df\r
-       ld c,(hl)               ;20e0\r
-       inc hl                  ;20e1\r
-       ld e,(hl)               ;20e2\r
-       inc hl                  ;20e3\r
-       ld d,(hl)               ;20e4\r
-       ld hl,t_MNEMONICS       ;20e5\r
-       ld b,000h               ;20e8\r
-       add hl,bc               ;20ea\r
-       scf                     ;20eb\r
-       ret                     ;20ec\r
+       inc hl\r
+       ld c,(hl)\r
+       inc hl\r
+       ld e,(hl)\r
+       inc hl\r
+       ld d,(hl)\r
+       ld hl,t_MNEMONICS\r
+       ld b,000h\r
+       add hl,bc\r
+       scf\r
+       ret\r
 \r
 b_0x20ED_start:                        ;       1 byte opcodes (no parameters)\r
        db      076h            ;20ed   halt\r
-       db      039h            ;20ee   \r
+       db      039h            ;20ee\r
        db      0d9h            ;20ef   exx\r
-       db      036h            ;20f0\r
+       db      036h\r
        db      0f3h            ;20f1   di\r
-       db      02ch            ;20f2\r
+       db      02ch\r
        db      0fbh            ;20f3   ei\r
-       db      032h            ;20f4\r
+       db      032h\r
        db      000h            ;20f5   nop\r
-       db      069h            ;20f6\r
+       db      069h\r
        db      007h            ;20f7   rlca\r
-       db      09eh            ;20f8\r
+       db      09eh\r
        db      00fh            ;20f9   rrca\r
-       db      0adh            ;20fa\r
+       db      0adh\r
        db      017h            ;20fb   rla\r
-       db      098h            ;20fc\r
+       db      098h\r
        db      01fh            ;20fd   rra\r
-       db      0a7h            ;20fe\r
+       db      0a7h\r
        db      027h            ;20ff   daa\r
-       db      026h            ;2100\r
+       db      026h\r
        db      02fh            ;2101   cpl\r
-       db      023h            ;2102\r
+       db      023h\r
        db      037h            ;2103   scf\r
-       db      0bah            ;2104\r
+       db      0bah\r
        db      03fh            ;2105   ccf\r
-       db      010h            ;2106\r
+       db      010h\r
        db      0ffh            ;2107   EOT\r
 \r
 b_0x2108_start:                        ;       1 byte opcodes\r
        defb 0c0h               ;2108   ld r,r\r
-       defb 040h               ;2109\r
-       defb 056h               ;210a\r
-       defw l22fch             ;210b\r
+       defb 040h\r
+       defb 056h\r
+       defw l22fch\r
 \r
        defb 0f8h               ;210d   add a,r\r
-       defb 080h               ;210e\r
-       defb 003h               ;210f\r
-       defw l2305h             ;2110\r
+       defb 080h\r
+       defb 003h\r
+       defw l2305h\r
 \r
        defb 0f8h               ;2112   adc a,r\r
-       defb 088h               ;2113\r
-       defb 000h               ;2114\r
-       defw l2305h             ;2115\r
-\r
-       defb 0f8h               ;2117\r
-       defb 090h               ;2118\r
-       defb 0c9h               ;2119\r
-       defw l24ebh             ;211a\r
-\r
-       defb 0f8h               ;211c\r
-       defb 098h               ;211d\r
-       defb 0b7h               ;211e\r
-       defw l2305h             ;211f\r
-\r
-       defb 0f8h               ;2121\r
-       defb 0a0h               ;2122\r
-       defb 006h               ;2123\r
-       defw l24ebh             ;2124\r
-\r
-       defb 0f8h               ;2126\r
-       defb 0a8h               ;2127\r
-       defb 0cch               ;2128\r
-       defw l24ebh             ;2129\r
-\r
-       defb 0f8h               ;212b\r
-       defb 0b0h               ;212c\r
-       defb 06ch               ;212d\r
-       defw l24ebh             ;212e\r
-\r
-       defb 0f8h               ;2130\r
-       defb 0b8h               ;2131\r
-       defb 013h               ;2132\r
-       defw l24ebh             ;2133\r
-\r
-       defb 0c7h               ;2135\r
+       defb 088h\r
+       defb 000h\r
+       defw l2305h\r
+\r
+       defb 0f8h\r
+       defb 090h\r
+       defb 0c9h\r
+       defw l24ebh\r
+\r
+       defb 0f8h\r
+       defb 098h\r
+       defb 0b7h\r
+       defw l2305h\r
+\r
+       defb 0f8h\r
+       defb 0a0h\r
+       defb 006h\r
+       defw l24ebh\r
+\r
+       defb 0f8h\r
+       defb 0a8h\r
+       defb 0cch\r
+       defw l24ebh\r
+\r
+       defb 0f8h\r
+       defb 0b0h\r
+       defb 06ch\r
+       defw l24ebh\r
+\r
+       defb 0f8h\r
+       defb 0b8h\r
+       defb 013h\r
+       defw l24ebh\r
+\r
+       defb 0c7h\r
        defb 0c0h               ;2136   ret cc\r
-       defb 08bh               ;2137\r
-       defw l2561h             ;2138\r
+       defb 08bh\r
+       defw l2561h\r
 \r
        defb 0c7h               ;213a   rst\r
-       defb 0c7h               ;213b\r
-       defb 0b4h               ;213c\r
-       defw l231eh             ;213d\r
+       defb 0c7h\r
+       defb 0b4h\r
+       defw l231eh\r
 \r
        defb 0ffh               ;213f   ret\r
-       defb 0c9h               ;2140\r
-       defb 08bh               ;2141\r
-       defw l230bh             ;2142\r
+       defb 0c9h\r
+       defb 08bh\r
+       defw l230bh\r
 \r
        defb 0cfh               ;2144   pop rr\r
-       defb 0c1h               ;2145\r
-       defb 081h               ;2146\r
-       defw l2546h             ;2147\r
+       defb 0c1h\r
+       defb 081h\r
+       defw l2546h\r
 \r
        defb 0cfh               ;2149   push rr\r
-       defb 0c5h               ;214a\r
-       defb 084h               ;214b\r
-       defw l2546h             ;214c\r
+       defb 0c5h\r
+       defb 084h\r
+       defw l2546h\r
 \r
        defb 0ffh               ;214e   ex (sp),hl\r
-       defb 0e3h               ;214f\r
-       defb 034h               ;2150\r
-       defw l232ah             ;2151\r
+       defb 0e3h\r
+       defb 034h\r
+       defw l232ah\r
 \r
        defb 0ffh               ;2153   jp (hl)\r
-       defb 0e9h               ;2154\r
-       defb 052h               ;2155\r
-       defw l2338h             ;2156\r
+       defb 0e9h\r
+       defb 052h\r
+       defw l2338h\r
 \r
        defb 0ffh               ;2158   ex de,hl\r
-       defb 0ebh               ;2159\r
-       defb 034h               ;215a\r
-       defw l2345h             ;215b\r
+       defb 0ebh\r
+       defb 034h\r
+       defw l2345h\r
 \r
        defb 0ffh               ;215d   ld sp,hl\r
-       defb 0f9h               ;215e\r
-       defb 056h               ;215f\r
-       defw l234bh             ;2160\r
+       defb 0f9h\r
+       defb 056h\r
+       defw l234bh\r
 \r
        defb 0cfh               ;2162   inc rr\r
-       defb 003h               ;2163\r
-       defb 041h               ;2164\r
-       defw l254bh             ;2165\r
+       defb 003h\r
+       defb 041h\r
+       defw l254bh\r
 \r
        defb 0cfh               ;2167   dec rr\r
-       defb 00bh               ;2168\r
-       defb 029h               ;2169\r
-       defw l254bh             ;216a\r
+       defb 00bh\r
+       defb 029h\r
+       defw l254bh\r
 \r
        defb 0c7h               ;216c   inc r\r
-       defb 004h               ;216d\r
-       defb 041h               ;216e\r
-       defw l24dfh             ;216f\r
+       defb 004h\r
+       defb 041h\r
+       defw l24dfh\r
 \r
        defb 0c7h               ;2171   dec r\r
-       defb 005h               ;2172\r
-       defb 029h               ;2173\r
-       defw l24dfh             ;2174\r
+       defb 005h\r
+       defb 029h\r
+       defw l24dfh\r
 \r
        defb 0ffh               ;2176   ex af,af'\r
-       defb 008h               ;2177\r
-       defb 034h               ;2178\r
-       defw l2357h             ;2179\r
+       defb 008h\r
+       defb 034h\r
+       defw l2357h\r
 \r
        defb 0cfh               ;217b   add hl,rr\r
-       defb 009h               ;217c\r
-       defb 003h               ;217d\r
-       defw l235dh             ;217e\r
+       defb 009h\r
+       defb 003h\r
+       defw l235dh\r
 \r
        defb 0efh               ;2180   ld (rr),a ;rr=bc,de\r
-       defb 002h               ;2181\r
-       defb 056h               ;2182\r
-       defw l2366h             ;2183\r
+       defb 002h\r
+       defb 056h\r
+       defw l2366h\r
 \r
        defb 0efh               ;2185   ld a,(rr) ;rr=bc,de\r
-       defb 00ah               ;2186\r
-       defb 056h               ;2187\r
-       defw l236fh             ;2188\r
+       defb 00ah\r
+       defb 056h\r
+       defw l236fh\r
 \r
        defb 000h               ;218a   EOT\r
 \r
 b_0x218B_start:                        ;       2 byte opdodes\r
        defb 0c7h               ;218b   ld r,nn\r
-       defb 006h               ;218c\r
-       defb 056h               ;218d\r
-       defw l2384h             ;218e\r
+       defb 006h\r
+       defb 056h\r
+       defw l2384h\r
 \r
        defb 0ffh               ;2190   add a,nn\r
-       defb 0c6h               ;2191\r
-       defb 003h               ;2192\r
-       defw l237fh             ;2193\r
+       defb 0c6h\r
+       defb 003h\r
+       defw l237fh\r
 \r
        defb 0ffh               ;2195   adc a,nn\r
-       defb 0ceh               ;2196\r
-       defb 000h               ;2197\r
-       defw l237fh             ;2198\r
+       defb 0ceh\r
+       defb 000h\r
+       defw l237fh\r
 \r
        defb 0ffh               ;219a   sub a,nn\r
-       defb 0d6h               ;219b\r
-       defb 0c9h               ;219c\r
-       defw l2397h             ;219d\r
+       defb 0d6h\r
+       defb 0c9h\r
+       defw l2397h\r
 \r
-       defb 0ffh               ;219f\r
-       defb 0deh               ;21a0\r
-       defb 0b7h               ;21a1\r
-       defw l237fh             ;21a2\r
+       defb 0ffh\r
+       defb 0deh\r
+       defb 0b7h\r
+       defw l237fh\r
 \r
        defb 0ffh               ;21a4   and a,nn\r
-       defb 0e6h               ;21a5\r
-       defb 006h               ;21a6\r
-       defw l2397h             ;21a7\r
+       defb 0e6h\r
+       defb 006h\r
+       defw l2397h\r
 \r
-       defb 0ffh               ;21a9\r
-       defb 0eeh               ;21aa\r
-       defb 0cch               ;21ab\r
-       defw l2397h             ;21ac\r
+       defb 0ffh\r
+       defb 0eeh\r
+       defb 0cch\r
+       defw l2397h\r
 \r
-       defb 0ffh               ;21ae\r
-       defb 0f6h               ;21af\r
-       defb 06ch               ;21b0\r
-       defw l2397h             ;21b1\r
+       defb 0ffh\r
+       defb 0f6h\r
+       defb 06ch\r
+       defw l2397h\r
 \r
        defb 0ffh               ;21b3   cp a,nn\r
-       defb 0feh               ;21b4\r
-       defb 013h               ;21b5\r
-       defw l2397h             ;21b6\r
+       defb 0feh\r
+       defb 013h\r
+       defw l2397h\r
 \r
        defb 0ffh               ;21b8   djnz\r
-       defb 010h               ;21b9\r
-       defb 02eh               ;21ba\r
-       defw l23b0h             ;21bb\r
+       defb 010h\r
+       defb 02eh\r
+       defw l23b0h\r
 \r
        defb 0ffh               ;21bd   jr\r
-       defb 018h               ;21be\r
-       defb 054h               ;21bf\r
-       defw l23b0h             ;21c0\r
+       defb 018h\r
+       defb 054h\r
+       defw l23b0h\r
 \r
        defb 0e7h               ;21c2   jr,cc\r
-       defb 020h               ;21c3\r
-       defb 054h               ;21c4\r
-       defw l23a1h             ;21c5\r
+       defb 020h\r
+       defb 054h\r
+       defw l23a1h\r
 \r
-       defb 0ffh               ;21c7\r
+       defb 0ffh\r
        defb 0d3h               ;21c8   out (nn),a\r
-       defb 076h               ;21c9\r
-       defw l23d5h             ;21ca\r
+       defb 076h\r
+       defw l23d5h\r
 \r
        defb 0ffh               ;21cc   in a,(nn)\r
-       defb 0dbh               ;21cd\r
-       defb 03fh               ;21ce\r
-       defw l23c3h             ;21cf\r
+       defb 0dbh\r
+       defb 03fh\r
+       defw l23c3h\r
 \r
        defb 000h               ;21d1   EOT\r
 \r
 b_0x21D2_start:                        ;       3 byte opcodes\r
-       defb 0c7h               ;21d2\r
-       defb 0c2h               ;21d3\r
-       defb 052h               ;21d4\r
-       defw l23e0h             ;21d5\r
-\r
-       defb 0c7h               ;21d7\r
-       defb 0c4h               ;21d8\r
-       defb 00ch               ;21d9\r
-       defw l23e0h             ;21da\r
-\r
-       defb 0cfh               ;21dc\r
-       defb 001h               ;21dd\r
-       defb 056h               ;21de\r
-       defw l23fch             ;21df\r
-\r
-       defb 0ffh               ;21e1\r
-       defb 0c3h               ;21e2\r
-       defb 052h               ;21e3\r
-       defw l23e6h             ;21e4\r
-\r
-       defb 0ffh               ;21e6\r
-       defb 0cdh               ;21e7\r
-       defb 00ch               ;21e8\r
-       defw l23e6h             ;21e9\r
-\r
-       defb 0ffh               ;21eb\r
-       defb 022h               ;21ec\r
-       defb 056h               ;21ed\r
-       defw l2404h             ;21ee\r
-\r
-       defb 0ffh               ;21f0\r
-       defb 02ah               ;21f1\r
-       defb 056h               ;21f2\r
-       defw l240dh             ;21f3\r
-\r
-       defb 0ffh               ;21f5\r
-       defb 032h               ;21f6\r
-       defb 056h               ;21f7\r
-       defw l2416h             ;21f8\r
-\r
-       defb 0ffh               ;21fa\r
-       defb 03ah               ;21fb\r
-       defb 056h               ;21fc\r
-       defw l2421h             ;21fd\r
-\r
-       defb 000h               ;21ff\r
+       defb 0c7h\r
+       defb 0c2h\r
+       defb 052h\r
+       defw l23e0h\r
+\r
+       defb 0c7h\r
+       defb 0c4h\r
+       defb 00ch\r
+       defw l23e0h\r
+\r
+       defb 0cfh\r
+       defb 001h\r
+       defb 056h\r
+       defw l23fch\r
+\r
+       defb 0ffh\r
+       defb 0c3h\r
+       defb 052h\r
+       defw l23e6h\r
+\r
+       defb 0ffh\r
+       defb 0cdh\r
+       defb 00ch\r
+       defw l23e6h\r
+\r
+       defb 0ffh\r
+       defb 022h\r
+       defb 056h\r
+       defw l2404h\r
+\r
+       defb 0ffh\r
+       defb 02ah\r
+       defb 056h\r
+       defw l240dh\r
+\r
+       defb 0ffh\r
+       defb 032h\r
+       defb 056h\r
+       defw l2416h\r
+\r
+       defb 0ffh\r
+       defb 03ah\r
+       defb 056h\r
+       defw l2421h\r
+\r
+       defb 000h\r
 \r
 b_0x2200_start:                        ;       prefix ED + 1 byte opcode\r
        defb 044h               ;2200   neg\r
-       defb 066h               ;2201\r
+       defb 066h\r
        defb 045h               ;2202   retn\r
-       defb 092h               ;2203\r
+       defb 092h\r
        defb 04dh               ;2204   reti\r
-       defb 08eh               ;2205\r
+       defb 08eh\r
        defb 067h               ;2206   rrd\r
-       defb 0b1h               ;2207\r
+       defb 0b1h\r
        defb 06fh               ;2208   rld\r
-       defb 0a2h               ;2209\r
+       defb 0a2h\r
        defb 0a0h               ;220a   ldi\r
-       defb 05fh               ;220b\r
-       defb 0a1h               ;220c\r
-       defb 01ch               ;220d\r
-       defb 0a2h               ;220e\r
-       defb 04bh               ;220f\r
-       defb 0a3h               ;2210\r
-       defb 07dh               ;2211\r
+       defb 05fh\r
+       defb 0a1h\r
+       defb 01ch\r
+       defb 0a2h\r
+       defb 04bh\r
+       defb 0a3h\r
+       defb 07dh\r
        defb 0a8h               ;2212   ldd\r
-       defb 058h               ;2213\r
-       defb 0a9h               ;2214\r
-       defb 015h               ;2215\r
-       defb 0aah               ;2216\r
-       defb 044h               ;2217\r
-       defb 0abh               ;2218\r
-       defb 079h               ;2219\r
+       defb 058h\r
+       defb 0a9h\r
+       defb 015h\r
+       defb 0aah\r
+       defb 044h\r
+       defb 0abh\r
+       defb 079h\r
        defb 0b0h               ;221a   ldir\r
-       defb 062h               ;221b\r
-       defb 0b1h               ;221c\r
-       defb 01fh               ;221d\r
-       defb 0b2h               ;221e\r
-       defb 04eh               ;221f\r
-       defb 0b3h               ;2220\r
-       defb 072h               ;2221\r
+       defb 062h\r
+       defb 0b1h\r
+       defb 01fh\r
+       defb 0b2h\r
+       defb 04eh\r
+       defb 0b3h\r
+       defb 072h\r
        defb 0b8h               ;2222   lddr\r
-       defb 05bh               ;2223\r
-       defb 0b9h               ;2224\r
-       defb 018h               ;2225\r
-       defb 0bah               ;2226\r
-       defb 047h               ;2227\r
-       defb 0bbh               ;2228\r
-       defb 06eh               ;2229\r
+       defb 05bh\r
+       defb 0b9h\r
+       defb 018h\r
+       defb 0bah\r
+       defb 047h\r
+       defb 0bbh\r
+       defb 06eh\r
        defb 08bh               ;222a   otdm\r
-       defb 0d5h               ;222b\r
+       defb 0d5h\r
        defb 09bh               ;222c   otdmr\r
-       defb 0d9h               ;222d\r
+       defb 0d9h\r
        defb 083h               ;222e   otim\r
-       defb 0deh               ;222f\r
+       defb 0deh\r
        defb 093h               ;2230   otimr\r
-       defb 0e2h               ;2231\r
+       defb 0e2h\r
        defb 076h               ;2232   slp\r
-       defb 0ebh               ;2233\r
+       defb 0ebh\r
        defb 0ffh               ;2234   EOT\r
-       \r
+\r
 l2235h:\r
        defb 0e7h               ;2235   in r,(c) ;r=bcde\r
-       defb 040h               ;2236\r
-       defb 03fh               ;2237\r
-       defw l2455h             ;2238\r
+       defb 040h\r
+       defb 03fh\r
+       defw l2455h\r
 \r
        defb 0f7h               ;223a   in r,(c) ;r=hl\r
-       defb 060h               ;223b\r
-       defb 03fh               ;223c\r
-       defw l2455h             ;223d\r
+       defb 060h\r
+       defb 03fh\r
+       defw l2455h\r
 \r
        defb 0ffh               ;223f   in r,(c) ;r=a\r
-       defb 078h               ;2240\r
-       defb 03fh               ;2241\r
-       defw l2455h             ;2242\r
+       defb 078h\r
+       defb 03fh\r
+       defw l2455h\r
 \r
-       defb 0e7h               ;2244\r
-       defb 041h               ;2245\r
-       defb 076h               ;2246\r
-       defw l2461h             ;2247\r
+       defb 0e7h\r
+       defb 041h\r
+       defb 076h\r
+       defw l2461h\r
 \r
-       defb 0f7h               ;2249\r
-       defb 061h               ;224a\r
-       defb 076h               ;224b\r
-       defw l2461h             ;224c\r
+       defb 0f7h\r
+       defb 061h\r
+       defb 076h\r
+       defw l2461h\r
 \r
        defb 0ffh               ;224e   out (c),r ;r=a\r
-       defb 079h               ;224f\r
-       defb 076h               ;2250\r
-       defw l2461h             ;2251\r
+       defb 079h\r
+       defb 076h\r
+       defw l2461h\r
 \r
        defb 0cfh               ;2253   sbc hl,rr\r
-       defb 042h               ;2254\r
-       defb 0b7h               ;2255\r
-       defw l246dh             ;2256\r
+       defb 042h\r
+       defb 0b7h\r
+       defw l246dh\r
 \r
        defb 0cfh               ;2258   adc hl,rr\r
-       defb 04ah               ;2259\r
-       defb 000h               ;225a\r
-       defw l246dh             ;225b\r
+       defb 04ah\r
+       defb 000h\r
+       defw l246dh\r
 \r
        defb 0ffh               ;225d   im 0\r
-       defb 046h               ;225e\r
-       defb 03dh               ;225f\r
-       defw l2427h             ;2260\r
+       defb 046h\r
+       defb 03dh\r
+       defw l2427h\r
 \r
        defb 0ffh               ;2262   im 1\r
-       defb 056h               ;2263\r
-       defb 03dh               ;2264\r
-       defw l242bh             ;2265\r
+       defb 056h\r
+       defb 03dh\r
+       defw l242bh\r
 \r
        defb 0ffh               ;2267   im 2\r
-       defb 05eh               ;2268\r
-       defb 03dh               ;2269\r
-       defw l242fh             ;226a\r
+       defb 05eh\r
+       defb 03dh\r
+       defw l242fh\r
 \r
        defb 0ffh               ;226c   ld i,a\r
-       defb 047h               ;226d\r
-       defb 056h               ;226e\r
-       defw l2434h             ;226f\r
+       defb 047h\r
+       defb 056h\r
+       defw l2434h\r
 \r
-       defb 0ffh               ;2271\r
-       defb 057h               ;2272\r
-       defb 056h               ;2273\r
-       defw l2439h             ;2274\r
+       defb 0ffh\r
+       defb 057h\r
+       defb 056h\r
+       defw l2439h\r
 \r
-       defb 0ffh               ;2276\r
-       defb 04fh               ;2277\r
-       defb 056h               ;2278\r
-       defw l243eh             ;2279\r
+       defb 0ffh\r
+       defb 04fh\r
+       defb 056h\r
+       defw l243eh\r
 \r
-       defb 0ffh               ;227b\r
-       defb 05fh               ;227c\r
-       defb 056h               ;227d\r
-       defw l2443h             ;227e\r
+       defb 0ffh\r
+       defb 05fh\r
+       defb 056h\r
+       defw l2443h\r
 \r
        defb 0cfh               ;2280   mlt rr\r
-       defb 04ch               ;2281\r
-       defb 0d2h               ;2282\r
-       defw l254bh             ;2283\r
+       defb 04ch\r
+       defb 0d2h\r
+       defw l254bh\r
 \r
        defb 0c7h               ;2285   tst r\r
-       defb 004h               ;2286\r
-       defb 0eeh               ;2287\r
-       defw l24dfh             ;2288\r
+       defb 004h\r
+       defb 0eeh\r
+       defw l24dfh\r
 \r
-       defb 000h               ;228a\r
+       defb 000h\r
 \r
 l228bh:\r
-       defb 0e7h               ;228b\r
-       defb 000h               ;228c\r
-       defb 0cfh               ;228d\r
+       defb 0e7h\r
+       defb 000h\r
+       defb 0cfh\r
 \r
 b_0x228E_start:\r
-       defw l230ch             ;228e\r
+       defw l230ch\r
 \r
 b_0x2290_start:\r
-       defb 0f7h               ;2290\r
-       defb 020h               ;2291\r
-       defb 0cfh               ;2292\r
+       defb 0f7h\r
+       defb 020h\r
+       defb 0cfh\r
 \r
 b_0x2293_start:\r
-       defw l230ch             ;2293\r
+       defw l230ch\r
 \r
 b_0x2295_start:\r
-       defb 0ffh               ;2295\r
-       defb 038h               ;2296\r
-       defb 0cfh               ;2297\r
+       defb 0ffh\r
+       defb 038h\r
+       defb 0cfh\r
 \r
 b_0x2298_start:\r
-       defw l230ch             ;2298\r
+       defw l230ch\r
 \r
 b_0x229A_start:\r
-       defb 0e7h               ;229a\r
-       defb 001h               ;229b\r
-       defb 0e7h               ;229c\r
+       defb 0e7h\r
+       defb 001h\r
+       defb 0e7h\r
 \r
 b_0x229D_start:\r
-       defw l2315h             ;229d\r
+       defw l2315h\r
 \r
 b_0x229F_start:\r
-       defb 0f7h               ;229f\r
-       defb 021h               ;22a0\r
-       defb 0e7h               ;22a1\r
+       defb 0f7h\r
+       defb 021h\r
+       defb 0e7h\r
 \r
 b_0x22A2_start:\r
-       defw l2315h             ;22a2\r
+       defw l2315h\r
 \r
 b_0x22A4_start:\r
-       defb 0ffh               ;22a4\r
-       defb 039h               ;22a5\r
-       defb 0e7h               ;22a6\r
+       defb 0ffh\r
+       defb 039h\r
+       defb 0e7h\r
 \r
 b_0x22A7_start:\r
-       defw l2315h             ;22a7\r
+       defw l2315h\r
 \r
 b_0x22A9_start:\r
-       defb 0ffh               ;22a9\r
-       defb 064h               ;22aa\r
-       defb 0eeh               ;22ab\r
+       defb 0ffh\r
+       defb 064h\r
+       defb 0eeh\r
 \r
 b_0x22AC_start:\r
-       defw l2397h             ;22ac\r
+       defw l2397h\r
 \r
 b_0x22AE_start:\r
-       defb 0ffh               ;22ae\r
-       defb 074h               ;22af\r
-       defb 0f1h               ;22b0\r
+       defb 0ffh\r
+       defb 074h\r
+       defb 0f1h\r
 \r
 b_0x22B1_start:\r
-       defw l2397h             ;22b1\r
+       defw l2397h\r
 \r
 b_0x22B3_start:\r
-       defb 000h               ;22b3\r
+       defb 000h\r
 l22b4h:\r
-       defb 0efh               ;22b4\r
-       defb 043h               ;22b5\r
-       defb 056h               ;22b6\r
+       defb 0efh\r
+       defb 043h\r
+       defb 056h\r
 \r
 b_0x22B7_start:\r
-       defw l2476h             ;22b7\r
+       defw l2476h\r
 \r
 b_0x22B9_start:\r
-       defb 0ffh               ;22b9\r
-       defb 073h               ;22ba\r
-       defb 056h               ;22bb\r
+       defb 0ffh\r
+       defb 073h\r
+       defb 056h\r
 \r
 b_0x22BC_start:\r
-       defw l2476h             ;22bc\r
+       defw l2476h\r
 \r
 b_0x22BE_start:\r
-       defb 0efh               ;22be\r
-       defb 04bh               ;22bf\r
-       defb 056h               ;22c0\r
+       defb 0efh\r
+       defb 04bh\r
+       defb 056h\r
 \r
 b_0x22C1_start:\r
-       defw l247fh             ;22c1\r
+       defw l247fh\r
 \r
 b_0x22C3_start:\r
-       defb 0ffh               ;22c3\r
-       defb 07bh               ;22c4\r
-       defb 056h               ;22c5\r
+       defb 0ffh\r
+       defb 07bh\r
+       defb 056h\r
 \r
 b_0x22C6_start:\r
-       defw l247fh             ;22c6\r
+       defw l247fh\r
 \r
 b_0x22C8_start:\r
-       defb 000h               ;22c8\r
+       defb 000h\r
 l22c9h:\r
-       defb 0f8h               ;22c9\r
-       defb 000h               ;22ca\r
-       defb 09bh               ;22cb\r
+       defb 0f8h\r
+       defb 000h\r
+       defb 09bh\r
 \r
 b_0x22CC_start:\r
-       defw l24aeh             ;22cc\r
+       defw l24aeh\r
 \r
 b_0x22CE_start:\r
-       defb 0f8h               ;22ce\r
-       defb 008h               ;22cf\r
-       defb 0aah               ;22d0\r
+       defb 0f8h\r
+       defb 008h\r
+       defb 0aah\r
 \r
 b_0x22D1_start:\r
-       defw l24aeh             ;22d1\r
+       defw l24aeh\r
 \r
 b_0x22D3_start:\r
-       defb 0f8h               ;22d3\r
-       defb 010h               ;22d4\r
-       defb 096h               ;22d5\r
+       defb 0f8h\r
+       defb 010h\r
+       defb 096h\r
 \r
 b_0x22D6_start:\r
-       defw l24aeh             ;22d6\r
+       defw l24aeh\r
 \r
 b_0x22D8_start:\r
-       defb 0f8h               ;22d8\r
-       defb 018h               ;22d9\r
-       defb 0a5h               ;22da\r
+       defb 0f8h\r
+       defb 018h\r
+       defb 0a5h\r
 \r
 b_0x22DB_start:\r
-       defw l24aeh             ;22db\r
+       defw l24aeh\r
 \r
 b_0x22DD_start:\r
-       defb 0f8h               ;22dd\r
-       defb 020h               ;22de\r
-       defb 0c0h               ;22df\r
+       defb 0f8h\r
+       defb 020h\r
+       defb 0c0h\r
 \r
 b_0x22E0_start:\r
-       defw l24aeh             ;22e0\r
+       defw l24aeh\r
 \r
 b_0x22E2_start:\r
-       defb 0f8h               ;22e2\r
-       defb 028h               ;22e3\r
-       defb 0c3h               ;22e4\r
+       defb 0f8h\r
+       defb 028h\r
+       defb 0c3h\r
 \r
 b_0x22E5_start:\r
-       defw l24aeh             ;22e5\r
+       defw l24aeh\r
 \r
 b_0x22E7_start:\r
-       defb 0f8h               ;22e7\r
-       defb 038h               ;22e8\r
-       defb 0c6h               ;22e9\r
+       defb 0f8h\r
+       defb 038h\r
+       defb 0c6h\r
 \r
 b_0x22EA_start:\r
-       defw l24aeh             ;22ea\r
+       defw l24aeh\r
 \r
 b_0x22EC_start:\r
-       defb 0c0h               ;22ec\r
-       defb 040h               ;22ed\r
-       defb 009h               ;22ee\r
+       defb 0c0h\r
+       defb 040h\r
+       defb 009h\r
 \r
 b_0x22EF_start:\r
-       defw l2487h             ;22ef\r
+       defw l2487h\r
 \r
 b_0x22F1_start:\r
-       defb 0c0h               ;22f1\r
-       defb 080h               ;22f2\r
-       defb 088h               ;22f3\r
+       defb 0c0h\r
+       defb 080h\r
+       defb 088h\r
 \r
 b_0x22F4_start:\r
-       defw l2487h             ;22f4\r
+       defw l2487h\r
 \r
 b_0x22F6_start:\r
-       defb 0c0h               ;22f6\r
-       defb 0c0h               ;22f7\r
-       defb 0bdh               ;22f8\r
+       defb 0c0h\r
+       defb 0c0h\r
+       defb 0bdh\r
 \r
 b_0x22F9_start:\r
-       defw l2487h             ;22f9\r
+       defw l2487h\r
 \r
 b_0x22FB_start:\r
-       defb 000h               ;22fb\r
+       defb 000h\r
 l22fch:\r
-       call l24dfh             ;22fc\r
-       call sub_257ch          ;22ff\r
-       jp l24ebh               ;2302\r
+       call l24dfh\r
+       call sub_257ch\r
+       jp l24ebh\r
 l2305h:\r
-       call sub_2579h          ;2305\r
-       jp l24ebh               ;2308\r
+       call sub_2579h\r
+       jp l24ebh\r
 l230bh:\r
-       ret                     ;230b\r
+       ret\r
 l230ch:\r
-       call l24dfh             ;230c\r
-       call sub_257ch          ;230f\r
-       jp l23c6h               ;2312\r
+       call l24dfh\r
+       call sub_257ch\r
+       jp l23c6h\r
 l2315h:\r
-       call l23c6h             ;2315\r
-       call sub_257ch          ;2318\r
-       jp l24dfh               ;231b\r
+       call l23c6h\r
+       call sub_257ch\r
+       jp l24dfh\r
 l231eh:\r
-       comst                   ;231e\r
-       ld a,(iy+000h)          ;2322\r
+       comst\r
+       ld a,(iy+000h)\r
        comend\r
-       and 038h                ;2325\r
-       jp out.hex              ;2327\r
+       and 038h\r
+       jp out.hex\r
 l232ah:\r
-       ld hl,b_0x2333_start    ;232a\r
-       call PSTR               ;232d\r
-       jp l253eh               ;2330\r
+       ld hl,b_0x2333_start\r
+       call PSTR\r
+       jp l253eh\r
 \r
 b_0x2333_start:\r
        DC      '(SP),'\r
 \r
 l2338h:\r
-       ld a,'('                ;2338\r
-       call OUTCHAR            ;233a\r
-       call l253eh             ;233d\r
-       ld a,')'                ;2340\r
-       jp OUTCHAR              ;2342\r
+       ld a,'('\r
+       call OUTCHAR\r
+       call l253eh\r
+       ld a,')'\r
+       jp OUTCHAR\r
 l2345h:\r
-       ld hl,l1d86h            ;2345\r
-       jp PSTR                 ;2348\r
+       ld hl,l1d86h\r
+       jp PSTR\r
 l234bh:\r
-       ld hl,b_0x2354_start    ;234b\r
-       call PSTR               ;234e\r
-       jp l253eh               ;2351\r
+       ld hl,b_0x2354_start\r
+       call PSTR\r
+       jp l253eh\r
 \r
 b_0x2354_start:\r
        DC      'SP,'\r
 \r
 l2357h:\r
-       ld hl,b_0x1D80_start    ;2357\r
-       jp PSTR                 ;235a\r
+       ld hl,b_0x1D80_start\r
+       jp PSTR\r
 l235dh:\r
-       call l253eh             ;235d\r
-       call sub_257ch          ;2360\r
-       jp l254bh               ;2363\r
+       call l253eh\r
+       call sub_257ch\r
+       jp l254bh\r
 l2366h:\r
-       call sub_2372h          ;2366\r
-       call sub_257ch          ;2369\r
-       jp l23dbh               ;236c\r
+       call sub_2372h\r
+       call sub_257ch\r
+       jp l23dbh\r
 l236fh:\r
-       call sub_2579h          ;236f\r
+       call sub_2579h\r
 sub_2372h:\r
-       ld a,'('                ;2372\r
-       call OUTCHAR            ;2374\r
-       call l254bh             ;2377\r
-       ld a,')'                ;237a\r
-       jp OUTCHAR              ;237c\r
+       ld a,'('\r
+       call OUTCHAR\r
+       call l254bh\r
+       ld a,')'\r
+       jp OUTCHAR\r
 l237fh:\r
-       call sub_2579h          ;237f\r
-       jr l2397h               ;2382\r
+       call sub_2579h\r
+       jr l2397h\r
 l2384h:\r
-       call l24dfh             ;2384\r
-       call sub_257ch          ;2387\r
-       ld a,(is.pfx.IXY)               ;238a\r
-       and a                   ;238d\r
-       comst                   ;238e\r
-       ld a,(iy+002h)          ;2392\r
+       call l24dfh\r
+       call sub_257ch\r
+       ld a,(is.pfx.IXY)\r
+       and a\r
+       comst\r
+       ld a,(iy+002h)\r
        comend\r
-       jr nz,l239eh            ;2395\r
+       jr nz,l239eh\r
 l2397h:\r
-       comst                   ;2397\r
-       ld a,(iy+001h)          ;239b\r
+       comst\r
+       ld a,(iy+001h)\r
        comend\r
 l239eh:\r
-       jp out.hex              ;239e\r
+       jp out.hex\r
 l23a1h:\r
-       comst                   ;23a1\r
-       ld a,(iy+000h)          ;23a5\r
+       comst\r
+       ld a,(iy+000h)\r
        comend\r
-       and 018h                ;23a8\r
-       call sub_2568h          ;23aa\r
-       call sub_257ch          ;23ad\r
+       and 018h\r
+       call sub_2568h\r
+       call sub_257ch\r
 l23b0h:\r
-       comst                   ;23b0\r
-       ld c,(iy+001h)          ;23b4\r
+       comst\r
+       ld c,(iy+001h)\r
        comend\r
-       ld a,c                  ;23b7\r
-       rla                     ;23b8\r
-       sbc a,a                 ;23b9\r
-       ld b,a                  ;23ba\r
-       push iy                 ;23bb\r
-       pop hl                  ;23bd\r
-       add hl,bc               ;23be\r
-       inc hl                  ;23bf\r
-       inc hl                  ;23c0\r
-       jr l23f0h               ;23c1\r
+       ld a,c\r
+       rla\r
+       sbc a,a\r
+       ld b,a\r
+       push iy\r
+       pop hl\r
+       add hl,bc\r
+       inc hl\r
+       inc hl\r
+       jr l23f0h\r
 l23c3h:\r
-       call sub_2579h          ;23c3\r
+       call sub_2579h\r
 l23c6h:\r
-       ld a,028h               ;23c6\r
-       call OUTCHAR            ;23c8\r
-       comst                   ;23cb\r
-       ld a,(iy+001h)          ;23cf\r
+       ld a,028h\r
+       call OUTCHAR\r
+       comst\r
+       ld a,(iy+001h)\r
        comend\r
-       jp l252bh               ;23d2\r
+       jp l252bh\r
 l23d5h:\r
-       call l23c6h             ;23d5\r
-       call sub_257ch          ;23d8\r
+       call l23c6h\r
+       call sub_257ch\r
 l23dbh:\r
-       ld a,041h               ;23db\r
-       jp OUTCHAR              ;23dd\r
+       ld a,041h\r
+       jp OUTCHAR\r
 l23e0h:\r
-       call l2561h             ;23e0\r
-       call sub_257ch          ;23e3\r
+       call l2561h\r
+       call sub_257ch\r
 l23e6h:\r
-       comst                   ;23e6\r
-       ld l,(iy+001h)          ;23ea\r
-       ld h,(iy+002h)          ;23ed\r
+       comst\r
+       ld l,(iy+001h)\r
+       ld h,(iy+002h)\r
        comend\r
 l23f0h:\r
-       ld a,002h               ;23f0\r
+       ld a,002h\r
 sub_23f2h:\r
-       ld (XBE03),a            ;23f2\r
-       ld (XBE01),hl           ;23f5\r
-       call out.hl             ;23f8\r
-       ret                     ;23fb\r
+       ld (XBE03),a\r
+       ld (XBE01),hl\r
+       call out.hl\r
+       ret\r
 l23fch:\r
-       call l254bh             ;23fc\r
-       call sub_257ch          ;23ff\r
-       jr l23e6h               ;2402\r
+       call l254bh\r
+       call sub_257ch\r
+       jr l23e6h\r
 l2404h:\r
-       call sub_24c6h          ;2404\r
-       call sub_257ch          ;2407\r
-       jp l253eh               ;240a\r
+       call sub_24c6h\r
+       call sub_257ch\r
+       jp l253eh\r
 l240dh:\r
-       call l253eh             ;240d\r
-       call sub_257ch          ;2410\r
-       jp sub_24c6h            ;2413\r
+       call l253eh\r
+       call sub_257ch\r
+       jp sub_24c6h\r
 l2416h:\r
-       call sub_24c6h          ;2416\r
-       call sub_257ch          ;2419\r
-       ld a,041h               ;241c\r
-       jp OUTCHAR              ;241e\r
+       call sub_24c6h\r
+       call sub_257ch\r
+       ld a,041h\r
+       jp OUTCHAR\r
 l2421h:\r
-       call sub_2579h          ;2421\r
-       jp sub_24c6h            ;2424\r
+       call sub_2579h\r
+       jp sub_24c6h\r
 l2427h:\r
-       ld a,030h               ;2427\r
-       jr l2431h               ;2429\r
+       ld a,030h\r
+       jr l2431h\r
 l242bh:\r
-       ld a,031h               ;242b\r
-       jr l2431h               ;242d\r
+       ld a,031h\r
+       jr l2431h\r
 l242fh:\r
-       ld a,032h               ;242f\r
+       ld a,032h\r
 l2431h:\r
-       jp OUTCHAR              ;2431\r
+       jp OUTCHAR\r
 l2434h:\r
-       ld hl,b_0x2449_start    ;2434\r
-       jr l2446h               ;2437\r
+       ld hl,b_0x2449_start\r
+       jr l2446h\r
 l2439h:\r
-       ld hl,l244ch            ;2439\r
-       jr l2446h               ;243c\r
+       ld hl,l244ch\r
+       jr l2446h\r
 l243eh:\r
-       ld hl,l244fh            ;243e\r
-       jr l2446h               ;2441\r
+       ld hl,l244fh\r
+       jr l2446h\r
 l2443h:\r
-       ld hl,l2452h            ;2443\r
+       ld hl,l2452h\r
 l2446h:\r
-       jp PSTR                 ;2446\r
+       jp PSTR\r
 \r
 b_0x2449_start:\r
        DC      'I,A'\r
@@ -5402,124 +5420,124 @@ l2452h:
        DC      'A,R'\r
 \r
 l2455h:\r
-       call l24dfh             ;2455\r
-       call sub_257ch          ;2458\r
-       ld hl,t__C_             ;245b\r
-       jp PSTR         ;245e\r
+       call l24dfh\r
+       call sub_257ch\r
+       ld hl,t__C_\r
+       jp PSTR\r
 l2461h:\r
-       ld hl,t__C_             ;2461\r
-       call PSTR               ;2464\r
-       call sub_257ch          ;2467\r
-       jp l24dfh               ;246a\r
+       ld hl,t__C_\r
+       call PSTR\r
+       call sub_257ch\r
+       jp l24dfh\r
 l246dh:\r
-       call l253eh             ;246d\r
-       call sub_257ch          ;2470\r
-       jp l254bh               ;2473\r
+       call l253eh\r
+       call sub_257ch\r
+       jp l254bh\r
 l2476h:\r
-       call sub_24c6h          ;2476\r
-       call sub_257ch          ;2479\r
-       jp l254bh               ;247c\r
+       call sub_24c6h\r
+       call sub_257ch\r
+       jp l254bh\r
 l247fh:\r
-       call l254bh             ;247f\r
-       call sub_257ch          ;2482\r
-       jr sub_24c6h            ;2485\r
+       call l254bh\r
+       call sub_257ch\r
+       jr sub_24c6h\r
 l2487h:\r
-       ld a,(is.pfx.IXY)               ;2487\r
-       and a                   ;248a\r
-       jr nz,l2496h            ;248b\r
-       comst                   ;248d\r
-       ld a,(iy+001h)          ;2491\r
+       ld a,(is.pfx.IXY)\r
+       and a\r
+       jr nz,l2496h\r
+       comst\r
+       ld a,(iy+001h)\r
        comend\r
-       jr l249dh               ;2494\r
+       jr l249dh\r
 l2496h:\r
-       comst                   ;2496\r
-       ld a,(iy+002h)          ;249a\r
+       comst\r
+       ld a,(iy+002h)\r
        comend\r
 l249dh:\r
-       push af                 ;249d\r
-       rra                     ;249e\r
-       rra                     ;249f\r
-       rra                     ;24a0\r
-       and 007h                ;24a1\r
-       add a,'0'               ;24a3\r
-       call OUTCHAR            ;24a5\r
-       call sub_257ch          ;24a8\r
-       pop af                  ;24ab\r
-       jr l24f2h               ;24ac\r
+       push af\r
+       rra\r
+       rra\r
+       rra\r
+       and 007h\r
+       add a,'0'\r
+       call OUTCHAR\r
+       call sub_257ch\r
+       pop af\r
+       jr l24f2h\r
 l24aeh:\r
-       ld a,(is.pfx.IXY)               ;24ae\r
-       and a                   ;24b1\r
-       jr nz,l24bdh            ;24b2\r
-       comst                   ;24b4\r
-       ld a,(iy+001h)          ;24b8\r
+       ld a,(is.pfx.IXY)\r
+       and a\r
+       jr nz,l24bdh\r
+       comst\r
+       ld a,(iy+001h)\r
        comend\r
-       jr l24c4h               ;24bb\r
+       jr l24c4h\r
 l24bdh:\r
-       comst                   ;24bd\r
-       ld a,(iy+002h)          ;24c1\r
+       comst\r
+       ld a,(iy+002h)\r
        comend\r
 l24c4h:\r
-       jr l24f2h               ;24c4\r
+       jr l24f2h\r
 sub_24c6h:\r
-       ld a,'('                ;24c6\r
-       call OUTCHAR            ;24c8\r
-       comst                   ;24cb\r
-       ld l,(iy+001h)          ;24cf\r
-       ld h,(iy+002h)          ;24d2\r
+       ld a,'('\r
+       call OUTCHAR\r
+       comst\r
+       ld l,(iy+001h)\r
+       ld h,(iy+002h)\r
        comend\r
-       ld a,001h               ;24d5\r
-       call sub_23f2h          ;24d7\r
-       ld a,')'                ;24da\r
-       jp OUTCHAR              ;24dc\r
+       ld a,001h\r
+       call sub_23f2h\r
+       ld a,')'\r
+       jp OUTCHAR\r
 l24dfh:\r
-       comst                   ;24df\r
-       ld a,(iy+000h)          ;24e3\r
+       comst\r
+       ld a,(iy+000h)\r
        comend\r
-       rra                     ;24e6\r
-       rra                     ;24e7\r
-       rra                     ;24e8\r
-       jr l24f2h               ;24e9\r
+       rra\r
+       rra\r
+       rra\r
+       jr l24f2h\r
 l24ebh:\r
-       comst                   ;24eb\r
-       ld a,(iy+000h)          ;24ef\r
+       comst\r
+       ld a,(iy+000h)\r
        comend\r
 l24f2h:\r
-       and 007h                ;24f2\r
-       cp 006h                 ;24f4\r
-       jr nz,l2533h            ;24f6\r
-       ld a,(is.pfx.IXY)               ;24f8\r
-       and a                   ;24fb\r
-       ld a,006h               ;24fc\r
-       jr z,l2533h             ;24fe\r
-       ld hl,b_0x2538_start    ;2500\r
-       ld a,(is.pfx.IXY)               ;2503\r
-       dec a                   ;2506\r
-       jr z,l250ch             ;2507\r
-       ld hl,b_0x253B_start    ;2509\r
+       and 007h\r
+       cp 006h\r
+       jr nz,l2533h\r
+       ld a,(is.pfx.IXY)\r
+       and a\r
+       ld a,006h\r
+       jr z,l2533h\r
+       ld hl,b_0x2538_start\r
+       ld a,(is.pfx.IXY)\r
+       dec a\r
+       jr z,l250ch\r
+       ld hl,b_0x253B_start\r
 l250ch:\r
-       call PSTR               ;250c\r
-       comst                   ;250f\r
-       ld a,(iy+001h)          ;2513\r
+       call PSTR\r
+       comst\r
+       ld a,(iy+001h)\r
        comend\r
-       and a                   ;2516\r
-       push af                 ;2517\r
-       jp m,l2523h             ;2518\r
-       ld a,'+'                ;251b\r
-       call OUTCHAR            ;251d\r
-       pop af                  ;2520\r
-       jr l252bh               ;2521\r
+       and a\r
+       push af\r
+       jp m,l2523h\r
+       ld a,'+'\r
+       call OUTCHAR\r
+       pop af\r
+       jr l252bh\r
 l2523h:\r
-       ld a,'-'                ;2523\r
-       call OUTCHAR            ;2525\r
-       pop af                  ;2528\r
-       neg                     ;2529\r
+       ld a,'-'\r
+       call OUTCHAR\r
+       pop af\r
+       neg\r
 l252bh:\r
-       call out.hex            ;252b\r
-       ld a,')'                ;252e\r
-       jp OUTCHAR              ;2530\r
+       call out.hex\r
+       ld a,')'\r
+       jp OUTCHAR\r
 l2533h:\r
-       ld hl,t_BCDEHL_HL_A     ;2533\r
-       jr l2572h               ;2536\r
+       ld hl,t_BCDEHL_HL_A\r
+       jr l2572h\r
 \r
 b_0x2538_start:\r
        DC      '(IX'\r
@@ -5527,55 +5545,55 @@ b_0x253B_start:
        DC      '(IY'\r
 \r
 l253eh:\r
-       ld a,(is.pfx.IXY)               ;253e\r
-       ld hl,t_HL.IX.IY        ;2541\r
-       jr l2572h               ;2544\r
+       ld a,(is.pfx.IXY)\r
+       ld hl,t_HL.IX.IY\r
+       jr l2572h\r
 l2546h:\r
-       ld hl,t_BC.DE.HL.AF     ;2546\r
-       jr l254eh               ;2549\r
+       ld hl,t_BC.DE.HL.AF\r
+       jr l254eh\r
 l254bh:\r
-       ld hl,t_BC.DE.HL.SP     ;254b\r
+       ld hl,t_BC.DE.HL.SP\r
 l254eh:\r
-       comst                   ;254e\r
-       ld a,(iy+000h)          ;2552\r
+       comst\r
+       ld a,(iy+000h)\r
        comend\r
-       rra                     ;2555\r
-       rra                     ;2556\r
-       rra                     ;2557\r
-       rra                     ;2558\r
-       and 003h                ;2559\r
-       cp 002h                 ;255b\r
-       jr z,l253eh             ;255d\r
-       jr l2572h               ;255f\r
+       rra\r
+       rra\r
+       rra\r
+       rra\r
+       and 003h\r
+       cp 002h\r
+       jr z,l253eh\r
+       jr l2572h\r
 l2561h:\r
-       comst                   ;2561\r
-       ld a,(iy+000h)          ;2565\r
+       comst\r
+       ld a,(iy+000h)\r
        comend\r
 sub_2568h:\r
-       rra                     ;2568\r
-       rra                     ;2569\r
-       rra                     ;256a\r
-       and 007h                ;256b\r
-       ld hl,t_tstfl_ZCPS      ;256d\r
-       jr l2572h               ;2570\r
+       rra\r
+       rra\r
+       rra\r
+       and 007h\r
+       ld hl,t_tstfl_ZCPS\r
+       jr l2572h\r
 l2572h:\r
-       ld b,a                  ;2572\r
-       call sub_0a48h          ;2573\r
-       jp PSTR                 ;2576\r
+       ld b,a\r
+       call sub_0a48h\r
+       jp PSTR\r
 sub_2579h:\r
-       call l23dbh             ;2579\r
+       call l23dbh\r
 sub_257ch:\r
-       ld a,','                ;257c\r
-       jp OUTCHAR              ;257e\r
+       ld a,','\r
+       jp OUTCHAR\r
 sub_2581h:\r
-       call PSTR               ;2581\r
+       call PSTR\r
 l2584h:\r
-       call OUTBL              ;2584\r
-       inc c                   ;2587\r
-       ld a,c                  ;2588\r
-       cp 006h                 ;2589\r
-       jr nz,l2584h            ;258b\r
-       ret                     ;258d\r
+       call OUTBL\r
+       inc c\r
+       ld a,c\r
+       cp 006h\r
+       jr nz,l2584h\r
+       ret\r
 \r
 t_MNEMONICS:\r
        DC      'ADC'\r
@@ -5656,7 +5674,7 @@ t_MNEMONICS:
        DC      'TST'\r
        DC      'TSTIO'\r
        DB      0\r
-       \r
+\r
 t_BCDEHL_HL_A:\r
        DC      'B'\r
        DC      'C'\r
@@ -5729,563 +5747,491 @@ t__C_:
        DB      0\r
 \r
 sub_26e7h:\r
-       ld hl,(REG.PC)          ;26e7\r
-       ld a,h                  ;26ea\r
-       or l                    ;26eb\r
-       jr z,l2715h             ;26ec\r
-       ld iy,(REG.PC)          ;26ee\r
-       call sub_1f9eh          ;26f2\r
-       jp nc,ERROR             ;26f5\r
-       ld c,b                  ;26f8\r
-       ld b,000h               ;26f9\r
-       ld hl,(REG.PC)          ;26fb\r
-       add hl,bc               ;26fe\r
-       call sub_1117h          ;26ff\r
-       ld iy,(REG.PC)          ;2702\r
-       ld hl,b_0x2717_start    ;2706\r
-       call lookup_opc         ;2709\r
-       ccf                     ;270c\r
-       ret c                   ;270d\r
-       ex de,hl                ;270e\r
-       call CALL.HL            ;270f\r
-       call c,sub_1117h        ;2712\r
+       ld hl,(REG.PC)\r
+       ld a,h\r
+       or l\r
+       jr z,l2715h\r
+       ld iy,(REG.PC)\r
+       call sub_1f9eh\r
+       jp nc,ERROR\r
+       ld c,b\r
+       ld b,000h\r
+       ld hl,(REG.PC)\r
+       add hl,bc\r
+       call sub_1117h\r
+       ld iy,(REG.PC)\r
+       ld hl,b_0x2717_start\r
+       call lookup_opc\r
+       ccf\r
+       ret c\r
+       ex de,hl\r
+       call CALL.HL\r
+       call c,sub_1117h\r
 l2715h:\r
-       scf                     ;2715\r
-       ret                     ;2716\r
+       scf\r
+       ret\r
 \r
 b_0x2717_start:\r
-       db      0ffh            ;2717\r
-       db      0ddh            ;2718\r
-       db      000h            ;2719\r
+       db      0ffh\r
+       db      0ddh\r
+       db      000h\r
        dw      x278d\r
 \r
-       db      0ffh            ;271c\r
-       db      0fdh            ;271d\r
-       db      000h            ;271e\r
+       db      0ffh\r
+       db      0fdh\r
+       db      000h\r
        dw      x2792\r
 \r
-       db      0ffh            ;2721\r
-       db      0edh            ;2722\r
-       db      000h            ;2723\r
+       db      0ffh\r
+       db      0edh\r
+       db      000h\r
        dw      x27a2\r
 \r
 l2726h:\r
-       db      0ffh            ;2726\r
-       db      0cdh            ;2727\r
-       db      000h            ;2728\r
+       db      0ffh\r
+       db      0cdh\r
+       db      000h\r
        dw      x275e\r
 \r
-       db      0ffh            ;272b\r
-       db      0c3h            ;272c\r
-       db      000h            ;272d\r
+       db      0ffh\r
+       db      0c3h\r
+       db      000h\r
        dw      x2769\r
 \r
-       db      0ffh            ;2730\r
-       db      0e9h            ;2731\r
-       db      000h            ;2732\r
+       db      0ffh\r
+       db      0e9h\r
+       db      000h\r
        dw      x2788\r
 \r
-       db      0ffh            ;2735\r
-       db      0c9h            ;2736\r
-       db      000h            ;2737\r
+       db      0ffh\r
+       db      0c9h\r
+       db      000h\r
        dw      x27c9\r
 \r
-       db      0ffh            ;273a\r
-       db      0cfh            ;273b\r
-       db      000h            ;273c\r
+       db      0ffh\r
+       db      0cfh\r
+       db      000h\r
        dw      x280e\r
 \r
-       db      0c7h            ;273f\r
-       db      0c7h            ;2740\r
-       db      000h            ;2741\r
+       db      0c7h\r
+       db      0c7h\r
+       db      000h\r
        dw      x27ea\r
 \r
-       db      0c7h            ;2744\r
-       db      0c4h            ;2745\r
-       db      000h            ;2746\r
+       db      0c7h\r
+       db      0c4h\r
+       db      000h\r
        dw      x275e\r
 \r
-       db      0f7h            ;2749\r
-       db      010h            ;274a\r
-       db      000h            ;274b\r
+       db      0f7h\r
+       db      010h\r
+       db      000h\r
        dw      x2775\r
 \r
-       db      0e7h            ;274e\r
-       db      020h            ;274f\r
-       db      000h            ;2750\r
+       db      0e7h\r
+       db      020h\r
+       db      000h\r
        dw      x2775\r
 \r
-       db      0c7h            ;2753\r
-       db      0c2h            ;2754\r
-       db      000h            ;2755\r
+       db      0c7h\r
+       db      0c2h\r
+       db      000h\r
        dw      x2769\r
 \r
-       db      0c7h            ;2758\r
-       db      0c0h            ;2759\r
-       db      000h            ;275a\r
+       db      0c7h\r
+       db      0c0h\r
+       db      000h\r
        dw      x27b3\r
 \r
-       db      000h            ;275d\r
+       db      000h\r
 \r
 x275e:\r
-       ld a,(XBFE8)            ;275e\r
-       and a                   ;2761\r
-       jr nz,x2769             ;2762\r
-       ld a,(TCFLG)            ;2764\r
-       and a                   ;2767\r
-       ret nz                  ;2768\r
+       ld a,(XBFE8)\r
+       and a\r
+       jr nz,x2769\r
+       ld a,(TCFLG)\r
+       and a\r
+       ret nz\r
 \r
 x2769:\r
-       comst                   ;2769\r
-       ld l,(iy+001h)          ;276d\r
-       ld h,(iy+002h)          ;2770\r
+       comst\r
+       ld l,(iy+001h)\r
+       ld h,(iy+002h)\r
        comend\r
-       scf                     ;2773\r
-       ret                     ;2774\r
+       scf\r
+       ret\r
 \r
 x2775:\r
-       comst                   ;2775\r
-       ld c,(iy+001h)          ;2779\r
+       comst\r
+       ld c,(iy+001h)\r
        comend\r
-       ld a,c                  ;277c\r
-       rla                     ;277d\r
-       sbc a,a                 ;277e\r
-       ld b,a                  ;277f\r
-       ld hl,(REG.PC)          ;2780\r
-       add hl,bc               ;2783\r
-       inc hl                  ;2784\r
-       inc hl                  ;2785\r
-       scf                     ;2786\r
-       ret                     ;2787\r
+       ld a,c\r
+       rla\r
+       sbc a,a\r
+       ld b,a\r
+       ld hl,(REG.PC)\r
+       add hl,bc\r
+       inc hl\r
+       inc hl\r
+       scf\r
+       ret\r
 \r
 x2788:\r
-       ld hl,(REG.L)           ;2788\r
-       scf                     ;278b\r
-       ret                     ;278c\r
+       ld hl,(REG.L)\r
+       scf\r
+       ret\r
 \r
 x278d:\r
-       ld hl,(reg.ix)          ;278d\r
-       jr l2795h               ;2790\r
+       ld hl,(reg.ix)\r
+       jr l2795h\r
 \r
 x2792:\r
-       ld hl,(reg.iy)          ;2792\r
+       ld hl,(reg.iy)\r
 l2795h:\r
-       comst                   ;2795\r
-       ld a,(iy+001h)          ;2799\r
+       comst\r
+       ld a,(iy+001h)\r
        comend\r
-       cp 0e9h                 ;279c\r
-       scf                     ;279e\r
-       ret z                   ;279f\r
-       and a                   ;27a0\r
-       ret                     ;27a1\r
+       cp 0e9h\r
+       scf\r
+       ret z\r
+       and a\r
+       ret\r
 \r
 x27a2:\r
-       comst                   ;27a2\r
-       ld a,(iy+001h)          ;27a6\r
+       comst\r
+       ld a,(iy+001h)\r
        comend\r
-       cp 04dh                 ;27a9\r
-       jr z,x27c9              ;27ab\r
-       cp 045h                 ;27ad\r
-       jr z,x27c9              ;27af\r
-       and a                   ;27b1\r
-       ret                     ;27b2\r
+       cp 04dh\r
+       jr z,x27c9\r
+       cp 045h\r
+       jr z,x27c9\r
+       and a\r
+       ret\r
 \r
 x27b3:\r
-       comst                   ;27b3\r
-       ld a,(iy+000h)          ;27b7\r
+       comst\r
+       ld a,(iy+000h)\r
        comend\r
-       ld (XBEDD),a            ;27ba\r
-       ld hl,(REG.F)           ;27bd\r
-       push hl                 ;27c0\r
-       pop af                  ;27c1\r
-       call XBEDD              ;27c2\r
-       scf                     ;27c5\r
-       jr c,x27c9              ;27c6\r
-       ret                     ;27c8\r
+       ld (XBEDD),a\r
+       ld hl,(REG.F)\r
+       push hl\r
+       pop af\r
+       call XBEDD\r
+       scf\r
+       jr c,x27c9\r
+       ret\r
 \r
 x27c9:\r
-       ld a,(XBFE8)            ;27c9\r
-       and a                   ;27cc\r
-       jr nz,l27dah            ;27cd\r
-       ld a,(TCFLG)            ;27cf\r
-       and a                   ;27d2\r
-       jr z,l27dah             ;27d3\r
-       call l27dah             ;27d5\r
-       pop hl                  ;27d8\r
-       ret                     ;27d9\r
+       ld a,(XBFE8)\r
+       and a\r
+       jr nz,l27dah\r
+       ld a,(TCFLG)\r
+       and a\r
+       jr z,l27dah\r
+       call l27dah\r
+       pop hl\r
+       ret\r
 l27dah:\r
-       ld hl,(REG.SP)          ;27da\r
-       comst                   ;27dd\r
-       ld e,(hl)               ;27e1\r
-       inc hl                  ;27e2\r
-       ld d,(hl)               ;27e3\r
+       ld hl,(REG.SP)\r
+       comst\r
+       ld e,(hl)\r
+       inc hl\r
+       ld d,(hl)\r
        comend\r
-       ex de,hl                ;27e4\r
-       call sub_1117h          ;27e5\r
-       and a                   ;27e8\r
-       ret                     ;27e9\r
+       ex de,hl\r
+       call sub_1117h\r
+       and a\r
+       ret\r
 \r
 x27ea:\r
-       ld a,(ddtrst)           ;27ea\r
-       comst                   ;27ed\r
-       cp (iy+000h)            ;27f1\r
+       ld a,(ddtzrst)\r
+       comst\r
+       cp (iy+000h)\r
        comend\r
-       ret z                   ;27f4\r
-       comst                   ;27f5\r
-       ld a,(iy+000h)          ;27f9\r
+       ret z\r
+       comst\r
+       ld a,(iy+000h)\r
        comend\r
-       and 038h                ;27fc\r
-       ld l,a                  ;27fe\r
-       ld h,000h               ;27ff\r
-       ld a,(XBFE8)            ;2801\r
-       and a                   ;2804\r
-       jr nz,l280ch            ;2805\r
-       ld a,(TCFLG)            ;2807\r
-       and a                   ;280a\r
-       ret nz                  ;280b\r
+       and 038h\r
+       ld l,a\r
+       ld h,000h\r
+       ld a,(XBFE8)\r
+       and a\r
+       jr nz,l280ch\r
+       ld a,(TCFLG)\r
+       and a\r
+       ret nz\r
 l280ch:\r
-       scf                     ;280c\r
-       ret                     ;280d\r
+       scf\r
+       ret\r
 \r
 x280e:\r
-       and a                   ;280e\r
-       ret                     ;280f\r
+       and a\r
+       ret\r
 \r
 CMD.C:\r
-       ld hl,CMD.C             ;2810\r
-       ld a,001h               ;2813\r
-       jr l281bh               ;2815\r
+       ld hl,CMD.C\r
+       ld a,001h\r
+       jr l281bh\r
 \r
 CMD.T:\r
-       xor a                   ;2817\r
-       ld hl,CMD.T             ;2818\r
+       xor a\r
+       ld hl,CMD.T\r
 l281bh:\r
-       ld (CMD_RPT),hl         ;281b\r
-       ld (TCFLG),a            ;281e\r
-       ld a,(de)               ;2821\r
-       sub 'N'                 ;2822\r
-       jr nz,l2827h            ;2824\r
-       inc de                  ;2826\r
+       ld (CMD_RPT),hl\r
+       ld (TCFLG),a\r
+       ld a,(de)\r
+       sub 'N'\r
+       jr nz,l2827h\r
+       inc de\r
 l2827h:\r
-       ld (TCNFLG),a           ;2827\r
-       ld a,(de)               ;282a\r
-       sub 'J'                 ;282b\r
-       jr nz,l2830h            ;282d\r
-       inc de                  ;282f\r
+       ld (TCNFLG),a\r
+       ld a,(de)\r
+       sub 'J'\r
+       jr nz,l2830h\r
+       inc de\r
 l2830h:\r
-       ld (TRJFLG),a           ;2830\r
-       call sub_289fh          ;2833\r
-       jr z,l283eh             ;2836\r
-       ld hl,1                 ;2838\r
-       call get_lastarg_def    ;283b\r
+       ld (TRJFLG),a\r
+       call sub_289fh\r
+       jr z,l283eh\r
+       ld hl,1\r
+       call get_lastarg_def\r
 l283eh:\r
-       ld (TCCSTR),hl          ;283e\r
-       sub a                   ;2841\r
-       ld (XA747),a            ;2842\r
+       ld (TCCSTR),hl\r
+       sub a\r
+       ld (XA747),a\r
 l2845h:\r
-       call sub_26e7h          ;2845\r
-       jr l289ch               ;2848\r
+       call sub_26e7h\r
+       jr l289ch\r
 l284ah:\r
-       call sub_0e68h          ;284a\r
-       ld a,(TRJFLG)           ;284d\r
-       and a                   ;2850\r
-       jr nz,l2864h            ;2851\r
-       ld iy,(REG.PC)          ;2853\r
-       call sub_28c1h          ;2857\r
-       jr z,l2864h             ;285a\r
-       ld hl,l2726h            ;285c\r
-       call lookup_opc         ;285f\r
-       jr nc,l2845h            ;2862\r
+       call sub_0e68h\r
+       ld a,(TRJFLG)\r
+       and a\r
+       jr nz,l2864h\r
+       ld iy,(REG.PC)\r
+       call sub_28c1h\r
+       jr z,l2864h\r
+       ld hl,l2726h\r
+       call lookup_opc\r
+       jr nc,l2845h\r
 l2864h:\r
-       ld a,(XBFEA)            ;2864\r
-       and a                   ;2867\r
-       jr z,l2881h             ;2868\r
-       ld de,(TCCSTR)          ;286a\r
-       call EXPR               ;286e\r
-       ld a,h                  ;2871\r
-       or l                    ;2872\r
-       add a,0ffh              ;2873\r
-       sbc a,a                 ;2875\r
-       ld hl,XBFEA             ;2876\r
-       xor (hl)                ;2879\r
-       bit 1,a                 ;287a\r
-       jr z,l288ch             ;287c\r
+       ld a,(XBFEA)\r
+       and a\r
+       jr z,l2881h\r
+       ld de,(TCCSTR)\r
+       call EXPR\r
+       ld a,h\r
+       or l\r
+       add a,0ffh\r
+       sbc a,a\r
+       ld hl,XBFEA\r
+       xor (hl)\r
+       bit 1,a\r
+       jr z,l288ch\r
 l287eh:\r
-       jp l102eh               ;287e\r
+       jp l102eh\r
 l2881h:\r
-       ld hl,(TCCSTR)          ;2881\r
-       dec hl                  ;2884\r
-       ld (TCCSTR),hl          ;2885\r
-       ld a,h                  ;2888\r
-       or l                    ;2889\r
-       jr z,l287eh             ;288a\r
+       ld hl,(TCCSTR)\r
+       dec hl\r
+       ld (TCCSTR),hl\r
+       ld a,h\r
+       or l\r
+       jr z,l287eh\r
 l288ch:\r
-       call sub_26e7h          ;288c\r
-       jr nc,l287eh            ;288f\r
-       ld a,(TCNFLG)           ;2891\r
-       ld b,a                  ;2894\r
-       ld a,(XA747)            ;2895\r
-       or b                    ;2898\r
-       ld (XA747),a            ;2899\r
+       call sub_26e7h\r
+       jr nc,l287eh\r
+       ld a,(TCNFLG)\r
+       ld b,a\r
+       ld a,(XA747)\r
+       or b\r
+       ld (XA747),a\r
 l289ch:\r
-       jp l1183h               ;289c\r
+       jp l1183h\r
 \r
 sub_289fh:\r
-       call SKIPBL             ;289f\r
-       xor a                   ;28a2\r
-       ld (XBFEA),a            ;28a3\r
-       ld a,(de)               ;28a6\r
-       cp 'U'                  ;28a7\r
-       jr z,l28aeh             ;28a9\r
-       cp 'W'                  ;28ab\r
-       ret nz                  ;28ad\r
+       call SKIPBL\r
+       xor a\r
+       ld (XBFEA),a\r
+       ld a,(de)\r
+       cp 'U'\r
+       jr z,l28aeh\r
+       cp 'W'\r
+       ret nz\r
 \r
 l28aeh:\r
-       inc de                  ;28ae\r
-       push af                 ;28af\r
-       push de                 ;28b0\r
-       call EXPR               ;28b1\r
-       jp c,ERROR              ;28b4\r
-       call assert_eol         ;28b7\r
-       pop hl                  ;28ba\r
-       pop af                  ;28bb\r
-       ld (XBFEA),a            ;28bc\r
-       sub a                   ;28bf\r
-       ret                     ;28c0\r
+       inc de\r
+       push af\r
+       push de\r
+       call EXPR\r
+       jp c,ERROR\r
+       call assert_eol\r
+       pop hl\r
+       pop af\r
+       ld (XBFEA),a\r
+       sub a\r
+       ret\r
 \r
 sub_28c1h:\r
-       comst           \r
-       ld a,(iy+000h)  \r
+       comst\r
+       ld a,(iy+000h)\r
        ld b,(iy+0001)\r
        comend\r
-       cp 0edh         \r
-       jr z,l28dbh     \r
-       and 0dfh        \r
-       cp 0ddh         \r
-       ret nz          \r
+       cp 0edh\r
+       jr z,l28dbh\r
+       and 0dfh\r
+       cp 0ddh\r
+       ret nz\r
        ld a,b\r
-       cp 0e9h         \r
-       ret             \r
+       cp 0e9h\r
+       ret\r
 l28dbh:\r
        ld a,b\r
-       and 0f7h        \r
-       cp 045h         \r
-       ret             \r
+       and 0f7h\r
+       cp 045h\r
+       ret\r
 \r
 ?excom:\r
-       ex (sp),hl              ;28e7\r
-       push af                 ;28e8\r
-       push bc                 ;28e9\r
-       push de                 ;28ea\r
-       ld c,(hl)               ;28eb\r
-       ld b,000h               ;28ec\r
-       inc hl                  ;28ee\r
+       ex (sp),hl\r
+       push af\r
+       push bc\r
+       push de\r
+       ld c,(hl)\r
+       ld b,000h\r
+       inc hl\r
        ld a,?lcmax\r
        sub c\r
-       ld de,?exeit            ;28ef\r
+       ld de,?exeit\r
        ldir\r
        ex de,hl\r
        ld (hl),018h\r
        inc hl\r
        ld (hl),a\r
        ex de,hl\r
-       pop de                  ;28f7\r
-       pop bc                  ;28f8\r
-       pop af                  ;28f9\r
-       ex (sp),hl              ;28fa\r
-?exclst:\r
-       push hl                 ;28fb\r
-       ld hl,(ubbr)            ;2900\r
+       pop de\r
+       pop bc\r
+       pop af\r
+       ex (sp),hl\r
+       if CPU_Z180\r
+       push hl\r
+       ld hl,(ubbr)\r
 \r
+       else\r
+        push af\r
+        ld a,(ubnk)\r
+       endif\r
        if ROMSYS\r
-        push af                ;28fc\r
-        ld a,(uromen)          ;28fd\r
+        push af\r
+        ld a,(uromen)\r
        endif\r
-       jp ?comcod              ;2903\r
-       \r
+       jp ?comcod\r
+\r
 ;------------------------------------------\r
 ;      ddtram\r
 ;------------------------------------------\r
 \r
 vartab:\r
-       dseg\r
-ddtram:                                \r
+;      dseg\r
+       cseg\r
+ddtram:\r
 ;todo:\r
 ; The following 2 params are changeable by user.\r
 ; Should these moved to top ram?\r
 ;\r
-ddtrst:        inidat                  ;\r
-       rst     DRSTNUM         ;rst used by ddtz\r
-       inidate                 ;\r
-ddtei: inidat                  ;\r
-       ei                      ;ints enabled/disabled while ddtz is running\r
+ddtzrst:\r
+       rst     DDTZRSTVEC      ;rst used by ddtz\r
+ddtei: ei                      ;ints enabled/disabled while ddtz is running\r
        ret                     ;\r
-       inidate                 ;\r
 offs.pc:\r
-       inidat  \r
-       dw      TPA     \r
-       inidate\r
+       dw      TPA\r
 offs.@:\r
-       inidat\r
-       dw      0       \r
-       inidate\r
+       dw      0\r
 CMD_ERR:\r
-       inidat\r
-       dw      0       \r
-       inidate\r
+       dw      0\r
 CMD_RPT:\r
-       inidat\r
-       dw      DDTZML  \r
-       inidate\r
+       dw      DDTZML\r
 ci.buf:\r
-       inidat\r
-       db      80      \r
+       db      80\r
        rept    83\r
        db      0\r
        endm\r
-       inidate\r
 CON.COL:\r
-       inidat\r
-       db      0       \r
-       inidate\r
+       db      0\r
 XA747:\r
-       inidat\r
-       db      0       \r
-       inidate\r
+       db      0\r
 bp_tab:\r
-       inidat\r
-       rept    BP_CNT  \r
+       rept    BP_CNT\r
        db      0,0\r
        dw      0,0,0\r
        endm\r
 BP_SIZE        equ     8\r
-       inidate\r
 sexp1:\r
-       inidat\r
-       dw      sexpbuf \r
-       inidate\r
+       dw      sexpbuf\r
 sexp2:\r
-       inidat\r
-       dw      sexpbuf \r
-       inidate\r
+       dw      sexpbuf\r
 sexpbuf:\r
-       inidat\r
-       rept    128     \r
+       rept    128\r
        db      0\r
        endm\r
-       inidate\r
 sexpbufe:\r
 \r
 msg.Y:\r
-       inidat\r
-       dc      'Y0'    \r
-       inidate\r
+       dc      'Y0'\r
 reg.Y:\r
-       inidat\r
-       rept    10      \r
+       rept    10\r
        dw      0\r
        endm\r
-       inidate\r
 lst.S:\r
-       inidat\r
-       dw      0       \r
-       inidate\r
+       dw      0\r
 lst.IP:\r
-       inidat\r
-       dw      0       \r
-       inidate\r
+       dw      0\r
 lst.OP:\r
-       inidat\r
-       dw      0       \r
-       inidate\r
+       dw      0\r
 lst.OD:\r
-       inidat\r
        db      0\r
-       inidate\r
 lst.Qj:\r
-       inidat\r
        db      0\r
-       inidate\r
 lst.D:\r
-       inidat\r
-       dw      0       \r
-       inidate\r
+       dw      0\r
 HILOD:\r
-       inidat\r
-       dw      0       \r
-       inidate\r
+       dw      0\r
 MAXLOD:\r
-       inidat\r
-       dw      0       \r
-       inidate\r
+       dw      0\r
 XB068:\r
-       inidat\r
-       dw      0       \r
-       inidate\r
+       dw      0\r
 lst.A:\r
-       inidat\r
-       dw      0       \r
-       inidate\r
+       dw      0\r
 XB06C:\r
-       inidat\r
-       dw      0       \r
-       inidate\r
+       dw      0\r
 pfx.IXY:\r
-       inidat\r
-       db      000h    \r
-       inidate\r
+       db      000h\r
 is.pfx.IXY:\r
-       inidat\r
-       db      000h    \r
-       inidate\r
+       db      000h\r
 lst.L:\r
-       inidat\r
-       dw      0       \r
-       inidate\r
+       dw      0\r
 XBE01:\r
-       inidat\r
-       dw      0       \r
-       inidate\r
+       dw      0\r
 XBE03:\r
-       inidat\r
-       db      000h    \r
-       inidate\r
+       db      000h\r
 XBEDD:\r
-       inidat\r
        ret             ;ret cc\r
-       and a           \r
-       pop hl          \r
-       inc hl          \r
-       jp (hl)         \r
-       inidate\r
+       and a\r
+       pop hl\r
+       inc hl\r
+       jp (hl)\r
 XBFE8:\r
-       inidat\r
-       db      0       \r
-       inidate\r
+       db      0\r
 TCFLG:\r
-       inidat\r
-       db      0       \r
-       inidate\r
+       db      0\r
 XBFEA:\r
-       inidat\r
-       db      0       \r
-       inidate\r
+       db      0\r
 TCCSTR:\r
-       inidat\r
-       dw      0       \r
-       inidate\r
+       dw      0\r
 TCNFLG:\r
-       inidat\r
-       db      0       \r
-       inidate\r
+       db      0\r
 TRJFLG:\r
-       inidat\r
-       db      0       \r
-       inidate\r
+       db      0\r
 wstrtflg:\r
-       inidat\r
        db      1\r
-       inidate\r
 \r
        cseg\r
 vartabe:\r
@@ -6322,8 +6268,13 @@ reg.b:   db      0               ; 0fe61h
 udcntl:         db     CWAITIO         ; 0fe62h        (mem-, io- wait)\r
 uromen:         db     ROM_DIS         ; 0fe63h\r
        endif\r
+       if CPU_Z180\r
 ubbr:  db      0               ; 0fe64h\r
 ucbar: db      USR$CBAR        ; 0fe65h\r
+       else\r
+        db     0               ; 0fe64h\r
+ubnk:   db     0               ; 0fe65h\r
+       endif\r
 reg.f: db      0               ; 0fe66h\r
 reg.a: db      0               ; 0fe67h\r
 reg.l: db      0               ; 0fe68h\r
@@ -6333,68 +6284,93 @@ reg.sp: dw      TOPRAM          ; 0fe6ah
 $go:\r
        if      ROMSYS\r
         out (000h),a           ;064c fe6c\r
-        out0 (dcntl),l         ;064e\r
-        pop hl                 ;0651\r
+        out0 (dcntl),l\r
+        pop hl\r
+       endif\r
+       if CPU_Z180\r
+       out0 (cbar),h\r
+       out0 (bbr),l\r
+       else\r
+        ld a,h\r
+        call selbnk\r
        endif\r
-       out0 (cbar),h           ;0652\r
-       out0 (bbr),l            ;0655\r
-       pop af                  ;0658\r
-       pop hl                  ;0659\r
-       ld sp,(reg.sp)          ;065a\r
+       pop af\r
+       pop hl\r
+       ld sp,(reg.sp)\r
 reg.iff:\r
-       ei                      ;065e\r
+       ei\r
        db      0C3h            ;jp TPA ;065f feff ($+1): reg.pc\r
 reg.pc:\r
        dw      TPA\r
-                               \r
+\r
 bpent:\r
        ld (reg.l),hl           ;0662 fe82: bpent:\r
-       pop hl                  ;0665\r
-       dec hl                  ;0666\r
-       ld (reg.pc),hl          ;0667\r
-       ld (reg.sp),sp          ;066a\r
-       ld sp,reg.l             ;066e\r
-       push af                 ;0671\r
-       in0 h,(cbar)            ;0672\r
-       in0 l,(bbr)             ;0675\r
-       push hl                 ;0678\r
-       ld a,SYS$CBAR           ;0679\r
-       out0 (cbar),a           ;067b\r
+       pop hl\r
+       dec hl\r
+       ld (reg.pc),hl\r
+       ld (reg.sp),sp\r
+       ld sp,reg.l\r
+       push af\r
+       if CPU_Z180\r
+;;;     TODO: cbar on trap?\r
+       in0 h,(cbar)\r
+       in0 l,(bbr)\r
+       ld a,SYS$CBAR\r
+       out0 (cbar),a\r
+       else\r
+        ld a,(@cbnk)\r
+        ld h,a\r
+        xor a\r
+        ld l,a\r
+        call selbnk\r
+       endif\r
+        push hl\r
 \r
        if ROMSYS\r
-        in0 l,(dcntl)          ;067e\r
-        ld a,CWAITROM+CWAITIO  ;0681\r
-        out0 (dcntl),a         ;0683\r
-        ld a,($crom)           ;0686\r
-        cp c$rom               ;0689\r
-        ld a,ROM_EN            ;068b\r
-        out (000h),a           ;068d\r
+        in0 l,(dcntl)\r
+        ld a,CWAITROM+CWAITIO\r
+        out0 (dcntl),a\r
+        ld a,($crom)\r
+        cp c$rom\r
+        ld a,ROM_EN\r
+        out (000h),a\r
        endif\r
 \r
-       jp bpddtz               ;068f\r
+       jp bpddtz\r
 \r
 ?comcod:\r
        if ROMSYS\r
         out (000h),a           ;0692 feb2\r
-        pop af                 ;069a\r
+        pop af\r
        endif\r
 \r
-       out0 (cbar),h           ;0694\r
-       out0 (bbr),l            ;0697\r
-       pop hl                  ;069b\r
+       if CPU_Z180\r
+       out0 (cbar),h\r
+       out0 (bbr),l\r
+       pop hl\r
+       else\r
+        call selbnk\r
+        pop af\r
+       endif\r
 ?exeit:\r
        ds ?lcmax+2\r
-       push af                 ;069f\r
-       ld a,SYS$CBAR           ;06a0\r
-       out0 (cbar),a           ;06a2\r
+       push af\r
+       if CPU_Z180\r
+       ld a,SYS$CBAR\r
+       out0 (cbar),a\r
 \r
+;;;     TODO: bbr?\r
+       else\r
+        xor a\r
+        call selbnk\r
+       endif\r
        if ROMSYS\r
-        ld a,ROM_EN            ;06a5\r
-        out (000h),a           ;06a7\r
+        ld a,ROM_EN\r
+        out (000h),a\r
        endif\r
-       \r
-       pop af                  ;06a9\r
-       ret                     ;06aa\r
+\r
+       pop af\r
+       ret\r
 \r
 topcodend:\r
 curph  defl    $\r
@@ -6402,4 +6378,3 @@ curph     defl    $
 sysrame:\r
 \r
        end\r
-\r
index dd99c53500a1876ccc62f21d6111115d57f4a20d..cbcece9152635a5d309ac41dda8fff3783861c5f 100644 (file)
@@ -1,6 +1,6 @@
        page    255\r
        .z80\r
-       \r
+\r
 ;\r
 ; FIFO channels for communication with stm32\r
 ;\r
 ;--------------------------------------------------------------\r
 \r
        dseg\r
-       \r
 \r
-       mkbuf   rx.buf,rx.buf_len\r
-       mkbuf   tx.buf,tx.buf_len\r
+\r
+       mkbuf   ci.fifo_id, rx.buf,rx.buf_len\r
+       mkbuf   co.fifo_id, tx.buf,tx.buf_len\r
 \r
 \r
 ;--------------------------------------------------------------\r
@@ -48,7 +48,7 @@ buf.empty:
        ret     z\r
        or      0ffh\r
        ret\r
-       \r
+\r
 \r
 f.in:\r
        push    ix\r
@@ -69,12 +69,12 @@ bg.wait:
        inc     h\r
 bg.nc:\r
        ld      l,(hl)\r
-       \r
+\r
        ld      a,(ix+o.out_idx)        ;\r
        inc     a\r
        and     (ix+o.mask)\r
        ld      (ix+o.out_idx),a\r
-       \r
+\r
        ld      a,l\r
        pop     hl\r
        pop     ix\r
@@ -118,7 +118,7 @@ bp.wait:
        jr      z,bp.wait\r
        ld      (hl),b\r
        ld      (ix+o.in_idx),a\r
-       \r
+\r
        ld      a,b\r
        pop     bc\r
        pop     hl\r
@@ -126,4 +126,3 @@ bp.wait:
        ret\r
 \r
        end\r
-\r
diff --git a/z180/init-80.180 b/z180/init-80.180
new file mode 100644 (file)
index 0000000..8b71993
--- /dev/null
@@ -0,0 +1,591 @@
+       page    255\r
+       .z80\r
+\r
+       extrn ddtz,bpent\r
+       extrn $stack\r
+       extrn charini,?const,?conin\r
+       extrn ?cono,?conos\r
+\r
+       extrn romend\r
+\r
+       global  iobyte\r
+       global  isv_sw\r
+\r
+       include config.inc\r
+\r
+\r
+\r
+\r
+;----------------------------------------------------------------------\r
+\r
+       cseg\r
+romstart equ   $\r
+\r
+       org     romstart+0\r
+       jp      start\r
+\r
+iobyte:        db      0\r
+\r
+; restart vectors\r
+\r
+rsti   defl    1\r
+       rept    7\r
+\r
+       org     8*rsti + romstart\r
+        jp bpent\r
+rsti    defl rsti+1\r
+       endm\r
+\r
+;----------------------------------------------------------------------\r
+       \r
+       org     romstart+40h\r
+\r
+       dw      0\r
+       db      0\r
+\r
+       cseg\r
+\r
+       if ROMSYS\r
+$crom:  defb c$rom             ;\r
+       else\r
+        db     0               ;\r
+       endif\r
+\r
+\r
+hwini0:\r
+       db      0               ;count\r
+;      db      rcr,CREFSH      ;configure DRAM refresh\r
+;      db      dcntl,INIWAITS  ;wait states\r
+;      db      cbar,SYS$CBAR\r
+\r
+\r
+;----------------------------------------------------------------------\r
+\r
+       org     romstart+50h\r
+\r
+start:\r
+       jp      cstart\r
+       jp      wstart\r
+       jp      ?const\r
+       jp      ?conin\r
+       jp      ?cono\r
+       jp      ?conos\r
+       jp      charini\r
+\r
+cstart:\r
+       di\r
+\r
+       xor     a\r
+       ld      (@cbnk),a\r
+\r
+; search warm start mark\r
+\r
+       ld ix,mark_55AA         ; top of common area\r
+       ld a,0aah               ;\r
+       cp (ix+000h)            ;\r
+       jr nz,kstart            ;\r
+       cp (ix+002h)            ;\r
+       jr nz,kstart            ;\r
+       cpl                     ;\r
+       cp (ix+001h)            ;\r
+       jr nz,kstart            ;\r
+       cp (ix+003h)            ;\r
+       jr nz,kstart            ;\r
+       ld sp,$stack            ; mark found, check\r
+;      call checkcrc_alv       ;\r
+       jp z,wstart             ; check ok,\r
+\r
+;\r
+; ram not ok, initialize    --  kstart --\r
+\r
+kstart:\r
+       ld      sp,$stack       ;01e1\r
+\r
+; Clear RAM \r
+\r
+; Init bank manager\r
+\r
+;----------------------------------------------------------------------\r
+;\r
+\r
+       ld      hl,055AAh       ;set warm start mark\r
+       ld      (mark_55AA),hl  ;\r
+       ld      (mark_55AA+2),hl;\r
+\r
+;\r
+;       --  wstart  --\r
+;\r
+wstart:\r
+       call    sysram_init     ;027f\r
+       call    ivtab_init\r
+\r
+       call    charini\r
+       call    bufferinit\r
+\r
+       ld      c,0\r
+       call    selbnk\r
+\r
+\r
+       im 2                    ;?030e\r
+       ei                      ;0282\r
+\r
+       call ?const             ;0284\r
+       call ?const             ;0287\r
+       or a                    ;028a\r
+       call nz,?conin          ;028d\r
+\r
+;;;    ld a,(banktab)          ;\r
+;;;    ld e,a                  ;\r
+       jp ddtz                 ;0290\r
+\r
+\r
+;----------------------------------------------------------------------\r
+;\r
+\r
+;TODO: Make a ringbuffer module.\r
+\r
+       global  buf.init\r
+\r
+buf.init:\r
+       ld      (ix+o.in_idx),0\r
+       ld      (ix+o.out_idx),0\r
+       ld      (ix+o.mask),a\r
+       ret\r
+\r
+;----------------------------------------------------------------------\r
+\r
+\r
+       extrn   msginit,msg.sout\r
+       extrn   mtx.fifo,mrx.fifo\r
+       extrn   co.fifo,ci.fifo\r
+\r
+\r
+bufferinit:\r
+       call     msginit\r
+\r
+       ld      hl,buffers\r
+       ld      b,buftablen\r
+bfi_1:\r
+       ld      a,(hl)\r
+       inc     hl\r
+       ld      (bufdat+0),a\r
+       ld      e,(hl)\r
+       inc     hl\r
+       ld      d,(hl)\r
+       inc     hl\r
+       ex      de,hl\r
+\r
+       or      a\r
+       jr      nz,bfi_2\r
+\r
+       ld      a,(@cbnk)\r
+       call    bnk2phys\r
+\r
+       ld      (40h+0),hl\r
+       ld      (40h+2),a\r
+       out     (AVRINT5),a\r
+       jr      bfi_3\r
+bfi_2:\r
+\r
+       ld      a,(@cbnk)\r
+       call    bnk2phys\r
+\r
+       ld      (bufdat+1),hl\r
+       ld      (bufdat+3),a\r
+       ld      hl,inimsg\r
+       call    msg.sout\r
+bfi_3:\r
+       ex      de,hl\r
+       djnz    bfi_1\r
+       ret\r
+\r
+\r
+buffers:\r
+       db      0\r
+       dw      mtx.fifo\r
+       db      1\r
+       dw      mrx.fifo\r
+       db      2\r
+       dw      co.fifo\r
+       db      3\r
+       dw      ci.fifo\r
+buftablen equ  ($ - buffers)/3\r
+\r
+inimsg:\r
+       db      inimsg_e - $ -1\r
+       db      0AEh\r
+       db      inimsg_e - $ -1\r
+       db      0\r
+bufdat:\r
+       db      0\r
+       dw      0\r
+       db      0\r
+inimsg_e:\r
+\r
+\r
+;\r
+;----------------------------------------------------------------------\r
+;\r
+\r
+bnk2phys:\r
+       sla     h\r
+       jr      nc,b2p_1                ;A15=1 --> common\r
+       ld      a,3\r
+b2p_1:\r
+       srl     a\r
+       rr      h\r
+       ret\r
+\r
+;\r
+;----------------------------------------------------------------------\r
+;\r
+\r
+sysram_init:\r
+       ld hl,sysramw\r
+       ld de,topcodsys\r
+       ld bc,sysrame-sysramw\r
+       ldir\r
+\r
+       ret\r
+\r
+;----------------------------------------------------------------------\r
+\r
+ivtab_init:\r
+       ld      hl,ivtab        ;\r
+       ld      a,h             ;\r
+       ld      i,a             ;\r
+;      out0    (il),l          ;\r
+\r
+; Let all vectors point to spurious int routines.\r
+\r
+       ld      d,high sp.int0\r
+       ld      a,low  sp.int0\r
+       ld      b,9\r
+ivt_i1:\r
+       ld      (hl),a\r
+       inc     l\r
+       ld      (hl),d\r
+       inc     l\r
+       add     a,sp.int.len\r
+       djnz    ivt_i1\r
+       ret\r
+\r
+;----------------------------------------------------------------------\r
+;\r
+\r
+       global io.ini\r
+       \r
+io.ini:\r
+       push    bc\r
+\r
+       if CPU_Z180\r
+\r
+       ld      b,0             ;high byte port adress\r
+       ld      a,(hl)          ;count\r
+       inc     hl\r
+       or      a\r
+       jr      z,ioi_e\r
+ioi_1:\r
+       ld      c,(hl)          ;port address\r
+       inc     hl\r
+       outi\r
+       inc     b               ;outi decrements b\r
+       dec     a\r
+       jr      nz,ioi_1\r
+\r
+       else\r
+       jr      ioi_nxt\r
+ioi_l:\r
+       ld      c,(hl)          ;port address\r
+       inc     hl\r
+       otir\r
+ioi_nxt:\r
+       ld      b,(hl)          ;count\r
+       inc     hl\r
+       inc     b\r
+       djnz    ioi_l\r
+       endif\r
+ioi_e: \r
+       pop     bc\r
+       ret\r
+\r
+       if CPU_Z180\r
+io.ini.m:\r
+       push    bc\r
+       ld      b,(hl)\r
+       inc     hl\r
+       ld      c,(hl)\r
+       inc     hl\r
+       otimr\r
+       pop     bc\r
+       ret\r
+       endif\r
+\r
+io.ini.l:\r
+;\r
+\r
+\r
+;----------------------------------------------------------------------\r
+;\r
+;return:\r
+; hl = hl + a\r
+; Flags undefined\r
+;\r
+\r
+add_hl_a:\r
+       add a,l\r
+       ld l,a\r
+       ret nc\r
+       inc h\r
+       ret\r
+\r
+; ---------------------------------------------------------\r
+\r
+sysramw:\r
+\r
+       .phase isvsw_loc\r
+topcodsys:\r
+\r
+; Trampoline for interrupt routines in banked ram.\r
+; Switch stack pointer to "system" stack in top ram\r
+\r
+; todo: z80 bank switch\r
+\r
+isv_sw:                                ;\r
+       ex (sp),hl              ; save hl, return adr in hl\r
+       push de                 ;\r
+       push af                 ;\r
+       ex de,hl                ;\r
+       ld hl,0                 ;\r
+       add hl,sp               ;\r
+       ld a,h                  ;\r
+       cp 0f8h                 ;\r
+       jr nc,isw_1             ;\r
+       ld sp,$stack            ;\r
+isw_1:\r
+       push hl                 ;\r
+                               ; save current bank\r
+;      in0 h,(cbar)            ;\r
+       push hl                 ;\r
+                               ; switch to system bank\r
+;      ld a,SYS$CBAR           ;\r
+;      out0 (cbar),a           ; \r
+       ex de,hl                ;\r
+       ld e,(hl)               ;\r
+       inc hl                  ;\r
+       ld d,(hl)               ;\r
+       ex de,hl                ;\r
+       push bc                 ;\r
+       call jphl               ;\r
+\r
+       pop bc                  ;\r
+       pop hl                  ; restore bank\r
+;      out0 (cbar),h           ;\r
+       pop hl                  ;\r
+       ld sp,hl                ;\r
+       pop af                  ;\r
+       pop de                  ;\r
+       pop hl                  ;\r
+       ei                      ;\r
+       ret                     ;\r
+jphl:\r
+       jp (hl)                 ;\r
+\r
+; ---------------------------------------------------------\r
+\r
+sp.int0:\r
+       ld      a,0d0h\r
+       jr      sp.i.1\r
+sp.int.len equ $-sp.int0\r
+       ld      a,0d1h\r
+       jr      sp.i.1\r
+       ld      a,0d2h\r
+       jr      sp.i.1\r
+       ld      a,0d3h\r
+       jr      sp.i.1\r
+       ld      a,0d4h\r
+       jr      sp.i.1\r
+       ld      a,0d5h\r
+       jr      sp.i.1\r
+       ld      a,0d6h\r
+       jr      sp.i.1\r
+       ld      a,0d7h\r
+       jr      sp.i.1\r
+       ld      a,0d8h\r
+sp.i.1:\r
+;      out     (80h),a\r
+       halt\r
+\r
+; ---------------------------------------------------------\r
+\r
+; Get IFF2\r
+; This routine may not be loaded in page zero\r
+;\r
+; return Carry clear, if INTs are enabled.\r
+;\r
+       global getiff\r
+getiff:\r
+       xor     a               ;clear accu and carry\r
+       push    af              ;stack bottom := 00xxh\r
+       pop     af\r
+       ld      a,i             ;P flag := IFF2\r
+       ret     pe              ;exit carry clear, if enabled\r
+       dec     sp\r
+       dec     sp              ;has stack bottom been overwritten?\r
+       pop     af\r
+       and     a               ;if not 00xxh, INTs were\r
+       ret     nz              ;actually enabled\r
+       scf                     ;Otherwise, they really are disabled\r
+       ret\r
+\r
+;----------------------------------------------------------------------\r
+\r
+       global  selbnk\r
+\r
+; a: bank (0..2)\r
+\r
+selbnk:\r
+       push    bc\r
+       ld      c,a\r
+       call    getiff\r
+       push    af\r
+\r
+       ld      a,c\r
+       di\r
+       ld      (@cbnk),a\r
+       ld      a,5\r
+       out     (SIOAC),a\r
+       ld      a,(mm_sio0)\r
+       rla\r
+       srl     c\r
+       rra\r
+       out     (SIOAC),a\r
+       ld      (mm_sio0),a\r
+\r
+       ld      a,5\r
+       out     (SIOBC),a\r
+       ld      a,(mm_sio1)\r
+       rla\r
+       srl     c\r
+       rra\r
+       out     (SIOBC),a\r
+       ld      (mm_sio1),a\r
+       pop     af\r
+       pop     bc\r
+       ret     c                       ;INTs were disabled\r
+       ei\r
+       ret\r
+\r
+;----------------------------------------------------------------------\r
+\r
+; c: bank (0..2)\r
+\r
+       if 0\r
+\r
+selbnk:\r
+       ld      a,(@cbnk)\r
+       xor     c\r
+       and     3\r
+       ret     z               ;no change\r
+\r
+       call    getiff\r
+       push    af\r
+       ld      a,c\r
+       di\r
+       ld      (@cbnk),a\r
+       ld      a,5\r
+       out     (SIOAC),a\r
+       ld      a,(mm_sio0)\r
+       rla\r
+       srl     c\r
+       rra\r
+       out     (SIOAC),a\r
+       ld      (mm_sio0),a\r
+\r
+       ld      a,5\r
+       out     (SIOBC),a\r
+       ld      a,(mm_sio1)\r
+       rla\r
+       srl     c\r
+       rra\r
+       out     (SIOBC),a\r
+       ld      (mm_sio1),a\r
+       pop     af\r
+       ret     nc                      ;INTs were disabled\r
+       ei\r
+       ret\r
+\r
+       endif\r
+\r
+;----------------------------------------------------------------------\r
+\r
+       if 0\r
+       ex      af,af'\r
+       push    af\r
+       ex      af,af'\r
+\r
+       rra\r
+       jr      nc,stbk1\r
+       ex      af,af'\r
+       ld      a,5\r
+       out     (SIOAC),a\r
+       ld      a,(mm_sio0)\r
+       rla\r
+       srl     c\r
+       rra\r
+       out     (SIOAC),a\r
+       ld      (mm_sio1),a\r
+       ex      af,af'\r
+\r
+stbk1:\r
+       rra\r
+       jr      nc,stbk2\r
+       ex      af,af'\r
+       ld      a,5\r
+       out     (SIOBC),a\r
+       ld      a,(mm_sio1)\r
+       rla\r
+       srl     c\r
+       rra\r
+       out     (SIOBC),a\r
+       ld      (mm_sio1),a\r
+       ex      af,af'\r
+\r
+stbk2:\r
+       endif\r
+\r
+       global  @cbnk\r
+       global  mm_sio0, mm_sio1\r
+\r
+@cbnk: db      0               ; current bank (0..2)\r
+mm_sio0:\r
+       ds      1\r
+mm_sio1:\r
+       ds      1\r
+\r
+;----------------------------------------------------------------------\r
+\r
+curph  defl    $\r
+       .dephase\r
+sysrame:\r
+       .phase curph\r
+tim_ms:        db      0\r
+tim_s: dw      0\r
+       .dephase\r
+\r
+;-----------------------------------------------------\r
+\r
+       cseg\r
+\r
+       ;.phase 0ffc0h\r
+;ivtab equ     0ffc0h          ; 0ffc0h        ;int vector table\r
+       ;.dephase\r
+\r
+       ;.phase 0fffch\r
+mark_55AA equ 0fffch\r
+       ;ds     4               ; 0fffch\r
+       ;.dephase\r
+\r
+\r
+       end\r
+\r
diff --git a/z180/init.180 b/z180/init.180
new file mode 100644 (file)
index 0000000..11f45ec
--- /dev/null
@@ -0,0 +1,950 @@
+       page    255\r
+       .z80\r
+\r
+       extrn ddtz,bpent\r
+       extrn $stack\r
+       extrn charini,?const,?conin\r
+       extrn ?cono,?conos\r
+       extrn romend\r
+\r
+\r
+       global  iobyte\r
+       global  isv_sw\r
+\r
+       include config.inc\r
+    if CPU_Z180\r
+       include z180reg.inc\r
+       include z180.lib\r
+    endif\r
+\r
+\r
+\r
+\r
+;----------------------------------------------------------------------\r
+\r
+       cseg\r
+romstart equ   $\r
+\r
+       org     romstart+0\r
+       jp start\r
+\r
+iobyte:        db      2\r
+\r
+; restart vectors\r
+\r
+rsti   defl    1\r
+       rept    7\r
+       org     8*rsti + romstart\r
+       jp bpent\r
+rsti   defl rsti+1\r
+       endm\r
+\r
+;----------------------------------------------------------------------\r
+; Config space\r
+;\r
+\r
+       org     romstart+40h\r
+\r
+       dw      0\r
+       db      0\r
+\r
+\r
+    if ROMSYS\r
+$crom: defb c$rom              ;\r
+    else\r
+       db      0               ;\r
+    endif\r
+\r
+INIWAITS defl  CWAITIO\r
+    if ROMSYS\r
+INIWAITS defl  INIWAITS+CWAITROM\r
+    endif\r
+\r
+;----------------------------------------------------------------------\r
+\r
+       org     romstart+50h\r
+start:\r
+       jp      cstart\r
+       jp      wstart\r
+       jp      ?const\r
+       jp      ?conin\r
+       jp      ?cono\r
+       jp      ?conos\r
+       jp      charini\r
+\r
+;----------------------------------------------------------------------\r
+\r
+hwini0:\r
+    if CPU_Z180\r
+       db      3               ;count\r
+       db      rcr,CREFSH      ;configure DRAM refresh\r
+       db      dcntl,INIWAITS  ;wait states\r
+       db      cbr,SYS$CBR\r
+       db      cbar,SYS$CBAR\r
+    endif\r
+       db     0\r
+\r
+    if CPU_Z180\r
+dmclrt:                                ;clear ram per dma\r
+       db      dmct_e-dmclrt-2 ;\r
+       db      sar0l           ;first port\r
+       dw      nullbyte        ;src (fixed)\r
+nullbyte:\r
+       db      000h            ;src\r
+       dw      romend          ;dst (inc), start after "rom" code\r
+       db      00h             ;dst\r
+       dw      0-romend        ;count (64k)\r
+dmct_e:\r
+       db      0\r
+    endif\r
+\r
+\r
+cstart:\r
+    if CPU_Z180\r
+\r
+       push af\r
+       in0 a,(itc)             ;Illegal opcode trap?\r
+       jp m,??st01\r
+       ld a,i                  ;I register == 0 ?\r
+       jr z,hw_reset           ;    yes, harware reset\r
+\r
+??st01:\r
+       ; TODO: SYS$CBR\r
+       ld      a,(syscbr)\r
+       out0    (cbr),a\r
+       pop af                  ;restore registers\r
+       jp bpent                ;\r
+\r
+hw_reset:\r
+       di                      ;0058\r
+       ld      a,CREFSH\r
+       out0    (rcr),a         ;       configure DRAM refresh\r
+       ld      a,CWAITIO\r
+       out0    (dcntl),a       ;       wait states\r
+\r
+       ld      a,M_NCD         ;No Clock Divide\r
+       out0    (ccr),a\r
+;      ld      a,M_X2CM        ;X2 Clock Multiplier\r
+;      out0    (cmr),a\r
+    else\r
+       di\r
+       xor     a\r
+       ld      (@cbnk),a\r
+    endif\r
+\r
+; check warm start mark\r
+\r
+       ld ix,mark_55AA         ; top of common area\r
+       ld a,0aah               ;\r
+       cp (ix+000h)            ;\r
+       jr nz,kstart            ;\r
+       cp (ix+002h)            ;\r
+       jr nz,kstart            ;\r
+       cpl                     ;\r
+       cp (ix+001h)            ;\r
+       jr nz,kstart            ;\r
+       cp (ix+003h)            ;\r
+       jr nz,kstart            ;\r
+       ld sp,$stack            ; mark found, check\r
+       jp z,wstart             ; check ok,\r
+\r
+; ram not ok, initialize    --  kstart --\r
+\r
+kstart:\r
+    if CPU_Z180\r
+       ld      a,SYS$CBR\r
+       out0    (cbr),a\r
+       ld      a,SYS$CBAR\r
+       out0    (cbar),a\r
+    endif\r
+\r
+       ld      sp,$stack       ;01e1\r
+\r
+; Clear RAM using DMA0\r
+\r
+    if CPU_Z180\r
+     if 0\r
+\r
+       ld      hl,dmclrt       ;load DMA registers\r
+       call    ioiniml\r
+       ld      a,0cbh          ;01ef   dst +1, src fixed, burst\r
+       out0    (dmode),a       ;01f1\r
+\r
+       ld      b,512/64\r
+       ld      a,062h          ;01f4   enable dma0,\r
+??cl_1:\r
+       out0    (dstat),a       ;01f9   clear (up to) 64k\r
+       djnz    ??cl_1          ;       end of RAM?\r
+\r
+     endif\r
+    endif\r
+\r
+       ld      hl,055AAh       ;set warm start mark\r
+       ld      (mark_55AA),hl\r
+       ld      (mark_55AA+2),hl\r
+\r
+;      --  wstart  --\r
+\r
+wstart:\r
+       call    sysram_init\r
+       call    ivtab_init\r
+    if CPU_Z180\r
+;      call    prt0_init\r
+    endif\r
+\r
+       call    charini\r
+       call    bufferinit\r
+\r
+    if CPU_Z80\r
+       ld      a,0\r
+       call    selbnk\r
+    endif\r
+\r
+       ld      a,INIDONEVAL    ;tell others (CP/M) that hardware and fifos\r
+       ld      (INIDONE),a     ;    are allready initialized\r
+\r
+       im 2\r
+       ei\r
+\r
+       call ?const\r
+       call ?const\r
+       or a\r
+       call nz,?conin\r
+\r
+    if CPU_Z180\r
+       ld e,0                  ;Sys$Bank\r
+    else\r
+; TODO:\r
+    endif\r
+       jp ddtz\r
+\r
+\r
+    if CPU_Z180\r
+; TODO: SYS$CBR\r
+syscbr:        db      0\r
+    endif\r
+\r
+;\r
+;----------------------------------------------------------------------\r
+;\r
+\r
+       global  buf.init\r
+\r
+buf.init:\r
+       ld      (ix+o.in_idx),0\r
+       ld      (ix+o.out_idx),0\r
+       ld      (ix+o.mask),a\r
+\r
+       ld      a,(ix+o.id)\r
+       cp      4\r
+       ret     nc\r
+\r
+       push    de\r
+       push    hl\r
+       ld      hl,fifo_list\r
+       push    hl              ;save fifo_list\r
+       ld      e,a\r
+       ld      d,0\r
+       add     hl,de\r
+       add     hl,de\r
+       add     hl,de\r
+       push    ix\r
+       pop     de\r
+; TODO: address translation\r
+       ld      (hl),e\r
+       inc     hl\r
+       ld      (hl),d\r
+       pop     hl              ;get fifo_list back\r
+       or      a\r
+       jr      nz,bufi_ex\r
+\r
+       ld      (040h),hl\r
+       ld      (040h+2),a\r
+bufi_ex:\r
+       pop     hl\r
+       pop     de\r
+\r
+       ret\r
+\r
+\r
+fifo_list:\r
+       rept 4\r
+        dw     0\r
+        db     0\r
+       endm\r
+\r
+;----------------------------------------------------------------------\r
+\r
+       extrn   msginit,msg.sout\r
+       extrn   mtx.fifo,mrx.fifo\r
+       extrn   co.fifo,ci.fifo\r
+\r
+\r
+bufferinit:\r
+    if CPU_Z180\r
+       call    msginit\r
+\r
+       ld      hl,buffers\r
+       ld      b,buftablen\r
+bfi_1:\r
+       ld      a,(hl)\r
+       inc     hl\r
+       ld      (bufdat+0),a\r
+       ld      e,(hl)\r
+       inc     hl\r
+       ld      d,(hl)\r
+       inc     hl\r
+       ex      de,hl\r
+\r
+       or      a\r
+       jr      nz,bfi_2\r
+;      call    hwl2phy\r
+;      ld      (40h+0),hl\r
+;      ld      (40h+2),a\r
+       out     (AVRINT5),a\r
+       jr      bfi_3\r
+bfi_2:\r
+       call    hwl2phy\r
+       ld      (bufdat+1),hl\r
+       ld      (bufdat+3),a\r
+       ld      hl,inimsg\r
+       call    msg.sout\r
+bfi_3:\r
+       ex      de,hl\r
+       djnz    bfi_1\r
+       ret\r
+\r
+    else ;CPU_Z180\r
+\r
+       call    msginit\r
+\r
+       ld      hl,buffers\r
+       ld      b,buftablen\r
+bfi_1:\r
+       ld      a,(hl)\r
+       inc     hl\r
+       ld      (bufdat+0),a\r
+       ld      e,(hl)\r
+       inc     hl\r
+       ld      d,(hl)\r
+       inc     hl\r
+       ex      de,hl\r
+\r
+       or      a\r
+       jr      nz,bfi_2\r
+\r
+       ld      a,(@cbnk)\r
+       call    bnk2phy\r
+\r
+       ld      (40h+0),hl\r
+       ld      (40h+2),a\r
+       out     (AVRINT5),a\r
+       jr      bfi_3\r
+bfi_2:\r
+\r
+       ld      a,(@cbnk)\r
+       call    bnk2phy\r
+\r
+       ld      (bufdat+1),hl\r
+       ld      (bufdat+3),a\r
+       ld      hl,inimsg\r
+       call    msg.sout\r
+bfi_3:\r
+       ex      de,hl\r
+       djnz    bfi_1\r
+       ret\r
+    endif\r
+\r
+buffers:\r
+       db      0\r
+       dw      mtx.fifo\r
+       db      1\r
+       dw      mrx.fifo\r
+       db      2\r
+       dw      co.fifo\r
+       db      3\r
+       dw      ci.fifo\r
+buftablen equ  ($ - buffers)/3\r
+\r
+inimsg:\r
+       db      inimsg_e - $ -1\r
+       db      0AEh\r
+       db      inimsg_e - $ -1\r
+       db      0\r
+bufdat:\r
+       db      0\r
+       dw      0\r
+       db      0\r
+inimsg_e:\r
+\r
+\r
+;\r
+;----------------------------------------------------------------------\r
+;\r
+\r
+sysram_init:\r
+       ld hl,sysramw\r
+       ld de,topcodsys\r
+       ld bc,sysrame-sysramw\r
+       ldir\r
+\r
+       ret\r
+\r
+;----------------------------------------------------------------------\r
+\r
+ivtab_init:\r
+       ld      hl,ivtab        ;\r
+       ld      a,h             ;\r
+       ld      i,a             ;\r
+    if CPU_Z180\r
+       out0    (il),l          ;\r
+    endif\r
+\r
+; Let all vectors point to spurious int routines.\r
+\r
+       ld      d,high sp.int0\r
+       ld      a,low  sp.int0\r
+       ld      b,9\r
+ivt_i1:\r
+       ld      (hl),a\r
+       inc     l\r
+       ld      (hl),d\r
+       inc     l\r
+       add     a,sp.int.len\r
+       djnz    ivt_i1\r
+       ret\r
+\r
+;----------------------------------------------------------------------\r
+\r
+    if CPU_Z180\r
+prt0_init:\r
+       ld      a,i\r
+       ld      h,a\r
+       in0     a,(il)\r
+       and     0E0h\r
+       or      IV$PRT0\r
+       ld      l,a\r
+       ld      (hl),low  iprt0\r
+       inc     hl\r
+       ld      (hl),high iprt0\r
+       ld      hl,prt0itab\r
+       call    ioiniml\r
+       ret\r
+\r
+prt0itab:\r
+       db      prt0it_e-prt0itab-2\r
+       db      tmdr0l\r
+       dw      PRT_TC10MS\r
+       dw      PRT_TC10MS\r
+       db      M_TIE0+M_TDE0   ;enable timer 0 interrupt and down count.\r
+prt0it_e:\r
+       db      0\r
+    endif\r
+\r
+\r
+;\r
+;----------------------------------------------------------------------\r
+;\r
+\r
+    if CPU_Z180\r
+io.ini:\r
+     if 0\r
+       push    bc\r
+       ld      b,0             ;high byte port adress\r
+ioi_nxt:\r
+       ld      a,(hl)          ;count\r
+       inc     hl\r
+       or      a\r
+       jr      z,ioi_e\r
+\r
+       ld      c,(hl)          ;port address\r
+       inc     hl\r
+ioi_r:\r
+       outi\r
+       inc     b               ;outi decrements b\r
+       dec     a\r
+       jr      nz,ioi_r\r
+       jr      ioi_nxt\r
+ioi_e:\r
+       pop     bc\r
+       ret\r
+\r
+     else ;(if 1/0)\r
+\r
+       push    bc\r
+       jr      ioi_nxt\r
+ioi_l:\r
+       ld      c,(hl)          ;port address\r
+       inc     hl\r
+       inc     c\r
+ioi_r:\r
+       dec     c               ;otim increments c\r
+       otim\r
+       jr      z,ioi_r\r
+ioi_nxt:\r
+       ld      b,(hl)          ;count\r
+       inc     hl\r
+       inc     b               ;stop if count == 0\r
+       djnz    ioi_l\r
+       pop     bc\r
+       ret\r
+\r
+     endif ;(1/0)\r
+\r
+    else\r
+\r
+io.ini:\r
+       push    bc\r
+       jr      ioi_nxt\r
+ioi_l:\r
+       ld      c,(hl)          ;port address\r
+       inc     hl\r
+       otir\r
+ioi_nxt:\r
+       ld      b,(hl)          ;count\r
+       inc     hl\r
+       inc     b\r
+       djnz    ioi_l\r
+    endif\r
+       pop     bc\r
+       ret\r
+\r
+;----------------------------------------------------------------------\r
+\r
+    if CPU_Z180\r
+\r
+       global ioiniml\r
+\r
+ioiniml:\r
+       push    bc\r
+       xor     a\r
+ioml_lp:\r
+       ld      b,(hl)\r
+       inc     hl\r
+       cp      b\r
+       jr      z,ioml_e\r
+\r
+       ld      c,(hl)\r
+       inc     hl\r
+       otimr\r
+       jr      ioml_lp\r
+ioml_e:\r
+       pop     bc\r
+       ret     z\r
+    endif\r
+\r
+io.ini.l:\r
+;\r
+\r
+\r
+\r
+;----------------------------------------------------------------------\r
+;\r
+    if CPU_Z180\r
+\r
+;--------------------------------------------------------------------\r
+; Return the BBR value for the given bank number\r
+;\r
+; in  a: Bank number\r
+; out a: bbr value\r
+\r
+bnk2log:\r
+       or      a               ;\r
+       ret     z               ; Bank 0 is at physical address 0\r
+\r
+       push    bc              ;\r
+       ld      b,a             ;\r
+       ld      c,CA            ;\r
+       mlt     bc              ;\r
+       ld      a,c             ;\r
+       add     a,10h           ;\r
+       pop     bc              ;\r
+       ret                     ;\r
+\r
+;--------------------------------------------------------------\r
+\r
+;in  hl: Log. Address\r
+;     a: Bank number\r
+;\r
+;out ahl: Phys. (linear) Address\r
+\r
+\r
+bnk2phy:\r
+       call    bnk2log\r
+       ; fall thru\r
+\r
+;--------------------------------------------------------------\r
+;\r
+; hl: Log. Address\r
+;  a: Bank base (bbr)\r
+;\r
+;           2           0       0\r
+;           0   6       8       0\r
+; hl             hhhhhhhhllllllll\r
+;  a   +     bbbbbbbb\r
+;\r
+; OP: ahl = (a<<12) + (h<<8) + l\r
+;\r
+;out ahl: Phys. (linear) Address\r
+\r
+log2phy:\r
+       push    bc              ;\r
+l2p_i:\r
+       ld      c,a             ;\r
+       ld      b,16            ;\r
+       mlt     bc              ; bc = a<<4\r
+       ld      a,c             ;\r
+       add     a,h             ;\r
+       ld      h,a             ;\r
+       ld      a,b             ;\r
+       adc     a,0             ;\r
+       pop     bc              ;\r
+       ret                     ;\r
+\r
+;--------------------------------------------------------------\r
+;\r
+; hl: Log. Address\r
+;\r
+;\r
+; OP: ahl = (bankbase<<12) + (d<<8) + e\r
+;\r
+;out ahl: Phys. (linear) Address\r
+\r
+\r
+hwl2phy:\r
+       push    bc              ;\r
+       in0     c,(cbar)        ;\r
+       ld      a,h             ;\r
+       or      00fh            ; log. addr in common1?\r
+       cp      c\r
+       jr      c,hlp_1\r
+\r
+       in0     a,(cbr)         ; yes, cbr is address base\r
+       jr      hl2p_x\r
+hlp_1:\r
+       ld      b,16            ; log. address in baked area?\r
+       mlt     bc\r
+       ld      a,h\r
+       cp      c\r
+       jr      c,hlp_2\r
+       in0     a,(bbr)         ; yes, bbr is address base\r
+       jr      hl2p_x\r
+hlp_2:\r
+       xor     a               ; common1\r
+hl2p_x:\r
+       jr      nz,l2p_i\r
+\r
+       pop     bc              ; bank part is 0, no translation\r
+       ret                     ;\r
+\r
+\r
+\r
+    else       ;CPU_Z180\r
+\r
+;----------------------------------------------------------------------\r
+;\r
+\r
+bnk2phy:\r
+       sla     h\r
+       jr      nc,b2p_1                ;A15=1 --> common\r
+       ld      a,3\r
+b2p_1:\r
+       srl     a\r
+       rr      h\r
+       ret\r
+\r
+    endif\r
+\r
+;--------------------------------------------------------------\r
+;\r
+;return:\r
+; hl = hl + a\r
+; Flags undefined\r
+;\r
+\r
+add_hl_a:\r
+       add a,l\r
+       ld l,a\r
+       ret nc\r
+       inc h\r
+       ret\r
+\r
+; ---------------------------------------------------------\r
+\r
+sysramw:\r
+\r
+       .phase isvsw_loc\r
+topcodsys:\r
+\r
+; Trampoline for interrupt routines in banked ram.\r
+; Switch stack pointer to "system" stack in top ram\r
+; Save cbar\r
+\r
+isv_sw:                                ;\r
+       ex (sp),hl              ;save hl, 'return adr' in hl\r
+       push de                 ;\r
+       push af                 ;\r
+       ex de,hl                ;'return address' in de\r
+       ld hl,0                 ;\r
+       add hl,sp               ;\r
+       ld a,h                  ;\r
+       cp 0f8h                 ;\r
+       jr nc,isw_1             ;stack allready in top ram\r
+       ld sp,$stack            ;\r
+isw_1:\r
+       push hl                 ;save user stack pointer\r
+       in0 h,(cbar)            ;\r
+       push hl                 ;\r
+       ld a,SYS$CBAR           ;\r
+       out0 (cbar),a           ;\r
+       ex de,hl                ;\r
+       ld e,(hl)               ;\r
+       inc hl                  ;\r
+       ld d,(hl)               ;\r
+       ex de,hl                ;\r
+       push bc                 ;\r
+       call jphl               ;\r
+\r
+       pop bc                  ;\r
+       pop hl                  ;\r
+       out0 (cbar),h           ;\r
+       pop hl                  ;\r
+       ld sp,hl                ;\r
+       pop af                  ;\r
+       pop de                  ;\r
+       pop hl                  ;\r
+       ei                      ;\r
+       ret                     ;\r
+jphl:\r
+       jp (hl)                 ;\r
+\r
+; ---------------------------------------------------------\r
+\r
+    if CPU_Z180\r
+\r
+iprt0:\r
+       push    af\r
+       push    hl\r
+       in0     a,(tcr)\r
+       in0     a,(tmdr0l)\r
+       in0     a,(tmdr0h)\r
+       ld      a,(tim_ms)\r
+       inc     a\r
+       cp      100\r
+       jr      nz,iprt_1\r
+       xor     a\r
+       ld      hl,(tim_s)\r
+       inc     hl\r
+       ld      (tim_s),hl\r
+iprt_1:\r
+       ld      (tim_ms),a\r
+       pop     hl\r
+       pop     af\r
+       ei\r
+       ret\r
+\r
+    endif\r
+\r
+; ---------------------------------------------------------\r
+\r
+sp.int0:\r
+       ld      a,0d0h\r
+       jr      sp.i.1\r
+sp.int.len equ $-sp.int0\r
+       ld      a,0d1h\r
+       jr      sp.i.1\r
+       ld      a,0d2h\r
+       jr      sp.i.1\r
+       ld      a,0d3h\r
+       jr      sp.i.1\r
+       ld      a,0d4h\r
+       jr      sp.i.1\r
+       ld      a,0d5h\r
+       jr      sp.i.1\r
+       ld      a,0d6h\r
+       jr      sp.i.1\r
+       ld      a,0d7h\r
+       jr      sp.i.1\r
+       ld      a,0d8h\r
+sp.i.1:\r
+;      out     (80h),a\r
+       halt\r
+\r
+; ---------------------------------------------------------\r
+\r
+    if CPU_Z80\r
+\r
+; Get IFF2\r
+; This routine may not be loaded in page zero\r
+;\r
+; return Carry clear, if INTs are enabled.\r
+;\r
+       global getiff\r
+getiff:\r
+       xor     a               ;clear accu and carry\r
+       push    af              ;stack bottom := 00xxh\r
+       pop     af\r
+       ld      a,i             ;P flag := IFF2\r
+       ret     pe              ;exit carry clear, if enabled\r
+       dec     sp\r
+       dec     sp              ;has stack bottom been overwritten?\r
+       pop     af\r
+       and     a               ;if not 00xxh, INTs were\r
+       ret     nz              ;actually enabled\r
+       scf                     ;Otherwise, they really are disabled\r
+       ret\r
+\r
+;----------------------------------------------------------------------\r
+\r
+       global  selbnk\r
+\r
+; a: bank (0..2)\r
+\r
+selbnk:\r
+       push    bc\r
+       ld      c,a\r
+       call    getiff\r
+       push    af\r
+\r
+       ld      a,c\r
+       di\r
+       ld      (@cbnk),a\r
+       ld      a,5\r
+       out     (SIOAC),a\r
+       ld      a,(mm_sio0)\r
+       rla\r
+       srl     c\r
+       rra\r
+       out     (SIOAC),a\r
+       ld      (mm_sio0),a\r
+\r
+       ld      a,5\r
+       out     (SIOBC),a\r
+       ld      a,(mm_sio1)\r
+       rla\r
+       srl     c\r
+       rra\r
+       out     (SIOBC),a\r
+       ld      (mm_sio1),a\r
+       pop     af\r
+       pop     bc\r
+       ret     c                       ;INTs were disabled\r
+       ei\r
+       ret\r
+\r
+;----------------------------------------------------------------------\r
+\r
+; c: bank (0..2)\r
+\r
+    if 0\r
+\r
+selbnk:\r
+       ld      a,(@cbnk)\r
+       xor     c\r
+       and     3\r
+       ret     z               ;no change\r
+\r
+       call    getiff\r
+       push    af\r
+       ld      a,c\r
+       di\r
+       ld      (@cbnk),a\r
+       ld      a,5\r
+       out     (SIOAC),a\r
+       ld      a,(mm_sio0)\r
+       rla\r
+       srl     c\r
+       rra\r
+       out     (SIOAC),a\r
+       ld      (mm_sio0),a\r
+\r
+       ld      a,5\r
+       out     (SIOBC),a\r
+       ld      a,(mm_sio1)\r
+       rla\r
+       srl     c\r
+       rra\r
+       out     (SIOBC),a\r
+       ld      (mm_sio1),a\r
+       pop     af\r
+       ret     nc                      ;INTs were disabled\r
+       ei\r
+       ret\r
+\r
+    endif\r
+\r
+;----------------------------------------------------------------------\r
+\r
+    if 0\r
+       ex      af,af'\r
+       push    af\r
+       ex      af,af'\r
+\r
+       rra\r
+       jr      nc,stbk1\r
+       ex      af,af'\r
+       ld      a,5\r
+       out     (SIOAC),a\r
+       ld      a,(mm_sio0)\r
+       rla\r
+       srl     c\r
+       rra\r
+       out     (SIOAC),a\r
+       ld      (mm_sio1),a\r
+       ex      af,af'\r
+\r
+stbk1:\r
+       rra\r
+       jr      nc,stbk2\r
+       ex      af,af'\r
+       ld      a,5\r
+       out     (SIOBC),a\r
+       ld      a,(mm_sio1)\r
+       rla\r
+       srl     c\r
+       rra\r
+       out     (SIOBC),a\r
+       ld      (mm_sio1),a\r
+       ex      af,af'\r
+\r
+stbk2:\r
+    endif\r
+\r
+       global  @cbnk\r
+       global  mm_sio0, mm_sio1\r
+\r
+@cbnk: db      0               ; current bank (0..2)\r
+mm_sio0:\r
+       ds      1\r
+mm_sio1:\r
+       ds      1\r
+\r
+\r
+    endif\r
+\r
+;----------------------------------------------------------------------\r
+\r
+curph  defl    $\r
+       .dephase\r
+sysrame:\r
+       .phase curph\r
+tim_ms:        db      0\r
+tim_s: dw      0\r
+       .dephase\r
+\r
+;-----------------------------------------------------\r
+\r
+\r
+       cseg\r
+\r
+       ;.phase 0ffc0h\r
+;ivtab equ     0ffc0h          ; 0ffc0h        ;int vector table\r
+       ;.dephase\r
+\r
+       ;.phase 0fffah\r
+mark_55AA equ 0 - 2 - 4                ;2 byte for trap stack\r
+       ;ds     4\r
+       ;.dephase\r
+\r
+\r
+       end\r
index 36e08715db1304e3443110a131d61ffd1aa93d03..7e8c9ccc6e7ceb92ff8f4847eaa440c7f90ea7cf 100644 (file)
@@ -1,22 +1,24 @@
        page    255\r
        .z80\r
-       \r
+\r
        global  mrx.fifo,mtx.fifo\r
 \r
        global  msginit,msgi.st,msg.in,msgo.st,msg.out\r
        global  msg.sout\r
-       \r
+\r
        extrn   buf.init\r
 \r
        include config.inc\r
+       if CPU_Z180\r
        include z180reg.inc\r
+       endif\r
 \r
 ;--------------------------------------------------------------\r
 \r
        dseg\r
 \r
-       mkbuf   mrx.fifo,mrx.fifo_len\r
-       mkbuf   mtx.fifo,mtx.fifo_len\r
+       mkbuf   mtx.fifo_id, mtx.fifo, mtx.fifo_len\r
+       mkbuf   mrx.fifo_id, mrx.fifo, mrx.fifo_len\r
 \r
 ;--------------------------------------------------------------\r
 \r
 ;\r
 ; Init buffer\r
 ;\r
-       \r
+\r
 msginit:\r
-       ld      ix,mrx.fifo\r
-       ld      a,mrx.fifo.mask\r
-       call    buf.init\r
        ld      ix,mtx.fifo\r
        ld      a,mtx.fifo.mask\r
+       call    buf.init\r
+       ld      ix,mrx.fifo\r
+       ld      a,mrx.fifo.mask\r
        jp      buf.init\r
 \r
 ;--------------------------------------------------------------\r
@@ -47,7 +49,7 @@ buf.empty:
        ret     z\r
        or      0ffh\r
        ret\r
-       \r
+\r
 ;--------------------------------------------------------------\r
 \r
 msg.in:\r
@@ -69,12 +71,12 @@ bg.wait:
        inc     h\r
 bg.nc:\r
        ld      l,(hl)\r
-       \r
+\r
        ld      a,(ix+o.out_idx)        ;\r
        inc     a\r
        and     (ix+o.mask)\r
        ld      (ix+o.out_idx),a\r
-       \r
+\r
        ld      a,l\r
        pop     hl\r
        pop     ix\r
@@ -98,6 +100,8 @@ buf.full:
 \r
 ;--------------------------------------------------------------\r
 \r
+    if 0\r
+\r
 msg.out:\r
        push    ix\r
        ld      ix,mtx.fifo             ;\r
@@ -120,58 +124,162 @@ bp.wait:
        jr      z,bp.wait\r
        ld      (hl),b\r
        ld      (ix+o.in_idx),a\r
-       \r
+\r
        ld      a,b\r
-       out0    (AVRINT5),a\r
+       out     (AVRINT5),a\r
        pop     bc\r
        pop     hl\r
        pop     ix\r
        ret\r
 \r
+    endif\r
 \r
 ;--------------------------------------------------------------\r
-;\r
-; (hl): data\r
 \r
-msg.sout:\r
+\r
+\r
+msg.out:\r
        push    ix\r
        ld      ix,mtx.fifo             ;\r
 \r
+buf.put:\r
        push    bc\r
-       push    de\r
-       ld      b,(hl)                  ;\r
-       inc     hl\r
-       ex      de,hl\r
-       \r
-ms.ol:\r
-       push    ix\r
-       pop     hl\r
        ld      c,(ix+o.in_idx)         ;\r
-       ld      a,c\r
-       add     l\r
-       ld      l,a\r
-       jr      nc,ms.on\r
-       inc     h\r
-ms.on:\r
+       ld      b,0\r
+       push    ix                      ;14\r
+       add     ix,bc                   ;10\r
+       ld      (ix+0),a                ;15\r
+       pop     ix                      ;12 / 51\r
+       ld      b,a                     ; 4\r
        ld      a,c                     ;\r
-       inc     a\r
-       and     (ix+o.mask)\r
-ms.wait:\r
+       inc     a                       ;\r
+       and     (ix+o.mask)             ;\r
+bp.wait:\r
+       cp      (ix+o.out_idx)          ;\r
+       jr      z,bp.wait               ;\r
+       ld      (ix+o.in_idx),a         ;\r
+\r
+       ld      a,b\r
+       out     (AVRINT5),a\r
+       pop     bc\r
+       pop     ix\r
+       ret\r
+\r
+\r
+;--------------------------------------------------------------\r
+\r
+    if 0\r
+       ; Works only, if buffer size < (128 - 3)\r
+       ;       --> mask must be 03fh or less\r
+\r
+msg.out:\r
+       push    ix\r
+       ld      ix,mtx.fifo             ;\r
+\r
+buf.put:\r
+       push    bc\r
+       ld      b,a                     ; 4\r
+       ld      a,(ix+o.in_idx)         ;14\r
+       ld      ($ + 3 + 2),a           ;15\r
+       ld      (ix+0),b                ;15\r
+       inc     a                       ;\r
+       and     (ix+o.mask)             ;\r
+bp.wait:\r
        cp      (ix+o.out_idx)          ;\r
-       jr      z,ms.wait\r
-       ld      c,a\r
-       ld      a,(de)\r
-       inc     de\r
-       ld      (hl),a\r
-       ld      (ix+o.in_idx),c\r
-       djnz    ms.ol\r
-       out0    (AVRINT5),a\r
-       ex      de,hl\r
-       pop     de\r
+       jr      z,bp.wait               ;\r
+       ld      (ix+o.in_idx),a         ;\r
+\r
+       ld      a,b\r
+       out     (AVRINT5),a\r
        pop     bc\r
        pop     ix\r
        ret\r
 \r
+    endif\r
+\r
+;--------------------------------------------------------------\r
+;\r
+; (hl): data\r
+\r
+msg.sout:\r
+       push    ix                      ;14\r
+       ld      ix,mtx.fifo             ;12\r
+       push    bc                      ;11\r
+       push    de                      ;11\r
+       ld      c,(hl)                  ; 6\r
+       ld      b,0                     ; 6\r
+       inc     hl                      ; 7\r
+ms.ol:                                 ;       \\r
+       ld      a,low mtx.fifo          ; 6\r
+       add     a,(ix+o.in_idx)         ;14\r
+       ld      e,a                     ; 4\r
+       ld      a,high mtx.fifo         ; 6\r
+       adc     a,b                     ; 4\r
+       ld      d,a                     ; 4\r
+\r
+       ld      a,(ix+o.in_idx)         ;14\r
+       inc     a                       ; 4\r
+       and     (ix+o.mask)             ;14\r
+ms.wait:\r
+       cp      (ix+o.out_idx)          ;14\r
+       jr      z,ms.wait               ; 6/8\r
+\r
+       ldi                             ;12\r
+       ld      (ix+o.in_idx),a         ;15\r
+       jp      pe,ms.ol                ; 6/9    -- 126\r
+\r
+       out     (AVRINT5),a             ;10\r
+       pop     de                      ; 9\r
+       pop     bc                      ; 9\r
+       pop     ix                      ;12\r
+       ret                             ; 9\r
+\r
+;--------------------------------------------------------------\r
+;\r
+; (hl): data\r
+\r
+    if 0\r
+\r
+msg.sout:\r
+       push    ix                      ;14\r
+       ld      ix,mtx.fifo             ;12\r
+       push    bc                      ;11\r
+       push    de                      ;11\r
+       ld      b,(hl)                  ; 6\r
+       inc     hl                      ; 4\r
+       ex      de,hl                   ; 3\r
+ms.ol:                                 ;       \\r
+       push    ix                      ;14\r
+       pop     hl                      ; 9\r
+       ld      c,(ix+o.in_idx)         ;14\r
+       ld      a,c                     ; 4\r
+       add     l                       ; 4\r
+       ld      l,a                     ; 4\r
+       jr      nc,ms.on                ; 6/8\r
+       inc     h                       ; 4\r
+ms.on:\r
+       ld      a,c                     ; 4\r
+       inc     a                       ; 4\r
+       and     (ix+o.mask)             ;14\r
+ms.wait:\r
+       cp      (ix+o.out_idx)          ;14\r
+       jr      z,ms.wait               ; 6/8\r
+       ld      c,a                     ; 4\r
+       ld      a,(de)                  ; 6\r
+       inc     de                      ; 4\r
+       ld      (hl),a                  ; 7\r
+       ld      (ix+o.in_idx),c         ;15\r
+       djnz    ms.ol                   ; 7/9   -- 130\r
+\r
+       out     (AVRINT5),a             ;10\r
+       ex      de,hl                   ; 3\r
+       pop     de                      ; 9\r
+       pop     bc                      ; 9\r
+       pop     ix                      ;12\r
+       ret                             ; 9\r
+\r
+    endif\r
+\r
 ;--------------------------------------------------------------\r
 \r
 msg.co:\r
@@ -183,8 +291,8 @@ msg.co:
        pop     hl\r
        pop     af\r
        ret\r
-       \r
-       \r
+\r
+\r
 buf:\r
        db      buf_end - $ - 1         ;output string length\r
        db      0AEh                    ; message start token\r
@@ -198,4 +306,3 @@ buf_end:
 ;----------------------------------------------------------------------\r
 \r
        end\r
-\r
index 582c219aebf974aae8b9f964b94db433019dca79..cf1ae2a4eb8b53d98c63398a11a845bc3b802775 100644 (file)
@@ -1,11 +1,11 @@
        page    255\r
        .z80\r
-       \r
+\r
        global  msg_rx_fifo,msg_tx_fifo\r
 \r
        global  msginit,msgi.st,msg.in,msgo.st,msg.out\r
        global  msg.sout,msg.co\r
-       \r
+\r
        extrn   buf.init\r
 \r
        include config.inc\r
@@ -15,8 +15,8 @@
 \r
        dseg\r
 \r
-       mkbuf   msg_rx_fifo,msg_rx_fifo_len\r
-       mkbuf   msg_tx_fifo,msg_tx_fifo_len\r
+       mkbuf   mtx.fifo_id, msg_tx_fifo, msg_tx_fifo_len\r
+       mkbuf   mrx.fifo_id, msg_rx_fifo, msg_rx_fifo_len\r
 \r
 \r
 \r
@@ -27,7 +27,7 @@
 ;\r
 ; Init buffer\r
 ;\r
-       \r
+\r
 msginit:\r
        ld      ix,msg_rx_fifo\r
        ld      a,msg_rx_fifo.mask\r
@@ -49,7 +49,7 @@ buf.empty:
        ret     z\r
        or      0ffh\r
        ret\r
-       \r
+\r
 ;--------------------------------------------------------------\r
 \r
 msg.in:\r
@@ -71,12 +71,12 @@ bg.wait:
        inc     h\r
 bg.nc:\r
        ld      l,(hl)\r
-       \r
+\r
        ld      a,(ix+o.out_idx)        ;\r
        inc     a\r
        and     (ix+o.mask)\r
        ld      (ix+o.out_idx),a\r
-       \r
+\r
        ld      a,l\r
        pop     hl\r
        pop     ix\r
@@ -122,7 +122,7 @@ bp.wait:
        jr      z,bp.wait\r
        ld      (hl),b\r
        ld      (ix+o.in_idx),a\r
-       \r
+\r
        ld      a,b\r
        out0    (AVRINT5),a\r
        pop     bc\r
@@ -152,7 +152,7 @@ bp.wait:
        ld      a,b\r
        out     (PMSG),a\r
        ld      (ix+o.in_idx),c\r
-       \r
+\r
        pop     bc\r
        pop     ix\r
        ret\r
@@ -171,7 +171,7 @@ msg.sout:
        ld      b,(hl)                  ;\r
        inc     hl\r
        ex      de,hl\r
-       \r
+\r
 ms.ol:\r
        push    ix\r
        pop     hl\r
@@ -242,8 +242,8 @@ msg.co:
        pop     hl\r
        pop     af\r
        ret\r
-       \r
-       \r
+\r
+\r
 buf:\r
        db      buf_end - $ - 1         ;output string length\r
        db      081h                    ; message start token\r
@@ -257,4 +257,3 @@ buf_end:
 ;----------------------------------------------------------------------\r
 \r
        end\r
-\r
diff --git a/z180/r3init.180 b/z180/r3init.180
deleted file mode 100644 (file)
index 9edeaf2..0000000
+++ /dev/null
@@ -1,957 +0,0 @@
-       page    255\r
-       .z80\r
-\r
-       extrn ddtz,bpent\r
-       extrn $stack\r
-       extrn charini,?const,?conin\r
-\r
-       extrn romend\r
-\r
-\r
-       global  isv_sw\r
-\r
-       include config.inc\r
-       include z180reg.inc\r
-       include z180.lib\r
-\r
-;CR    equ     0dh\r
-\r
-\r
-\r
-;----------------------------------------------------------------------\r
-\r
-       cseg\r
-\r
-       jp start\r
-\r
-; restart vectors\r
-\r
-rsti   defl    1\r
-       rept    7\r
-        db 0, 0, 0, 0, 0\r
-        jp bpent\r
-rsti    defl rsti+1\r
-       endm\r
-        db 0, 0, 0, 0, 0\r
-\r
-;----------------------------------------------------------------------\r
-       \r
-       ;org    40h\r
-\r
-       dw      0\r
-       db      0\r
-\r
-\r
-       if ROMSYS\r
-$crom:  defb c$rom             ;\r
-       else\r
-        db     0               ;\r
-       endif\r
-\r
-dmclrt:                                ;clear ram per dma\r
-       db      dmct_e-dmclrt-2 ;\r
-       db      sar0l           ;first port\r
-       dw      nullbyte        ;src (fixed)\r
-nullbyte:\r
-       db      000h            ;src\r
-       dw      romend          ;dst (inc), start after "rom" code\r
-       db      00h             ;dst\r
-       dw      0-romend        ;count (64k)\r
-dmct_e:\r
-\r
-INIWAITS defl  CWAITIO\r
-       if      ROMSYS\r
-INIWAITS defl  INIWAITS+CWAITROM\r
-       endif\r
-\r
-hwini0:\r
-       db      3               ;count\r
-       db      rcr,CREFSH      ;configure DRAM refresh\r
-       db      dcntl,INIWAITS  ;wait states\r
-       db      cbar,SYS$CBAR\r
-\r
-;----------------------------------------------------------------------\r
-\r
-start:\r
-       ld      (tmpstack),sp\r
-       ld      sp,tmpstack\r
-       push af\r
-       in0 a,(itc)             ;Illegal opcode trap?\r
-       jp m,??st01\r
-       ld a,i                  ;I register == 0 ?\r
-       jr z,??st02             ;    yes, harware reset\r
-\r
-??st01:\r
-       ld      a,(syscbr)\r
-       out0    (cbr),a\r
-       pop af                  ;restore registers\r
-       ld      sp,(tmpstack)   ;\r
-       jp bpent                ;\r
-\r
-??st02:\r
-       di                      ;0058\r
-       ld      a,CREFSH\r
-       out0    (rcr),a         ;       configure DRAM refresh\r
-       ld      a,CWAITIO\r
-       out0    (dcntl),a       ;       wait states\r
-\r
-       ld      a,M_NCD         ;No Clock Divide\r
-       out0    (ccr),a\r
-;      ld      a,M_X2CM        ;X2 Clock Multiplier\r
-;      out0    (cmr),a\r
-\r
-; search warm start mark\r
-\r
-       ld ix,mark_55AA         ;00b8   ; top of common area\r
-       ld a,SYS$CBAR           ;\r
-       out0 (cbar),a           ;\r
-       ld a,071h               ;00bc\r
-       ex af,af'               ;00be   ;for cbr = 0x70 downto 0x40\r
-swsm_l:\r
-       ex af,af'               ;00bf\r
-       dec a                   ;00c0\r
-       cp 03fh                 ;00c1\r
-       jr z,kstart             ;00c3   ;  break (mark not found)\r
-       out0 (cbr),a            ;00c5\r
-       ex af,af'               ;00c8\r
-       ld a,0aah               ;00c9\r
-       cp (ix+000h)            ;00cb\r
-       jr nz,swsm_l            ;00ce\r
-       cp (ix+002h)            ;00d0\r
-       jr nz,swsm_l            ;00d3\r
-       cpl                     ;00d5\r
-       cp (ix+001h)            ;00d6\r
-       jr nz,swsm_l            ;00d9\r
-       cp (ix+003h)            ;00db\r
-       jr nz,swsm_l            ;00de\r
-       ld sp,$stack            ;00e0   mark found, check\r
-       call checkcrc_alv       ;00e3\r
-       jp z,wstart             ;00e6   check ok,\r
-\r
-;\r
-; ram not ok, initialize    --  kstart --\r
-\r
-kstart:\r
-\r
-       ld      a,088h          ;00e9   0000-7fff: common 0\r
-       out0    (cbar),a        ;00eb   8000-ffff: common 1\r
-       ld      ix,08000h       ;00f3\r
-       ld      a,0             ;00f1   start at 008000 (2. phys. 32k block)\r
-??f_0:\r
-       out0    (cbr),a         ;00f9\r
-\r
-       ld      (ix+0),a        ;0103\r
-       cpl\r
-       ld      (ix+1),a        ;0103\r
-       cpl\r
-       add     a,8             ;010a   next 'bank'\r
-       cp      078h            ;010c   stop at 078000\r
-       jr      nz,??f_0        ;010e\r
-\r
-       ld      de,8000h        ;0114   first block not tested, but mark as ok\r
-       ld      a,0             ;00f1   start at 008000 (2. phys. 32k block)\r
-??cp_0:\r
-       out0    (cbr),a         ;011c\r
-       ld      c,a\r
-       xor     (ix+0)\r
-       ld      b,a\r
-       ld      a,c\r
-       cpl\r
-       xor     (ix+1)\r
-       or      b\r
-       jr      nz,??cp_1\r
-       scf\r
-??cp_1:\r
-       rr      d\r
-       rr      e\r
-       ld      a,c\r
-       add     a,8\r
-       cp      078h            ;       stop at 078000\r
-       jr      nz,??cp_0\r
-\r
-;\r
-;  ram test found 1 or more error free blocks (32k)\r
-;\r
-\r
-ramok:\r
-       ld      a,SYS$CBAR      ;01c8\r
-       out0    (cbar),a        ;01ca\r
-       ld      h,d\r
-       ld      l,e\r
-       ld      c,070h          ;01ce   highest block\r
-       ld      b,15            ;01d0\r
-??sr_1:\r
-       add     hl,hl\r
-       jr      c,alloc         ;01d4   highest "error free" block\r
-       ld      a,c             ;01d6\r
-       sub     008h            ;01d7\r
-       ld      c,a             ;01d9\r
-       djnz    ??sr_1          ;01da\r
-\r
-       slp                     ;01dc   should never be reached\r
-\r
-alloc:\r
-       out0    (cbr),c         ;01de\r
-       ld      a,c\r
-       ld      (syscbr),a\r
-       ld      sp,$stack       ;01e1\r
-\r
-; Clear RAM using DMA0\r
-\r
-       ld      hl,dmclrt       ;load DMA registers\r
-       call    io.ini.m\r
-       ld      a,0cbh          ;01ef   dst +1, src fixed, burst\r
-       out0    (dmode),a       ;01f1\r
-\r
-       ld      b,512/64\r
-       ld      a,062h          ;01f4   enable dma0,\r
-??cl_1:\r
-       out0    (dstat),a       ;01f9   clear (up to) 64k\r
-       djnz    ??cl_1          ;       end of RAM?\r
-\r
-; Init bank manager\r
-\r
-       ld      hl,banktabsys   ;020f\r
-       ld      (hl),c          ;       Common area\r
-       inc     hl              ;0213\r
-       ld      (hl),c          ;       System work area\r
-       inc     hl              ;0215   Point to bank 0 entry\r
-       ld      b,BANKS         ;0216\r
-l0218h:\r
-       ld      (hl),0ffh       ;0218   Mark all banks as unassigned\r
-       inc     hl              ;021a\r
-       djnz    l0218h          ;021b\r
-\r
-       ld      hl,memalv       ;\r
-       ld      b,8             ;       8*4k ie. first 32k\r
-??a_0:\r
-       ld      (hl),0e0h       ;       mark as sys ("rom"/monitor)\r
-       inc     hl\r
-       djnz    ??a_0\r
-\r
-       rr      d               ;       shift out bit for block 0\r
-       rr      e               ;\r
-       ld      c,15            ;022c   15*32k remaining blocks\r
-l022eh:\r
-       ld      a,0feh          ;       0xfe == block with error(s)\r
-       rr      d               ;\r
-       rr      e\r
-       adc     a,0             ;       ==> 0xff : block ok\r
-       ld      b,32/4          ;       32k == 8 * 4k\r
-l0236h:\r
-       ld      (hl),a          ;\r
-       inc     hl              ;\r
-       djnz    l0236h          ;\r
-       dec     c               ;\r
-       jr      nz,l022eh       ;next 32k block\r
-\r
-       ld      hl,memalv+0ch   ;memalv+0ch\r
-       ld      a,(banktabsys)  ;\r
-       call    add_hl_a\r
-       ld      b,3             ;\r
-l024ah:\r
-       ld      (hl),0ech       ;alloc system ram\r
-       inc     hl              ;\r
-       djnz    l024ah          ;\r
-       ld      (hl),0efh       ;alloc common\r
-       call    gencrc_alv\r
-\r
-       ld      hl,0000h        ;bank #\r
-       ld      bc,0f0fh        ;  size (?) (4k blocks)\r
-       xor     a               ;\r
-       call    sub_0420h       ;alloc mem for bank 0\r
-       ld      c,l             ;\r
-       or      a               ;\r
-       call    z,sub_04b5h     ;\r
-\r
-       ld      hl,0101h        ;\r
-       ld      bc,0f0fh        ;\r
-       xor     a               ;\r
-       call    sub_0420h       ;\r
-       ld      c,l             ;\r
-       or      a               ;\r
-       call    z,sub_04b5h     ;\r
-\r
-       ld      hl,055AAh       ;set warm start mark\r
-       ld      (mark_55AA),hl  ;\r
-       ld      (mark_55AA+2),hl;\r
-\r
-;\r
-; crc ok       --  wstart  --\r
-;\r
-wstart:\r
-       call    sysram_init     ;027f\r
-       call    ivtab_init\r
-\r
-       call    prt0_init\r
-\r
-       call    charini\r
-\r
-       call    bufferinit\r
-\r
-\r
-\r
-       im 2                    ;?030e\r
-       ei                      ;0282\r
-\r
-       call ?const             ;0284\r
-       call ?const             ;0287\r
-       or a                    ;028a\r
-       call nz,?conin          ;028d\r
-\r
-       ld a,(banktab)          ;\r
-       ld e,a                  ;\r
-       jp ddtz                 ;0290\r
-\r
-\r
-       ds      8\r
-tmpstack:\r
-       dw      2\r
-syscbr:        db      1\r
-\r
-;\r
-;----------------------------------------------------------------------\r
-;\r
-\r
-;TODO: Make a ringbuffer module.\r
-\r
-       global  buf.init\r
-\r
-buf.init:\r
-       ld      (ix+o.in_idx),0\r
-       ld      (ix+o.out_idx),0\r
-       ld      (ix+o.mask),a\r
-       ret\r
-\r
-;----------------------------------------------------------------------\r
-if 0\r
-       extrn   msginit,msg_tx_fifo,msg_rx_fifo\r
-       extrn   msg.sout\r
-\r
-bufferinit:\r
-\r
-       ld      de,msg_tx_fifo\r
-       in0     a,cbr\r
-       call    log2phys\r
-       ld      (40h+0),hl\r
-       ld      (40h+2),a\r
-\r
-;      ld      (bufdat+1),hl\r
-;      ld      (bufdat+3),a\r
-;      ld      a,1\r
-;      ld      (bufdat+0),a\r
-;      ld      hl,inimsg\r
-;      call    msg.sout\r
-\r
-       ld      de,msg_rx_fifo\r
-       in0     a,cbr\r
-       call    log2phys\r
-       ld      (bufdat+1),hl\r
-       ld      (bufdat+3),a\r
-       ld      a,2\r
-       ld      (bufdat+0),a\r
-       ld      hl,inimsg\r
-       call    msg.sout\r
-\r
-       ret\r
-\r
-inimsg:\r
-       db      inimsg_e - $ - 1\r
-       db      0AEh\r
-       db      inimsg_e - $ - 1\r
-       db      0\r
-bufdat:\r
-       db      0\r
-       dw      0\r
-       db      0\r
-inimsg_e:\r
-\r
-endif\r
-;----------------------------------------------------------------------\r
-;\r
-\r
-       extrn   msginit,msg.sout\r
-       extrn   mtx.fifo,mrx.fifo\r
-       extrn   co.fifo,ci.fifo\r
-\r
-\r
-bufferinit:\r
-       call     msginit\r
-\r
-       ld      hl,buffers\r
-       ld      b,buftablen\r
-bfi_1:\r
-       ld      a,(hl)\r
-       inc     hl\r
-       ld      (bufdat+0),a\r
-       ld      e,(hl)\r
-       inc     hl\r
-       ld      d,(hl)\r
-       inc     hl\r
-       push    hl\r
-\r
-       or      a\r
-       jr      nz,bfi_2\r
-       in0     a,cbr\r
-       call    log2phys\r
-       ld      (40h+0),hl\r
-       ld      (40h+2),a\r
-       out0    (AVRINT5),a\r
-       jr      bfi_3   \r
-bfi_2:\r
-       in0     a,cbr\r
-       call    log2phys\r
-       ld      (bufdat+1),hl\r
-       ld      (bufdat+3),a\r
-       ld      hl,inimsg\r
-       call    msg.sout\r
-bfi_3:\r
-       pop     hl\r
-       djnz    bfi_1\r
-       ret\r
-\r
-buffers:\r
-       db      0\r
-       dw      mtx.fifo\r
-       db      1\r
-       dw      mrx.fifo\r
-       db      2\r
-       dw      co.fifo\r
-       db      3\r
-       dw      ci.fifo\r
-buftablen equ  ($ - buffers)/3\r
-\r
-inimsg:\r
-       db      inimsg_e - $ -1\r
-       db      0AEh\r
-       db      inimsg_e - $ -1\r
-       db      0\r
-bufdat:\r
-       db      0\r
-       dw      0\r
-       db      0\r
-inimsg_e:\r
-\r
-\r
-;\r
-;----------------------------------------------------------------------\r
-;\r
-\r
-sysram_init:\r
-       ld hl,sysramw\r
-       ld de,topcodsys\r
-       ld bc,sysrame-sysramw\r
-       ldir\r
-\r
-       ret\r
-\r
-;----------------------------------------------------------------------\r
-\r
-ivtab_init:\r
-       ld      hl,ivtab        ;\r
-       ld      a,h             ;\r
-       ld      i,a             ;\r
-       out0    (il),l          ;\r
-\r
-; Let all vectors point to spurious int routines.\r
-\r
-       ld      d,high sp.int0\r
-       ld      a,low  sp.int0\r
-       ld      b,9\r
-ivt_i1:\r
-       ld      (hl),a\r
-       inc     l\r
-       ld      (hl),d\r
-       inc     l\r
-       add     a,sp.int.len\r
-       djnz    ivt_i1\r
-       ret\r
-\r
-;----------------------------------------------------------------------\r
-\r
-prt0_init:\r
-       ld      a,i\r
-       ld      h,a\r
-       in0     a,(il)\r
-       and     0E0h\r
-       or      IV$PRT0\r
-       ld      l,a\r
-       ld      (hl),low  iprt0\r
-       inc     hl\r
-       ld      (hl),high iprt0\r
-       ld      hl,prt0itab\r
-       call    io.ini.m\r
-       ret\r
-\r
-prt0itab:\r
-       db      prt0it_e-prt0itab-2\r
-       db      tmdr0l\r
-       dw      PRT_TC10MS\r
-       dw      PRT_TC10MS\r
-       db      M_TIE0+M_TDE0   ;enable timer 0 interrupt and down count.\r
-prt0it_e:\r
-\r
-\r
-;\r
-;----------------------------------------------------------------------\r
-;\r
-\r
-io.ini:\r
-       push    bc\r
-       ld      b,0             ;high byte port adress\r
-       ld      a,(hl)          ;count\r
-       inc     hl\r
-ioi_1:\r
-       ld      c,(hl)          ;port address\r
-       inc     hl\r
-       outi\r
-       inc     b               ;outi decrements b\r
-       dec     a\r
-       jr      nz,ioi_1\r
-       pop     bc\r
-       ret\r
-\r
-io.ini.m:\r
-       push    bc\r
-       ld      b,(hl)\r
-       inc     hl\r
-       ld      c,(hl)\r
-       inc     hl\r
-       otimr\r
-       pop     bc\r
-       ret\r
-\r
-io.ini.l:\r
-;\r
-\r
-;----------------------------------------------------------------------\r
-;\r
-\r
-; compute crc\r
-; hl: start adr\r
-; bc: len\r
-; bc returns crc val\r
-\r
-do_crc16:\r
-       ld      de,0FFFFh\r
-crc1:\r
-       ld      a,(hl)\r
-       xor     e\r
-       ld      e,a\r
-       rrca\r
-       rrca\r
-       rrca\r
-       rrca\r
-       and     0Fh\r
-       xor     e\r
-       ld      e,a\r
-       rrca\r
-       rrca\r
-       rrca\r
-       push    af\r
-       and     1Fh\r
-       xor     d\r
-       ld      d,a\r
-       pop     af\r
-       push    af\r
-       rrca\r
-       and     0F0h\r
-       xor     d\r
-       ld      d,a\r
-       pop     af\r
-       and     0E0h\r
-       xor     e\r
-       ld      e,d\r
-       ld      d,a\r
-       cpi\r
-       jp      pe,crc1\r
-       or      e               ;z-flag\r
-       ret\r
-\r
-\r
-gencrc_alv:\r
-       push hl                 ;03f6\r
-       push de                 ;03f7\r
-       push bc\r
-       push af                 ;03f8\r
-       ld hl,banktabsys        ;03f9\r
-       ld bc,crc_len           ;03fc\r
-       call do_crc16           ;03ff\r
-       ld (hl),e\r
-       inc hl\r
-       ld (hl),d\r
-       pop af                  ;0406\r
-       pop bc\r
-       pop de                  ;0407\r
-       pop hl                  ;0408\r
-       ret                     ;0409\r
-\r
-checkcrc_alv:\r
-       push hl                 ;040a\r
-       push de\r
-       push bc                 ;040b\r
-       ld hl,banktabsys        ;040d\r
-       ld bc,crc_len+2         ;0410\r
-       call do_crc16           ;0413\r
-       pop bc                  ;041d\r
-       pop de\r
-       pop hl                  ;041e\r
-       ret                     ;041f\r
-\r
-;----------------------------------------------------------------------\r
-\r
-;\r
-;  alloc\r
-;\r
-;      h:      max bank #\r
-;      l:      min bank #\r
-;      b:      max size\r
-;      c:      min size\r
-;\r
-;    ret:\r
-;      a:      0  == ok\r
-;              1  ==\r
-;              2  == no bank # in requested range\r
-;              ff == crc error\r
-;\r
-\r
-sub_0420h:\r
-       call checkcrc_alv       ;0420\r
-       jr nz,l049ch            ;0424   crc error, tables corrupt\r
-\r
-       call sub_049dh          ;0427   bank # in req. range available?\r
-       jr c,l0499h             ;042a\r
-       push ix                 ;042c\r
-       push iy                 ;042e\r
-       push de                 ;0430\r
-       push hl                 ;0431\r
-       push bc                 ;0432\r
-       ld c,b                  ;0433\r
-       ld b,alv_len+1          ;0434\r
-       ld d,0                  ;0436\r
-       ld hl,memalv-1          ;0438\r
-       jr l0441h               ;043b\r
-\r
-; find free blocks\r
-\r
-l043dh:\r
-       ld a,(hl)               ;043d\r
-       inc a                   ;043e   free blocks are marked 0ffh\r
-       jr z,l0446h             ;043f\r
-l0441h:\r
-       inc hl                  ;0441\r
-       djnz l043dh             ;0442\r
-       jr l0464h               ;0444\r
-l0446h:\r
-       push hl                 ;0446\r
-       pop ix                  ;0447   free blocks start here\r
-       ld e,000h               ;0449\r
-       jr l0451h               ;044b\r
-l044dh:                                ;       count free blocks\r
-       ld a,(hl)               ;044d\r
-       inc a                   ;044e\r
-       jr nz,l0457h            ;044f\r
-l0451h:\r
-       inc e                   ;0451\r
-       inc hl                  ;0452\r
-       djnz l044dh             ;0453\r
-       jr l0464h               ;0455\r
-\r
-; end of free blocks run.\r
-\r
-l0457h:\r
-       ld a,d                  ;0457\r
-       cp e                    ;0458   nr of blocks >= requested ?\r
-       jr nc,l0441h            ;0459\r
-\r
-       ld d,e                  ;045b\r
-       push ix                 ;045c\r
-       pop iy                  ;045e\r
-       ld a,d                  ;0460\r
-       cp c                    ;0461\r
-       jr c,l0441h             ;0462\r
-l0464h:\r
-       pop bc                  ;0464\r
-       ld a,d                  ;0465\r
-       cp b                    ;0466\r
-       jr c,l046ch             ;0467\r
-       ld d,b                  ;0469\r
-       jr l0471h               ;046a\r
-l046ch:\r
-       cp c                    ;046c\r
-       jr nc,l0471h            ;046d\r
-       ld d,000h               ;046f\r
-l0471h:\r
-       ld a,d                  ;0471\r
-       push iy                 ;0472\r
-       pop hl                  ;0474\r
-       ld de,memalv            ;0475\r
-       or a                    ;0478\r
-       sbc hl,de               ;0479\r
-       ld b,l                  ;047b\r
-       ld c,a                  ;047c\r
-       pop hl                  ;047d\r
-l047eh:\r
-       or a                    ;047e\r
-       jr z,l0489h             ;047f\r
-       ld (iy+0),l             ;0481\r
-       inc iy                  ;0484\r
-       dec a                   ;0486\r
-       jr l047eh               ;0487\r
-l0489h:\r
-       pop de                  ;0489\r
-       pop iy                  ;048a\r
-       pop ix                  ;048c\r
-       call gencrc_alv         ;048e\r
-       ld a,c                  ;0491\r
-       or a                    ;0492\r
-       ld a,000h               ;0493\r
-       ret nz                  ;0495\r
-       or 001h                 ;0496\r
-       ret                     ;0498\r
-\r
-l0499h:\r
-       ld a,2                  ;0499\r
-l049ch:\r
-       or a\r
-       ret                     ;049c\r
-\r
-\r
-; search a free bank number in range\r
-;      h: max #\r
-;      l: min #\r
-;    ret:\r
-;      l: bank number available\r
-;      nc, if found, bank nr. in l\r
-;      cy, if none found\r
-\r
-sub_049dh:\r
-       push de                 ;049d\r
-       push bc                 ;049e\r
-       ex de,hl                ;049f\r
-       dec e                   ;04a0\r
-l04a1h:\r
-       inc e                   ;04a1   test next #\r
-       ld a,d                  ;04a2\r
-       cp e                    ;04a3\r
-       jr c,l04b1h             ;04a4\r
-       ld a,e                  ;04a6\r
-       ld hl,memalv            ;04a7\r
-       ld bc,alv_len           ;04aa\r
-       cpir                    ;04ad   bank# allready allocated?\r
-       jr z,l04a1h             ;04af   if yes, search for next\r
-l04b1h:\r
-       ex de,hl                ;04b1\r
-       pop bc                  ;04b2\r
-       pop de                  ;04b3\r
-       ret                     ;04b4\r
-\r
-\r
-sub_04b5h:\r
-       ld a,l                  ;04b5\r
-       cp 012h                 ;04b6\r
-       ccf                     ;04b8\r
-       ret c                   ;04b9\r
-       push hl                 ;04ba\r
-       ld hl,banktab           ;04bb\r
-       call add_hl_a\r
-       ld (hl),b               ;04c3\r
-       call gencrc_alv         ;04c4\r
-       pop hl                  ;04c7\r
-       or a                    ;04c8   clear carry\r
-       ret                     ;04c9\r
-\r
-\r
-;--------------------------------------------------------------\r
-;\r
-; de: Log. Address\r
-;  a: Bank number\r
-;\r
-;out ahl: Phys. (linear) Address\r
-\r
-\r
-bnk2phys:\r
-       push    hl\r
-       ld      hl,banktab\r
-       call    add_hl_a\r
-       ld      a,(hl)\r
-       pop     hl\r
-\r
-       ; fall thru\r
-;--------------------------------------------------------------\r
-;\r
-; de: Log. Address\r
-;  a: Bank (bbr)\r
-;\r
-; OP: ahl = (a<<12) + (d<<8) + e\r
-;\r
-;out ahl: Phys. (linear) Address\r
-\r
-\r
-log2phys:\r
-       push    bc              ;\r
-       ld      c,a             ;\r
-       ld      b,16            ;\r
-       mlt     bc              ;bc = a<<4\r
-       ld      l,d             ;\r
-       ld      h,0             ;\r
-       add     hl,bc           ;bc + d == a<<4 + d\r
-       ld      a,h             ;\r
-       ld      h,l             ;\r
-       ld      l,e             ;\r
-       pop     bc              ;\r
-       ret                     ;\r
-\r
-\r
-;--------------------------------------------------------------\r
-;\r
-;return:\r
-; hl = hl + a\r
-; Flags undefined\r
-;\r
-\r
-add_hl_a:\r
-       add a,l\r
-       ld l,a\r
-       ret nc\r
-       inc h\r
-       ret\r
-\r
-; ---------------------------------------------------------\r
-\r
-sysramw:\r
-\r
-       .phase isvsw_loc\r
-topcodsys:\r
-\r
-; Trampoline for interrupt routines in banked ram.\r
-; Switch stack pointer to "system" stack in top ram\r
-; Save cbar\r
-\r
-isv_sw:                                ;\r
-       ex (sp),hl              ;       save hl, return adr in hl\r
-       push de                 ;\r
-       push af                 ;\r
-       ex de,hl                ;\r
-       ld hl,0                 ;\r
-       add hl,sp               ;\r
-       ld a,h                  ;\r
-       cp 0f8h                 ;\r
-       jr nc,isw_1             ;\r
-       ld sp,$stack            ;\r
-isw_1:\r
-       push hl                 ;\r
-       in0 h,(cbar)            ;\r
-       push hl                 ;\r
-       ld a,SYS$CBAR           ;\r
-       out0 (cbar),a           ;\r
-       ex de,hl                ;\r
-       ld e,(hl)               ;\r
-       inc hl                  ;\r
-       ld d,(hl)               ;\r
-       ex de,hl                ;\r
-       push bc                 ;\r
-       call jphl               ;\r
-\r
-       pop bc                  ;\r
-       pop hl                  ;\r
-       out0 (cbar),h           ;\r
-       pop hl                  ;\r
-       ld sp,hl                ;\r
-       pop af                  ;\r
-       pop de                  ;\r
-       pop hl                  ;\r
-       ei                      ;\r
-       ret                     ;\r
-jphl:\r
-       jp (hl)                 ;\r
-\r
-; ---------------------------------------------------------\r
-\r
-\r
-iprt0:\r
-       push    af\r
-       push    hl\r
-       in0     a,(tcr)\r
-       in0     a,(tmdr0l)\r
-       in0     a,(tmdr0h)\r
-       ld      a,(tim_ms)\r
-       inc     a\r
-       cp      100\r
-       jr      nz,iprt_1\r
-       xor     a\r
-       ld      hl,(tim_s)\r
-       inc     hl\r
-       ld      (tim_s),hl\r
-iprt_1:\r
-       ld      (tim_ms),a\r
-       pop     hl\r
-       pop     af\r
-       ei\r
-       ret\r
-\r
-; ---------------------------------------------------------\r
-\r
-sp.int0:\r
-       ld      a,0d0h\r
-       jr      sp.i.1\r
-sp.int.len equ $-sp.int0\r
-       ld      a,0d1h\r
-       jr      sp.i.1\r
-       ld      a,0d2h\r
-       jr      sp.i.1\r
-       ld      a,0d3h\r
-       jr      sp.i.1\r
-       ld      a,0d4h\r
-       jr      sp.i.1\r
-       ld      a,0d5h\r
-       jr      sp.i.1\r
-       ld      a,0d6h\r
-       jr      sp.i.1\r
-       ld      a,0d7h\r
-       jr      sp.i.1\r
-       ld      a,0d8h\r
-sp.i.1:\r
-;      out     (80h),a\r
-       halt\r
-\r
-curph  defl    $\r
-       .dephase\r
-sysrame:\r
-       .phase curph\r
-tim_ms:        db      0\r
-tim_s: dw      0\r
-       .dephase\r
-\r
-;-----------------------------------------------------\r
-\r
-       dseg\r
-\r
-       ds      1\r
-banktabsys:\r
-       ds      1       ;0c001h\r
-       ds      1       ;0c002h\r
-banktab:\r
-       ds      BANKS   ;0c003h\r
-memalv:\r
-       ds      512/4           ;Number of 4k blocks\r
-alv_len        equ     $-memalv\r
-crc_len        equ     $-banktabsys\r
-\r
-crc_memalv:\r
-       ds      2       ;\r
-\r
-       cseg\r
-\r
-       ;.phase 0ffc0h\r
-;ivtab equ     0ffc0h          ; 0ffc0h        ;int vector table\r
-       ;.dephase\r
-\r
-       ;.phase 0fffch\r
-mark_55AA equ 0fffch\r
-       ;ds     4               ; 0fffch\r
-       ;.dephase\r
-\r
-\r
-       end\r
-\r
index 5bbd088d68277901ccb0230569bb4096692b310c..271a4468a1593074f44bb7790c0ec9cbadc5cf28 100644 (file)
@@ -76,6 +76,13 @@ tcr  equ     IOBASE+10h      ;Timer Control Register
 \r
 asext0 equ     IOBASE+12h      ;ASCI Extension Control Register\r
 asext1 equ     IOBASE+13h      ;ASCI Extension Control Register\r
+       b2m DCD0DIS,6           ;DCD0 Disable\r
+       b2m CTS0DIS,5           ;CTS0 Disable\r
+       b2m X1,4                ;CKA * 1 Clock/Samle Rate Divider\r
+       b2m BRGMOD,3            ;BRG Mode (Baud rate generator)\r
+       b2m BREAKEN,2           ;Break Enable\r
+       b2m BREAK,1             ;Break detected\r
+       b2m SENDBREAK,0         ;Send Break\r
 \r
 tmdr1l equ     IOBASE+14h      ;Timer Data Register Channel 1\r
 tmdr1h equ     IOBASE+15h      ;\r