summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO.md6
-rw-r--r--avr/Tupfile2
-rw-r--r--avr/cli.c18
-rw-r--r--avr/cli_readline.c11
-rw-r--r--avr/cmd_boot.c6
-rw-r--r--avr/cmd_fat.c106
-rw-r--r--avr/cmd_loadcpm3.c151
-rw-r--r--avr/cmd_loadihex.c261
-rw-r--r--avr/cmd_mem.c371
-rw-r--r--avr/cmd_misc.c45
-rw-r--r--avr/command.c6
-rw-r--r--avr/command_tbl.c37
-rw-r--r--avr/env.c39
-rw-r--r--avr/main.c21
-rw-r--r--avr/z180-serv.c300
-rw-r--r--avr/z80-if.c3
-rw-r--r--include/cmd_mem.h3
-rw-r--r--include/common.h6
-rw-r--r--include/config.h10
-rw-r--r--z180/Makefile17
-rw-r--r--z180/Tupfile18
-rw-r--r--z180/asci-p.180133
-rw-r--r--z180/asci1-i.180 (renamed from z180/ser1-i.180)42
-rw-r--r--z180/bioscio.1803
-rw-r--r--z180/chario.18034
-rw-r--r--z180/conbuf-a.180100
-rw-r--r--z180/config.inc142
-rw-r--r--z180/console.180143
-rw-r--r--z180/ddtz.1808453
-rw-r--r--z180/fifoio.18017
-rw-r--r--z180/init-80.180591
-rw-r--r--z180/init.180950
-rw-r--r--z180/msgbuf-a.180199
-rw-r--r--z180/msgfifo.18027
-rw-r--r--z180/r3init.180957
-rw-r--r--z180/z180reg.inc7
36 files changed, 7454 insertions, 5781 deletions
diff --git a/TODO.md b/TODO.md
index b952c9d..75c9679 100644
--- 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
diff --git a/avr/Tupfile b/avr/Tupfile
index 78e9744..0c35de4 100644
--- a/avr/Tupfile
+++ b/avr/Tupfile
@@ -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
diff --git a/avr/cli.c b/avr/cli.c
index 52c85db..6b26b6f 100644
--- 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;
}
diff --git a/avr/cli_readline.c b/avr/cli_readline.c
index 04d32b1..93a0355 100644
--- a/avr/cli_readline.c
+++ b/avr/cli_readline.c
@@ -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;
diff --git a/avr/cmd_boot.c b/avr/cmd_boot.c
index 301f4f5..f9f8f90 100644
--- a/avr/cmd_boot.c
+++ b/avr/cmd_boot.c
@@ -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) {
diff --git a/avr/cmd_fat.c b/avr/cmd_fat.c
index 8ed7ae3..af2f772 100644
--- a/avr/cmd_fat.c
+++ b/avr/cmd_fat.c
@@ -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
index 0000000..fd685b2
--- /dev/null
+++ b/avr/cmd_loadcpm3.c
@@ -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
index 0000000..18d5331
--- /dev/null
+++ b/avr/cmd_loadihex.c
@@ -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;
+}
diff --git a/avr/cmd_mem.c b/avr/cmd_mem.c
index 20a4412..53b1842 100644
--- a/avr/cmd_mem.c
+++ b/avr/cmd_mem.c
@@ -16,13 +16,15 @@
#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 */
diff --git a/avr/cmd_misc.c b/avr/cmd_misc.c
index b29aedd..c9a3c45 100644
--- a/avr/cmd_misc.c
+++ b/avr/cmd_misc.c
@@ -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;
diff --git a/avr/command.c b/avr/command.c
index b6fa418..ed25dee 100644
--- a/avr/command.c
+++ b/avr/command.c
@@ -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 ? */
diff --git a/avr/command_tbl.c b/avr/command_tbl.c
index cbd2382..3273093 100644
--- a/avr/command_tbl.c
+++ b/avr/command_tbl.c
@@ -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,
@@ -131,6 +134,20 @@ CMD_TBL_ITEM(
""
),
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'",
"addr\n"
@@ -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)"
),
diff --git a/avr/env.c b/avr/env.c
index 7be7d03..a947583 100644
--- a/avr/env.c
+++ b/avr/env.c
@@ -31,13 +31,17 @@
#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;
}
/**
diff --git a/avr/main.c b/avr/main.c
index f4d4c6f..3852e75 100644
--- a/avr/main.c
+++ b/avr/main.c
@@ -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"));
diff --git a/avr/z180-serv.c b/avr/z180-serv.c
index e0b763f..9b4228a 100644
--- a/avr/z180-serv.c
+++ b/avr/z180-serv.c
@@ -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);
+
}
/*--------------------------------------------------------------------------*/
diff --git a/avr/z80-if.c b/avr/z80-if.c
index d5dc2d7..21ffeac 100644
--- a/avr/z80-if.c
+++ b/avr/z80-if.c
@@ -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);
diff --git a/include/cmd_mem.h b/include/cmd_mem.h
index 05227cc..782c10a 100644
--- a/include/cmd_mem.h
+++ b/include/cmd_mem.h
@@ -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 */
diff --git a/include/common.h b/include/common.h
index cfbbae5..10c4417 100644
--- a/include/common.h
+++ b/include/common.h
@@ -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
diff --git a/include/config.h b/include/config.h
index e40d016..99e4e78 100644
--- a/include/config.h
+++ b/include/config.h
@@ -12,7 +12,11 @@
#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
diff --git a/z180/Makefile b/z180/Makefile
index f676826..c6727b9 100644
--- a/z180/Makefile
+++ b/z180/Makefile
@@ -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}
-
diff --git a/z180/Tupfile b/z180/Tupfile
index bb88946..50ede98 100644
--- a/z180/Tupfile
+++ b/z180/Tupfile
@@ -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
index 0000000..956faf1
--- /dev/null
+++ b/z180/asci-p.180
@@ -0,0 +1,133 @@
+ page 200
+
+ extrn ioiniml
+
+ global as0init
+ global as0ista,as0inp
+ global as0osta,as0out
+ global as1init
+ global as1ista,as1inp
+ global as1osta,as1out
+
+ include config.inc
+ include z180reg.inc
+
+
+;-----------------------------------------------------
+;
+;
+; TC = (f PHI /(2*baudrate*Clock_mode)) - 2
+;
+; TC = (f PHI / (32 * baudrate)) - 2
+;
+
+ cseg
+;
+; Init Serial I/O for console input and output (ASCI1)
+;
+
+
+
+as0init:
+ ld hl,initab0
+ jp ioiniml
+
+as1init:
+ ld hl,initab1
+ jp ioiniml
+
+
+ ld a,M_MPBT
+ out0 (cntlb1),a
+ ld a,M_RE + M_TE + M_MOD2 ;Rx/Tx enable
+ out0 (cntla1),a
+ ld a,M_RIE
+ out0 (stat1),a ;Enable rx interrupts
+
+ ret ;
+
+
+initab0:
+ db 1,stat0,0 ;Disable rx/tx interrupts
+ ;Enable baud rate generator
+ db 1,asext0,M_BRGMOD+M_DCD0DIS+M_CTS0DIS
+ db 2,astc0l,low 28, high 28
+ db 1,cntlb0,M_MPBT ;No MP Mode, X16
+ db 1,cntla0,M_RE+M_TE+M_MOD2 ;Rx/Tx enable, 8N1
+ db 0
+
+initab1:
+ db 1,stat1,0 ;Disable rx/tx ints, disable CTS1
+ db 1,asext1,M_BRGMOD ;Enable baud rate generator
+ db 2,astc1l,low 3, high 3
+ db 1,cntlb1,M_MPBT ;No MP Mode, X16
+ db 1,cntla1,M_RE+M_TE+M_MOD2 ;Rx/Tx enable, 8N1
+ db 0
+
+
+
+as0ista:
+ in0 a,(stat0)
+ and M_RDRF
+ ret z
+ or 0ffh
+ ret
+
+as1ista:
+ in0 a,(stat1)
+ and M_RDRF
+ ret z
+ or 0ffh
+ ret
+
+
+as0inp:
+ in0 a,(stat0)
+ rlca
+ jr nc,as0inp
+ in0 a,rdr0
+ ret
+
+as1inp:
+ in0 a,(stat1)
+ rlca
+ jr nc,as1inp
+ in0 a,rdr1
+ ret
+
+
+
+as0osta:
+ in0 a,(stat0)
+ and M_TDRE
+ ret z
+ or 0ffh
+ ret
+
+as1osta:
+ in0 a,(stat1)
+ and M_TDRE
+ ret z
+ or 0ffh
+ ret
+
+
+as0out:
+ in0 a,(stat0)
+ and M_TDRE
+ jr z,as0out
+ out0 (tdr0),c
+ ld a,c
+ ret
+
+as1out:
+ in0 a,(stat1)
+ and M_TDRE
+ jr z,as1out
+ out0 (tdr1),c
+ ld a,c
+ ret
+
+ end
+
+
diff --git a/z180/ser1-i.180 b/z180/asci1-i.180
index 2410e38..15e121a 100644
--- a/z180/ser1-i.180
+++ b/z180/asci1-i.180
@@ -4,12 +4,12 @@
extrn buf.init
extrn isv_sw
-
+
global ser.init
global ser.ist,ser.in
global ser.ost,ser.out
-;TODO: define a trampoline area somewhere in top ram.
+;TODO: define a trampoline area somewhere in top ram.
rtxisvjmp equ 0FF60h ;momentan frei...
include config.inc
@@ -19,10 +19,10 @@ rtxisvjmp equ 0FF60h ;momentan frei...
;-----------------------------------------------------
dseg
-
+
buf_start:
- mkbuf ser1.inbuf,s1.rx_len
- mkbuf ser1.outbuf,s1.tx_len
+ mkbuf s1.rx_id, ser1.inbuf, s1.rx_len
+ mkbuf s1.tx_id, ser1.outbuf, s1.tx_len
buf_end:
@@ -33,7 +33,7 @@ buf_end:
;
; Init Serial I/O for console input and output (ASCI1)
;
-
+
ser.init:
; ld a,i
@@ -42,10 +42,10 @@ ser.init:
xor a ;
out0 (stat1),a ;Disable rx/tx interrupts
-
+
ld hl,rxtx_src ;move rx and tx isv to common ram
ld de,rxtx_dst ;
- ld bc,rxtx_src_e-rxtx_src ;
+ ld bc,rxtx_src_e-rxtx_src ;
ldir ;
ld hl,rtxisvjmp ;rx/tx int vector
@@ -59,7 +59,7 @@ ser.init:
; ASCI1: 8N1, highest baudrate (56700), CTS disabled
- ld a,M_MPBT
+ ld a,M_MPBT
out0 (cntlb1),a
ld a,M_RE + M_TE + M_MOD2
out0 (cntla1),a
@@ -89,21 +89,21 @@ buf.empty:
ret z
or 0ffh
ret
-
+
ser.in:
- push hl ;11
+ push hl ;11
push de ;11
- ld hl,ser1.inbuf-1 ; 9 hl = &rx.out_idx
+ ld hl,ser1.inbuf-1 ; 9 hl = &rx.out_idx
ld a,(hl) ; 6 a = rx.out_idx
dec hl ; 4 hl = &rx.in_idx
jr bg.w1
bg.wait:
halt
bg.w1:
- cp (hl) ; 6 while (out_idx==in_idx)
+ cp (hl) ; 6 while (out_idx==in_idx)
jr z,bg.wait ; 6 (/8) ;
- ld e,a ; 4
+ ld e,a ; 4
ld d,0 ; 6
inc de
inc de
@@ -111,20 +111,20 @@ bg.w1:
ex de,hl ; 3
add hl,de ;10
ld l,(hl) ; 6
- ex de,hl ; 3
+ ex de,hl ; 3
inc a ; 4
dec hl ; 4
- and (hl) ; 6
+ and (hl) ; 6
inc hl ; 4
inc hl ; 4
ld (hl),a ; 7
-
+
ld a,e ; 4
pop de ; 9
pop hl ; 9
ret ; 9
- ; 153
+ ; 153
ser.ost:
push ix
@@ -191,7 +191,7 @@ rxtxisv:
in0 d,(rdr1) ;todo: break detection
bit FE,a ;framing error?
jr nz,??ri_1
-
+
push ix
ld ix,ser1.inbuf ;
ld hl,ser1.inbuf ;
@@ -233,7 +233,7 @@ txisv:
??ti_1:
ld l,(hl)
out0 (tdr1),l ;071b
-
+
ld a,(ix+o.out_idx) ;
inc a
and (ix+o.mask)
@@ -254,5 +254,3 @@ rxtx_src_e:
end
-
-
diff --git a/z180/bioscio.180 b/z180/bioscio.180
index 5ec55c6..2d8e5e0 100644
--- a/z180/bioscio.180
+++ b/z180/bioscio.180
@@ -65,7 +65,8 @@ c$init$loop:
dec c
jp p,c$init$loop
- ld hl,1000000000000000b ; assign console to HOST
+; ld hl,1000000000000000b ; assign console to HOST
+ ld hl,0010000000000000b ; assign console to ASCI1
ld (@civec),hl
ld (@covec),hl
ld hl,0000000000000000b ; assign auxiliary to nothing
diff --git a/z180/chario.180 b/z180/chario.180
index 6632690..4d37b89 100644
--- a/z180/chario.180
+++ b/z180/chario.180
@@ -2,20 +2,21 @@
.z80
-; CP/M 3 compatible character i/o
+; CP/M 3 compatible character i/o
public ?cinit,?ci,?co,?cist,?cost
public @ctbl
extrn ff.init,ff.i.st,ff.in,ff.o.st,ff.out
- extrn ser.init,ser.ist,ser.in,ser.ost,ser.out
-
+ extrn as0init,as0ista,as0inp,as0osta,as0out
+ extrn as1init,as1ista,as1inp,as1osta,as1out
+
include config.inc
include z180reg.inc
include modebaud.inc ; define mode bits and baud eqautes
-max$device equ 2
+max$device equ 3
cseg
@@ -25,7 +26,8 @@ max$device equ 2
ld b,c
call vector$io
dw ff.init
- dw ser.init
+ dw as0init
+ dw as1init
dw rret
; b = device, c = output char, a = input char
@@ -33,25 +35,29 @@ max$device equ 2
?ci: ; character input
call vector$io
dw ff.in
- dw ser.in
+ dw as0inp
+ dw as1inp
dw null$input
?cist: ; character input status
call vector$io
dw ff.i.st
- dw ser.ist
+ dw as0ista
+ dw as1ista
dw null$status
?co: ; character output
call vector$io
dw ff.out
- dw ser.out
+ dw as0out
+ dw as1out
dw rret
?cost: ; character output status
call vector$io
dw ff.o.st
- dw ser.ost
+ dw as0osta
+ dw as1osta
dw ret$true
vector$io:
@@ -89,10 +95,15 @@ null$status:
@ctbl:
db 'HOST ' ; device 0
- db mb$output
+ db mb$in$out
db baud$none
- db 'ASCI1 ' ; device 0
+ db 'ASCI0 ' ; device 1
+ db mb$in$out+mb$serial+mb$soft$baud
+ser0$baud:
+ db baud$19200
+
+ db 'ASCI1 ' ; device 2
db mb$in$out+mb$serial+mb$soft$baud
ser1$baud:
db baud$19200
@@ -100,4 +111,3 @@ ser1$baud:
db 0 ; table terminator
end
-
diff --git a/z180/conbuf-a.180 b/z180/conbuf-a.180
index 8534f73..e86b8b2 100644
--- a/z180/conbuf-a.180
+++ b/z180/conbuf-a.180
@@ -1,6 +1,6 @@
page 255
.z80
-
+
;
; FIFO channels for communication with avr
;
@@ -9,16 +9,18 @@
extrn buf.init
include config.inc
+ if CPU_Z180
include z180reg.inc
+ endif
;--------------------------------------------------------------
dseg
-
- mkbuf co.fifo,co.fifo_len
- mkbuf ci.fifo,ci.fifo_len
+
+ mkbuf co.fifo_id, co.fifo, co.fifo_len
+ mkbuf ci.fifo_id, ci.fifo, ci.fifo_len
;--------------------------------------------------------------
@@ -48,7 +50,7 @@ buf.empty:
ret z
or 0ffh
ret
-
+
ff.in:
push ix
@@ -69,12 +71,12 @@ bg.wait:
inc h
bg.nc:
ld l,(hl)
-
+
ld a,(ix+o.out_idx) ;
inc a
and (ix+o.mask)
ld (ix+o.out_idx),a
-
+
ld a,l
pop hl
pop ix
@@ -96,36 +98,68 @@ buf.full:
ret
+ if 1
ff.out:
- push ix
- ld ix,co.fifo ;
+ push ix ;15
+ ld ix,co.fifo ;14
buf.put:
- push hl ;
- push bc
- push ix
- pop hl
- ld a,c
- ld c,(ix+o.in_idx) ;
- ld b,0
- add hl,bc
- ld b,a
+ push hl ;11
+ push bc ;11
+ push ix ;15
+ pop hl ;10
+ ld a,c ;4
+ ld c,(ix+o.in_idx) ;19
+ ld b,0 ;7
+ add hl,bc ;11
+ ld (hl),a ;7
+ ld b,a ;4
+
+ ld a,c ;4
+ inc a ;4
+ and (ix+o.mask) ;19
+bp.wait:
+ cp (ix+o.out_idx) ;19
+ jr z,bp.wait ;12/7
+ ld (ix+o.in_idx),a ;19
- ld a,c ;
- inc a
- and (ix+o.mask)
+ out (AVRINT6),a ;11
+ ld a,b ;4
+ pop bc ;10
+ pop hl ;10
+ pop ix ;14
+ ret ;10
+
+ else
+
+ff.out:
+ push ix ;15
+ ld ix,co.fifo ;14
+
+buf.put:
+ push hl ;11
+ push ix ;15
+ pop hl ;10
+ ld a,(ix+o.in_idx) ;19
+ add a,l ;4
+ ld l,a ;4
+ jr nc,bp.1 ;12/7
+ inc l ;4
+ ld (hl),c ;7
+ ld a,(ix+o.in_idx) ;19
+ inc a ;4
+ and (ix+o.mask) ;19
bp.wait:
- cp (ix+o.out_idx) ;
- jr z,bp.wait
- ld (hl),b
- ld (ix+o.in_idx),a
-
- out (AVRINT6),a
- ld a,b
- pop bc
- pop hl
- pop ix
- ret
+ cp (ix+o.out_idx) ;19
+ jr z,bp.wait ;12/7
+ ld (ix+o.in_idx),a ;19
- end
+ out (AVRINT6),a ;11
+ ld a,c ;4
+ pop hl ;10
+ pop ix ;14
+ ret ;10 |
+
+ endif
+ end
diff --git a/z180/config.inc b/z180/config.inc
index 9cef051..7b6d7ac 100644
--- a/z180/config.inc
+++ b/z180/config.inc
@@ -1,7 +1,42 @@
+FALSE equ 0
+TRUE equ NOT FALSE
+
+
+DEBUG equ true
+
+banked equ true
+
+;-----------------------------------------------------
+; CPU and BANKING types
+
+
+CPU_Z180 equ TRUE
+CPU_Z80 equ FALSE
+
+ROMSYS equ FALSE
+
+AVRCLK equ 18432 ;[KHz]
+
+ if CPU_Z180
+
+;-----------------------------------------------------
+FOSC equ AVRCLK/2 ;Oscillator frequency [KHz]
+PHI equ FOSC*2 ;CPU frequency (clock doubler enabled)
+
+;----------------------------------------------------------------------
+; Baudrate Generator for x16 clock mode:
+; TC = (f PHI / (32 * baudrate)) - 2
+;
+; PHI [MHz]: 9.216 18.432
+; baudrate TC TC
+; ----------------------
+; 115200 - 3
+; 57600 3 8
+; 38400 - 13
+; 19200 13 28
+; 9600 28 58
-FOSC equ 9216 ;Oscillator frequency [KHz]
-PHI equ FOSC*2 ;CPU frequency
;-----------------------------------------------------
; Programmable Reload Timer (PRT)
@@ -16,8 +51,21 @@ PRT_TC10MS equ PHI / (PRT_PRE/10)
;-----------------------------------------------------
; MMU
-SYS$CBAR equ 0C8h
-USR$CBAR equ 0F0h
+COMMON_SIZE equ 16*1024 ;Common Area size in bytes
+ ;must be multiple of 4K
+
+if (COMMON_SIZE mod 1000h)
+ .printx COMMON_SIZE not multiple of 4K!
+ end ;stop assembly
+endif
+
+CSK equ COMMON_SIZE/1000h ;
+CA equ 10h - CSK ;common area start
+BA equ 0 ;banked area start
+
+SYS$CBR equ 0
+SYS$CBAR equ CA*16 + CA ;CBAR in system mode
+USR$CBAR equ CA*16 + BA ;CBAR in user mode (CP/M)
BANKS equ 18 ;max nr. of banks
@@ -26,36 +74,81 @@ BANKS equ 18 ;max nr. of banks
CREFSH equ 0 ;Refresh rate register (disable refresh)
CWAITIO equ 3 shl IWI0 ;Max I/O Wait States, 0 Memory Wait States
-
-
-ROMSYS equ 0
-
- if ROMSYS
+PHI_X2 equ 0 ;set to M_X2CM to enable the clock doubler
+
+ endif ;CPU_Z180
+ if CPU_Z80
+
+PHI equ AVRCLK/5 ;CPU frequency [KHz]
+BAUDCLCK equ AVRCLK/10 ;Baudrate clock [KHz]
+;BDCLK16 equ
+
+SIOAD EQU 0bch
+SIOAC EQU 0bdh
+SIOBD EQU 0beh
+SIOBC EQU 0bfh
+
+CTC0 EQU 0f4h
+CTC1 EQU 0f5h
+CTC2 EQU 0f6h
+CTC3 EQU 0f7h
+
+;
+; Init Serial I/O for console input and output (SIO-A)
+;
+; Baudrate clock: 1843200 Hz (Bus connector pin A17)
+;
+; Baudrate Divider SIO CTC
+; ---------------------------------
+; 115200 16 16 1
+; 57600 32 16 2
+; 38400 48 16 3
+; 19200 96 16 6
+; 9600 192 16 12
+; 4800 384 16 24
+; 2400 768 16 48
+; 1200 1536 16 96
+; 600 3072 16 192
+; 300 6144 64 92
+
+ endif ; CPU_Z80
+
+ if ROMSYS
c$rom equ 0a5h
ROM_EN equ 0C0h
ROM_DIS equ ROMEN+1
+ if CPU_Z180
CWAITROM equ 2 shl MWI0
- endif
+ endif
+ endif
-DRSTNUM equ 30h ;DDTZ Restart vector (breakpoints)
+DDTZRSTVEC equ 030h ;DDTZ Restart vector (breakpoints)
+INIDONE equ 03Fh ;CP/M skip hw init, if this address
+INIDONEVAL equ 080h ; is set to this value.
-mrx.fifo_len equ 256
-mtx.fifo_len equ 256
+mtx.fifo_len equ 32 ;Message transfer fifos
+mtx.fifo_id equ 0 ; This *must* have #0
+mrx.fifo_len equ 32
+mrx.fifo_id equ 1
-ci.fifo_len equ 128
-co.fifo_len equ 256
+ci.fifo_len equ 32 ;AVRCON Character I/O via AVR
+ci.fifo_id equ 2
+co.fifo_len equ 32
+co.fifo_id equ 3
-s1.rx_len equ 256 ;Serial 1 (ASCI1) buffers
-s1.tx_len equ 256 ;
+s1.rx_len equ 128 ;Serial 1 (ASCI1) buffers
+s1.rx_id equ 4 ;
+s1.tx_len equ 128 ;
+s1.tx_id equ 5 ;
-AVRINT5 equ 40h
-AVRINT6 equ 50h
+AVRINT5 equ 4Fh
+AVRINT6 equ 5Fh
;PMSG equ 80h
;-----------------------------------------------------
-; Definition of (locical) top 2 memory pages
+; Definition of (logical) top 2 memory pages
sysram_start equ 0FE00h
stacksize equ 80
@@ -69,24 +162,26 @@ iv2tab equ ivtab + 2*9
;-----------------------------------------------------
-
+o.id equ -4
o.mask equ -3
o.in_idx equ -2
o.out_idx equ -1
.lall
-mkbuf macro name,size
- if ((size & (size-1)) ne 0) or (size gt 256)
+mkbuf macro id,name,size
+ if ((size AND (size-1)) NE 0) OR (size GT 256)
.printx Error: buffer ^size must be power of 2 and in range 0..256!
name&.mask equ ;wrong size error
else
+ db id
ds 3
name:: ds size
name&.mask equ low (size-1)
if size ne 0
name&.end equ $-1
name&.len equ size
+ name&.id equ id
endif
endif
endm
@@ -103,4 +198,3 @@ inidate macro
dseg
ds ??ps.len
endm
-
diff --git a/z180/console.180 b/z180/console.180
index d4f4130..1241d5a 100644
--- a/z180/console.180
+++ b/z180/console.180
@@ -2,47 +2,136 @@
.z80
- global $coninit
- global $cists,$ci
- global $co
+; iobyte:
+; 0 = console on AVR-System
+; 1 = console on SIO/ASCI
- extrn ser.init,ser.ist,ser.in,ser.ost,ser.out
+ extrn iobyte
extrn ff.init,ff.i.st,ff.in
extrn ff.o.st,ff.out
+ if CPU_Z180
+ extrn as0init,as0ista,as0inp,as0osta,as0out
+ extrn as1init,as1ista,as1inp,as1osta,as1out
+ else
+ extrn ser.init,ser.ist,ser.in,ser.ost,ser.out
+ endif
+ public charini
+ public ?const,?conin
+ public ?conos,?cono
include config.inc
+ if CPU_Z180
include z180reg.inc
+ endif
cseg
-;
-;
-$coninit:
+ if CPU_Z180
+charini:
+ call ff.init
+ call as0init
+ jp as1init
+
+?const:
+ ld a,(iobyte)
+ and 03h
+ jp z,ff.i.st
+ dec a
+ jp z,as0ista
+ dec a
+ jp z,as1ista
+ jr nullstatus
+
+?conin:
+ ld a,(iobyte)
+ and 03h
+ jp z,ff.in
+ dec a
+ jp z,as0inp
+ dec a
+ jp z,as1inp
+ jr nullinput
+
+?conos:
+ ld a,(iobyte)
+ and 03h
+ jp z,ff.o.st
+ dec a
+ jp z,as0osta
+ dec a
+ jp z,as1osta
+ jr rettrue
+
+?cono:
+ ld a,(iobyte)
+ and 03h
+ jp z,ff.out
+ dec a
+ jp z,as0out
+ dec a
+ jp z,as1out
+ jr nulloutput
+
+ else
+
+charini:
call ff.init
+ ld c,0
call ser.init
+ ld c,1
+ jp ser.init
+
+?const:
+ ld a,(iobyte)
+ and 03h
+ jp z,ff.i.st
+ dec a
+ ld b,a
+ jp ser.ist
+
+?conin:
+ ld a,(iobyte)
+ and 03h
+ jp z,ff.in
+ dec a
+ ld b,a
+ jp ser.in
+
+?conos:
+ ld a,(iobyte)
+ and 03h
+ jp z,ff.o.st
+ dec a
+ ld b,a
+ jp ser.ost
+
+?cono:
+ ld a,(iobyte)
+ and 03h
+ jp z,ff.out
+ dec a
+ ld b,a
+ jp ser.out
+ endif
+
+
+nullinput:
+ ld a,1Ah
ret
-
-$cists:
- call ff.i.st
- ret nz
- call ser.ist
+
+nulloutput:
+ ld a,c
ret
-
-$ci:
- call ff.i.st
- jp nz,ff.in
- call ser.ist
- jp nz,ser.in
- jr $ci
-
-;$costs:
-; jp f.o.st
-
-$co:
- call ff.out
- jp ser.out
-
+
+rettrue:
+ or 0FFh
+ ret
+
+nullstatus:
+ xor a
+ ret
+
end
diff --git a/z180/ddtz.180 b/z180/ddtz.180
index 10fecf8..e8a26fd 100644
--- a/z180/ddtz.180
+++ b/z180/ddtz.180
@@ -2,14 +2,18 @@
.z80
extrn ?const,?conin,?cono
+ extrn getiff
+ extrn selbnk,@cbnk
global ddtz,bpent
global $stack
include config.inc
+ if CPU_Z180
include z180reg.inc
include z180.lib
+ endif
BS equ 08h
TAB equ 09h
@@ -51,10 +55,6 @@ comend macro
endif
endm
-; repeat execution of last common code snippet
-comrep macro
- call ?exclst
- endm
@@ -97,7 +97,7 @@ ddtz:
ld sp,$stack
ld a,(wstrtflg) ;check warm start flag
or a
- jr nz,ddtz_w
+;;; jr nz,ddtz_w
exx
ld hl,sysramc
@@ -105,97 +105,95 @@ ddtz:
ld bc,topcodend-topcodbeg
ldir
- ld hl,vartab
- ld de,ddtram
- ld bc,vartabe-vartab
- ldir
exx
+ if CPU_Z180
ld a,e
ld (ubbr),a
+ endif
ddtz_w:
- ld hl,MSG ;073c
- call PSTR ;073f
- call ddtei ;0742
+ ld hl,MSG
+ call PSTR
+ call ddtei
; DDTZ main loop
DDTZML:
- ld sp,$stack ;0761
- ld hl,l07eah ;0764
- ld (CMD_ERR),hl ;0767
- ld hl,(REG.PC) ;076a
- ld (OFFS.pc),hl ;076d
- call sub_0e68h ;0770
- ld hl,(CMD_RPT) ;0773
- ld de,DDTZML ;0776
- call CP.HL.DE ;0779
- ld a,'>' ;077c
- call OUTCHAR ;077e
- call nz,OUTCHAR ;0781
- call z,OUTBL ;0784
- call INLINE ;0787
- call SKIPBL ;078a
- jr z,exe_hl ;078d
- ld hl,DDTZML ;078f
- ld (CMD_RPT),hl ;0792
- inc de ;0795
- sub '?' ;0796
- jr c,ERROR ;0798
- cp 'Z'+1-'?' ;079a
- jr nc,ERROR ;079c
- add a,a ;079e
- ld hl,CMDTAB ;079f
- call ADD_HL_A ;07a2
- ld a,(hl) ;07a5
- inc hl ;07a6
- ld h,(hl) ;07a7
- ld l,a ;07a8
- jr exe_hl ;07a9
+ ld sp,$stack
+ ld hl,l07eah
+ ld (CMD_ERR),hl
+ ld hl,(REG.PC)
+ ld (OFFS.pc),hl
+ call sub_0e68h
+ ld hl,(CMD_RPT)
+ ld de,DDTZML
+ call CP.HL.DE
+ ld a,'>'
+ call OUTCHAR
+ call nz,OUTCHAR
+ call z,OUTBL
+ call INLINE
+ call SKIPBL
+ jr z,exe_hl
+ ld hl,DDTZML
+ ld (CMD_RPT),hl
+ inc de
+ sub '?'
+ jr c,ERROR
+ cp 'Z'+1-'?'
+ jr nc,ERROR
+ add a,a
+ ld hl,CMDTAB
+ call ADD_HL_A
+ ld a,(hl)
+ inc hl
+ ld h,(hl)
+ ld l,a
+ jr exe_hl
ERROR:
- ld hl,(CMD_ERR) ;07ab
+ ld hl,(CMD_ERR)
exe_hl:
- call CALL.HL ;07ae
- jr DDTZML ;07b1
+ call CALL.HL
+ jr DDTZML
CALL.HL:
- jp (hl) ;07b3
+ jp (hl)
CMDTAB:
- defw CMD.?
- defw CMD.@ ;07b4
- defw CMD.A ;07b6
- defw CMD.B ;07b8
- defw CMD.C ;07ba
- defw CMD.D ;07bc
- defw ERROR ;07be
- defw ERROR ;07c0
- defw CMD.G ;07c2
- defw CMD.H ;07c4
- defw CMD.I ;07c6
- defw ERROR ;07c8
- defw ERROR ;07ca
- defw CMD.L ;07cc
- defw CMD.M ;07ce
- defw ERROR ;07d0
- defw CMD.O ;07d2
- defw ERROR ;07d4
- defw CMD.Q ;07d6
- defw CMD.R ;07d8
- defw CMD.S ;07da
- defw CMD.T ;07dc
- defw ERROR ;07de
- defw CMD.V ;07e0
- defw ERROR ;07e2
- defw CMD.X ;07e4
- defw CMD.Y ;07e6
- defw CMD.Z ;07e8
+ defw CMD.? ;Help
+ defw CMD.@ ;Offset
+ defw CMD.A ;Assemble
+ defw CMD.B ;Breakpoint
+ defw CMD.C ;Call
+ defw CMD.D ;Display
+ defw ERROR ;
+ defw ERROR ;
+ defw CMD.G ;Go
+ defw CMD.H ;Hex Math
+ defw CMD.I ;In Port
+ defw ERROR ;
+ defw ERROR ;
+ defw CMD.L ;List
+ defw CMD.M ;Move
+ defw ERROR ;
+ defw CMD.O ;Out Port
+ defw ERROR ;
+ defw CMD.Q ;Query
+ defw CMD.R ;Read Intel Hex
+ defw CMD.S ;Substitute
+ defw CMD.T ;Trace
+ defw ERROR ;
+ defw CMD.V ;Verify
+ defw ERROR ;
+ defw CMD.X ;eXamine
+ defw CMD.Y ;eXamine Y Registers
+ defw CMD.Z ;Zap (fill) memory
l07eah:
- ld a,'?' ;07ea
- call OUTCHAR ;07ec
- jp CRLF ;07ef
+ ld a,'?'
+ call OUTCHAR
+ jp CRLF
CMD.?:
call assert_eol
@@ -295,7 +293,7 @@ l085ch:
ld (hl),a ;
cp ' ' ;
jr nc,l0869h ;
- ld a,'^' ;Controle characters
+ ld a,'^' ;Controll characters
call $co ;
ld a,(hl) ;
add a,'@' ;
@@ -427,74 +425,74 @@ l0911h:
sub_0917h:
- dec b ;0917
- push de ;0918
- ld de,10 ;0919
- call DIV_HL_DE ;091c
- ld a,h ;091f
- or l ;0920
- call nz,sub_0917h ;0921
- ld a,e ;0924
- pop de ;0925
- jr out.digit ;0926
+ dec b
+ push de
+ ld de,10
+ call DIV_HL_DE
+ ld a,h
+ or l
+ call nz,sub_0917h
+ ld a,e
+ pop de
+ jr out.digit
sub_0928h:
- push hl ;0928
- call sub_08f7h ;0929
- call out.hl ;092c
- pop hl ;092f
- ret ;0930
+ push hl
+ call sub_08f7h
+ call out.hl
+ pop hl
+ ret
out.hl:
- ld a,h ;0931
- call out.hex ;0932
- ld a,l ;0935
+ ld a,h
+ call out.hex
+ ld a,l
out.hex:
- push af ;0936
- rra ;0937
- rra ;0938
- rra ;0939
- rra ;093a
- call out.digit ;093b
- pop af ;093e
+ push af
+ rra
+ rra
+ rra
+ rra
+ call out.digit
+ pop af
out.digit:
- and 00fh ;093f
- cp 10 ;0941
- jr c,l0947h ;0943
- add a,007h ;0945
+ and 00fh
+ cp 10
+ jr c,l0947h
+ add a,007h
l0947h:
- add a,'0' ;0947
- jr OUTCHAR ;0949
+ add a,'0'
+ jr OUTCHAR
l094bh:
- ld a,'-' ;094b
- call OUTCHAR ;094d
- ld a,040h ;0950
+ ld a,'-'
+ call OUTCHAR
+ ld a,040h
out.ascii:
- ex af,af' ;0952
- call outquote ;0953
- ex af,af' ;0956
- push af ;0957
- res 7,a ;0958
- cp ' ' ;095a
- jr nc,l0960h ;095c
- sub 0c0h ;095e
+ ex af,af'
+ call outquote
+ ex af,af'
+ push af
+ res 7,a
+ cp ' '
+ jr nc,l0960h
+ sub 0c0h
l0960h:
- call OUTCHAR ;0960
- push af ;0963
- cp '''' ;0964
- call z,OUTCHAR ;0966
- pop af ;0969
- ex af,af' ;096a
- call outquote ;096b
- pop af ;096e
- or a ;096f
- ld a,'.' ;0970
- call m,OUTCHAR ;0972
- ex af,af' ;0975
- jr c,l094bh ;0976
- ret ;0978
+ call OUTCHAR
+ push af
+ cp ''''
+ call z,OUTCHAR
+ pop af
+ ex af,af'
+ call outquote
+ pop af
+ or a
+ ld a,'.'
+ call m,OUTCHAR
+ ex af,af'
+ jr c,l094bh
+ ret
outquote:
- ld a,'''' ;0979
+ ld a,''''
OUTCHAR:
push hl
push de
@@ -509,7 +507,7 @@ OUTCHAR:
pop bc
pop de
pop hl
- ret ;0988
+ ret
inchar:
push hl
@@ -519,406 +517,407 @@ inchar:
and a
jr z,inch1
call ?conin
- scf ;0991
+ scf
inch1:
pop bc
pop de
pop hl
- ret ;0992
+ ret
PSTR:
- ld c,000h ;0993
+ ld c,000h
l0995h:
- ld a,(hl) ;0995
- and a ;0996
- ret z ;0997
- call OUTCHAR ;0998
- inc c ;099b
- inc hl ;099c
- and a ;099d
- ret m ;099e
- jr l0995h ;099f
+ ld a,(hl)
+ and a
+ ret z
+ call OUTCHAR
+ inc c
+ inc hl
+ and a
+ ret m
+ jr l0995h
outbl6:
- call outbl2 ;09a1
+ call outbl2
outbl4:
- call outbl2 ;09a4
+ call outbl2
outbl2:
- call OUTBL ;09a7
+ call OUTBL
OUTBL:
- ld a,' ' ;09aa
- jr OUTCHAR ;09ac
+ ld a,' '
+ jr OUTCHAR
CRLF:
- call inchar ;09ae
- ld a,CR ;09b1
- call OUTCHAR ;09b3
- ld a,LF ;09b6
- call OUTCHAR ;09b8
- ld a,000h ;09bb
- ld (CON.COL),a ;09bd
- jp c,DDTZML ;09c0
- ret ;09c3
+ call inchar
+ ld a,CR
+ call OUTCHAR
+ ld a,LF
+ call OUTCHAR
+ ld a,000h
+ ld (CON.COL),a
+ jp c,DDTZML
+ ret
ADD_HL_A:
- add a,l ;09c4
- ld l,a ;09c5
- ret nc ;09c6
- inc h ;09c7
- ret ;09c8
+ add a,l
+ ld l,a
+ ret nc
+ inc h
+ ret
SKIPBL0:
- inc de ;09c9
+ inc de
SKIPBL:
- ld a,(de) ;09ca
- cp ' ' ;09cb
- jr z,SKIPBL0 ;09cd
- cp 009h ;09cf
- jr z,SKIPBL0 ;09d1
- or a ;09d3
- ret ;09d4
+ ld a,(de)
+ cp ' '
+ jr z,SKIPBL0
+ cp 009h
+ jr z,SKIPBL0
+ or a
+ ret
skip_to_nextarg:
- call SKIPBL ;09d5
- cp ',' ;09d8
- ret nz ;09da
- inc de ;09db
- call SKIPBL ;09dc
- cp a ;09df
- ret ;09e0
+ call SKIPBL
+ cp ','
+ ret nz
+ inc de
+ call SKIPBL
+ cp a
+ ret
assert_eol:
- call SKIPBL ;09e1
- ret z ;09e4
+ call SKIPBL
+ ret z
l09e5h:
- jp ERROR ;09e5
+ jp ERROR
chk.sp:
- push hl ;09e8
- push de ;09e9
- ld hl,0 ;09ea
- add hl,sp ;09ed
- ld de,$stack-50 ;09ee
- call CP.HL.DE ;09f1
- pop de ;09f4
- pop hl ;09f5
- jr c,l09e5h ;09f6
- ret ;09f8
+ push hl
+ push de
+ ld hl,0
+ add hl,sp
+ ld de,$stack-50
+ call CP.HL.DE
+ pop de
+ pop hl
+ jr c,l09e5h
+ ret
CP.HL.DE:
- and a ;09f9
- sbc hl,de ;09fa
- add hl,de ;09fc
- ret ;09fd
+ and a
+ sbc hl,de
+ add hl,de
+ ret
lookupch:
- ld b,000h ;09fe
+ ld b,000h
l0a00h:
- ld a,(hl) ;0a00
- and a ;0a01
- ret z ;0a02
- ld a,(de) ;0a03
- cp (hl) ;0a04
- jr z,l0a0bh ;0a05
- inc hl ;0a07
- inc b ;0a08
- jr l0a00h ;0a09
+ ld a,(hl)
+ and a
+ ret z
+ ld a,(de)
+ cp (hl)
+ jr z,l0a0bh
+ inc hl
+ inc b
+ jr l0a00h
l0a0bh:
- scf ;0a0b
- inc de ;0a0c
- ret ;0a0d
+ scf
+ inc de
+ ret
sub_0a0eh:
- ld hl,b_0x132A_start ;0a0e
- ld b,07fh ;0a11
- jr l0a17h ;0a13
+ ld hl,b_0x132A_start
+ ld b,07fh
+ jr l0a17h
sub_0a15h:
- ld b,0ffh ;0a15
+ ld b,0ffh
l0a17h:
- inc b ;0a17
- ld a,(hl) ;0a18
- and a ;0a19
- ret z ;0a1a
- call l0a27 ;0a1b
- jr nc,l0a17h ;0a1e
- res 7,b ;0a20
- ret ;0a22
+ inc b
+ ld a,(hl)
+ and a
+ ret z
+ call l0a27
+ jr nc,l0a17h
+ res 7,b
+ ret
sub_0a23h:
- push bc ;0a23
- res 7,b ;0a24
+ push bc
+ res 7,b
db 3eh ;0a26 ld a,0c5h
l0a27:
- push bc ;0a27
- push de ;0a28
+ push bc
+ push de
l0a29h:
- ld a,(de) ;0a29
- xor (hl) ;0a2a
- and 07fh ;0a2b
- jr nz,l0a41h ;0a2d
- bit 7,(hl) ;0a2f
- inc hl ;0a31
- inc de ;0a32
- jr z,l0a29h ;0a33
- scf ;0a35
- bit 7,b ;0a36
- call z,sub_0d20h ;0a38
- jr nc,l0a44h ;0a3b
- pop af ;0a3d
- scf ;0a3e
- pop bc ;0a3f
- ret ;0a40
+ ld a,(de)
+ xor (hl)
+ and 07fh
+ jr nz,l0a41h
+ bit 7,(hl)
+ inc hl
+ inc de
+ jr z,l0a29h
+ scf
+ bit 7,b
+ call z,sub_0d20h
+ jr nc,l0a44h
+ pop af
+ scf
+ pop bc
+ ret
l0a41h:
- call sub_0a50h ;0a41
+ call sub_0a50h
l0a44h:
- pop de ;0a44
- and a ;0a45
- pop bc ;0a46
- ret ;0a47
+ pop de
+ and a
+ pop bc
+ ret
sub_0a48h:
- inc b ;0a48
+ inc b
l0a49h:
- dec b ;0a49
- ret z ;0a4a
- call sub_0a50h ;0a4b
- jr l0a49h ;0a4e
+ dec b
+ ret z
+ call sub_0a50h
+ jr l0a49h
sub_0a50h:
- ld a,(hl) ;0a50
- and a ;0a51
- ret z ;0a52
+ ld a,(hl)
+ and a
+ ret z
l0a53h:
- ld a,(hl) ;0a53
- inc hl ;0a54
- and a ;0a55
- ret m ;0a56
- jr l0a53h ;0a57
+ ld a,(hl)
+ inc hl
+ and a
+ ret m
+ jr l0a53h
get_arg3:
- call get_arg_range ;0a59
- push hl ;0a5c
- push bc ;0a5d
- call skip_to_nextarg ;0a5e
- call get_arg ;0a61
- ex de,hl ;0a64
- pop bc ;0a65
- pop hl ;0a66
- ret ;0a67
+ call get_arg_range
+ push hl
+ push bc
+ call skip_to_nextarg
+ call get_arg
+ ex de,hl
+ pop bc
+ pop hl
+ ret
sub_0a68h:
- call EXPR ;0a68
- jr c,error0 ;0a6b
- ret ;0a6d
+ call EXPR
+ jr c,error0
+ ret
get_arg:
- call sub_0a68h ;0a6e
+ call sub_0a68h
l0a71h:
- jp assert_eol ;0a71
+ jp assert_eol
get_lastarg_def:
- call get_arg_def ;0a74
- jr l0a71h ;0a77
+ call get_arg_def
+ jr l0a71h
get_arg_def:
- push hl ;0a79
- call EXPR ;0a7a
- jr c,l0a80h ;0a7d
- ex (sp),hl ;0a7f
+ push hl
+ call EXPR
+ jr c,l0a80h
+ ex (sp),hl
l0a80h:
- pop hl ;0a80
- ret ;0a81
+ pop hl
+ ret
sub_0a82h:
- call sub_0a87h ;0a82
- jr l0a71h ;0a85
+ call sub_0a87h
+ jr l0a71h
sub_0a87h:
db 0e6h ;0a87 and 037h (clear carry)
get_arg_range:
scf
- ex af,af' ;0a89
- push bc ;0a8a
- push hl ;0a8b
- call EXPR ;0a8c
- jr nc,l0a97h ;0a8f
- ex af,af' ;0a91
- jr c,error0 ;0a92
- ex af,af' ;0a94
- pop hl ;0a95
-
- defb 03eh ;0a96
+ ex af,af'
+ push bc
+ push hl
+ call EXPR
+ jr nc,l0a97h
+ ex af,af'
+ jr c,error0
+ ex af,af'
+ pop hl
+
+ defb 03eh
l0a97h:
- pop af ;0a97
- call sub_0aa5h ;0a98
- jr nc,l0aa3h ;0a9b
- ex af,af' ;0a9d
- pop bc ;0a9e
- ret nc ;0a9f
+ pop af
+ call sub_0aa5h
+ jr nc,l0aa3h
+ ex af,af'
+ pop bc
+ ret nc
error0:
- jp ERROR ;0aa0
+ jp ERROR
l0aa3h:
- pop af ;0aa3
- ret ;0aa4
+ pop af
+ ret
sub_0aa5h:
- call skip_to_nextarg ;0aa5
- cp 'S' ;0aa8
- jr nz,l0aadh ;0aaa
- inc de ;0aac
+ call skip_to_nextarg
+ cp 'S'
+ jr nz,l0aadh
+ inc de
l0aadh:
- push hl ;0aad
- push af ;0aae
- call EXPR ;0aaf
- jr c,l0ac3h ;0ab2
- ld b,h ;0ab4
- ld c,l ;0ab5
- pop af ;0ab6
- pop hl ;0ab7
- jr z,l0ac1h ;0ab8
- ld a,c ;0aba
- sub l ;0abb
- ld c,a ;0abc
- ld a,b ;0abd
- sbc a,h ;0abe
- ld b,a ;0abf
- inc bc ;0ac0
+ push hl
+ push af
+ call EXPR
+ jr c,l0ac3h
+ ld b,h
+ ld c,l
+ pop af
+ pop hl
+ jr z,l0ac1h
+ ld a,c
+ sub l
+ ld c,a
+ ld a,b
+ sbc a,h
+ ld b,a
+ inc bc
l0ac1h:
- and a ;0ac1
- ret ;0ac2
+ and a
+ ret
l0ac3h:
- pop af ;0ac3
- pop hl ;0ac4
- jr z,error0 ;0ac5
- scf ;0ac7
- ret ;0ac8
+ pop af
+ pop hl
+ jr z,error0
+ scf
+ ret
EXPR:
- call SKIPBL ;0ac9
+ call SKIPBL
EXPR1:
- call do_subexpr ;0acc
- ret c ;0acf
- call do_rel_op ;0ad0
- ret nc ;0ad3
- push bc ;0ad4
- push hl ;0ad5
- call do_subexpr ;0ad6
- jr c,error0 ;0ad9
- ex de,hl ;0adb
- ex (sp),hl ;0adc
- and a ;0add
- sbc hl,de ;0ade
- ld hl,0ffffh ;0ae0
- pop de ;0ae3
- ret ;0ae4
+ call do_subexpr
+ ret c
+ call do_rel_op
+ ret nc
+ push bc
+ push hl
+ call do_subexpr
+ jr c,error0
+ ex de,hl
+ ex (sp),hl
+ and a
+ sbc hl,de
+ ld hl,0ffffh
+ pop de
+ ret
do_op_eq:
- jr z,l0af8h ;0ae5
- jr l0af7h ;0ae7
+ jr z,l0af8h
+ jr l0af7h
do_op_ne:
- jr nz,l0af8h ;0ae9
- jr l0af7h ;0aeb
+ jr nz,l0af8h
+ jr l0af7h
do_op_le:
- jr z,l0af8h ;0aed
+ jr z,l0af8h
do_op_lt:
- jr c,l0af8h ;0aef
- jr l0af7h ;0af1
+ jr c,l0af8h
+ jr l0af7h
do_op_gt:
- jr z,l0af7h ;0af3
+ jr z,l0af7h
do_op_ge:
- jr nc,l0af8h ;0af5
+ jr nc,l0af8h
l0af7h:
- inc hl ;0af7
+ inc hl
l0af8h:
- and a ;0af8
- ret ;0af9
+ and a
+ ret
do_rel_op:
- push hl ;0afa
- ld hl,tab_eq_le_ge ;0afb
- call lookupch ;0afe
- jr nc,l0b28h ;0b01
- ld a,b ;0b03
- or a ;0b04
- jr z,l0b1ch ;0b05
- ld a,(de) ;0b07
- cp '=' ;0b08
- jr nz,l0b11h ;0b0a
- inc de ;0b0c
- inc b ;0b0d
- inc b ;0b0e
- jr l0b1ch ;0b0f
+ push hl
+ ld hl,tab_eq_le_ge
+ call lookupch
+ jr nc,l0b28h
+ ld a,b
+ or a
+ jr z,l0b1ch
+ ld a,(de)
+ cp '='
+ jr nz,l0b11h
+ inc de
+ inc b
+ inc b
+ jr l0b1ch
l0b11h:
- bit 0,b ;0b11
- jr z,l0b1ch ;0b13
- cp '>' ;0b15
- jr nz,l0b1ch ;0b17
- inc de ;0b19
- ld b,005h ;0b1a
+ bit 0,b
+ jr z,l0b1ch
+ cp '>'
+ jr nz,l0b1ch
+ inc de
+ ld b,005h
l0b1ch:
- ld hl,tab_func_eqlege ;0b1c
- ld a,b ;0b1f
- add a,a ;0b20
- call ADD_HL_A ;0b21
- ld c,(hl) ;0b24
- inc hl ;0b25
- ld b,(hl) ;0b26
- scf ;0b27
+ ld hl,tab_func_eqlege
+ ld a,b
+ add a,a
+ call ADD_HL_A
+ ld c,(hl)
+ inc hl
+ ld b,(hl)
+ scf
l0b28h:
- pop hl ;0b28
- ret ;0b29
+ pop hl
+ ret
tab_eq_le_ge:
db '=<>',0
tab_func_eqlege:
- defw do_op_eq ;0b2e
- defw do_op_lt ;0b30
- defw do_op_gt ;0b32
- defw do_op_le ;0b34
- defw do_op_ge ;0b36
- defw do_op_ne ;0b38
+ defw do_op_eq
+ defw do_op_lt
+ defw do_op_gt
+ defw do_op_le
+ defw do_op_ge
+ defw do_op_ne
do_subexpr:
- call do_factor ;0b3a
- ret c ;0b3d
+ call do_factor
+ ret c
l0b3eh:
- call do_binary_op ;0b3e
- push hl ;0b41
- push bc ;0b42
- call do_factor ;0b43
- pop bc ;0b46
- ex de,hl ;0b47
- ex (sp),hl ;0b48
- jr nc,l0b52h ;0b49
- pop de ;0b4b
- ld a,b ;0b4c
- or c ;0b4d
- ret z ;0b4e
- jp ERROR ;0b4f
+ call do_binary_op
+ push hl
+ push bc
+ call do_factor
+ pop bc
+ ex de,hl
+ ex (sp),hl
+ jr nc,l0b52h
+ pop de
+ ld a,b
+ or c
+ ret z
+ jp ERROR
l0b52h:
- ld a,b ;0b52
- or c ;0b53
- push bc ;0b54
- ret nz ;0b55
- pop bc ;0b56
+ ld a,b
+ or c
+ push bc
+ ret nz
+ pop bc
do_op_add:
- add hl,de ;0b57
+ add hl,de
l0b58h:
- pop de ;0b58
- jr l0b3eh ;0b59
+ pop de
+ jr l0b3eh
do_op_sub:
- and a ;0b5b
- sbc hl,de ;0b5c
- jr l0b58h ;0b5e
+ and a
+ sbc hl,de
+ jr l0b58h
do_op_mlt:
- push bc ;0b60
+ push bc
+ if CPU_Z180
ld b,h
ld c,e
ld h,e
@@ -930,462 +929,478 @@ do_op_mlt:
add a,c
add a,e
ld h,a
- pop bc ;0b72
- jr l0b58h ;0b73
+ else
+ ld b,h
+ ld c,l
+ ld hl,0
+ ld a,16
+mlt_1:
+ add hl,hl
+ ex de,hl
+ add hl,hl
+ ex de,hl
+ jr nc,mlt_2
+ add hl,bc
+mlt_2:
+ dec a
+ jr nz,mlt_1
+ endif
+ pop bc
+ jr l0b58h
do_op_div:
- call DIV_HL_DE ;0b75
- jr l0b58h ;0b78
+ call DIV_HL_DE
+ jr l0b58h
do_op_mod:
- call DIV_HL_DE ;0b7a
- ex de,hl ;0b7d
- jr l0b58h ;0b7e
+ call DIV_HL_DE
+ ex de,hl
+ jr l0b58h
DIV_HL_DE:
- push bc ;0b80
- ex de,hl ;0b81
- ld b,h ;0b82
- ld c,l ;0b83
- ld hl,0 ;0b84
- ld a,16 ;0b87
+ push bc
+ ex de,hl
+ ld b,h
+ ld c,l
+ ld hl,0
+ ld a,16
l0b89h:
- push af ;0b89
- add hl,hl ;0b8a
- ex de,hl ;0b8b
- xor a ;0b8c
- add hl,hl ;0b8d
- ex de,hl ;0b8e
- adc a,l ;0b8f
- sub c ;0b90
- ld l,a ;0b91
- ld a,h ;0b92
- sbc a,b ;0b93
- ld h,a ;0b94
- inc de ;0b95
- jr nc,l0b9ah ;0b96
- add hl,bc ;0b98
- dec de ;0b99
+ push af
+ add hl,hl
+ ex de,hl
+ xor a
+ add hl,hl
+ ex de,hl
+ adc a,l
+ sub c
+ ld l,a
+ ld a,h
+ sbc a,b
+ ld h,a
+ inc de
+ jr nc,l0b9ah
+ add hl,bc
+ dec de
l0b9ah:
- pop af ;0b9a
- dec a ;0b9b
- jr nz,l0b89h ;0b9c
- ex de,hl ;0b9e
- pop bc ;0b9f
- ret ;0ba0
+ pop af
+ dec a
+ jr nz,l0b89h
+ ex de,hl
+ pop bc
+ ret
do_op_and:
- ld a,h ;0ba1
- and d ;0ba2
- ld h,a ;0ba3
- ld a,l ;0ba4
- and e ;0ba5
- ld l,a ;0ba6
- jr l0b58h ;0ba7
+ ld a,h
+ and d
+ ld h,a
+ ld a,l
+ and e
+ ld l,a
+ jr l0b58h
do_op_or:
- ld a,h ;0ba9
- or d ;0baa
- ld h,a ;0bab
- ld a,l ;0bac
- or e ;0bad
- ld l,a ;0bae
- jr l0b58h ;0baf
+ ld a,h
+ or d
+ ld h,a
+ ld a,l
+ or e
+ ld l,a
+ jr l0b58h
do_op_xor:
- ld a,h ;0bb1
- xor d ;0bb2
- ld h,a ;0bb3
- ld a,l ;0bb4
- xor e ;0bb5
- ld l,a ;0bb6
- jr l0b58h ;0bb7
+ ld a,h
+ xor d
+ ld h,a
+ ld a,l
+ xor e
+ ld l,a
+ jr l0b58h
do_binary_op:
- push hl ;0bb9
- ld hl,tab_op_a ;0bba
- call lookupch ;0bbd
- ld a,b ;0bc0
- ld hl,tab_func_opa ;0bc1
- add a,a ;0bc4
- call ADD_HL_A ;0bc5
- ld c,(hl) ;0bc8
- inc hl ;0bc9
- ld b,(hl) ;0bca
- pop hl ;0bcb
- ret ;0bcc
+ push hl
+ ld hl,tab_op_a
+ call lookupch
+ ld a,b
+ ld hl,tab_func_opa
+ add a,a
+ call ADD_HL_A
+ ld c,(hl)
+ inc hl
+ ld b,(hl)
+ pop hl
+ ret
tab_op_a:
DB '+-*/%&!#',0
tab_func_opa:
- defw do_op_add ;0bd6
- defw do_op_sub ;0bd8
- defw do_op_mlt ;0bda
- defw do_op_div ;0bdc
- defw do_op_mod ;0bde
- defw do_op_and ;0be0
- defw do_op_or ;0be2
- defw do_op_xor ;0be4
- defw 0 ;0be6
+ defw do_op_add
+ defw do_op_sub
+ defw do_op_mlt
+ defw do_op_div
+ defw do_op_mod
+ defw do_op_and
+ defw do_op_or
+ defw do_op_xor
+ defw 0
fact_factor:
- call do_factor ;0be8
- ret nc ;0beb
- jp ERROR ;0bec
+ call do_factor
+ ret nc
+ jp ERROR
do_factor:
- call chk.sp ;0bef
- call get.number ;0bf2
- ret nc ;0bf5
- inc de ;0bf6
- ld hl,TOPRAM ;0bf7
- cp 'T' ;0bfa
- ret z ;0bfc
- ld hl,(HILOD) ;0bfd
- cp 'H' ;0c00
- ret z ;0c02
- ld hl,(MAXLOD) ;0c03
- cp 'M' ;0c06
- ret z ;0c08
- ld hl,TPA ;0c09
- cp 'L' ;0c0c
- ret z ;0c0e
- ld hl,(offs.@) ;0c0f
- cp '@' ;0c12
- ret z ;0c14
- ld hl,(OFFS.pc) ;0c15
- cp '$' ;0c18
- ret z ;0c1a
- cp '-' ;0c1b
- jr z,fact_factneg ;0c1d
- cp '~' ;0c1f
- jr z,fact_factinv ;0c21
- cp '+' ;0c23
- jr z,fact_factor ;0c25
- cp '^' ;0c27
- jr z,fact_reg.CPU ;0c29
- cp 'Y' ;0c2b
- jr z,fact_reg.Y ;0c2d
- cp '(' ;0c2f
- jr z,fact_mem ;0c31
- cp '[' ;0c33
+ call chk.sp
+ call get.number
+ ret nc
+ inc de
+ ld hl,TOPRAM
+ cp 'T'
+ ret z
+ ld hl,(HILOD)
+ cp 'H'
+ ret z
+ ld hl,(MAXLOD)
+ cp 'M'
+ ret z
+ ld hl,TPA
+ cp 'L'
+ ret z
+ ld hl,(offs.@)
+ cp '@'
+ ret z
+ ld hl,(OFFS.pc)
+ cp '$'
+ ret z
+ cp '-'
+ jr z,fact_factneg
+ cp '~'
+ jr z,fact_factinv
+ cp '+'
+ jr z,fact_factor
+ cp '^'
+ jr z,fact_reg.CPU
+ cp 'Y'
+ jr z,fact_reg.Y
+ cp '('
+ jr z,fact_mem
+ cp '['
jp z,EXPR_BRCKT ;0c35 [ expression ]
- cp '''' ;0c38
- jr z,fact_factstring ;0c3a
- dec de ;0c3c
- scf ;0c3d
- ret ;0c3e
+ cp ''''
+ jr z,fact_factstring
+ dec de
+ scf
+ ret
fact_reg.Y:
- call get.decdigit ;0c3f
- jp c,ERROR ;0c42
- inc de ;0c45
- add a,a ;0c46
- ld hl,reg.Y ;0c47
- call ADD_HL_A ;0c4a
- ld a,(hl) ;0c4d
- inc hl ;0c4e
- ld h,(hl) ;0c4f
- ld l,a ;0c50
- and a ;0c51
- ret ;0c52
+ call get.decdigit
+ jp c,ERROR
+ inc de
+ add a,a
+ ld hl,reg.Y
+ call ADD_HL_A
+ ld a,(hl)
+ inc hl
+ ld h,(hl)
+ ld l,a
+ and a
+ ret
fact_factstring:
- ld hl,0 ;0c53
+ ld hl,0
l0c56h:
- ld a,(de) ;0c56
- cp '''' ;0c57
- jr z,l0c62h ;0c59
- and a ;0c5b
- ret z ;0c5c
+ ld a,(de)
+ cp ''''
+ jr z,l0c62h
+ and a
+ ret z
l0c5dh:
- ld h,l ;0c5d
- ld l,a ;0c5e
- inc de ;0c5f
- jr l0c56h ;0c60
+ ld h,l
+ ld l,a
+ inc de
+ jr l0c56h
l0c62h:
- inc de ;0c62
- ld a,(de) ;0c63
- cp '''' ;0c64
- jr z,l0c5dh ;0c66
- sub '.' ;0c68
- or a ;0c6a
- ret nz ;0c6b
- inc de ;0c6c
- set 7,l ;0c6d
- ret ;0c6f
+ inc de
+ ld a,(de)
+ cp ''''
+ jr z,l0c5dh
+ sub '.'
+ or a
+ ret nz
+ inc de
+ set 7,l
+ ret
fact_reg.CPU:
- call sub_1315h ;0c70
- jr nc,l0cbbh ;0c73
- ld a,(hl) ;0c75
- inc hl ;0c76
- ld h,(hl) ;0c77
- ld l,a ;0c78
- and a ;0c79
- bit 0,c ;0c7a
- ret nz ;0c7c
- ld h,000h ;0c7d
- ret ;0c7f
+ call sub_1315h
+ jr nc,l0cbbh
+ ld a,(hl)
+ inc hl
+ ld h,(hl)
+ ld l,a
+ and a
+ bit 0,c
+ ret nz
+ ld h,000h
+ ret
fact_factneg:
- call fact_factor ;0c80
- dec hl ;0c83
+ call fact_factor
+ dec hl
cpl.hl:
- ld a,h ;0c84
- cpl ;0c85
- ld h,a ;0c86
- ld a,l ;0c87
- cpl ;0c88
- ld l,a ;0c89
- ret ;0c8a
+ ld a,h
+ cpl
+ ld h,a
+ ld a,l
+ cpl
+ ld l,a
+ ret
fact_factinv:
- call fact_factor ;0c8b
- jr cpl.hl ;0c8e
+ call fact_factor
+ jr cpl.hl
fact_mem:
- call EXPR1 ;0c90
- jr c,l0cbbh ;0c93
- ld a,(de) ;0c95
- cp ')' ;0c96
- jr nz,l0cbbh ;0c98
- inc de ;0c9a
+ call EXPR1
+ jr c,l0cbbh
+ ld a,(de)
+ cp ')'
+ jr nz,l0cbbh
+ inc de
comst
- ld a,(hl) ;0c9f
+ ld a,(hl)
inc hl ;
ld h,(hl) ;
comend
- ld l,a ;0ca7
- ld a,(de) ;0ca8
- inc de ;0ca9
- cp '.' ;0caa
- ret z ;0cac
- dec de ;0cad
- xor a ;0cae
- ld h,a ;0caf
- ret ;0cb0
+ ld l,a
+ ld a,(de)
+ inc de
+ cp '.'
+ ret z
+ dec de
+ xor a
+ ld h,a
+ ret
EXPR_BRCKT:
- call EXPR1 ;0cb1
- jr c,l0cbbh ;0cb4
- ld a,(de) ;0cb6
- cp ']' ;0cb7
- inc de ;0cb9
- ret z ;0cba
+ call EXPR1
+ jr c,l0cbbh
+ ld a,(de)
+ cp ']'
+ inc de
+ ret z
l0cbbh:
- jp ERROR ;0cbb
+ jp ERROR
get.number:
- call get.hexdigit ;0cbe
- ret c ;0cc1
- push de ;0cc2
+ call get.hexdigit
+ ret c
+ push de
l0cc3h:
- inc de ;0cc3
- call get.hexdigit ;0cc4
- jr nc,l0cc3h ;0cc7
- pop de ;0cc9
- cp '.' ;0cca
- jr z,l0d04h ;0ccc
- cp '"' ;0cce
- jr z,l0ce9h ;0cd0
- ld hl,0 ;0cd2
+ inc de
+ call get.hexdigit
+ jr nc,l0cc3h
+ pop de
+ cp '.'
+ jr z,l0d04h
+ cp '"'
+ jr z,l0ce9h
+ ld hl,0
l0cd5h:
- call get.hexdigit ;0cd5
- jr c,l0ce4h ;0cd8
- add hl,hl ;0cda
- add hl,hl ;0cdb
- add hl,hl ;0cdc
- add hl,hl ;0cdd
- call ADD_HL_A ;0cde
- inc de ;0ce1
- jr l0cd5h ;0ce2
+ call get.hexdigit
+ jr c,l0ce4h
+ add hl,hl
+ add hl,hl
+ add hl,hl
+ add hl,hl
+ call ADD_HL_A
+ inc de
+ jr l0cd5h
l0ce4h:
- xor 'H' ;0ce4
- ret nz ;0ce6
- inc de ;0ce7
- ret ;0ce8
+ xor 'H'
+ ret nz
+ inc de
+ ret
l0ce9h:
- ld hl,0 ;0ce9
+ ld hl,0
l0cech:
- call get.decdigit ;0cec
+ call get.decdigit
l0cefh:
- inc de ;0cef
- jr c,l0cf8h ;0cf0
- add hl,hl ;0cf2
- call ADD_HL_A ;0cf3
- jr l0cech ;0cf6
+ inc de
+ jr c,l0cf8h
+ add hl,hl
+ call ADD_HL_A
+ jr l0cech
l0cf8h:
- cp '"' ;0cf8
- jp nz,ERROR ;0cfa
- call get.decdigit ;0cfd
- jr nc,l0cefh ;0d00
- or a ;0d02
- ret ;0d03
+ cp '"'
+ jp nz,ERROR
+ call get.decdigit
+ jr nc,l0cefh
+ or a
+ ret
l0d04h:
- ld hl,0 ;0d04
+ ld hl,0
l0d07h:
- call get.decdigit ;0d07
- inc de ;0d0a
- jr c,l0d1ah ;0d0b
- push bc ;0d0d
+ call get.decdigit
+ inc de
+ jr c,l0d1ah
+ push bc
add hl,hl ;0d0e hl *= 10
- ld b,h ;0d0f
- ld c,l ;0d10
- add hl,hl ;0d11
- add hl,hl ;0d12
- add hl,bc ;0d13
- pop bc ;0d14
- call ADD_HL_A ;0d15
- jr l0d07h ;0d18
+ ld b,h
+ ld c,l
+ add hl,hl
+ add hl,hl
+ add hl,bc
+ pop bc
+ call ADD_HL_A
+ jr l0d07h
l0d1ah:
- cp '.' ;0d1a
- ret z ;0d1c
- jp ERROR ;0d1d
+ cp '.'
+ ret z
+ jp ERROR
sub_0d20h:
- ld a,(de) ;0d20
- cp 05bh ;0d21
- jr l0d28h ;0d23
+ ld a,(de)
+ cp 05bh
+ jr l0d28h
get.hexdigit:
- ld a,(de) ;0d25
+ ld a,(de)
sub_0d26h:
- cp 'F'+1 ;0d26
+ cp 'F'+1
l0d28h:
- ccf ;0d28
- ret c ;0d29
- cp 'A' ;0d2a
- jr c,l0d32h ;0d2c
- sub 'A'-10 ;0d2e
- ret ;0d30
+ ccf
+ ret c
+ cp 'A'
+ jr c,l0d32h
+ sub 'A'-10
+ ret
get.decdigit:
- ld a,(de) ;0d31
+ ld a,(de)
l0d32h:
- cp '9'+1 ;0d32
- jr l0d39h ;0d34
+ cp '9'+1
+ jr l0d39h
get.bindigit:
- ld a,(de) ;0d36
- cp '1'+1 ;0d37
+ ld a,(de)
+ cp '1'+1
l0d39h:
- ccf ;0d39
- ret c ;0d3a
- cp '0' ;0d3b
- ret c ;0d3d
- sub '0' ;0d3e
- ret ;0d40
+ ccf
+ ret c
+ cp '0'
+ ret c
+ sub '0'
+ ret
l0d41h:
- call assert_eol ;0d41
+ call assert_eol
prnt_cpustat:
- call prnt_f ;0d44
- call outbl2 ;0d47
- ld hl,b_0x0DFD_start ;0d4a
- ld de,b_0x0E1D_start ;0d4d
- ld b,006h ;0d50
+ call prnt_f
+ call outbl2
+ ld hl,b_0x0DFD_start
+ ld de,b_0x0E1D_start
+ ld b,006h
l0d52h:
- call prnt_regs ;0d52
- djnz l0d52h ;0d55
- push hl ;0d57
- push de ;0d58
- ld iy,(REG.PC) ;0d59
- call sub_1f77h ;0d5d
- exx ;0d60
- ex af,af' ;0d61
- call CRLF ;0d62
- call prnt_f2 ;0d65
- call outbl2 ;0d68
- pop de ;0d6b
- pop hl ;0d6c
- ld b,007h ;0d6d
+ call prnt_regs
+ djnz l0d52h
+ push hl
+ push de
+ ld iy,(REG.PC)
+ call sub_1f77h
+ exx
+ ex af,af'
+ call CRLF
+ call prnt_f2
+ call outbl2
+ pop de
+ pop hl
+ ld b,007h
l0d6fh:
- call prnt_regs ;0d6f
- djnz l0d6fh ;0d72
- exx ;0d74
- ex af,af' ;0d75
- and a ;0d76
- jr z,l0d7fh ;0d77
- call outbl6 ;0d79
- call sub_1f5bh ;0d7c
+ call prnt_regs
+ djnz l0d6fh
+ exx
+ ex af,af'
+ and a
+ jr z,l0d7fh
+ call outbl6
+ call sub_1f5bh
l0d7fh:
- jp crlf ;0d7f
+ jp crlf
prnt_f:
- ld a,(reg.f) ;0d82
- call prnt_flags ;0d85
- ld a,(reg.iff) ;0d88
- cp 0f3h ;0d8b
- jp z,outbl ;0d8d
- ld a,'E' ;0d90
- jp outchar ;0d92
+ ld a,(reg.f)
+ call prnt_flags
+ ld a,(reg.iff)
+ cp 0f3h
+ jp z,outbl
+ ld a,'E'
+ jp outchar
prnt_f2:
- ld a,(reg.f2) ;0d95
- call prnt_flags ;0d98
- jp outbl ;0d9b
+ ld a,(reg.f2)
+ call prnt_flags
+ jp outbl
prnt_flags:
- ld b,a ;0d9e
- ld a,'S' ;0d9f
- call sub_0dbeh ;0da1
- ld a,'Z' ;0da4
- call sub_0dbeh ;0da6
- rl b ;0da9
- ld a,'H' ;0dab
- call sub_0dbeh ;0dad
- rl b ;0db0
- ld a,'V' ;0db2
- call sub_0dbeh ;0db4
- ld a,'N' ;0db7
- call sub_0dbeh ;0db9
- ld a,'C' ;0dbc
+ ld b,a
+ ld a,'S'
+ call sub_0dbeh
+ ld a,'Z'
+ call sub_0dbeh
+ rl b
+ ld a,'H'
+ call sub_0dbeh
+ rl b
+ ld a,'V'
+ call sub_0dbeh
+ ld a,'N'
+ call sub_0dbeh
+ ld a,'C'
sub_0dbeh:
- rl b ;0dbe
- jp c,OUTCHAR ;0dc0
- jp OUTBL ;0dc3
+ rl b
+ jp c,OUTCHAR
+ jp OUTBL
prnt_regs:
- push bc ;0dc6
- push de ;0dc7
- call PSTR ;0dc8
- ld a,'=' ;0dcb
- call OUTCHAR ;0dcd
- ex (sp),hl ;0dd0
- ld e,(hl) ;0dd1
- inc hl ;0dd2
- ld d,(hl) ;0dd3
- inc hl ;0dd4
- ld a,(hl) ;0dd5
- inc hl ;0dd6
- push hl ;0dd7
- and a ;0dd8
- jr z,l0df2h ;0dd9
- push af ;0ddb
- ld a,(de) ;0ddc
- ld l,a ;0ddd
- inc de ;0dde
- ld a,(de) ;0ddf
- ld h,a ;0de0
- pop af ;0de1
- dec a ;0de2
- jr z,l0dedh ;0de3
- call out.hl.@ ;0de5
- call z,outbl6 ;0de8
- jr l0df6h ;0deb
+ push bc
+ push de
+ call PSTR
+ ld a,'='
+ call OUTCHAR
+ ex (sp),hl
+ ld e,(hl)
+ inc hl
+ ld d,(hl)
+ inc hl
+ ld a,(hl)
+ inc hl
+ push hl
+ and a
+ jr z,l0df2h
+ push af
+ ld a,(de)
+ ld l,a
+ inc de
+ ld a,(de)
+ ld h,a
+ pop af
+ dec a
+ jr z,l0dedh
+ call out.hl.@
+ call z,outbl6
+ jr l0df6h
l0dedh:
- call out.hl ;0ded
- jr l0df6h ;0df0
+ call out.hl
+ jr l0df6h
l0df2h:
- ld a,(de) ;0df2
- call out.hex ;0df3
+ ld a,(de)
+ call out.hex
l0df6h:
- call OUTBL ;0df6
- pop de ;0df9
- pop hl ;0dfa
- pop bc ;0dfb
- ret ;0dfc
+ call OUTBL
+ pop de
+ pop hl
+ pop bc
+ ret
b_0x0DFD_start:
DC 'A '
@@ -1404,522 +1419,510 @@ b_0x0DFD_start:
DB 0
b_0x0E1D_start:
- defw reg.a ;0e1d
- defb 000h ;0e1f
- defw reg.c ;0e20
- defb 001h ;0e22
- defw reg.e ;0e23
- defb 001h ;0e25
- defw reg.l ;0e26
- defb 001h ;0e28
- defw reg.sp ;0e29
- defb 001h ;0e2b
- defw reg.pc ;0e2c
- defb 002h ;0e2e
- defw reg.a2 ;0e2f
- defb 000h ;0e31
- defw reg.c2 ;0e32
- defb 001h ;0e34
- defw reg.e2 ;0e35
- defb 001h ;0e37
- defw reg.l2 ;0e38
- defb 001h ;0e3a
- defw reg.ix ;0e3b
- defb 001h ;0e3d
- defw reg.iy ;0e3e
- defb 001h ;0e40
- defw reg.i ;0e41
- dw 0 ;0e43
+ defw reg.a
+ defb 000h
+ defw reg.c
+ defb 001h
+ defw reg.e
+ defb 001h
+ defw reg.l
+ defb 001h
+ defw reg.sp
+ defb 001h
+ defw reg.pc
+ defb 002h
+ defw reg.a2
+ defb 000h
+ defw reg.c2
+ defb 001h
+ defw reg.e2
+ defb 001h
+ defw reg.l2
+ defb 001h
+ defw reg.ix
+ defb 001h
+ defw reg.iy
+ defb 001h
+ defw reg.i
+ dw 0
CMD.G:
- sub a ;0e45
- ld (TCFLG),a ;0e46
- ld (XA747),a ;0e49
- call EXPR ;0e4c
- jr c,l0e54h ;0e4f
- ld (REG.PC),hl ;0e51
+ sub a
+ ld (TCFLG),a
+ ld (XA747),a
+ call EXPR
+ jr c,l0e54h
+ ld (REG.PC),hl
l0e54h:
- call SKIPBL ;0e54
- jp z,l1183h ;0e57
- cp ';' ;0e5a
- jp nz,ERROR ;0e5c
- inc de ;0e5f
- ld a,002h ;0e60
- call sub_0f24h ;0e62
- jp l1183h ;0e65
+ call SKIPBL
+ jp z,l1183h
+ cp ';'
+ jp nz,ERROR
+ inc de
+ ld a,002h
+ call sub_0f24h
+ jp l1183h
sub_0e68h:
- ld b,BP_CNT ;0e68
- ld ix,bp_tab ;0e6a
+ ld b,BP_CNT
+ ld ix,bp_tab
l0e6eh:
- ld a,(ix+000h) ;0e6e
- and 0f1h ;0e71
- ld (ix+000h),a ;0e73
- call sub_11c5h ;0e76
- ld de,BP_SIZE ;0e79
- add ix,de ;0e7c
- djnz l0e6eh ;0e7e
- ret ;0e80
+ ld a,(ix+000h)
+ and 0f1h
+ ld (ix+000h),a
+ call sub_11c5h
+ ld de,BP_SIZE
+ add ix,de
+ djnz l0e6eh
+ ret
CMD.B:
- call SKIPBL ;0e81
- jr z,l0ecbh ;0e84
- inc de ;0e86
- cp 'X' ;0e87
- jr z,l0e91h ;0e89
- dec de ;0e8b
- ld a,001h ;0e8c
- jp sub_0f24h ;0e8e
+ call SKIPBL
+ jr z,l0ecbh
+ inc de
+ cp 'X'
+ jr z,l0e91h
+ dec de
+ ld a,001h
+ jp sub_0f24h
l0e91h:
- call SKIPBL ;0e91
- jr z,l0ea6h ;0e94
+ call SKIPBL
+ jr z,l0ea6h
l0e96h:
- call EXPR ;0e96
- jp c,assert_eol ;0e99
- push de ;0e9c
- call sub_0ea7h ;0e9d
- pop de ;0ea0
- call skip_to_nextarg ;0ea1
- jr l0e96h ;0ea4
+ call EXPR
+ jp c,assert_eol
+ push de
+ call sub_0ea7h
+ pop de
+ call skip_to_nextarg
+ jr l0e96h
l0ea6h:
- scf ;0ea6
+ scf
sub_0ea7h:
- ld b,BP_CNT ;0ea7
- ld ix,bp_tab ;0ea9
+ ld b,BP_CNT
+ ld ix,bp_tab
l0eadh:
- push af ;0ead
- jr c,l0ebbh ;0eae
- ld e,(ix+002h) ;0eb0
- ld d,(ix+003h) ;0eb3
- call CP.HL.DE ;0eb6
- jr nz,l0ec2h ;0eb9
+ push af
+ jr c,l0ebbh
+ ld e,(ix+002h)
+ ld d,(ix+003h)
+ call CP.HL.DE
+ jr nz,l0ec2h
l0ebbh:
- ld (ix+000h),000h ;0ebb
- call sub_11c5h ;0ebf
+ ld (ix+000h),000h
+ call sub_11c5h
l0ec2h:
- ld de,BP_SIZE ;0ec2
- add ix,de ;0ec5
- pop af ;0ec7
- djnz l0eadh ;0ec8
- ret ;0eca
+ ld de,BP_SIZE
+ add ix,de
+ pop af
+ djnz l0eadh
+ ret
l0ecbh:
- ld b,BP_CNT ;0ecb
- ld ix,bp_tab ;0ecd
+ ld b,BP_CNT
+ ld ix,bp_tab
l0ed1h:
- bit 0,(ix+000h) ;0ed1
- jr z,l0f1ch ;0ed5
- ld a,'R' ;0ed7
- bit 4,(ix+000h) ;0ed9
- jr nz,l0ee1h ;0edd
- ld a,' ' ;0edf
+ bit 0,(ix+000h)
+ jr z,l0f1ch
+ ld a,'R'
+ bit 4,(ix+000h)
+ jr nz,l0ee1h
+ ld a,' '
l0ee1h:
- call OUTCHAR ;0ee1
- call OUTBL ;0ee4
- ld l,(ix+002h) ;0ee7
- ld h,(ix+003h) ;0eea
- call out.hl.@ ;0eed
- call outbl2 ;0ef0
- ld a,':' ;0ef3
- call OUTCHAR ;0ef5
- ld l,(ix+004h) ;0ef8
- ld h,(ix+005h) ;0efb
- call out.hl ;0efe
- ld l,(ix+006h) ;0f01
- ld h,(ix+007h) ;0f04
- ld a,h ;0f07
- or l ;0f08
- jr z,l0f19h ;0f09
- call outbl4 ;0f0b
- ld a,'I' ;0f0e
- call OUTCHAR ;0f10
- call outbl2 ;0f13
- call PSTR ;0f16
+ call OUTCHAR
+ call OUTBL
+ ld l,(ix+002h)
+ ld h,(ix+003h)
+ call out.hl.@
+ call outbl2
+ ld a,':'
+ call OUTCHAR
+ ld l,(ix+004h)
+ ld h,(ix+005h)
+ call out.hl
+ ld l,(ix+006h)
+ ld h,(ix+007h)
+ ld a,h
+ or l
+ jr z,l0f19h
+ call outbl4
+ ld a,'I'
+ call OUTCHAR
+ call outbl2
+ call PSTR
l0f19h:
- call CRLF ;0f19
+ call CRLF
l0f1ch:
- ld de,BP_SIZE ;0f1c
- add ix,de ;0f1f
- djnz l0ed1h ;0f21
- ret ;0f23
+ ld de,BP_SIZE
+ add ix,de
+ djnz l0ed1h
+ ret
sub_0f24h:
- ld b,a ;0f24
- call SKIPBL ;0f25
- ret z ;0f28
- cp 'R' ;0f29
- jr nz,l0f30h ;0f2b
- inc de ;0f2d
- set 4,b ;0f2e
+ ld b,a
+ call SKIPBL
+ ret z
+ cp 'R'
+ jr nz,l0f30h
+ inc de
+ set 4,b
l0f30h:
- push bc ;0f30
- call EXPR ;0f31
- jp c,ERROR ;0f34
- pop bc ;0f37
- bit 0,b ;0f38
- push bc ;0f3a
- push de ;0f3b
- push hl ;0f3c
- call nz,sub_0ea7h ;0f3d
- pop hl ;0f40
- call sub_0f68h ;0f41
- pop de ;0f44
- ld (ix+002h),l ;0f45
- ld (ix+003h),h ;0f48
- call sub_0f80h ;0f4b
- ld (ix+004h),l ;0f4e
- ld (ix+005h),h ;0f51
- call sub_0f91h ;0f54
- ld (ix+006h),l ;0f57
- ld (ix+007h),h ;0f5a
- call skip_to_nextarg ;0f5d
- pop af ;0f60
- ld (ix+000h),a ;0f61
- and 00fh ;0f64
- jr sub_0f24h ;0f66
+ push bc
+ call EXPR
+ jp c,ERROR
+ pop bc
+ bit 0,b
+ push bc
+ push de
+ push hl
+ call nz,sub_0ea7h
+ pop hl
+ call sub_0f68h
+ pop de
+ ld (ix+002h),l
+ ld (ix+003h),h
+ call sub_0f80h
+ ld (ix+004h),l
+ ld (ix+005h),h
+ call sub_0f91h
+ ld (ix+006h),l
+ ld (ix+007h),h
+ call skip_to_nextarg
+ pop af
+ ld (ix+000h),a
+ and 00fh
+ jr sub_0f24h
sub_0f68h:
- ld b,BP_CNT ;0f68
- ld ix,bp_tab ;0f6a
+ ld b,BP_CNT
+ ld ix,bp_tab
l0f6eh:
- ld a,(ix+000h) ;0f6e
- and 00fh ;0f71
- ret z ;0f73
- push bc ;0f74
- ld bc,BP_SIZE ;0f75
- add ix,bc ;0f78
- pop bc ;0f7a
- djnz l0f6eh ;0f7b
- jp ERROR ;0f7d
+ ld a,(ix+000h)
+ and 00fh
+ ret z
+ push bc
+ ld bc,BP_SIZE
+ add ix,bc
+ pop bc
+ djnz l0f6eh
+ jp ERROR
sub_0f80h:
- call SKIPBL ;0f80
- ld hl,1 ;0f83
- cp 03ah ;0f86
- ret nz ;0f88
- inc de ;0f89
- call EXPR ;0f8a
- jp c,ERROR ;0f8d
- ret ;0f90
+ call SKIPBL
+ ld hl,1
+ cp 03ah
+ ret nz
+ inc de
+ call EXPR
+ jp c,ERROR
+ ret
sub_0f91h:
- call SKIPBL ;0f91
- cp 049h ;0f94
- ld hl,0 ;0f96
- ret nz ;0f99
- inc de ;0f9a
- call SKIPBL ;0f9b
- push de ;0f9e
- call EXPR ;0f9f
- jp c,ERROR ;0fa2
- ex de,hl ;0fa5
- pop de ;0fa6
- push de ;0fa7
- sbc hl,de ;0fa8
- ld b,h ;0faa
- ld c,l ;0fab
- ld hl,(sexp1) ;0fac
- push hl ;0faf
- add hl,bc ;0fb0
- ld de,sexpbufe ;0fb1
- call CP.HL.DE ;0fb4
- jp nc,ERROR ;0fb7
- pop hl ;0fba
- ld (sexp2),hl ;0fbb
- pop de ;0fbe
- ex de,hl ;0fbf
- ldir ;0fc0
- xor a ;0fc2
- ld (de),a ;0fc3
- inc de ;0fc4
- ex de,hl ;0fc5
- ld (sexp1),hl ;0fc6
- ld hl,(sexp2) ;0fc9
- ret ;0fcc
+ call SKIPBL
+ cp 049h
+ ld hl,0
+ ret nz
+ inc de
+ call SKIPBL
+ push de
+ call EXPR
+ jp c,ERROR
+ ex de,hl
+ pop de
+ push de
+ sbc hl,de
+ ld b,h
+ ld c,l
+ ld hl,(sexp1)
+ push hl
+ add hl,bc
+ ld de,sexpbufe
+ call CP.HL.DE
+ jp nc,ERROR
+ pop hl
+ ld (sexp2),hl
+ pop de
+ ex de,hl
+ ldir
+ xor a
+ ld (de),a
+ inc de
+ ex de,hl
+ ld (sexp1),hl
+ ld hl,(sexp2)
+ ret
bpddtz:
if ROMSYS
- ld h,ROMEN ;0fcd
- jr z,l0fd2h ;0fcf
- inc h ;0fd1
+ ld h,ROMEN
+ jr z,l0fd2h
+ inc h
l0fd2h:
- push hl ;0fd2 save rom enable stat
+ push hl ;save rom enable stat
+ endif
+ push bc
+ push de
+ push ix
+ push iy
+ ld a,i
+ ld h,a
+ ld l,000h
+ push hl ;save I register
+
+ if CPU_Z180
+ ld a,0f3h ;DI
+ jp po,l0fe6h
+ ld a,0fbh ;EI
+ else ;NMOS Z80 design flaw
+ call getiff ;return Carry set, if INTs are disabled.
+ ld a,0f3h ;DI
+ jr c,l0fe6h
+ ld a,0fbh ;EI
endif
- push bc ;0fd3
- push de ;0fd4
- push ix ;0fd5
- push iy ;0fd7
- ld a,i ;0fd9
- ld h,a ;0fdb
- ld l,000h ;0fdc
- push hl ;0fde
- ld a,0f3h ;0fdf DI
- jp po,l0fe6h ;0fe1
- ld a,0fbh ;0fe4 EI
l0fe6h:
- ld (reg.iff),a ;0fe6
- ld hl,ivtab ;0fe9
- ld a,h ;0fec
- ld i,a ;0fed
- call ddtei ;0fef
- ex af,af' ;0ff2
- push af ;0ff3
- exx ;0ff4
- push bc ;0ff5
- push de ;0ff6
- push hl ;0ff7
- call bp.unset ;0ff8
- in0 a,(itc) ;0ffb
- jp p,l1017h ;0ffe
- res TRAP,a ;1001
- out0 (itc),a ;1003
- bit UFO,a ;1006
- jr z,l1011h ;1008
- ld hl,(REG.PC) ;100a
- dec hl ;100d
- ld (REG.PC),hl ;100e
+ ld (reg.iff),a
+ ld hl,ivtab
+ ld a,h
+ ld i,a
+ call ddtei
+ ex af,af'
+ push af
+ exx
+ push bc
+ push de
+ push hl
+ call bp.unset
+ if CPU_Z180
+ in0 a,(itc)
+ jp p,l1017h
+ res TRAP,a
+ out0 (itc),a
+ bit UFO,a
+ jr z,l1011h
+ ld hl,(REG.PC)
+ dec hl
+ ld (REG.PC),hl
l1011h:
- ld hl,MSG_trap ;1011
- call PSTR ;1014
+ ld hl,MSG_trap
+ call PSTR
l1017h:
- ld a,(XBFE8) ;1017
- dec a ;101a
- jr z,l1051h ;101b
- call inchar ;101d
- jr c,l102eh ;1020
- call sub_1059h ;1022
- and a ;1025
- jp z,l1183h ;1026
- and 083h ;1029
- jp z,l284ah ;102b
+ endif
+
+ ld a,(XBFE8)
+ dec a
+ jr z,l1051h
+ call inchar
+ jr c,l102eh
+ call sub_1059h
+ and a
+ jp z,l1183h
+ and 083h
+ jp z,l284ah
l102eh:
- call sub_0e68h ;102e
- call prnt_cpustat ;1031
- jp DDTZML ;1034
+ call sub_0e68h
+ call prnt_cpustat
+ jp DDTZML
+ if CPU_Z180
MSG_trap:
DB CR,LF,'Undefined opcode trap'
DB CR,LF,0
+ endif
l1051h:
- ld (XBFE8),a ;1051
- ld c,007h ;1054
- jp l119fh ;1056
+ ld (XBFE8),a
+ ld c,007h
+ jp l119fh
sub_1059h:
- ld a,080h ;1059
- ex af,af' ;105b
- sub a ;105c
- ld (XA747),a ;105d
- ld b,BP_CNT ;1060
- ld ix,bp_tab ;1062
+ ld a,080h
+ ex af,af'
+ sub a
+ ld (XA747),a
+ ld b,BP_CNT
+ ld ix,bp_tab
l1066h:
- ld a,(ix+000h) ;1066
- and 007h ;1069
- jr z,l107eh ;106b
- ld e,(ix+002h) ;106d
- ld d,(ix+003h) ;1070
- ld hl,(REG.PC) ;1073
- call CP.HL.DE ;1076
- push bc ;1079
- call z,sub_1087h ;107a
- pop bc ;107d
+ ld a,(ix+000h)
+ and 007h
+ jr z,l107eh
+ ld e,(ix+002h)
+ ld d,(ix+003h)
+ ld hl,(REG.PC)
+ call CP.HL.DE
+ push bc
+ call z,sub_1087h
+ pop bc
l107eh:
- ld de,BP_SIZE ;107e
- add ix,de ;1081
- djnz l1066h ;1083
- ex af,af' ;1085
- ret ;1086
+ ld de,BP_SIZE
+ add ix,de
+ djnz l1066h
+ ex af,af'
+ ret
sub_1087h:
- ex af,af' ;1087
- res 7,a ;1088
- ex af,af' ;108a
- ld e,(ix+006h) ;108b
- ld d,(ix+007h) ;108e
- ld a,d ;1091
- or e ;1092
- ld hl,0ffffh ;1093
- call nz,EXPR ;1096
- ld a,h ;1099
- or l ;109a
- jr z,l10aeh ;109b
- ld e,(ix+004h) ;109d
- ld d,(ix+005h) ;10a0
- dec de ;10a3
- ld a,d ;10a4
- or e ;10a5
- jr z,l10b9h ;10a6
- ld (ix+004h),e ;10a8
- ld (ix+005h),d ;10ab
+ ex af,af'
+ res 7,a
+ ex af,af'
+ ld e,(ix+006h)
+ ld d,(ix+007h)
+ ld a,d
+ or e
+ ld hl,0ffffh
+ call nz,EXPR
+ ld a,h
+ or l
+ jr z,l10aeh
+ ld e,(ix+004h)
+ ld d,(ix+005h)
+ dec de
+ ld a,d
+ or e
+ jr z,l10b9h
+ ld (ix+004h),e
+ ld (ix+005h),d
l10aeh:
- bit 4,(ix+000h) ;10ae
- ret z ;10b2
- ld a,001h ;10b3
- ld (XA747),a ;10b5
- ret ;10b8
+ bit 4,(ix+000h)
+ ret z
+ ld a,001h
+ ld (XA747),a
+ ret
l10b9h:
- ex af,af' ;10b9
- or (ix+000h) ;10ba
- ex af,af' ;10bd
+ ex af,af'
+ or (ix+000h)
+ ex af,af'
ret
bp.unset:
- ld b,BP_CNT ;10bf
- ld ix,bp_tab ;10c1
+ ld b,BP_CNT
+ ld ix,bp_tab
l10c5h:
- bit 5,(ix+000h) ;10c5
- res 5,(ix+000h) ;10c9
- jr z,l10e7h ;10cd
- ld l,(ix+002h) ;10cf
- ld h,(ix+003h) ;10d2
- ld a,(ddtrst) ;10d5
- comst ;10e2
- cp (hl) ;10dc
+ bit 5,(ix+000h)
+ res 5,(ix+000h)
+ jr z,l10e7h
+ ld l,(ix+002h)
+ ld h,(ix+003h)
+ ld a,(ddtzrst)
+ comst
+ cp (hl)
comend
- jr nz,l10e7h ;10dd
- ld a,(ix+001h) ;10df
- comst ;10e2
- ld (hl),a ;10e6
+ jr nz,l10e7h
+ ld a,(ix+001h)
+ comst
+ ld (hl),a
comend
l10e7h:
- res 3,(ix+000h) ;10e7
- ld de,BP_SIZE ;10eb
- add ix,de ;10ee
- djnz l10c5h ;10f0
- ret ;10f2
+ res 3,(ix+000h)
+ ld de,BP_SIZE
+ add ix,de
+ djnz l10c5h
+ ret
sub_10f3h:
- ld b,BP_CNT ;10f3
- ld ix,bp_tab ;10f5
+ ld b,BP_CNT
+ ld ix,bp_tab
l10f9h:
- ld a,(ix+000h) ;10f9
- and 003h ;10fc
- jr z,l110dh ;10fe
- ld e,(ix+002h) ;1100
- ld d,(ix+003h) ;1103
- ld hl,(REG.PC) ;1106
- call CP.HL.DE ;1109
- ret z ;110c
+ ld a,(ix+000h)
+ and 003h
+ jr z,l110dh
+ ld e,(ix+002h)
+ ld d,(ix+003h)
+ ld hl,(REG.PC)
+ call CP.HL.DE
+ ret z
l110dh:
- ld de,BP_SIZE ;110d
- add ix,de ;1110
- djnz l10f9h ;1112
- sub a ;1114
- inc a ;1115
- ret ;1116
+ ld de,BP_SIZE
+ add ix,de
+ djnz l10f9h
+ sub a
+ inc a
+ ret
sub_1117h:
- call sub_0f68h ;1117
- ld (ix+004h),001h ;111a
- ld (ix+005h),000h ;111e
- ld (ix+002h),l ;1122
- ld (ix+003h),h ;1125
- ld (ix+006h),000h ;1128
- ld (ix+007h),000h ;112c
- ld a,(XBFE8) ;1130
- and a ;1133
- ld a,008h ;1134
- jr nz,l113ah ;1136
- ld a,004h ;1138
+ call sub_0f68h
+ ld (ix+004h),001h
+ ld (ix+005h),000h
+ ld (ix+002h),l
+ ld (ix+003h),h
+ ld (ix+006h),000h
+ ld (ix+007h),000h
+ ld a,(XBFE8)
+ and a
+ ld a,008h
+ jr nz,l113ah
+ ld a,004h
l113ah:
- ld (ix+000h),a ;113a
- ret ;113d
+ ld (ix+000h),a
+ ret
bp.set:
- ld b,BP_CNT ;113e
- ld ix,bp_tab ;1140
+ ld b,BP_CNT
+ ld ix,bp_tab
l1144h:
- ld a,(ix+000h) ;1144
- and c ;1147
- jr z,l117bh ;1148
- set 5,(ix+000h) ;114a
- ld l,(ix+002h) ;114e
- ld h,(ix+003h) ;1151
+ ld a,(ix+000h)
+ and c
+ jr z,l117bh
+ set 5,(ix+000h)
+ ld l,(ix+002h)
+ ld h,(ix+003h)
- if 0
- comst ;1154
- ld a,(hl) ;1158
- comend
- ld (ix+001h),a ;1159
- ld a,(ddtrst) ;115c
- comst ;115f
- ld (hl),a ;1163
- comend
- and 038h ;1164
- ld h,000h ;1166
- ld l,a ;1168
- ld a,0c3h ;1169
- comrep ;116b
- inc hl ;116e
- ld de,bpent ;116f
- ld a,e ;1172
- comrep ;1173
- inc hl ;1176
- ld a,d ;1177
- comrep ;1178
-
- else
-
- ld a,(ddtrst) ;115c
- comst ;115f
- ld e,(hl) ;1158
- ld (hl),a ;1163
+ ld a,(ddtzrst)
+ comst
+ ld e,(hl)
+ ld (hl),a
comend
- ld (ix+001h),e ;1159
- and 038h ;1164
- ld h,0 ;1166
- ld l,a ;1168
- ld de,bpent ;116f
+ ld (ix+001h),e
+ and 038h
+ ld h,0
+ ld l,a
+ ld de,bpent
comst ;
- ld (hl),0c3h ;1169
- inc hl ;116e
- ld (hl),e ;1172
- inc hl ;1176
- ld (hl),d ;1177
+ ld (hl),0c3h
+ inc hl
+ ld (hl),e
+ inc hl
+ ld (hl),d
comend
- endif
-
+
l117bh:
- ld de,BP_SIZE ;117b
- add ix,de ;117e
- djnz l1144h ;1180
+ ld de,BP_SIZE
+ add ix,de
+ djnz l1144h
ret
- ;1182
+
l1183h:
- sub a ;1183
- ld (XBFE8),a ;1184
- ld a,(XA747) ;1187
- and a ;118a
- call nz,prnt_cpustat ;118b
- call sub_10f3h ;118e
- ld c,007h ;1191
- jr nz,l119fh ;1193
- ld a,001h ;1195
- ld (XBFE8),a ;1197
- call sub_26e7h ;119a
- ld c,008h ;119d
+ sub a
+ ld (XBFE8),a
+ ld a,(XA747)
+ and a
+ call nz,prnt_cpustat
+ call sub_10f3h
+ ld c,007h
+ jr nz,l119fh
+ ld a,001h
+ ld (XBFE8),a
+ call sub_26e7h
+ ld c,008h
l119fh:
- call bp.set ;119f
+ call bp.set
ld sp,$stack ;11a2 set/restore user cpu state
- pop hl ;11a5
- pop de ;11a6
- pop bc ;11a7
- pop af ;11a8
- exx ;11a9
- ex af,af' ;11aa
- pop af ;11ab
- ld i,a ;11ac
- pop iy ;11ae
- pop ix ;11b0
- pop de ;11b2
- pop bc ;11b3
+ pop hl
+ pop de
+ pop bc
+ pop af
+ exx
+ ex af,af'
+ pop af
+ ld i,a
+ pop iy
+ pop ix
+ pop de
+ pop bc
if ROMSYS
- pop hl ;11b4
- ld a,l ;11b5
- and M_MWI ;11b6
- ld l,a ;11b8
- di ;11b9
- in0 a,(dcntl) ;11ba
- and ~M_MWI ;11bd
- or l ;11bf
- ld l,a ;11c0
- ld a,h ;11c1
+ pop hl
+ ld a,l
+ and M_MWI
+ ld l,a
+ di
+ in0 a,(dcntl)
+ and ~M_MWI
+ or l
+ ld l,a
+ ld a,h
else
pop hl
di
@@ -1927,227 +1930,234 @@ l119fh:
jp $go ;11c2 common ram, switch banks and go to user prog
sub_11c5h:
- ld a,(ix+000h) ;11c5
- and 003h ;11c8
- ret nz ;11ca
- ld e,(ix+006h) ;11cb
- ld d,(ix+007h) ;11ce
- ld a,d ;11d1
- or e ;11d2
- ret z ;11d3
- push bc ;11d4
- ld h,d ;11d5
- ld l,e ;11d6
- sub a ;11d7
- ld (ix+006h),a ;11d8
- ld (ix+007h),a ;11db
- ld bc,0ffffh ;11de
- cpir ;11e1
+ ld a,(ix+000h)
+ and 003h
+ ret nz
+ ld e,(ix+006h)
+ ld d,(ix+007h)
+ ld a,d
+ or e
+ ret z
+ push bc
+ ld h,d
+ ld l,e
+ sub a
+ ld (ix+006h),a
+ ld (ix+007h),a
+ ld bc,0ffffh
+ cpir
l11e3h:
- push de ;11e3
- ld de,(sexp1) ;11e4
- call CP.HL.DE ;11e8
- pop de ;11eb
- jr nc,l11f9h ;11ec
- call sub_11ffh ;11ee
+ push de
+ ld de,(sexp1)
+ call CP.HL.DE
+ pop de
+ jr nc,l11f9h
+ call sub_11ffh
l11f1h:
- ld a,(hl) ;11f1
- ldi ;11f2
- and a ;11f4
- jr nz,l11f1h ;11f5
- jr l11e3h ;11f7
+ ld a,(hl)
+ ldi
+ and a
+ jr nz,l11f1h
+ jr l11e3h
l11f9h:
- ld (sexp1),de ;11f9
- pop bc ;11fd
- ret ;11fe
+ ld (sexp1),de
+ pop bc
+ ret
sub_11ffh:
- ld iy,bp_tab ;11ff
- push de ;1203
+ ld iy,bp_tab
+ push de
l1204h:
- ld e,(iy+006h) ;1204
- ld d,(iy+007h) ;1207
- call CP.HL.DE ;120a
- jr z,l1216h ;120d
- ld de,BP_SIZE ;120f
- add iy,de ;1212
- jr l1204h ;1214
+ ld e,(iy+006h)
+ ld d,(iy+007h)
+ call CP.HL.DE
+ jr z,l1216h
+ ld de,BP_SIZE
+ add iy,de
+ jr l1204h
l1216h:
- pop de ;1216
- ld (iy+006h),e ;1217
- ld (iy+007h),d ;121a
- ret ;121d
+ pop de
+ ld (iy+006h),e
+ ld (iy+007h),d
+ ret
CMD.Y:
- call get.decdigit ;121e
- jr c,l122fh ;1221
- inc de ;1223
- push af ;1224
- call assert_eol ;1225
- pop af ;1228
- call sub_1248h ;1229
- jp l127ch ;122c
+ call get.decdigit
+ jr c,l122fh
+ inc de
+ push af
+ call assert_eol
+ pop af
+ call sub_1248h
+ jp l127ch
l122fh:
- call assert_eol ;122f
- xor a ;1232
+ call assert_eol
+ xor a
l1233h:
- push af ;1233
- call sub_1248h ;1234
- call outbl4 ;1237
- pop af ;123a
- inc a ;123b
- bit 0,a ;123c
- push af ;123e
- call z,CRLF ;123f
- pop af ;1242
- cp LF ;1243
- jr c,l1233h ;1245
- ret ;1247
+ push af
+ call sub_1248h
+ call outbl4
+ pop af
+ inc a
+ bit 0,a
+ push af
+ call z,CRLF
+ pop af
+ cp LF
+ jr c,l1233h
+ ret
sub_1248h:
- ld c,a ;1248
- ld b,0 ;1249
- add a,'0'+080h ;124b
- ld de,msg.Y+1 ;124d
- ld (de),a ;1250
- dec de ;1251
- ld hl,reg.Y ;1252
- add hl,bc ;1255
- add hl,bc ;1256
- ex de,hl ;1257
- ld c,003h ;1258
- jp l129ah ;125a
+ ld c,a
+ ld b,0
+ add a,'0'+080h
+ ld de,msg.Y+1
+ ld (de),a
+ dec de
+ ld hl,reg.Y
+ add hl,bc
+ add hl,bc
+ ex de,hl
+ ld c,003h
+ jp l129ah
CMD.X:
- call SKIPBL ;125d
- call sub_1315h ;1260
- jp nc,l0d41h ;1263
- call assert_eol ;1266
- ld a,b ;1269
- cp 01fh ;126a
- jr z,l12c6h ;126c
- cp 020h ;126e
- jr z,l12b6h ;1270
- ex de,hl ;1272
- ld hl,b_0x132A_start ;1273
- call sub_0a48h ;1276
+ call SKIPBL
+ call sub_1315h
+ jp nc,l0d41h
+ call assert_eol
+ ld a,b
+ cp 01fh
+ jr z,l12c6h
+ cp 020h
+ jr z,l12b6h
+ ex de,hl
+ ld hl,b_0x132A_start
+ call sub_0a48h
l1279h:
- call l129ah ;1279
+ call l129ah
l127ch:
- call OUTBL ;127c
- push de ;127f
- push bc ;1280
- call INLINE ;1281
- call SKIPBL ;1284
- jr z,l1297h ;1287
- call get_arg ;1289
- ld b,h ;128c
- ld c,l ;128d
- pop af ;128e
- pop hl ;128f
- ld (hl),c ;1290
- bit 0,a ;1291
- ret z ;1293
- inc hl ;1294
- ld (hl),b ;1295
- ret ;1296
+ call OUTBL
+ push de
+ push bc
+ call INLINE
+ call SKIPBL
+ jr z,l1297h
+ call get_arg
+ ld b,h
+ ld c,l
+ pop af
+ pop hl
+ ld (hl),c
+ bit 0,a
+ ret z
+ inc hl
+ ld (hl),b
+ ret
l1297h:
- pop af ;1297
- pop hl ;1298
- ret ;1299
+ pop af
+ pop hl
+ ret
l129ah:
- ld b,c ;129a
- call PSTR ;129b
- ld a,'=' ;129e
- call OUTCHAR ;12a0
- ld a,(de) ;12a3
- bit 0,b ;12a4
- jp z,out.hex ;12a6
- ld l,a ;12a9
- inc de ;12aa
- ld a,(de) ;12ab
- dec de ;12ac
- ld h,a ;12ad
- bit 1,b ;12ae
- jp z,out.hl ;12b0
- jp out.hl.@ ;12b3
+ ld b,c
+ call PSTR
+ ld a,'='
+ call OUTCHAR
+ ld a,(de)
+ bit 0,b
+ jp z,out.hex
+ ld l,a
+ inc de
+ ld a,(de)
+ dec de
+ ld h,a
+ bit 1,b
+ jp z,out.hl
+ jp out.hl.@
l12b6h:
- call prnt_f ;12b6
- ld a,0f3h ;12b9
- ld (reg.iff),a ;12bb
- scf ;12be
- call sub_12d1h ;12bf
- ld (reg.f),a ;12c2
- ret ;12c5
+ call prnt_f
+ ld a,0f3h
+ ld (reg.iff),a
+ scf
+ call sub_12d1h
+ ld (reg.f),a
+ ret
l12c6h:
- call prnt_f2 ;12c6
- and a ;12c9
- call sub_12d1h ;12ca
- ld (reg.f2),a ;12cd
- ret ;12d0
+ call prnt_f2
+ and a
+ call sub_12d1h
+ ld (reg.f2),a
+ ret
sub_12d1h:
- ex af,af' ;12d1
- ld b,000h ;12d2
- call outbl ;12d4
- call assert_eol ;12d7
- call inline ;12da
+ ex af,af'
+ ld b,000h
+ call outbl
+ call assert_eol
+ call inline
l12ddh:
- call skipbl ;12dd
- ld a,b ;12e0
- ret z ;12e1
- push bc ;12e2
- ld hl,tab_pr_flags ;12e3
- call lookupch ;12e6
- jp nc,error ;12e9
- ld a,b ;12ec
- cp 008h ;12ed
- jr z,l12feh ;12ef
- inc b ;12f1
- ld a,001h ;12f2
- jr l12f7h ;12f4
+ call skipbl
+ ld a,b
+ ret z
+ push bc
+ ld hl,tab_pr_flags
+ call lookupch
+ jp nc,error
+ ld a,b
+ cp 008h
+ jr z,l12feh
+ inc b
+ ld a,001h
+ jr l12f7h
l12f6h:
- rlca ;12f6
+ rlca
l12f7h:
- djnz l12f6h ;12f7
- pop bc ;12f9
- or b ;12fa
- ld b,a ;12fb
- jr l12ddh ;12fc
+ djnz l12f6h
+ pop bc
+ or b
+ ld b,a
+ jr l12ddh
l12feh:
- ex af,af' ;12fe
- jp nc,ERROR ;12ff
- ex af,af' ;1302
- ld a,0FBh ;1303
- ld (reg.iff),a ;1305
- pop bc ;1308
- jr l12ddh ;1309
+ ex af,af'
+ jp nc,ERROR
+ ex af,af'
+ ld a,0FBh
+ ld (reg.iff),a
+ pop bc
+ jr l12ddh
tab_pr_flags:
db 'CNV H ZSE'
db 0
sub_1315h:
- call sub_0a0eh ;1315
- ret nc ;1318
- ld a,b ;1319
- add a,b ;131a
- add a,b ;131b
- ld hl,b_0x136C_start ;131c
- call ADD_HL_A ;131f
- ld c,(hl) ;1322
- inc hl ;1323
- ld a,(hl) ;1324
- inc hl ;1325
- ld h,(hl) ;1326
- ld l,a ;1327
- scf ;1328
- ret ;1329
+ call sub_0a0eh
+ ret nc
+ ld a,b
+ add a,b
+ add a,b
+ ld hl,b_0x136C_start
+ call ADD_HL_A
+ ld c,(hl)
+ inc hl
+ ld a,(hl)
+ inc hl
+ ld h,(hl)
+ ld l,a
+ scf
+ ret
b_0x132A_start:
+ if ROMSYS
+ DC 'ROMSEL'
+ endif
+ if CPU_Z180
DC 'CBAR'
DC 'BBR'
+ else
+ DC 'BNK'
+ endif
DC 'BC'''
DC 'DE'''
DC 'HL'''
@@ -2179,659 +2189,667 @@ b_0x132A_start:
DC 'I'
DC 'F'''
DC 'F'
- if ROMSYS
- DC 'ROMSEL'
- endif
DB 0
b_0x136C_start:
- defb 000h ;136c
- defw ucbar ;136d
- defb 000h ;136f
- defw ubbr ;1370
- defb 003h ;1372
- defw reg.c2 ;1373
- defb 003h ;1375
- defw reg.e2 ;1376
- defb 003h ;1378
- defw reg.l2 ;1379
- defb 003h ;137b
- defw reg.c ;137c
- defb 003h ;137e
- defw reg.e ;137f
- defb 003h ;1381
- defw reg.l ;1382
- defb 000h ;1384
- defw reg.a2 ;1385
- defb 000h ;1387
- defw reg.b2 ;1388
- defb 000h ;138a
- defw reg.c2 ;138b
- defb 000h ;138d
- defw reg.d2 ;138e
- defb 000h ;1390
- defw reg.e2 ;1391
- defb 000h ;1393
- defw reg.h2 ;1394
- defb 000h ;1396
- defw reg.l2 ;1397
- defb 000h ;1399
- defw reg.a ;139a
- defb 000h ;139c
- defw reg.b ;139d
- defb 000h ;139f
- defw reg.c ;13a0
- defb 000h ;13a2
- defw reg.d ;13a3
- defb 000h ;13a5
- defw reg.e ;13a6
- defb 000h ;13a8
- defw reg.h ;13a9
- defb 000h ;13ab
- defw reg.l ;13ac
- defb 003h ;13ae
- defw reg.ix ;13af
- defb 003h ;13b1
- defw reg.iy ;13b2
- defb 003h ;13b4
- defw reg.sp ;13b5
- defb 003h ;13b7
- defw reg.pc ;13b8
- defb 003h ;13ba
- defw reg.ix ;13bb
- defb 003h ;13bd
- defw reg.iy ;13be
- defb 003h ;13c0
- defw reg.sp ;13c1
- defb 003h ;13c3
- defw reg.pc ;13c4
- defb 000h ;13c6
- defw reg.i ;13c7
- defb 000h ;13c9
- defw reg.f2 ;13ca
- defb 000h ;13cc
- defw reg.f ;13cd
if ROMSYS
- defb 000h ;13cf
- defw uromen ;13d0
+ defb 000h
+ defw uromen
+ endif
+ if CPU_Z180
+ defb 000h
+ defw ucbar
+ defb 000h
+ defw ubbr
+ else
+ defb 000h
+ defw ubnk
endif
+ defb 003h
+ defw reg.c2
+ defb 003h
+ defw reg.e2
+ defb 003h
+ defw reg.l2
+ defb 003h
+ defw reg.c
+ defb 003h
+ defw reg.e
+ defb 003h
+ defw reg.l
+ defb 000h
+ defw reg.a2
+ defb 000h
+ defw reg.b2
+ defb 000h
+ defw reg.c2
+ defb 000h
+ defw reg.d2
+ defb 000h
+ defw reg.e2
+ defb 000h
+ defw reg.h2
+ defb 000h
+ defw reg.l2
+ defb 000h
+ defw reg.a
+ defb 000h
+ defw reg.b
+ defb 000h
+ defw reg.c
+ defb 000h
+ defw reg.d
+ defb 000h
+ defw reg.e
+ defb 000h
+ defw reg.h
+ defb 000h
+ defw reg.l
+ defb 003h
+ defw reg.ix
+ defb 003h
+ defw reg.iy
+ defb 003h
+ defw reg.sp
+ defb 003h
+ defw reg.pc
+ defb 003h
+ defw reg.ix
+ defb 003h
+ defw reg.iy
+ defb 003h
+ defw reg.sp
+ defb 003h
+ defw reg.pc
+ defb 000h
+ defw reg.i
+ defb 000h
+ defw reg.f2
+ defb 000h
+ defw reg.f
CMD.S:
- ld hl,(lst.S) ;13d2
- call get_lastarg_def ;13d5
+ ld hl,(lst.S)
+ call get_lastarg_def
l13d8h:
- ld (lst.S),hl ;13d8
- call out.hl.@ ;13db
- call OUTBL ;13de
- comst ;13e1
- ld a,(hl) ;13e5
+ ld (lst.S),hl
+ call out.hl.@
+ call OUTBL
+ comst
+ ld a,(hl)
comend
- call out.hex ;13e6
- call outbl2 ;13e9
- call INLINE ;13ec
- call SKIPBL ;13ef
- inc hl ;13f2
- jr z,l13d8h ;13f3
- dec hl ;13f5
- inc de ;13f6
- cp '.' ;13f7
- jp z,assert_eol ;13f9
- cp '-' ;13fc
- jr nz,l1406h ;13fe
- ld a,(de) ;1400
- or a ;1401
- dec hl ;1402
- jr z,l13d8h ;1403
- inc hl ;1405
+ call out.hex
+ call outbl2
+ call INLINE
+ call SKIPBL
+ inc hl
+ jr z,l13d8h
+ dec hl
+ inc de
+ cp '.'
+ jp z,assert_eol
+ cp '-'
+ jr nz,l1406h
+ ld a,(de)
+ or a
+ dec hl
+ jr z,l13d8h
+ inc hl
l1406h:
- dec de ;1406
- call get_bytes_m ;1407
- jr l13d8h ;140a
+ dec de
+ call get_bytes_m
+ jr l13d8h
CMD.@:
- call assert_eol ;140c
- ld hl,MSG_at ;140f
- ld de,offs.@ ;1412
- ld c,001h ;1415
- jp l1279h ;1417
+ call assert_eol
+ ld hl,MSG_at
+ ld de,offs.@
+ ld c,001h
+ jp l1279h
MSG_at:
dc '@'
CMD.I:
- ld hl,CMD.I ;141b
- ld (CMD_RPT),hl ;141e
- ld hl,(lst.IP) ;1421
- call get_lastarg_def ;1424
- ld (lst.IP),hl ;1427
- ld b,h ;142a
- ld c,l ;142b
- ld a,b ;142c
- or a ;142d
- jr nz,l1442h ;142e
- ld a,c ;1430
- ld hl,ucbar ;1431
- cp cbar ;1434
- jr z,l143fh ;1436
- ld hl,ubbr ;1438
- cp bbr ;143b
- jr nz,l1442h ;143d
+ ld hl,CMD.I
+ ld (CMD_RPT),hl
+ ld hl,(lst.IP)
+ call get_lastarg_def
+ ld (lst.IP),hl
+ ld b,h
+ ld c,l
+ if CPU_Z180
+ ld a,b
+ or a
+ jr nz,l1442h
+ ld a,c
+ ld hl,ucbar
+ cp cbar
+ jr z,l143fh
+ ld hl,ubbr
+ cp bbr
+ jr nz,l1442h
l143fh:
- ld a,(hl) ;143f
- jr l1444h ;1440
+ ld a,(hl)
+ jr l1444h
l1442h:
- in a,(c) ;1442
+ endif
+ in a,(c)
l1444h:
- push af ;1444
- call out.hex ;1445
- call outbl4 ;1448
- pop af ;144b
- call out.bin.b ;144c
- jp CRLF ;144f
+ push af
+ call out.hex
+ call outbl4
+ pop af
+ call out.bin.b
+ jp CRLF
CMD.O:
- ld hl,CMD.O ;1452
- ld (CMD_RPT),hl ;1455
- ld hl,(lst.OD) ;1458
- call get_arg_def ;145b
- ld a,l ;145e
- ld (lst.OD),a ;145f
- push af ;1462
- call skip_to_nextarg ;1463
- ld hl,(lst.OP) ;1466
- call get_lastarg_def ;1469
- ld (lst.OP),hl ;146c
- ld b,h ;146f
- ld c,l ;1470
- ld a,b ;1471
- or a ;1472
- jr nz,l1489h ;1473
- ld a,c ;1475
- ld hl,ucbar ;1476
- cp cbar ;1479
- jr z,l148dh ;147b
- ld hl,ubbr ;147d
- cp bbr ;1480
- jr z,l148dh ;1482
- cp cbr ;1484
- jp z,ERROR ;1486
+ ld hl,CMD.O
+ ld (CMD_RPT),hl
+ ld hl,(lst.OD)
+ call get_arg_def
+ ld a,l
+ ld (lst.OD),a
+ push af
+ call skip_to_nextarg
+ ld hl,(lst.OP)
+ call get_lastarg_def
+ ld (lst.OP),hl
+ ld b,h
+ ld c,l
+ if CPU_Z180
+ ld a,b
+ or a
+ jr nz,l1489h
+ ld a,c
+ ld hl,ucbar
+ cp cbar
+ jr z,l148dh
+ ld hl,ubbr
+ cp bbr
+ jr z,l148dh
+ cp cbr
+ jp z,ERROR
l1489h:
- pop af ;1489
- out (c),a ;148a
- ret ;148c
+ endif
+ pop af
+ out (c),a
+ ret
+ if CPU_Z180
l148dh:
- pop af ;148d
- ld (hl),a ;148e
- ret ;148f
+ pop af
+ ld (hl),a
+ ret
+ endif
CMD.V:
call get_arg3 ;1490 get from, size, to
cmp_mem:
- push bc ;1493
- comst ;1494
- ld a,(de) ;1498
- ld b,(hl) ;1499
+ push bc
+ comst
+ ld a,(de)
+ ld b,(hl)
comend
- cp b ;149a
- jr z,l14bah ;149b
- ld c,a ;149d
- call out.hl.@ ;149e
- call OUTBL ;14a1
- ld a,b ;14a4
- call out.hex ;14a5
- call outbl2 ;14a8
- ld a,c ;14ab
- call out.hex ;14ac
- call OUTBL ;14af
- ex de,hl ;14b2
- call out.hl.@ ;14b3
- ex de,hl ;14b6
- call CRLF ;14b7
+ cp b
+ jr z,l14bah
+ ld c,a
+ call out.hl.@
+ call OUTBL
+ ld a,b
+ call out.hex
+ call outbl2
+ ld a,c
+ call out.hex
+ call OUTBL
+ ex de,hl
+ call out.hl.@
+ ex de,hl
+ call CRLF
l14bah:
- pop bc ;14ba
- inc hl ;14bb
- inc de ;14bc
- dec bc ;14bd
- ld a,b ;14be
- or c ;14bf
- jr nz,cmp_mem ;14c0
- ret ;14c2
+ pop bc
+ inc hl
+ inc de
+ dec bc
+ ld a,b
+ or c
+ jr nz,cmp_mem
+ ret
CMD.M:
- ld a,(de) ;14c3
- cp 'V' ;14c4
- jr nz,bm_nv ;14c6
- inc de ;14c8
+ ld a,(de)
+ cp 'V'
+ jr nz,bm_nv
+ inc de
bm_nv:
push af ;14c9 save 'V' flag
- call get_arg3 ;14ca
- push hl ;14cd
- push de ;14ce
- push bc ;14cf
- call CP.HL.DE ;14d0
- jr nc,bm_mvdown ;14d3
- add hl,bc ;14d5
- ex de,hl ;14d6
- add hl,bc ;14d7
- ex de,hl ;14d8
- dec hl ;14d9
- dec de ;14da
- comst ;14db
- lddr ;14df
+ call get_arg3
+ push hl
+ push de
+ push bc
+ call CP.HL.DE
+ jr nc,bm_mvdown
+ add hl,bc
+ ex de,hl
+ add hl,bc
+ ex de,hl
+ dec hl
+ dec de
+ comst
+ lddr
comend
- jr bm_done ;14e1
+ jr bm_done
bm_mvdown:
- comst ;14e3
- ldir ;14e7
+ comst
+ ldir
comend
bm_done:
- pop bc ;14e9
- pop de ;14ea
- pop hl ;14eb
- pop af ;14ec
+ pop bc
+ pop de
+ pop hl
+ pop af
jr z,cmp_mem ;14ed validate?
- ret ;14ef
+ ret
CMD.H:
- call EXPR ;14f0
- jp c,l173ch ;14f3
- call skip_to_nextarg ;14f6
- push hl ;14f9
- call EXPR ;14fa
- push af ;14fd
- call assert_eol ;14fe
- pop af ;1501
- ex de,hl ;1502
- pop hl ;1503
- jr c,l1511h ;1504
- push hl ;1506
- push de ;1507
- add hl,de ;1508
- call l1511h ;1509
- pop de ;150c
- pop hl ;150d
- and a ;150e
- sbc hl,de ;150f
+ call EXPR
+ jp c,l173ch
+ call skip_to_nextarg
+ push hl
+ call EXPR
+ push af
+ call assert_eol
+ pop af
+ ex de,hl
+ pop hl
+ jr c,l1511h
+ push hl
+ push de
+ add hl,de
+ call l1511h
+ pop de
+ pop hl
+ and a
+ sbc hl,de
l1511h:
call out.hl ;1511 val
- call outbl2 ;1514
+ call outbl2
call sub_0928h ;1517 -val
- call outbl4 ;151a
+ call outbl4
call out.hl.dec ;151d dec
- call outbl2 ;1520
+ call outbl2
call out.hl.decm ;1523 -dec
- call outbl4 ;1526
+ call outbl4
call out.bin.w ;1529 bin
- call outbl2 ;152c
- ld a,l ;152f
- call out.ascii ;1530
- jp CRLF ;1533
+ call outbl2
+ ld a,l
+ call out.ascii
+ jp CRLF
CMD.Q:
- ld a,(de) ;1536
- sub 'J' ;1537
- ld (lst.Qj),a ;1539
- jr nz,l153fh ;153c
- inc de ;153e
+ ld a,(de)
+ sub 'J'
+ ld (lst.Qj),a
+ jr nz,l153fh
+ inc de
l153fh:
- call get_arg_range ;153f
- push bc ;1542
- push hl ;1543
- call sub_15a7h ;1544
- pop hl ;1547
+ call get_arg_range
+ push bc
+ push hl
+ call sub_15a7h
+ pop hl
l1548h:
- call sub_1594h ;1548
- jr nz,l1562h ;154b
- push bc ;154d
- push hl ;154e
- ld a,(lst.Qj) ;154f
- or a ;1552
- jr nz,l1559h ;1553
- ld bc,-8 ;1555
- add hl,bc ;1558
+ call sub_1594h
+ jr nz,l1562h
+ push bc
+ push hl
+ ld a,(lst.Qj)
+ or a
+ jr nz,l1559h
+ ld bc,-8
+ add hl,bc
l1559h:
- ld bc,MEMDUMP_CNT ;1559
- and a ;155c
- call memdump ;155d
- pop hl ;1560
- pop bc ;1561
+ ld bc,MEMDUMP_CNT
+ and a
+ call memdump
+ pop hl
+ pop bc
l1562h:
- inc hl ;1562
- ex (sp),hl ;1563
- dec hl ;1564
- ld a,h ;1565
- or l ;1566
- ex (sp),hl ;1567
- jr nz,l1548h ;1568
- pop bc ;156a
- ret ;156b
+ inc hl
+ ex (sp),hl
+ dec hl
+ ld a,h
+ or l
+ ex (sp),hl
+ jr nz,l1548h
+ pop bc
+ ret
CMD.Z:
- call get_arg_range ;156c
- push bc ;156f
- push hl ;1570
- call sub_15a7h ;1571
- ld a,b ;1574
- pop hl ;1575
- pop bc ;1576
- push hl ;1577
- ex de,hl ;1578
+ call get_arg_range
+ push bc
+ push hl
+ call sub_15a7h
+ ld a,b
+ pop hl
+ pop bc
+ push hl
+ ex de,hl
l1579h:
- push af ;1579
- ld a,(hl) ;157a
- comst ;157b
- ld (de),a ;157f
+ push af
+ ld a,(hl)
+ comst
+ ld (de),a
comend
- pop af ;1580
- inc de ;1581
- cpi ;1582
- jp po,l1592h ;1584
- dec a ;1587
- jr nz,l1579h ;1588
- pop hl ;158a
- comst ;158b
- ldir ;158f
+ pop af
+ inc de
+ cpi
+ jp po,l1592h
+ dec a
+ jr nz,l1579h
+ pop hl
+ comst
+ ldir
comend
- ret ;1591
+ ret
l1592h:
- pop hl ;1592
- ret ;1593
+ pop hl
+ ret
sub_1594h:
- push hl ;1594
- push de ;1595
- push bc ;1596
+ push hl
+ push de
+ push bc
l1597h:
- ld a,(de) ;1597
- comst ;1598
- cp (hl) ;159c
+ ld a,(de)
+ comst
+ cp (hl)
comend
- jr nz,l15a3h ;159d
- inc de ;159f
- inc hl ;15a0
- djnz l1597h ;15a1
+ jr nz,l15a3h
+ inc de
+ inc hl
+ djnz l1597h
l15a3h:
- pop bc ;15a3
- pop de ;15a4
- pop hl ;15a5
- ret ;15a6
+ pop bc
+ pop de
+ pop hl
+ ret
sub_15a7h:
- ld hl,ci.buf+1 ;15a7
- call get_bytes ;15aa
- ld de,ci.buf+1 ;15ad
- and a ;15b0
- sbc hl,de ;15b1
- ld b,l ;15b3
- ret nz ;15b4
- jp ERROR ;15b5
+ ld hl,ci.buf+1
+ call get_bytes
+ ld de,ci.buf+1
+ and a
+ sbc hl,de
+ ld b,l
+ ret nz
+ jp ERROR
get_bytes:
db 0e6h ;15b8 and 037h (clear carry, skip next opc)
get_bytes_m:
scf
l15bah:
- push af ;15ba
- call skip_to_nextarg ;15bb
- cp 'W' ;15be
- jr nz,l15d9h ;15c0
- inc de ;15c2
- push hl ;15c3
- call sub_0a68h ;15c4
- ex de,hl ;15c7
- pop bc ;15c8
- pop af ;15c9
- push af ;15ca
- push bc ;15cb
- ex (sp),hl ;15cc
- jr nc,l15d3h ;15cd
- comst ;15cf
+ push af
+ call skip_to_nextarg
+ cp 'W'
+ jr nz,l15d9h
+ inc de
+ push hl
+ call sub_0a68h
+ ex de,hl
+ pop bc
+ pop af
+ push af
+ push bc
+ ex (sp),hl
+ jr nc,l15d3h
+ comst
l15d3h:
- ld (hl),e ;15d3
+ ld (hl),e
comend
- inc hl ;15d4
- ld c,d ;15d5
- pop de ;15d6
- jr l15e5h ;15d7
+ inc hl
+ ld c,d
+ pop de
+ jr l15e5h
l15d9h:
- cp '''' ;15d9
- jr z,l15f1h ;15db
- push hl ;15dd
- call EXPR ;15de
- ld c,l ;15e1
- pop hl ;15e2
- jr c,l1626h ;15e3
+ cp ''''
+ jr z,l15f1h
+ push hl
+ call EXPR
+ ld c,l
+ pop hl
+ jr c,l1626h
l15e5h:
- pop af ;15e5
- push af ;15e6
- jr nc,l15edh ;15e7
- comst ;15e9
+ pop af
+ push af
+ jr nc,l15edh
+ comst
l15edh:
- ld (hl),c ;15ed
+ ld (hl),c
comend
- inc hl ;15ee
- jr l161eh ;15ef
+ inc hl
+ jr l161eh
l15f1h:
- inc de ;15f1
- ld a,(de) ;15f2
- cp '''' ;15f3
- jr z,l1607h ;15f5
- or a ;15f7
- jr z,l1626h ;15f8
+ inc de
+ ld a,(de)
+ cp ''''
+ jr z,l1607h
+ or a
+ jr z,l1626h
l15fah:
- ld c,a ;15fa
- pop af ;15fb
- push af ;15fc
- jr nc,l1603h ;15fd
- comst ;15ff
+ ld c,a
+ pop af
+ push af
+ jr nc,l1603h
+ comst
l1603h:
- ld (hl),c ;1603
+ ld (hl),c
comend
- inc hl ;1604
- jr l15f1h ;1605
+ inc hl
+ jr l15f1h
l1607h:
- inc de ;1607
- ld a,(de) ;1608
- cp '''' ;1609
- jr z,l15fah ;160b
- cp '.' ;160d
- jr nz,l161eh ;160f
- inc de ;1611
- dec hl ;1612
- pop af ;1613
- push af ;1614
- jr nc,l161bh ;1615
- comst ;1617
+ inc de
+ ld a,(de)
+ cp ''''
+ jr z,l15fah
+ cp '.'
+ jr nz,l161eh
+ inc de
+ dec hl
+ pop af
+ push af
+ jr nc,l161bh
+ comst
l161bh:
- set 7,(hl) ;161b
+ set 7,(hl)
comend
- inc hl ;161d
+ inc hl
l161eh:
- pop af ;161e
- jr nc,l15bah ;161f
- ld (lst.S),hl ;1621
- jr l15bah ;1624
+ pop af
+ jr nc,l15bah
+ ld (lst.S),hl
+ jr l15bah
l1626h:
- pop af ;1626
- ret nc ;1627
- ld (lst.S),hl ;1628
- ret ;162b
+ pop af
+ ret nc
+ ld (lst.S),hl
+ ret
CMD.D:
- ld hl,CMD.D ;162c
- ld (CMD_RPT),hl ;162f
- ld hl,(lst.D) ;1632
- ld bc,00080h ;1635
- call sub_0a82h ;1638
- scf ;163b
+ ld hl,CMD.D
+ ld (CMD_RPT),hl
+ ld hl,(lst.D)
+ ld bc,00080h
+ call sub_0a82h
+ scf
memdump:
- push bc ;163c
- push de ;163d
- push hl ;163e
- ex af,af' ;163f
+ push bc
+ push de
+ push hl
+ ex af,af'
l1640h:
- call out.hl.@ ;1640
- call z,outbl2 ;1643
- call OUTBL ;1646
- ld de,0 ;1649
+ call out.hl.@
+ call z,outbl2
+ call OUTBL
+ ld de,0
l164ch:
- comst ;164c
- ld a,(hl) ;1650
+ comst
+ ld a,(hl)
comend
- inc hl ;1651
- call out.hex ;1652
- call OUTBL ;1655
- dec bc ;1658
- inc e ;1659
- ld a,e ;165a
- cp 010h ;165b
- jr z,l1668h ;165d
- and 003h ;165f
- call z,OUTBL ;1661
- ld a,b ;1664
- or c ;1665
- jr nz,l164ch ;1666
+ inc hl
+ call out.hex
+ call OUTBL
+ dec bc
+ inc e
+ ld a,e
+ cp 010h
+ jr z,l1668h
+ and 003h
+ call z,OUTBL
+ ld a,b
+ or c
+ jr nz,l164ch
l1668h:
- call OUTBL ;1668
- and a ;166b
- sbc hl,de ;166c
+ call OUTBL
+ and a
+ sbc hl,de
l166eh:
- comst ;166e
- ld a,(hl) ;1672
+ comst
+ ld a,(hl)
comend
- call sub_168fh ;1673
- call OUTCHAR ;1676
- inc hl ;1679
- dec e ;167a
- jr nz,l166eh ;167b
- ex af,af' ;167d
- jr nc,l1683h ;167e
- ld (lst.D),hl ;1680
+ call sub_168fh
+ call OUTCHAR
+ inc hl
+ dec e
+ jr nz,l166eh
+ ex af,af'
+ jr nc,l1683h
+ ld (lst.D),hl
l1683h:
- ex af,af' ;1683
- call CRLF ;1684
- ld a,b ;1687
- or c ;1688
- jr nz,l1640h ;1689
- pop hl ;168b
- pop de ;168c
- pop bc ;168d
- ret ;168e
+ ex af,af'
+ call CRLF
+ ld a,b
+ or c
+ jr nz,l1640h
+ pop hl
+ pop de
+ pop bc
+ ret
sub_168fh:
- and 07fh ;168f
- cp 07fh ;1691
- jr z,l1698h ;1693
- cp 020h ;1695
- ret nc ;1697
+ and 07fh
+ cp 07fh
+ jr z,l1698h
+ cp 020h
+ ret nc
l1698h:
- ld a,02eh ;1698
- ret ;169a
+ ld a,02eh
+ ret
; Read Intel Hex File from console.
CMD.R:
- ld hl,0 ;169b
+ ld hl,0
call get_lastarg_def ;169e get offset from command line
- push hl ;16a1
- ld hl,0 ;16a2
- ld (HILOD),hl ;16a5
+ push hl
+ ld hl,0
+ ld (HILOD),hl
w_recstart:
- call i.getchar ;16a8
- jr z,l16deh ;16ab
- cp ':' ;16ad
- jr nz,w_recstart ;16af
+ call i.getchar
+ jr z,l16deh
+ cp ':'
+ jr nz,w_recstart
ld c,0 ;16b1 init checksum
call i.gethexbyte ;16b3 record len
- ld b,a ;16b6
+ ld b,a
call i.gethexbyte ;16b7 address high
- ld h,a ;16ba
+ ld h,a
call i.gethexbyte ;16bb address low
- ld l,a ;16be
+ ld l,a
call i.gethexbyte ;16bf record type (ignored)
- ld a,b ;16c2
+ ld a,b
and a ;16c3 record len == 0?
- jr z,l16deh ;16c4
+ jr z,l16deh
l16c6h:
- call i.gethexbyte ;16c6
+ call i.gethexbyte
pop de ;16c9 offset
- push de ;16ca
- push hl ;16cb
- add hl,de ;16cc
- call i.storebyte ;16cd
- pop hl ;16d0
- inc hl ;16d1
+ push de
+ push hl
+ add hl,de
+ call i.storebyte
+ pop hl
+ inc hl
djnz l16c6h ;16d2 repeat for record len
call i.gethexbyte ;16d4 checksum
- ld a,c ;16d7
- and a ;16d8
+ ld a,c
+ and a
jp nz,ERROR ;16d9 exit if checksum error
jr w_recstart ;16dc next record
l16deh:
- pop hl ;16de
- call i.gethexbyte ;16df
- jp l173fh ;16e2
+ pop hl
+ call i.gethexbyte
+ jp l173fh
i.gethexbyte:
- call sub_16f6h ;16e5
- rlca ;16e8
- rlca ;16e9
- rlca ;16ea
- rlca ;16eb
- ld d,a ;16ec
- call sub_16f6h ;16ed
- add a,d ;16f0
- ld d,a ;16f1
- add a,c ;16f2
- ld c,a ;16f3
- ld a,d ;16f4
- ret ;16f5
+ call sub_16f6h
+ rlca
+ rlca
+ rlca
+ rlca
+ ld d,a
+ call sub_16f6h
+ add a,d
+ ld d,a
+ add a,c
+ ld c,a
+ ld a,d
+ ret
sub_16f6h:
- call i.getchar ;16f6
- jr z,l16ffh ;16f9
- call sub_0d26h ;16fb
- ret nc ;16fe
+ call i.getchar
+ jr z,l16ffh
+ call sub_0d26h
+ ret nc
l16ffh:
- jp ERROR ;16ff
+ jp ERROR
i.getchar:
- call $ci ;1702
- cp 01ah ;1705
- ret ;1707
+ call $ci
+ cp 01ah
+ ret
i.storebyte:
- push af ;1708
- push de ;1709
+ push af
+ push de
ld de,TPA ;170a lowest allowed load address
- call CP.HL.DE ;170d
- jp c,ERROR ;1710
+ call CP.HL.DE
+ jp c,ERROR
ld de,$stcka ;1713 highest allowed load address
- call CP.HL.DE ;1716
- jp nc,ERROR ;1719
- ld de,(HILOD) ;171c
- call CP.HL.DE ;1720
- jr c,l1728h ;1723
- ld (HILOD),hl ;1725
+ call CP.HL.DE
+ jp nc,ERROR
+ ld de,(HILOD)
+ call CP.HL.DE
+ jr c,l1728h
+ ld (HILOD),hl
l1728h:
- ld de,(MAXLOD) ;1728
- call CP.HL.DE ;172c
- jr c,l1734h ;172f
- ld (MAXLOD),hl ;1731
+ ld de,(MAXLOD)
+ call CP.HL.DE
+ jr c,l1734h
+ ld (MAXLOD),hl
l1734h:
- pop de ;1734
- pop af ;1735
- comst ;1736
+ pop de
+ pop af
+ comst
ld (hl),a ;173a store byte
comend
- ret ;173b
+ ret
l173ch:
- call assert_eol ;173c
+ call assert_eol
l173fh:
- ld hl,MSG_high ;173f
- call PSTR ;1742
- ld hl,(HILOD) ;1745
- call out.hl ;1748
- ld hl,MSG_max ;174b
- call PSTR ;174e
- ld hl,(MAXLOD) ;1751
- call out.hl ;1754
- jp CRLF ;1757
+ ld hl,MSG_high
+ call PSTR
+ ld hl,(HILOD)
+ call out.hl
+ ld hl,MSG_max
+ call PSTR
+ ld hl,(MAXLOD)
+ call out.hl
+ jp CRLF
MSG_high:
DC 'High = '
@@ -2839,1067 +2857,1067 @@ MSG_max:
DC ' Max = '
CMD.A:
- ld hl,(lst.A) ;1769
- call get_lastarg_def ;176c
- push hl ;176f
- pop iy ;1770
- ld hl,l17c4h ;1772
- ld (CMD_ERR),hl ;1775
- ld (XB068),sp ;1778
+ ld hl,(lst.A)
+ call get_lastarg_def
+ push hl
+ pop iy
+ ld hl,l17c4h
+ ld (CMD_ERR),hl
+ ld (XB068),sp
l177ch:
- push iy ;177c
- pop hl ;177e
- ld (lst.A),hl ;177f
- ld (OFFS.pc),hl ;1782
- push hl ;1785
- call sub_1f3fh ;1786
- pop iy ;1789
- ld c,b ;178b
- ld de,(offs.@) ;178c
- ld a,d ;1790
- or e ;1791
- ld b,011h ;1792
- jr z,l1798h ;1794
- ld b,019h ;1796
+ push iy
+ pop hl
+ ld (lst.A),hl
+ ld (OFFS.pc),hl
+ push hl
+ call sub_1f3fh
+ pop iy
+ ld c,b
+ ld de,(offs.@)
+ ld a,d
+ or e
+ ld b,011h
+ jr z,l1798h
+ ld b,019h
l1798h:
- call OUTBL ;1798
- ld a,(CON.COL) ;179b
- cp b ;179e
- jr c,l1798h ;179f
- push bc ;17a1
- call INLINE ;17a2
- pop bc ;17a5
- call SKIPBL ;17a6
- cp '.' ;17a9
- ret z ;17ab
- cp '-' ;17ac
- jr nz,l17b6h ;17ae
- ld iy,(XB06C) ;17b0
- jr l177ch ;17b4
+ call OUTBL
+ ld a,(CON.COL)
+ cp b
+ jr c,l1798h
+ push bc
+ call INLINE
+ pop bc
+ call SKIPBL
+ cp '.'
+ ret z
+ cp '-'
+ jr nz,l17b6h
+ ld iy,(XB06C)
+ jr l177ch
l17b6h:
- and a ;17b6
- call nz,sub_17cdh ;17b7
- ld (XB06C),iy ;17ba
- ld b,0 ;17be
- add iy,bc ;17c0
- jr l177ch ;17c2
+ and a
+ call nz,sub_17cdh
+ ld (XB06C),iy
+ ld b,0
+ add iy,bc
+ jr l177ch
l17c4h:
- call l07eah ;17c4
- ld sp,(XB068) ;17c7
- jr l177ch ;17cb
+ call l07eah
+ ld sp,(XB068)
+ jr l177ch
sub_17cdh:
- call SKIPBL ;17cd
- ld hl,t_MNEMONICS ;17d0
- call sub_0a15h ;17d3
- jp nc,ERROR ;17d6
- call SKIPBL ;17d9
- push de ;17dc
- ld a,b ;17dd
- add a,b ;17de
- add a,b ;17df
- ld hl,b_0x17EE_start ;17e0
- call ADD_HL_A ;17e3
- ld e,(hl) ;17e6
- inc hl ;17e7
- ld d,(hl) ;17e8
- inc hl ;17e9
- ld b,(hl) ;17ea
- ex de,hl ;17eb
- pop de ;17ec
- jp (hl) ;17ed
+ call SKIPBL
+ ld hl,t_MNEMONICS
+ call sub_0a15h
+ jp nc,ERROR
+ call SKIPBL
+ push de
+ ld a,b
+ add a,b
+ add a,b
+ ld hl,b_0x17EE_start
+ call ADD_HL_A
+ ld e,(hl)
+ inc hl
+ ld d,(hl)
+ inc hl
+ ld b,(hl)
+ ex de,hl
+ pop de
+ jp (hl)
b_0x17EE_start:
- defw l1b54h ;17ee
+ defw l1b54h
b_0x17F0_start:
- defb 088h ;17f0
+ defb 088h
b_0x17F1_start:
- defw l1b74h ;17f1
+ defw l1b74h
b_0x17F3_start:
- defb 080h ;17f3
+ defb 080h
b_0x17F4_start:
- defw l1babh ;17f4
+ defw l1babh
b_0x17F6_start:
- defb 0a0h ;17f6
+ defb 0a0h
b_0x17F7_start:
- defw l1c14h ;17f7
+ defw l1c14h
b_0x17F9_start:
- defb 040h ;17f9
+ defb 040h
b_0x17FA_start:
- defw l1c38h ;17fa
+ defw l1c38h
b_0x17FC_start:
- defb 0c4h ;17fc
+ defb 0c4h
b_0x17FD_start:
- defw l1b36h ;17fd
+ defw l1b36h
b_0x17FF_start:
- defb 03fh ;17ff
+ defb 03fh
b_0x1800_start:
- defw l1babh ;1800
+ defw l1babh
b_0x1802_start:
- defb 0b8h ;1802
+ defb 0b8h
b_0x1803_start:
- defw gen.opc.ED2 ;1803
+ defw gen.opc.ED2
b_0x1805_start:
- defb 0a9h ;1805
+ defb 0a9h
b_0x1806_start:
- defw gen.opc.ED2 ;1806
+ defw gen.opc.ED2
b_0x1808_start:
- defb 0b9h ;1808
+ defb 0b9h
b_0x1809_start:
- defw gen.opc.ED2 ;1809
+ defw gen.opc.ED2
b_0x180B_start:
- defb 0a1h ;180b
+ defb 0a1h
b_0x180C_start:
- defw gen.opc.ED2 ;180c
+ defw gen.opc.ED2
b_0x180E_start:
- defb 0b1h ;180e
+ defb 0b1h
b_0x180F_start:
- defw l1b36h ;180f
+ defw l1b36h
b_0x1811_start:
- defb 02fh ;1811
+ defb 02fh
b_0x1812_start:
- defw l1b36h ;1812
+ defw l1b36h
b_0x1814_start:
- defb 027h ;1814
+ defb 027h
b_0x1815_start:
- defw l1dabh ;1815
+ defw l1dabh
b_0x1817_start:
- defb 005h ;1817
+ defb 005h
b_0x1818_start:
- defw l1b36h ;1818
+ defw l1b36h
b_0x181A_start:
- defb 0f3h ;181a
+ defb 0f3h
b_0x181B_start:
- defw l1ca4h ;181b
+ defw l1ca4h
b_0x181D_start:
- defb 010h ;181d
+ defb 010h
b_0x181E_start:
- defw l1b36h ;181e
+ defw l1b36h
b_0x1820_start:
- defb 0fbh ;1820
+ defb 0fbh
b_0x1821_start:
- defw l1d54h ;1821
+ defw l1d54h
b_0x1823_start:
- defb 0e3h ;1823
+ defb 0e3h
b_0x1824_start:
- defw l1b36h ;1824
+ defw l1b36h
b_0x1826_start:
- defb 0d9h ;1826
+ defb 0d9h
b_0x1827_start:
- defw l1b36h ;1827
+ defw l1b36h
b_0x1829_start:
- defb 076h ;1829
+ defb 076h
b_0x182A_start:
- defw l1cbfh ;182a
+ defw l1cbfh
b_0x182C_start:
- defb 046h ;182c
+ defb 046h
b_0x182D_start:
- defw l1cf8h ;182d
+ defw l1cf8h
b_0x182F_start:
- defb 040h ;182f
+ defb 040h
b_0x1830_start:
- defw l1dabh ;1830
+ defw l1dabh
b_0x1832_start:
- defb 004h ;1832
+ defb 004h
b_0x1833_start:
- defw gen.opc.ED2 ;1833
+ defw gen.opc.ED2
b_0x1835_start:
- defb 0aah ;1835
+ defb 0aah
b_0x1836_start:
- defw gen.opc.ED2 ;1836
+ defw gen.opc.ED2
b_0x1838_start:
- defb 0bah ;1838
+ defb 0bah
b_0x1839_start:
- defw gen.opc.ED2 ;1839
+ defw gen.opc.ED2
b_0x183B_start:
- defb 0a2h ;183b
+ defb 0a2h
b_0x183C_start:
- defw gen.opc.ED2 ;183c
+ defw gen.opc.ED2
b_0x183E_start:
- defb 0b2h ;183e
+ defb 0b2h
b_0x183F_start:
- defw l1c5eh ;183f
+ defw l1c5eh
b_0x1841_start:
- defb 0c2h ;1841
+ defb 0c2h
b_0x1842_start:
- defw l1cabh ;1842
+ defw l1cabh
b_0x1844_start:
- defb 020h ;1844
+ defb 020h
b_0x1845_start:
- defw l1934h ;1845
+ defw l1934h
b_0x1847_start:
- defb 040h ;1847
+ defb 040h
b_0x1848_start:
- defw gen.opc.ED2 ;1848
+ defw gen.opc.ED2
b_0x184A_start:
- defb 0a8h ;184a
+ defb 0a8h
b_0x184B_start:
- defw gen.opc.ED2 ;184b
+ defw gen.opc.ED2
b_0x184D_start:
- defb 0b8h ;184d
+ defb 0b8h
b_0x184E_start:
- defw gen.opc.ED2 ;184e
+ defw gen.opc.ED2
b_0x1850_start:
- defb 0a0h ;1850
+ defb 0a0h
b_0x1851_start:
- defw gen.opc.ED2 ;1851
+ defw gen.opc.ED2
b_0x1853_start:
- defb 0b0h ;1853
+ defb 0b0h
b_0x1854_start:
- defw gen.opc.ED2 ;1854
+ defw gen.opc.ED2
b_0x1856_start:
- defb 044h ;1856
+ defb 044h
b_0x1857_start:
- defw l1b36h ;1857
+ defw l1b36h
b_0x1859_start:
- defb 000h ;1859
+ defb 000h
b_0x185A_start:
- defw l1babh ;185a
+ defw l1babh
b_0x185C_start:
- defb 0b0h ;185c
+ defb 0b0h
b_0x185D_start:
- defw gen.opc.ED2 ;185d
+ defw gen.opc.ED2
b_0x185F_start:
- defb 0bbh ;185f
+ defb 0bbh
b_0x1860_start:
- defw gen.opc.ED2 ;1860
+ defw gen.opc.ED2
b_0x1862_start:
- defb 0b3h ;1862
+ defb 0b3h
b_0x1863_start:
- defw l1d2ch ;1863
+ defw l1d2ch
b_0x1865_start:
- defb 041h ;1865
+ defb 041h
b_0x1866_start:
- defw gen.opc.ED2 ;1866
+ defw gen.opc.ED2
b_0x1868_start:
- defb 0abh ;1868
+ defb 0abh
b_0x1869_start:
- defw gen.opc.ED2 ;1869
+ defw gen.opc.ED2
b_0x186B_start:
- defb 0a3h ;186b
+ defb 0a3h
b_0x186C_start:
- defw l1ce4h ;186c
+ defw l1ce4h
b_0x186E_start:
- defb 0c1h ;186e
+ defb 0c1h
b_0x186F_start:
- defw l1ce4h ;186f
+ defw l1ce4h
b_0x1871_start:
- defb 0c5h ;1871
+ defb 0c5h
b_0x1872_start:
- defw l1c14h ;1872
+ defw l1c14h
b_0x1874_start:
- defb 080h ;1874
+ defb 080h
b_0x1875_start:
- defw l1c50h ;1875
+ defw l1c50h
b_0x1877_start:
- defb 0c0h ;1877
+ defb 0c0h
b_0x1878_start:
- defw gen.opc.ED2 ;1878
+ defw gen.opc.ED2
b_0x187A_start:
- defb 04dh ;187a
+ defb 04dh
b_0x187B_start:
- defw gen.opc.ED2 ;187b
+ defw gen.opc.ED2
b_0x187D_start:
- defb 045h ;187d
+ defb 045h
b_0x187E_start:
- defw l1bd8h ;187e
+ defw l1bd8h
b_0x1880_start:
- defb 010h ;1880
+ defb 010h
b_0x1881_start:
- defw l1b36h ;1881
+ defw l1b36h
b_0x1883_start:
- defb 017h ;1883
+ defb 017h
b_0x1884_start:
- defw l1bd8h ;1884
+ defw l1bd8h
b_0x1886_start:
- defb 000h ;1886
+ defb 000h
b_0x1887_start:
- defw l1b36h ;1887
+ defw l1b36h
b_0x1889_start:
- defb 007h ;1889
+ defb 007h
b_0x188A_start:
- defw gen.opc.ED2 ;188a
+ defw gen.opc.ED2
b_0x188C_start:
- defb 06fh ;188c
+ defb 06fh
b_0x188D_start:
- defw l1bd8h ;188d
+ defw l1bd8h
b_0x188F_start:
- defb 018h ;188f
+ defb 018h
b_0x1890_start:
- defw l1b36h ;1890
+ defw l1b36h
b_0x1892_start:
- defb 01fh ;1892
+ defb 01fh
b_0x1893_start:
- defw l1bd8h ;1893
+ defw l1bd8h
b_0x1895_start:
- defb 008h ;1895
+ defb 008h
b_0x1896_start:
- defw l1b36h ;1896
+ defw l1b36h
b_0x1898_start:
- defb 00fh ;1898
+ defb 00fh
b_0x1899_start:
- defw gen.opc.ED2 ;1899
+ defw gen.opc.ED2
b_0x189B_start:
- defb 067h ;189b
+ defb 067h
b_0x189C_start:
- defw l1cd5h ;189c
+ defw l1cd5h
b_0x189E_start:
- defb 0c7h ;189e
+ defb 0c7h
b_0x189F_start:
- defw l1b54h ;189f
+ defw l1b54h
b_0x18A1_start:
- defb 098h ;18a1
+ defb 098h
b_0x18A2_start:
- defw l1b36h ;18a2
+ defw l1b36h
b_0x18A4_start:
- defb 037h ;18a4
+ defb 037h
b_0x18A5_start:
- defw l1c14h ;18a5
+ defw l1c14h
b_0x18A7_start:
- defb 0c0h ;18a7
+ defb 0c0h
b_0x18A8_start:
- defw l1bd8h ;18a8
+ defw l1bd8h
b_0x18AA_start:
- defb 020h ;18aa
+ defb 020h
b_0x18AB_start:
- defw l1bd8h ;18ab
+ defw l1bd8h
b_0x18AD_start:
- defb 028h ;18ad
+ defb 028h
b_0x18AE_start:
- defw l1bd8h ;18ae
+ defw l1bd8h
b_0x18B0_start:
- defb 038h ;18b0
+ defb 038h
b_0x18B1_start:
- defw l1babh ;18b1
+ defw l1babh
b_0x18B3_start:
- defb 090h ;18b3
+ defb 090h
b_0x18B4_start:
- defw l1babh ;18b4
+ defw l1babh
b_0x18B6_start:
- defb 0a8h ;18b6
+ defb 0a8h
b_0x18B7_start:
- defw A.IN0 ;18b7
+ defw A.IN0
b_0x18B9_start:
- defb 000h ;18b9
+ defb 000h
b_0x18BA_start:
- defw A.MLT ;18ba
+ defw A.MLT
b_0x18BC_start:
- defb 04ch ;18bc
- ld b,e ;18bd
- dec de ;18be
+ defb 04ch
+ ld b,e
+ dec de
b_0x18BF_start:
- defb 08bh ;18bf
+ defb 08bh
b_0x18C0_start:
- defw gen.opc.ED2 ;18c0
+ defw gen.opc.ED2
b_0x18C2_start:
- defb 09bh ;18c2
+ defb 09bh
b_0x18C3_start:
- defw gen.opc.ED2 ;18c3
+ defw gen.opc.ED2
b_0x18C5_start:
- defb 083h ;18c5
+ defb 083h
b_0x18C6_start:
- defw gen.opc.ED2 ;18c6
+ defw gen.opc.ED2
b_0x18C8_start:
- defb 093h ;18c8
+ defb 093h
b_0x18C9_start:
- defw l18fdh ;18c9
+ defw l18fdh
b_0x18CB_start:
- defb 001h ;18cb
+ defb 001h
b_0x18CC_start:
- defw gen.opc.ED2 ;18cc
+ defw gen.opc.ED2
b_0x18CE_start:
- defb 076h ;18ce
+ defb 076h
b_0x18CF_start:
- defw l191dh ;18cf
+ defw l191dh
b_0x18D1_start:
- defb 004h ;18d1
+ defb 004h
b_0x18D2_start:
- defw l192ch ;18d2
+ defw l192ch
b_0x18D4_start:
- defb 074h ;18d4
+ defb 074h
A.IN0:
- call sub_1e41h ;18d5
- jr nc,l1931h ;18d8
- cp 006h ;18da
- jr z,l1931h ;18dc
- rlca ;18de
- rlca ;18df
- rlca ;18e0
- add a,b ;18e1
- ld b,a ;18e2
- call sub_1ed1h ;18e3
- call sub_1e06h ;18e6
+ call sub_1e41h
+ jr nc,l1931h
+ cp 006h
+ jr z,l1931h
+ rlca
+ rlca
+ rlca
+ add a,b
+ ld b,a
+ call sub_1ed1h
+ call sub_1e06h
l18e9h:
- call assert_eol ;18e9
- comst ;18ec
- ld (iy+000h),0edh ;18f0
- ld (iy+001h),b ;18f4
- ld (iy+002h),l ;18f7
+ call assert_eol
+ comst
+ ld (iy+000h),0edh
+ ld (iy+001h),b
+ ld (iy+002h),l
comend
- ld c,003h ;18fa
- ret ;18fc
+ ld c,003h
+ ret
l18fdh:
- call sub_1e06h ;18fd
- call sub_1ed1h ;1900
- call sub_1e41h ;1903
- jr nc,l1931h ;1906
- cp 006h ;1908
- jr z,l1931h ;190a
- rlca ;190c
- rlca ;190d
- rlca ;190e
- add a,b ;190f
- ld b,a ;1910
- jr l18e9h ;1911
+ call sub_1e06h
+ call sub_1ed1h
+ call sub_1e41h
+ jr nc,l1931h
+ cp 006h
+ jr z,l1931h
+ rlca
+ rlca
+ rlca
+ add a,b
+ ld b,a
+ jr l18e9h
A.MLT:
- call sub_1e2eh ;1913
- jr nc,l1931h ;1916
- add a,b ;1918
- ld b,a ;1919
- jp gen.opc.ED2 ;191a
+ call sub_1e2eh
+ jr nc,l1931h
+ add a,b
+ ld b,a
+ jp gen.opc.ED2
l191dh:
- call sub_1e41h ;191d
- jr nc,l192ah ;1920
- rlca ;1922
- rlca ;1923
- rlca ;1924
- add a,b ;1925
- ld b,a ;1926
- jp gen.opc.ED2 ;1927
+ call sub_1e41h
+ jr nc,l192ah
+ rlca
+ rlca
+ rlca
+ add a,b
+ ld b,a
+ jp gen.opc.ED2
l192ah:
- ld b,064h ;192a
+ ld b,064h
l192ch:
- call sub_1e12h ;192c
- jr l18e9h ;192f
+ call sub_1e12h
+ jr l18e9h
l1931h:
- jp ERROR ;1931
+ jp ERROR
l1934h:
- call sub_1e41h ;1934
- jp c,l19bfh ;1937
- call sub_1e68h ;193a
- jp c,l1a64h ;193d
- call sub_1e2eh ;1940
- jp c,l1a93h ;1943
- call sub_1e50h ;1946
- jp c,l1af0h ;1949
- ld a,(de) ;194c
- cp 049h ;194d
- jp z,l1b0ch ;194f
- cp 052h ;1952
- jp z,l1b14h ;1954
- cp 028h ;1957
- jp nz,ERROR ;1959
- inc de ;195c
- call sub_1e2eh ;195d
- jp c,l1b23h ;1960
- call tst_EXPR ;1963
- call sub_1ed8h ;1966
- call sub_1ed1h ;1969
- call sub_1e2eh ;196c
- jr c,l19adh ;196f
- call sub_1e50h ;1971
- jr nc,l1991h ;1974
- ld b,022h ;1976
+ call sub_1e41h
+ jp c,l19bfh
+ call sub_1e68h
+ jp c,l1a64h
+ call sub_1e2eh
+ jp c,l1a93h
+ call sub_1e50h
+ jp c,l1af0h
+ ld a,(de)
+ cp 049h
+ jp z,l1b0ch
+ cp 052h
+ jp z,l1b14h
+ cp 028h
+ jp nz,ERROR
+ inc de
+ call sub_1e2eh
+ jp c,l1b23h
+ call tst_EXPR
+ call sub_1ed8h
+ call sub_1ed1h
+ call sub_1e2eh
+ jr c,l19adh
+ call sub_1e50h
+ jr nc,l1991h
+ ld b,022h
l1978h:
- call assert_eol ;1978
- ld a,(pfx.IXY) ;197b
+ call assert_eol
+ ld a,(pfx.IXY)
l197eh:
- comst ;197e
- ld (iy+000h),a ;1982
- ld (iy+001h),b ;1985
- ld (iy+002h),l ;1988
- ld (iy+003h),h ;198b
+ comst
+ ld (iy+000h),a
+ ld (iy+001h),b
+ ld (iy+002h),l
+ ld (iy+003h),h
comend
- ld c,004h ;198e
- ret ;1990
+ ld c,004h
+ ret
l1991h:
- ld a,(de) ;1991
- cp 041h ;1992
- jp nz,ERROR ;1994
- inc de ;1997
- ld b,032h ;1998
+ ld a,(de)
+ cp 041h
+ jp nz,ERROR
+ inc de
+ ld b,032h
l199ah:
- call assert_eol ;199a
- comst ;199d
- ld (iy+000h),b ;19a1
- ld (iy+001h),l ;19a4
- ld (iy+002h),h ;19a7
+ call assert_eol
+ comst
+ ld (iy+000h),b
+ ld (iy+001h),l
+ ld (iy+002h),h
comend
- ld c,003h ;19aa
- ret ;19ac
+ ld c,003h
+ ret
l19adh:
- cp 020h ;19ad
- jr z,l19bbh ;19af
- add a,043h ;19b1
- ld b,a ;19b3
+ cp 020h
+ jr z,l19bbh
+ add a,043h
+ ld b,a
l19b4h:
- call assert_eol ;19b4
- ld a,0edh ;19b7
- jr l197eh ;19b9
+ call assert_eol
+ ld a,0edh
+ jr l197eh
l19bbh:
- ld b,022h ;19bb
- jr l199ah ;19bd
+ ld b,022h
+ jr l199ah
l19bfh:
- ld b,a ;19bf
- call sub_1ed1h ;19c0
- call sub_1e41h ;19c3
- jr nc,l19dbh ;19c6
- push af ;19c8
- ld a,b ;19c9
- rlca ;19ca
- rlca ;19cb
- rlca ;19cc
- ld b,a ;19cd
- pop af ;19ce
- add a,b ;19cf
- add a,040h ;19d0
- cp 076h ;19d2
- jp z,ERROR ;19d4
+ ld b,a
+ call sub_1ed1h
+ call sub_1e41h
+ jr nc,l19dbh
+ push af
+ ld a,b
+ rlca
+ rlca
+ rlca
+ ld b,a
+ pop af
+ add a,b
+ add a,040h
+ cp 076h
+ jp z,ERROR
l19d7h:
- ld b,a ;19d7
- jp l1b36h ;19d8
+ ld b,a
+ jp l1b36h
l19dbh:
- call sub_1e68h ;19db
- jr nc,l1a02h ;19de
- ld a,b ;19e0
- rlca ;19e1
- rlca ;19e2
- rlca ;19e3
- add a,046h ;19e4
- cp 076h ;19e6
- jp z,ERROR ;19e8
+ call sub_1e68h
+ jr nc,l1a02h
+ ld a,b
+ rlca
+ rlca
+ rlca
+ add a,046h
+ cp 076h
+ jp z,ERROR
l19ebh:
- ld b,a ;19eb
- call assert_eol ;19ec
- ld a,(pfx.IXY) ;19ef
- comst ;19f2
- ld (iy+000h),a ;19f6
- ld (iy+001h),b ;19f9
- ld (iy+002h),c ;19fc
+ ld b,a
+ call assert_eol
+ ld a,(pfx.IXY)
+ comst
+ ld (iy+000h),a
+ ld (iy+001h),b
+ ld (iy+002h),c
comend
- ld c,003h ;19ff
- ret ;1a01
+ ld c,003h
+ ret
l1a02h:
- ld a,(de) ;1a02
- cp 'I' ;1a03
- jr z,l1a15h ;1a05
- cp 'R' ;1a07
- jr nz,l1a21h ;1a09
- ld a,b ;1a0b
- cp 007h ;1a0c
- jp nz,ERROR ;1a0e
- ld b,05fh ;1a11
- jr l1a1dh ;1a13
+ ld a,(de)
+ cp 'I'
+ jr z,l1a15h
+ cp 'R'
+ jr nz,l1a21h
+ ld a,b
+ cp 007h
+ jp nz,ERROR
+ ld b,05fh
+ jr l1a1dh
l1a15h:
- ld a,b ;1a15
- cp 007h ;1a16
- jp nz,ERROR ;1a18
- ld b,057h ;1a1b
+ ld a,b
+ cp 007h
+ jp nz,ERROR
+ ld b,057h
l1a1dh:
- inc de ;1a1d
- jp gen.opc.ED2 ;1a1e
+ inc de
+ jp gen.opc.ED2
l1a21h:
- cp '(' ;1a21
- jr z,l1a3fh ;1a23
- call sub_1e12h ;1a25
+ cp '('
+ jr z,l1a3fh
+ call sub_1e12h
ld a,b ;1a28 ld r,nn
- rlca ;1a29
- rlca ;1a2a
- rlca ;1a2b
- add a,006h ;1a2c
+ rlca
+ rlca
+ rlca
+ add a,006h
l1a2eh:
- ld b,a ;1a2e
+ ld b,a
l1a2fh:
- call assert_eol ;1a2f
- comst ;1a32
- ld (iy+000h),b ;1a36
- ld (iy+001h),l ;1a39
+ call assert_eol
+ comst
+ ld (iy+000h),b
+ ld (iy+001h),l
comend
- ld c,002h ;1a3c
- ret ;1a3e
+ ld c,002h
+ ret
l1a3fh:
- inc de ;1a3f
- ld a,b ;1a40
- cp 007h ;1a41
- jp nz,ERROR ;1a43
- call sub_1e2eh ;1a46
- jr nc,l1a59h ;1a49
- cp 030h ;1a4b
- jp nc,ERROR ;1a4d
- add a,00ah ;1a50
- ld b,a ;1a52
- call sub_1ed8h ;1a53
- jp l1b36h ;1a56
+ inc de
+ ld a,b
+ cp 007h
+ jp nz,ERROR
+ call sub_1e2eh
+ jr nc,l1a59h
+ cp 030h
+ jp nc,ERROR
+ add a,00ah
+ ld b,a
+ call sub_1ed8h
+ jp l1b36h
l1a59h:
- call tst_EXPR ;1a59
- call sub_1ed8h ;1a5c
- ld b,03ah ;1a5f
- jp l199ah ;1a61
+ call tst_EXPR
+ call sub_1ed8h
+ ld b,03ah
+ jp l199ah
l1a64h:
- call sub_1ed1h ;1a64
- call sub_1e41h ;1a67
- jr nc,l1a76h ;1a6a
- cp 006h ;1a6c
- jp z,ERROR ;1a6e
- add a,070h ;1a71
- jp l19ebh ;1a73
+ call sub_1ed1h
+ call sub_1e41h
+ jr nc,l1a76h
+ cp 006h
+ jp z,ERROR
+ add a,070h
+ jp l19ebh
l1a76h:
- call sub_1e12h ;1a76
- call assert_eol ;1a79
- ld a,(pfx.IXY) ;1a7c
- comst ;1a7f
+ call sub_1e12h
+ call assert_eol
+ ld a,(pfx.IXY)
+ comst
ld (iy+000h),a ;1a83 dd/fd
- ld (iy+001h),036h ;1a86
+ ld (iy+001h),036h
ld (iy+002h),c ;1a8a displacement
ld (iy+003h),l ;1a8d nn
comend
- ld c,4 ;1a90
- ret ;1a92
+ ld c,4
+ ret
l1a93h:
- ld b,a ;1a93
- call sub_1ed1h ;1a94
- ld hl,t_HL.AF ;1a97
- call sub_0a23h ;1a9a
- jr c,l1abeh ;1a9d
- call sub_1e50h ;1a9f
- jr nc,l1ac7h ;1aa2
- ld a,b ;1aa4
- cp 030h ;1aa5
- jr nz,l1b20h ;1aa7
- ld b,0f9h ;1aa9
+ ld b,a
+ call sub_1ed1h
+ ld hl,t_HL.AF
+ call sub_0a23h
+ jr c,l1abeh
+ call sub_1e50h
+ jr nc,l1ac7h
+ ld a,b
+ cp 030h
+ jr nz,l1b20h
+ ld b,0f9h
l1aabh:
- call assert_eol ;1aab
- ld a,(pfx.IXY) ;1aae
- comst ;1ab1
- ld (iy+000h),a ;1ab5
- ld (iy+001h),b ;1ab8
+ call assert_eol
+ ld a,(pfx.IXY)
+ comst
+ ld (iy+000h),a
+ ld (iy+001h),b
comend
- ld c,002h ;1abb
- ret ;1abd
+ ld c,002h
+ ret
l1abeh:
- ld a,b ;1abe
- cp 030h ;1abf
- jr nz,l1b20h ;1ac1
- ld b,0f9h ;1ac3
- jr l1b36h ;1ac5
+ ld a,b
+ cp 030h
+ jr nz,l1b20h
+ ld b,0f9h
+ jr l1b36h
l1ac7h:
- ld a,(de) ;1ac7
- cp 028h ;1ac8
- jr nz,l1ae3h ;1aca
- inc de ;1acc
- call tst_EXPR ;1acd
- call sub_1ed8h ;1ad0
- ld a,b ;1ad3
- cp 020h ;1ad4
- jr z,l1adeh ;1ad6
- add a,04bh ;1ad8
- ld b,a ;1ada
- jp l19b4h ;1adb
+ ld a,(de)
+ cp 028h
+ jr nz,l1ae3h
+ inc de
+ call tst_EXPR
+ call sub_1ed8h
+ ld a,b
+ cp 020h
+ jr z,l1adeh
+ add a,04bh
+ ld b,a
+ jp l19b4h
l1adeh:
- ld b,02ah ;1ade
- jp l199ah ;1ae0
+ ld b,02ah
+ jp l199ah
l1ae3h:
- call tst_EXPR ;1ae3
- call assert_eol ;1ae6
- ld a,001h ;1ae9
- add a,b ;1aeb
- ld b,a ;1aec
- jp l199ah ;1aed
+ call tst_EXPR
+ call assert_eol
+ ld a,001h
+ add a,b
+ ld b,a
+ jp l199ah
l1af0h:
- call sub_1ed1h ;1af0
- ld a,(de) ;1af3
- cp 028h ;1af4
- jr nz,l1b04h ;1af6
- inc de ;1af8
- call tst_EXPR ;1af9
- call sub_1ed8h ;1afc
- ld b,02ah ;1aff
- jp l1978h ;1b01
+ call sub_1ed1h
+ ld a,(de)
+ cp 028h
+ jr nz,l1b04h
+ inc de
+ call tst_EXPR
+ call sub_1ed8h
+ ld b,02ah
+ jp l1978h
l1b04h:
- call tst_EXPR ;1b04
- ld b,021h ;1b07
- jp l1978h ;1b09
+ call tst_EXPR
+ ld b,021h
+ jp l1978h
l1b0ch:
- inc de ;1b0c
- call sub_1ed1h ;1b0d
- ld b,047h ;1b10
- jr l1b1ah ;1b12
+ inc de
+ call sub_1ed1h
+ ld b,047h
+ jr l1b1ah
l1b14h:
- inc de ;1b14
- call sub_1ed1h ;1b15
- ld b,04fh ;1b18
+ inc de
+ call sub_1ed1h
+ ld b,04fh
l1b1ah:
- ld a,(de) ;1b1a
- inc de ;1b1b
- cp 041h ;1b1c
- jr z,gen.opc.ED2 ;1b1e
+ ld a,(de)
+ inc de
+ cp 041h
+ jr z,gen.opc.ED2
l1b20h:
- jp ERROR ;1b20
+ jp ERROR
l1b23h:
- cp 020h ;1b23
- jr nc,l1b20h ;1b25
- add a,002h ;1b27
- ld b,a ;1b29
- call sub_1ed8h ;1b2a
- call sub_1ed1h ;1b2d
- ld a,(de) ;1b30
- cp 041h ;1b31
- jr nz,l1b20h ;1b33
- inc de ;1b35
+ cp 020h
+ jr nc,l1b20h
+ add a,002h
+ ld b,a
+ call sub_1ed8h
+ call sub_1ed1h
+ ld a,(de)
+ cp 041h
+ jr nz,l1b20h
+ inc de
l1b36h:
- call assert_eol ;1b36
- comst ;1b39
- ld (iy+000h),b ;1b3d
+ call assert_eol
+ comst
+ ld (iy+000h),b
comend
- ld c,001h ;1b40
- ret ;1b42
+ ld c,001h
+ ret
gen.opc.ED2:
- call assert_eol ;1b43
- comst ;1b46
- ld (iy+000h),0edh ;1b4a
- ld (iy+001h),b ;1b4e
+ call assert_eol
+ comst
+ ld (iy+000h),0edh
+ ld (iy+001h),b
comend
- ld c,002h ;1b51
- ret ;1b53
+ ld c,002h
+ ret
l1b54h:
- ld hl,t_HL.AF ;1b54
- call sub_0a23h ;1b57
- jr nc,l1babh ;1b5a
- call sub_1ed1h ;1b5c
- call sub_1e2eh ;1b5f
- jp nc,ERROR ;1b62
- push af ;1b65
- ld a,b ;1b66
- cp 088h ;1b67
- ld b,04ah ;1b69
- jr z,l1b6fh ;1b6b
- ld b,042h ;1b6d
+ ld hl,t_HL.AF
+ call sub_0a23h
+ jr nc,l1babh
+ call sub_1ed1h
+ call sub_1e2eh
+ jp nc,ERROR
+ push af
+ ld a,b
+ cp 088h
+ ld b,04ah
+ jr z,l1b6fh
+ ld b,042h
l1b6fh:
- pop af ;1b6f
- add a,b ;1b70
+ pop af
+ add a,b
l1b71h:
- ld b,a ;1b71
- jr gen.opc.ED2 ;1b72
+ ld b,a
+ jr gen.opc.ED2
l1b74h:
- ld hl,t_HL.AF ;1b74
- call sub_0a23h ;1b77
- jr c,l1b9dh ;1b7a
- call sub_1e50h ;1b7c
- jr nc,l1babh ;1b7f
- call sub_1ed1h ;1b81
- ld hl,t_BC.DE.IX.SP ;1b84
- ld a,(pfx.IXY) ;1b87
- cp 0fdh ;1b8a
- jr nz,l1b91h ;1b8c
- ld hl,t_BC.DE.IY.SP ;1b8e
+ ld hl,t_HL.AF
+ call sub_0a23h
+ jr c,l1b9dh
+ call sub_1e50h
+ jr nc,l1babh
+ call sub_1ed1h
+ ld hl,t_BC.DE.IX.SP
+ ld a,(pfx.IXY)
+ cp 0fdh
+ jr nz,l1b91h
+ ld hl,t_BC.DE.IY.SP
l1b91h:
- call sub_1e2bh ;1b91
- jp nc,ERROR ;1b94
- add a,009h ;1b97
+ call sub_1e2bh
+ jp nc,ERROR
+ add a,009h
l1b99h:
- ld b,a ;1b99
- jp l1aabh ;1b9a
+ ld b,a
+ jp l1aabh
l1b9dh:
- call sub_1ed1h ;1b9d
- call sub_1e2eh ;1ba0
- jp nc,ERROR ;1ba3
- add a,009h ;1ba6
- jp l19d7h ;1ba8
+ call sub_1ed1h
+ call sub_1e2eh
+ jp nc,ERROR
+ add a,009h
+ jp l19d7h
l1babh:
- ld a,(de) ;1bab
- cp 041h ;1bac
- jr nz,l1bbbh ;1bae
- push de ;1bb0
- inc de ;1bb1
- call skip_to_nextarg ;1bb2
- jr z,l1bbah ;1bb5
- pop de ;1bb7
- jr l1bbbh ;1bb8
+ ld a,(de)
+ cp 041h
+ jr nz,l1bbbh
+ push de
+ inc de
+ call skip_to_nextarg
+ jr z,l1bbah
+ pop de
+ jr l1bbbh
l1bbah:
- pop af ;1bba
+ pop af
l1bbbh:
- call sub_1e41h ;1bbb
- jr c,l1bceh ;1bbe
- call sub_1e68h ;1bc0
- jr c,l1bd2h ;1bc3
- call sub_1e12h ;1bc5
- ld a,b ;1bc8
- add a,046h ;1bc9
- jp l1a2eh ;1bcb
+ call sub_1e41h
+ jr c,l1bceh
+ call sub_1e68h
+ jr c,l1bd2h
+ call sub_1e12h
+ ld a,b
+ add a,046h
+ jp l1a2eh
l1bceh:
- add a,b ;1bce
- jp l19d7h ;1bcf
+ add a,b
+ jp l19d7h
l1bd2h:
- ld a,b ;1bd2
- add a,006h ;1bd3
- jp l19ebh ;1bd5
+ ld a,b
+ add a,006h
+ jp l19ebh
l1bd8h:
- call sub_1e41h ;1bd8
- jr c,l1c01h ;1bdb
- call sub_1e68h ;1bdd
- jp nc,ERROR ;1be0
- ld a,b ;1be3
- add a,006h ;1be4
- ld b,a ;1be6
+ call sub_1e41h
+ jr c,l1c01h
+ call sub_1e68h
+ jp nc,ERROR
+ ld a,b
+ add a,006h
+ ld b,a
l1be7h:
- call assert_eol ;1be7
- ld a,(pfx.IXY) ;1bea
- comst ;1bed
- ld (iy+000h),a ;1bf1
- ld (iy+001h),0cbh ;1bf4
- ld (iy+002h),c ;1bf8
- ld (iy+003h),b ;1bfb
+ call assert_eol
+ ld a,(pfx.IXY)
+ comst
+ ld (iy+000h),a
+ ld (iy+001h),0cbh
+ ld (iy+002h),c
+ ld (iy+003h),b
comend
- ld c,004h ;1bfe
- ret ;1c00
+ ld c,004h
+ ret
l1c01h:
- add a,b ;1c01
+ add a,b
l1c02h:
- ld b,a ;1c02
- call assert_eol ;1c03
- comst ;1c06
- ld (iy+000h),0cbh ;1c0a
- ld (iy+001h),b ;1c0e
+ ld b,a
+ call assert_eol
+ comst
+ ld (iy+000h),0cbh
+ ld (iy+001h),b
comend
- ld c,002h ;1c11
- ret ;1c13
+ ld c,002h
+ ret
l1c14h:
- call sub_1de6h ;1c14
- call sub_1ed1h ;1c17
- call sub_1e41h ;1c1a
- jr c,l1c2fh ;1c1d
- call sub_1e68h ;1c1f
- jp nc,ERROR ;1c22
- ld a,l ;1c25
- rlca ;1c26
- rlca ;1c27
- rlca ;1c28
- add a,006h ;1c29
- add a,b ;1c2b
- ld b,a ;1c2c
- jr l1be7h ;1c2d
+ call sub_1de6h
+ call sub_1ed1h
+ call sub_1e41h
+ jr c,l1c2fh
+ call sub_1e68h
+ jp nc,ERROR
+ ld a,l
+ rlca
+ rlca
+ rlca
+ add a,006h
+ add a,b
+ ld b,a
+ jr l1be7h
l1c2fh:
- add a,b ;1c2f
- ld b,a ;1c30
- ld a,l ;1c31
- rlca ;1c32
- rlca ;1c33
- rlca ;1c34
- add a,b ;1c35
- jr l1c02h ;1c36
+ add a,b
+ ld b,a
+ ld a,l
+ rlca
+ rlca
+ rlca
+ add a,b
+ jr l1c02h
l1c38h:
- push de ;1c38
- call sub_1eb8h ;1c39
- jr nc,l1c47h ;1c3c
- add a,b ;1c3e
- ld b,a ;1c3f
- call skip_to_nextarg ;1c40
- jr z,l1c49h ;1c43
- pop de ;1c45
- push de ;1c46
+ push de
+ call sub_1eb8h
+ jr nc,l1c47h
+ add a,b
+ ld b,a
+ call skip_to_nextarg
+ jr z,l1c49h
+ pop de
+ push de
l1c47h:
- ld b,0cdh ;1c47
+ ld b,0cdh
l1c49h:
- pop af ;1c49
- call tst_EXPR ;1c4a
- jp l199ah ;1c4d
+ pop af
+ call tst_EXPR
+ jp l199ah
l1c50h:
- call sub_1eb8h ;1c50
- jr nc,l1c59h ;1c53
- add a,b ;1c55
- ld b,a ;1c56
- jr l1c5bh ;1c57
+ call sub_1eb8h
+ jr nc,l1c59h
+ add a,b
+ ld b,a
+ jr l1c5bh
l1c59h:
- ld b,0c9h ;1c59
+ ld b,0c9h
l1c5bh:
- jp l1b36h ;1c5b
+ jp l1b36h
l1c5eh:
- push de ;1c5e
- call sub_1eb8h ;1c5f
- jr c,l1c71h ;1c62
+ push de
+ call sub_1eb8h
+ jr c,l1c71h
l1c64h:
- pop de ;1c64
- ld hl,b_0x1C97_start ;1c65
- call sub_0a15h ;1c68
- jr c,l1c7fh ;1c6b
- ld b,0c3h ;1c6d
- jr l1c79h ;1c6f
+ pop de
+ ld hl,b_0x1C97_start
+ call sub_0a15h
+ jr c,l1c7fh
+ ld b,0c3h
+ jr l1c79h
l1c71h:
- add a,b ;1c71
- ld b,a ;1c72
- call skip_to_nextarg ;1c73
- jr nz,l1c64h ;1c76
- pop af ;1c78
+ add a,b
+ ld b,a
+ call skip_to_nextarg
+ jr nz,l1c64h
+ pop af
l1c79h:
- call tst_EXPR ;1c79
- jp l199ah ;1c7c
+ call tst_EXPR
+ jp l199ah
l1c7fh:
- call assert_eol ;1c7f
- ld a,b ;1c82
- and a ;1c83
- jr nz,l1c8bh ;1c84
- ld b,0e9h ;1c86
- jp l1b36h ;1c88
+ call assert_eol
+ ld a,b
+ and a
+ jr nz,l1c8bh
+ ld b,0e9h
+ jp l1b36h
l1c8bh:
- ld b,0ddh ;1c8b
- dec a ;1c8d
- jr z,l1c92h ;1c8e
- ld b,0fdh ;1c90
+ ld b,0ddh
+ dec a
+ jr z,l1c92h
+ ld b,0fdh
l1c92h:
- ld l,0e9h ;1c92
- jp l1a2fh ;1c94
+ ld l,0e9h
+ jp l1a2fh
b_0x1C97_start:
DC '(HL)'
@@ -3908,128 +3926,128 @@ b_0x1C97_start:
DB 0
l1ca4h:
- call skip_to_nextarg ;1ca4
- ld b,010h ;1ca7
- jr l1cb9h ;1ca9
+ call skip_to_nextarg
+ ld b,010h
+ jr l1cb9h
l1cabh:
- call sub_1ebfh ;1cab
- jr c,l1cb4h ;1cae
- ld b,018h ;1cb0
- jr l1cb9h ;1cb2
+ call sub_1ebfh
+ jr c,l1cb4h
+ ld b,018h
+ jr l1cb9h
l1cb4h:
- add a,b ;1cb4
- ld b,a ;1cb5
- call sub_1ed1h ;1cb6
+ add a,b
+ ld b,a
+ call sub_1ed1h
l1cb9h:
- call sub_1defh ;1cb9
- jp l1a2fh ;1cbc
+ call sub_1defh
+ jp l1a2fh
l1cbfh:
- call sub_1e12h ;1cbf
- ld a,l ;1cc2
- cp 003h ;1cc3
- jr nc,l1d23h ;1cc5
- and a ;1cc7
- jr z,l1cd2h ;1cc8
- ld b,056h ;1cca
- cp 001h ;1ccc
- jr z,l1cd2h ;1cce
- ld b,05eh ;1cd0
+ call sub_1e12h
+ ld a,l
+ cp 003h
+ jr nc,l1d23h
+ and a
+ jr z,l1cd2h
+ ld b,056h
+ cp 001h
+ jr z,l1cd2h
+ ld b,05eh
l1cd2h:
- jp gen.opc.ED2 ;1cd2
+ jp gen.opc.ED2
l1cd5h:
- call sub_1e12h ;1cd5
- ld a,l ;1cd8
- push af ;1cd9
- add a,b ;1cda
- ld b,a ;1cdb
- pop af ;1cdc
- and 0c7h ;1cdd
- jr nz,l1d23h ;1cdf
- jp l1b36h ;1ce1
+ call sub_1e12h
+ ld a,l
+ push af
+ add a,b
+ ld b,a
+ pop af
+ and 0c7h
+ jr nz,l1d23h
+ jp l1b36h
l1ce4h:
- call sub_1e50h ;1ce4
- jr c,l1cf2h ;1ce7
- call sub_1e25h ;1ce9
- jr nc,l1d23h ;1cec
- add a,b ;1cee
- jp l19d7h ;1cef
+ call sub_1e50h
+ jr c,l1cf2h
+ call sub_1e25h
+ jr nc,l1d23h
+ add a,b
+ jp l19d7h
l1cf2h:
- ld a,b ;1cf2
- add a,020h ;1cf3
- jp l1b99h ;1cf5
+ ld a,b
+ add a,020h
+ jp l1b99h
l1cf8h:
- call sub_1e41h ;1cf8
- jr nc,l1d23h ;1cfb
- cp 006h ;1cfd
- jr z,l1d23h ;1cff
- rlca ;1d01
- rlca ;1d02
- rlca ;1d03
- add a,b ;1d04
- ld b,a ;1d05
- cp 078h ;1d06
- jr nz,l1d1ah ;1d08
- call sub_1ed1h ;1d0a
- call sub_1d26h ;1d0d
- jr c,l1d20h ;1d10
- call sub_1e06h ;1d12
- ld b,0dbh ;1d15
- jp l1a2fh ;1d17
+ call sub_1e41h
+ jr nc,l1d23h
+ cp 006h
+ jr z,l1d23h
+ rlca
+ rlca
+ rlca
+ add a,b
+ ld b,a
+ cp 078h
+ jr nz,l1d1ah
+ call sub_1ed1h
+ call sub_1d26h
+ jr c,l1d20h
+ call sub_1e06h
+ ld b,0dbh
+ jp l1a2fh
l1d1ah:
- call sub_1ed1h ;1d1a
- call sub_1d26h ;1d1d
+ call sub_1ed1h
+ call sub_1d26h
l1d20h:
- jp c,gen.opc.ED2 ;1d20
+ jp c,gen.opc.ED2
l1d23h:
- jp ERROR ;1d23
+ jp ERROR
sub_1d26h:
- ld hl,t__C_ ;1d26
- jp sub_0a23h ;1d29
+ ld hl,t__C_
+ jp sub_0a23h
l1d2ch:
- call sub_1d26h ;1d2c
- jr nc,l1d44h ;1d2f
- call sub_1ed1h ;1d31
- call sub_1e41h ;1d34
- jr nc,l1d23h ;1d37
- cp 006h ;1d39
- jr z,l1d23h ;1d3b
- rlca ;1d3d
- rlca ;1d3e
- rlca ;1d3f
- add a,b ;1d40
- jp l1b71h ;1d41
+ call sub_1d26h
+ jr nc,l1d44h
+ call sub_1ed1h
+ call sub_1e41h
+ jr nc,l1d23h
+ cp 006h
+ jr z,l1d23h
+ rlca
+ rlca
+ rlca
+ add a,b
+ jp l1b71h
l1d44h:
- call sub_1e06h ;1d44
- call sub_1ed1h ;1d47
- cp 041h ;1d4a
- jr nz,l1d23h ;1d4c
- inc de ;1d4e
- ld b,0d3h ;1d4f
- jp l1a2fh ;1d51
+ call sub_1e06h
+ call sub_1ed1h
+ cp 041h
+ jr nz,l1d23h
+ inc de
+ ld b,0d3h
+ jp l1a2fh
l1d54h:
- ld hl,b_0x1D80_start ;1d54
- call sub_0a15h ;1d57
- jp nc,ERROR ;1d5a
- ld c,b ;1d5d
- call assert_eol ;1d5e
- ld b,000h ;1d61
- ld hl,b_0x1DA1_start ;1d63
- add hl,bc ;1d66
- add hl,bc ;1d67
- ld a,(hl) ;1d68
- comst ;1d69
- ld (iy+000h),a ;1d6d
+ ld hl,b_0x1D80_start
+ call sub_0a15h
+ jp nc,ERROR
+ ld c,b
+ call assert_eol
+ ld b,000h
+ ld hl,b_0x1DA1_start
+ add hl,bc
+ add hl,bc
+ ld a,(hl)
+ comst
+ ld (iy+000h),a
comend
- ld c,001h ;1d70
- inc hl ;1d72
- ld a,(hl) ;1d73
- and a ;1d74
- ret z ;1d75
- comst ;1d76
- ld (iy+001h),a ;1d7a
+ ld c,001h
+ inc hl
+ ld a,(hl)
+ and a
+ ret z
+ comst
+ ld (iy+001h),a
comend
- ld c,002h ;1d7d
- ret ;1d7f
+ ld c,002h
+ ret
b_0x1D80_start:
DC 'AF,AF'''
@@ -4038,1359 +4056,1359 @@ l1d86h:
DC '(SP),HL'
DC '(SP),IX'
DC '(SP),IY'
- db 000h ;1da0
+ db 000h
b_0x1DA1_start:
- db 008h ;1da1
- db 000h ;1da2
- db 0ebh ;1da3
- db 000h ;1da4
- db 0e3h ;1da5
- db 000h ;1da6
- db 0ddh ;1da7
- db 0e3h ;1da8
- db 0fdh ;1da9
- db 0e3h ;1daa
+ db 008h
+ db 000h
+ db 0ebh
+ db 000h
+ db 0e3h
+ db 000h
+ db 0ddh
+ db 0e3h
+ db 0fdh
+ db 0e3h
l1dabh:
- call sub_1e50h ;1dab
- jr c,l1dc6h ;1dae
- call sub_1e2eh ;1db0
- jr c,l1dd2h ;1db3
- call sub_1e41h ;1db5
- jr c,l1ddfh ;1db8
- call sub_1e68h ;1dba
- jp nc,ERROR ;1dbd
- ld a,b ;1dc0
- add a,030h ;1dc1
- jp l19ebh ;1dc3
+ call sub_1e50h
+ jr c,l1dc6h
+ call sub_1e2eh
+ jr c,l1dd2h
+ call sub_1e41h
+ jr c,l1ddfh
+ call sub_1e68h
+ jp nc,ERROR
+ ld a,b
+ add a,030h
+ jp l19ebh
l1dc6h:
- ld a,b ;1dc6
- ld b,023h ;1dc7
- cp 004h ;1dc9
- jr z,l1dcfh ;1dcb
- ld b,02bh ;1dcd
+ ld a,b
+ ld b,023h
+ cp 004h
+ jr z,l1dcfh
+ ld b,02bh
l1dcfh:
- jp l1aabh ;1dcf
+ jp l1aabh
l1dd2h:
- push af ;1dd2
- ld a,b ;1dd3
- ld b,003h ;1dd4
- cp 004h ;1dd6
- jr z,l1ddch ;1dd8
- ld b,00bh ;1dda
+ push af
+ ld a,b
+ ld b,003h
+ cp 004h
+ jr z,l1ddch
+ ld b,00bh
l1ddch:
- pop af ;1ddc
- jr l1de2h ;1ddd
+ pop af
+ jr l1de2h
l1ddfh:
- rlca ;1ddf
- rlca ;1de0
- rlca ;1de1
+ rlca
+ rlca
+ rlca
l1de2h:
- add a,b ;1de2
- jp l19d7h ;1de3
+ add a,b
+ jp l19d7h
sub_1de6h:
- call sub_1e12h ;1de6
- ld a,l ;1de9
- cp 008h ;1dea
- jr nc,error1 ;1dec
- ret ;1dee
+ call sub_1e12h
+ ld a,l
+ cp 008h
+ jr nc,error1
+ ret
sub_1defh:
- call tst_EXPR ;1def
- push bc ;1df2
- push iy ;1df3
- pop bc ;1df5
- and a ;1df6
- sbc hl,bc ;1df7
- dec hl ;1df9
- dec hl ;1dfa
- pop bc ;1dfb
- call sub_1e15h ;1dfc
- ld a,h ;1dff
- xor l ;1e00
- bit 7,a ;1e01
- jr nz,error1 ;1e03
- ret ;1e05
+ call tst_EXPR
+ push bc
+ push iy
+ pop bc
+ and a
+ sbc hl,bc
+ dec hl
+ dec hl
+ pop bc
+ call sub_1e15h
+ ld a,h
+ xor l
+ bit 7,a
+ jr nz,error1
+ ret
sub_1e06h:
- ld a,(de) ;1e06
- cp 028h ;1e07
- jr nz,sub_1e12h ;1e09
- inc de ;1e0b
- call sub_1e12h ;1e0c
- jp sub_1ed8h ;1e0f
+ ld a,(de)
+ cp 028h
+ jr nz,sub_1e12h
+ inc de
+ call sub_1e12h
+ jp sub_1ed8h
sub_1e12h:
- call tst_EXPR ;1e12
+ call tst_EXPR
sub_1e15h:
- ld a,h ;1e15
- and a ;1e16
- ret z ;1e17
- inc a ;1e18
- ret z ;1e19
- jr error1 ;1e1a
+ ld a,h
+ and a
+ ret z
+ inc a
+ ret z
+ jr error1
tst_EXPR:
- push bc ;1e1c
- call EXPR ;1e1d
- pop bc ;1e20
- ret nc ;1e21
+ push bc
+ call EXPR
+ pop bc
+ ret nc
error1:
- jp ERROR ;1e22
+ jp ERROR
sub_1e25h:
- push hl ;1e25
- ld hl,t_BC.DE.HL.AF ;1e26
- jr l1e32h ;1e29
+ push hl
+ ld hl,t_BC.DE.HL.AF
+ jr l1e32h
sub_1e2bh:
- push hl ;1e2b
- jr l1e32h ;1e2c
+ push hl
+ jr l1e32h
sub_1e2eh:
- push hl ;1e2e
- ld hl,t_BC.DE.HL.SP ;1e2f
+ push hl
+ ld hl,t_BC.DE.HL.SP
l1e32h:
- push bc ;1e32
- call sub_0a15h ;1e33
- jr nc,l1e3eh ;1e36
- ld a,b ;1e38
- rlca ;1e39
- rlca ;1e3a
- rlca ;1e3b
- rlca ;1e3c
- scf ;1e3d
+ push bc
+ call sub_0a15h
+ jr nc,l1e3eh
+ ld a,b
+ rlca
+ rlca
+ rlca
+ rlca
+ scf
l1e3eh:
- pop bc ;1e3e
- pop hl ;1e3f
- ret ;1e40
+ pop bc
+ pop hl
+ ret
sub_1e41h:
- call SKIPBL ;1e41
- push bc ;1e44
- push hl ;1e45
- ld hl,t_BCDEHL_HL_A ;1e46
- call sub_0a15h ;1e49
- ld a,b ;1e4c
- pop hl ;1e4d
- pop bc ;1e4e
- ret ;1e4f
+ call SKIPBL
+ push bc
+ push hl
+ ld hl,t_BCDEHL_HL_A
+ call sub_0a15h
+ ld a,b
+ pop hl
+ pop bc
+ ret
sub_1e50h:
- push hl ;1e50
- push bc ;1e51
- ld hl,t_IX.IY ;1e52
- call sub_0a15h ;1e55
- jr nc,l1e65h ;1e58
- ld a,0ddh ;1e5a
- dec b ;1e5c
- jr nz,l1e61h ;1e5d
- ld a,0fdh ;1e5f
+ push hl
+ push bc
+ ld hl,t_IX.IY
+ call sub_0a15h
+ jr nc,l1e65h
+ ld a,0ddh
+ dec b
+ jr nz,l1e61h
+ ld a,0fdh
l1e61h:
- ld (pfx.IXY),a ;1e61
- scf ;1e64
+ ld (pfx.IXY),a
+ scf
l1e65h:
- pop bc ;1e65
- pop hl ;1e66
- ret ;1e67
+ pop bc
+ pop hl
+ ret
sub_1e68h:
- push hl ;1e68
- push bc ;1e69
- ld a,(de) ;1e6a
- cp '(' ;1e6b
- jr nz,l1eb4h ;1e6d
- push de ;1e6f
- inc de ;1e70
- ld hl,t_IX.IY ;1e71
- call sub_0a15h ;1e74
- jr nc,l1eb3h ;1e77
- pop af ;1e79
- ld a,0ddh ;1e7a
- dec b ;1e7c
- jr nz,l1e81h ;1e7d
- ld a,0fdh ;1e7f
+ push hl
+ push bc
+ ld a,(de)
+ cp '('
+ jr nz,l1eb4h
+ push de
+ inc de
+ ld hl,t_IX.IY
+ call sub_0a15h
+ jr nc,l1eb3h
+ pop af
+ ld a,0ddh
+ dec b
+ jr nz,l1e81h
+ ld a,0fdh
l1e81h:
- ld (pfx.IXY),a ;1e81
- ld a,(de) ;1e84
- cp '+' ;1e85
- jr z,l1e95h ;1e87
- cp ')' ;1e89
- ld hl,0 ;1e8b
- jr z,l1eadh ;1e8e
- cp '-' ;1e90
- jp nz,ERROR ;1e92
+ ld (pfx.IXY),a
+ ld a,(de)
+ cp '+'
+ jr z,l1e95h
+ cp ')'
+ ld hl,0
+ jr z,l1eadh
+ cp '-'
+ jp nz,ERROR
l1e95h:
- push af ;1e95
- inc de ;1e96
+ push af
+ inc de
call sub_1e12h ;1e97 get displacement
- pop af ;1e9a
- cp '+' ;1e9b
- jr z,l1ea7h ;1e9d
- ld b,h ;1e9f
- ld c,l ;1ea0
- ld hl,0 ;1ea1
- and a ;1ea4
- sbc hl,bc ;1ea5
+ pop af
+ cp '+'
+ jr z,l1ea7h
+ ld b,h
+ ld c,l
+ ld hl,0
+ and a
+ sbc hl,bc
l1ea7h:
- ld a,(de) ;1ea7
- cp ')' ;1ea8
- jp nz,ERROR ;1eaa
+ ld a,(de)
+ cp ')'
+ jp nz,ERROR
l1eadh:
- inc de ;1ead
- pop bc ;1eae
- ld c,l ;1eaf
- pop hl ;1eb0
- scf ;1eb1
- ret ;1eb2
+ inc de
+ pop bc
+ ld c,l
+ pop hl
+ scf
+ ret
l1eb3h:
- pop de ;1eb3
+ pop de
l1eb4h:
- pop bc ;1eb4
- pop hl ;1eb5
- and a ;1eb6
- ret ;1eb7
+ pop bc
+ pop hl
+ and a
+ ret
sub_1eb8h:
- ld hl,t_tstfl_ZCPS ;1eb8
- ld c,007h ;1ebb
- jr l1ec4h ;1ebd
+ ld hl,t_tstfl_ZCPS
+ ld c,007h
+ jr l1ec4h
sub_1ebfh:
- ld hl,t_tstfl_ZC ;1ebf
- ld c,003h ;1ec2
+ ld hl,t_tstfl_ZC
+ ld c,003h
l1ec4h:
- push bc ;1ec4
- call sub_0a15h ;1ec5
- ld a,b ;1ec8
- pop bc ;1ec9
- ret nc ;1eca
- and c ;1ecb
- rlca ;1ecc
- rlca ;1ecd
- rlca ;1ece
- scf ;1ecf
- ret ;1ed0
+ push bc
+ call sub_0a15h
+ ld a,b
+ pop bc
+ ret nc
+ and c
+ rlca
+ rlca
+ rlca
+ scf
+ ret
sub_1ed1h:
- call skip_to_nextarg ;1ed1
- ret z ;1ed4
+ call skip_to_nextarg
+ ret z
l1ed5h:
- jp ERROR ;1ed5
+ jp ERROR
sub_1ed8h:
- ld a,(de) ;1ed8
- cp 029h ;1ed9
- jr nz,l1ed5h ;1edb
- inc de ;1edd
- ret ;1ede
+ ld a,(de)
+ cp 029h
+ jr nz,l1ed5h
+ inc de
+ ret
CMD.L:
- ld hl,CMD.L ;1edf
- ld (CMD_RPT),hl ;1ee2
- call EXPR ;1ee5
- jr nc,l1eedh ;1ee8
- ld hl,(lst.L) ;1eea
+ ld hl,CMD.L
+ ld (CMD_RPT),hl
+ call EXPR
+ jr nc,l1eedh
+ ld hl,(lst.L)
l1eedh:
- push hl ;1eed
- pop iy ;1eee
- call skip_to_nextarg ;1ef0
- call sub_0aa5h ;1ef3
- jr nc,l1f17h ;1ef6
- call assert_eol ;1ef8
- ld b,010h ;1efb
+ push hl
+ pop iy
+ call skip_to_nextarg
+ call sub_0aa5h
+ jr nc,l1f17h
+ call assert_eol
+ ld b,010h
l1efdh:
- push bc ;1efd
- push iy ;1efe
- pop hl ;1f00
- push hl ;1f01
- call sub_1f3fh ;1f02
- call CRLF ;1f05
- pop iy ;1f08
- ld c,b ;1f0a
- ld b,000h ;1f0b
- add iy,bc ;1f0d
- ld (lst.L),iy ;1f0f
- pop bc ;1f13
- djnz l1efdh ;1f14
- ret ;1f16
+ push bc
+ push iy
+ pop hl
+ push hl
+ call sub_1f3fh
+ call CRLF
+ pop iy
+ ld c,b
+ ld b,000h
+ add iy,bc
+ ld (lst.L),iy
+ pop bc
+ djnz l1efdh
+ ret
l1f17h:
- call assert_eol ;1f17
- ld h,b ;1f1a
- ld l,c ;1f1b
- ld a,b ;1f1c
- or c ;1f1d
- jr nz,l1f21h ;1f1e
- dec hl ;1f20
+ call assert_eol
+ ld h,b
+ ld l,c
+ ld a,b
+ or c
+ jr nz,l1f21h
+ dec hl
l1f21h:
- push hl ;1f21
- push iy ;1f22
- pop hl ;1f24
- push hl ;1f25
- call sub_1f3fh ;1f26
- call CRLF ;1f29
- pop iy ;1f2c
- ld e,b ;1f2e
- ld d,000h ;1f2f
- add iy,de ;1f31
- ld (lst.L),iy ;1f33
- pop hl ;1f37
- and a ;1f38
- sbc hl,de ;1f39
- ret z ;1f3b
- ret c ;1f3c
- jr l1f21h ;1f3d
+ push hl
+ push iy
+ pop hl
+ push hl
+ call sub_1f3fh
+ call CRLF
+ pop iy
+ ld e,b
+ ld d,000h
+ add iy,de
+ ld (lst.L),iy
+ pop hl
+ and a
+ sbc hl,de
+ ret z
+ ret c
+ jr l1f21h
sub_1f3fh:
- call out.hl.@ ;1f3f
- call z,OUTBL ;1f42
- call OUTBL ;1f45
- sub a ;1f48
- ld (CON.COL),a ;1f49
- call sub_1f77h ;1f4c
- and a ;1f4f
- ret z ;1f50
+ call out.hl.@
+ call z,OUTBL
+ call OUTBL
+ sub a
+ ld (CON.COL),a
+ call sub_1f77h
+ and a
+ ret z
l1f51h:
- call OUTBL ;1f51
- ld a,(CON.COL) ;1f54
- cp 010h ;1f57
- jr c,l1f51h ;1f59
+ call OUTBL
+ ld a,(CON.COL)
+ cp 010h
+ jr c,l1f51h
sub_1f5bh:
- ld de,(offs.@) ;1f5b
- ld a,d ;1f5f
- or e ;1f60
- ret z ;1f61
- ld a,'(' ;1f62
- call OUTCHAR ;1f64
- ld a,'@' ;1f67
- call OUTCHAR ;1f69
- and a ;1f6c
- sbc hl,de ;1f6d
- call out.hl ;1f6f
- ld a,')' ;1f72
- jp OUTCHAR ;1f74
+ ld de,(offs.@)
+ ld a,d
+ or e
+ ret z
+ ld a,'('
+ call OUTCHAR
+ ld a,'@'
+ call OUTCHAR
+ and a
+ sbc hl,de
+ call out.hl
+ ld a,')'
+ jp OUTCHAR
sub_1f77h:
- sub a ;1f77
- ld (XBE03),a ;1f78
- call sub_1f9eh ;1f7b
- jr nc,l1f91h ;1f7e
- push bc ;1f80
- call sub_2581h ;1f81
- ex de,hl ;1f84
- call sub_1fdbh ;1f85
- pop bc ;1f88
- ld a,(XBE03) ;1f89
- ld hl,(XBE01) ;1f8c
- scf ;1f8f
- ret ;1f90
+ sub a
+ ld (XBE03),a
+ call sub_1f9eh
+ jr nc,l1f91h
+ push bc
+ call sub_2581h
+ ex de,hl
+ call sub_1fdbh
+ pop bc
+ ld a,(XBE03)
+ ld hl,(XBE01)
+ scf
+ ret
l1f91h:
- ld hl,b_0x1F9B_start ;1f91
- call PSTR ;1f94
- ld b,001h ;1f97
- sub a ;1f99
- ret ;1f9a
+ ld hl,b_0x1F9B_start
+ call PSTR
+ ld b,001h
+ sub a
+ ret
b_0x1F9B_start:
DC '???'
-
+
sub_1f9eh:
- sub a ;1f9e
- ld (is.pfx.IXY),a ;1f9f
- comst ;1fa2
- ld a,(iy+000h) ;1fa6
+ sub a
+ ld (is.pfx.IXY),a
+ comst
+ ld a,(iy+000h)
comend
- cp 0edh ;1fa9
- jp z,disas_pfx.ED ;1fab
- cp 0ddh ;1fae
- jr z,l1fc5h ;1fb0
- cp 0fdh ;1fb2
- jr z,l1fc9h ;1fb4
+ cp 0edh
+ jp z,disas_pfx.ED
+ cp 0ddh
+ jr z,l1fc5h
+ cp 0fdh
+ jr z,l1fc9h
sub_1fb6h:
- comst ;1fb6
- ld a,(iy+000h) ;1fba
+ comst
+ ld a,(iy+000h)
comend
- cp 0cbh ;1fbd
- jp z,l2061h ;1fbf
- jp l2078h ;1fc2
+ cp 0cbh
+ jp z,l2061h
+ jp l2078h
l1fc5h:
- ld a,001h ;1fc5
- jr l1fcbh ;1fc7
+ ld a,001h
+ jr l1fcbh
l1fc9h:
- ld a,002h ;1fc9
+ ld a,002h
l1fcbh:
- ld (is.pfx.IXY),a ;1fcb
- call sub_1fdch ;1fce
- ret nc ;1fd1
- push bc ;1fd2
- call sub_1fb6h ;1fd3
- pop af ;1fd6
- add a,b ;1fd7
- ld b,a ;1fd8
- scf ;1fd9
- ret ;1fda
+ ld (is.pfx.IXY),a
+ call sub_1fdch
+ ret nc
+ push bc
+ call sub_1fb6h
+ pop af
+ add a,b
+ ld b,a
+ scf
+ ret
sub_1fdbh:
- jp (hl) ;1fdb
+ jp (hl)
sub_1fdch:
- inc iy ;1fdc
- ld hl,b_0x2011_start ;1fde
- call sub_20bbh ;1fe1
- ld b,002h ;1fe4
- ret c ;1fe6
- ld hl,l202ch ;1fe7
- call sub_20bbh ;1fea
- ld b,001h ;1fed
- ret c ;1fef
- comst ;1ff0
- ld a,(iy+000h) ;1ff4
+ inc iy
+ ld hl,b_0x2011_start
+ call sub_20bbh
+ ld b,002h
+ ret c
+ ld hl,l202ch
+ call sub_20bbh
+ ld b,001h
+ ret c
+ comst
+ ld a,(iy+000h)
comend
- cp 0cbh ;1ff7
- jr nz,l200fh ;1ff9
- comst ;1ffb
- ld a,(iy+002h) ;1fff
+ cp 0cbh
+ jr nz,l200fh
+ comst
+ ld a,(iy+002h)
comend
- cp 036h ;2002
- ret z ;2004
- and 007h ;2005
- cp 006h ;2007
- jr nz,l200fh ;2009
- ld b,002h ;200b
- scf ;200d
- ret ;200e
+ cp 036h
+ ret z
+ and 007h
+ cp 006h
+ jr nz,l200fh
+ ld b,002h
+ scf
+ ret
l200fh:
- and a ;200f
- ret ;2010
+ and a
+ ret
b_0x2011_start:
- db 034h ;2011
- db 035h ;2012
- db 036h ;2013
- db 046h ;2014
- db 04eh ;2015
- db 056h ;2016
- db 05eh ;2017
- db 066h ;2018
- db 06eh ;2019
- db 070h ;201a
- db 071h ;201b
- db 072h ;201c
- db 073h ;201d
- db 074h ;201e
- db 075h ;201f
- db 076h ;2020
- db 077h ;2021
- db 07eh ;2022
- db 086h ;2023
- db 08eh ;2024
- db 096h ;2025
- db 09eh ;2026
- db 0a6h ;2027
- db 0aeh ;2028
- db 0b6h ;2029
- db 0beh ;202a
- db 000h ;202b
+ db 034h
+ db 035h
+ db 036h
+ db 046h
+ db 04eh
+ db 056h
+ db 05eh
+ db 066h
+ db 06eh
+ db 070h
+ db 071h
+ db 072h
+ db 073h
+ db 074h
+ db 075h
+ db 076h
+ db 077h
+ db 07eh
+ db 086h
+ db 08eh
+ db 096h
+ db 09eh
+ db 0a6h
+ db 0aeh
+ db 0b6h
+ db 0beh
+ db 000h
l202ch:
- db 009h ;202c
- db 019h ;202d
- db 021h ;202e
- db 022h ;202f
- db 023h ;2030
- db 029h ;2031
- db 02ah ;2032
- db 02bh ;2033
- db 039h ;2034
- db 0e1h ;2035
- db 0e3h ;2036
- db 0e5h ;2037
- db 0e9h ;2038
- db 0f9h ;2039
- db 000h ;203a
+ db 009h
+ db 019h
+ db 021h
+ db 022h
+ db 023h
+ db 029h
+ db 02ah
+ db 02bh
+ db 039h
+ db 0e1h
+ db 0e3h
+ db 0e5h
+ db 0e9h
+ db 0f9h
+ db 000h
disas_pfx.ED:
- inc iy ;203b
- ld hl,b_0x2200_start ;203d
- call sub_209dh ;2040
- ld b,002h ;2043
- ret c ;2045
- ld hl,l2235h ;2046
- call lookup_opc ;2049
- ld b,002h ;204c
- ret c ;204e
- ld hl,l228bh ;204f
- call lookup_opc ;2052
- ld b,003h ;2055
- ret c ;2057
- ld hl,l22b4h ;2058
- call lookup_opc ;205b
- ld b,004h ;205e
- ret ;2060
+ inc iy
+ ld hl,b_0x2200_start
+ call sub_209dh
+ ld b,002h
+ ret c
+ ld hl,l2235h
+ call lookup_opc
+ ld b,002h
+ ret c
+ ld hl,l228bh
+ call lookup_opc
+ ld b,003h
+ ret c
+ ld hl,l22b4h
+ call lookup_opc
+ ld b,004h
+ ret
l2061h:
- push iy ;2061
- inc iy ;2063
- ld a,(is.pfx.IXY) ;2065
- and a ;2068
- jr z,l206dh ;2069
- inc iy ;206b
+ push iy
+ inc iy
+ ld a,(is.pfx.IXY)
+ and a
+ jr z,l206dh
+ inc iy
l206dh:
- ld hl,l22c9h ;206d
- call lookup_opc ;2070
- pop iy ;2073
- ld b,002h ;2075
- ret ;2077
+ ld hl,l22c9h
+ call lookup_opc
+ pop iy
+ ld b,002h
+ ret
l2078h:
- ld hl,b_0x218B_start ;2078
- call lookup_opc ;207b
- ld b,002h ;207e
- ret c ;2080
- ld hl,b_0x20ED_start ;2081
- call sub_209dh ;2084
- ld b,001h ;2087
- ret c ;2089
- ld hl,b_0x2108_start ;208a
- call lookup_opc ;208d
- ld b,001h ;2090
- ret c ;2092
- ld hl,b_0x21D2_start ;2093
- call lookup_opc ;2096
- ret nc ;2099
- ld b,003h ;209a
- ret ;209c
+ ld hl,b_0x218B_start
+ call lookup_opc
+ ld b,002h
+ ret c
+ ld hl,b_0x20ED_start
+ call sub_209dh
+ ld b,001h
+ ret c
+ ld hl,b_0x2108_start
+ call lookup_opc
+ ld b,001h
+ ret c
+ ld hl,b_0x21D2_start
+ call lookup_opc
+ ret nc
+ ld b,003h
+ ret
sub_209dh:
- ld a,(hl) ;209d
- cp 0ffh ;209e
- ret z ;20a0
- comst ;20a1
- cp (iy+000h) ;20a5
+ ld a,(hl)
+ cp 0ffh
+ ret z
+ comst
+ cp (iy+000h)
comend
- jr z,l20aeh ;20a8
- inc hl ;20aa
- inc hl ;20ab
- jr sub_209dh ;20ac
+ jr z,l20aeh
+ inc hl
+ inc hl
+ jr sub_209dh
l20aeh:
- inc hl ;20ae
- ld c,(hl) ;20af
- ld hl,t_MNEMONICS ;20b0
- ld b,000h ;20b3
- add hl,bc ;20b5
- ld de,l230bh ;20b6
- scf ;20b9
- ret ;20ba
+ inc hl
+ ld c,(hl)
+ ld hl,t_MNEMONICS
+ ld b,000h
+ add hl,bc
+ ld de,l230bh
+ scf
+ ret
sub_20bbh:
- ld a,(hl) ;20bb
- and a ;20bc
- ret z ;20bd
- inc hl ;20be
- comst ;20bf
- cp (iy+000h) ;20c3
+ ld a,(hl)
+ and a
+ ret z
+ inc hl
+ comst
+ cp (iy+000h)
comend
- jr nz,sub_20bbh ;20c6
- scf ;20c8
- ret ;20c9
+ jr nz,sub_20bbh
+ scf
+ ret
lookup_opc:
- comst ;20ca
- ld a,(iy+000h) ;20ce
+ comst
+ ld a,(iy+000h)
comend
- and (hl) ;20d1
- inc hl ;20d2
- cp (hl) ;20d3
- jr z,l20dfh ;20d4
- inc hl ;20d6
- inc hl ;20d7
- inc hl ;20d8
- inc hl ;20d9
- ld a,(hl) ;20da
- and a ;20db
- jr nz,lookup_opc ;20dc
- ret ;20de
+ and (hl)
+ inc hl
+ cp (hl)
+ jr z,l20dfh
+ inc hl
+ inc hl
+ inc hl
+ inc hl
+ ld a,(hl)
+ and a
+ jr nz,lookup_opc
+ ret
l20dfh:
- inc hl ;20df
- ld c,(hl) ;20e0
- inc hl ;20e1
- ld e,(hl) ;20e2
- inc hl ;20e3
- ld d,(hl) ;20e4
- ld hl,t_MNEMONICS ;20e5
- ld b,000h ;20e8
- add hl,bc ;20ea
- scf ;20eb
- ret ;20ec
+ inc hl
+ ld c,(hl)
+ inc hl
+ ld e,(hl)
+ inc hl
+ ld d,(hl)
+ ld hl,t_MNEMONICS
+ ld b,000h
+ add hl,bc
+ scf
+ ret
b_0x20ED_start: ; 1 byte opcodes (no parameters)
db 076h ;20ed halt
- db 039h ;20ee
+ db 039h ;20ee
db 0d9h ;20ef exx
- db 036h ;20f0
+ db 036h
db 0f3h ;20f1 di
- db 02ch ;20f2
+ db 02ch
db 0fbh ;20f3 ei
- db 032h ;20f4
+ db 032h
db 000h ;20f5 nop
- db 069h ;20f6
+ db 069h
db 007h ;20f7 rlca
- db 09eh ;20f8
+ db 09eh
db 00fh ;20f9 rrca
- db 0adh ;20fa
+ db 0adh
db 017h ;20fb rla
- db 098h ;20fc
+ db 098h
db 01fh ;20fd rra
- db 0a7h ;20fe
+ db 0a7h
db 027h ;20ff daa
- db 026h ;2100
+ db 026h
db 02fh ;2101 cpl
- db 023h ;2102
+ db 023h
db 037h ;2103 scf
- db 0bah ;2104
+ db 0bah
db 03fh ;2105 ccf
- db 010h ;2106
+ db 010h
db 0ffh ;2107 EOT
b_0x2108_start: ; 1 byte opcodes
defb 0c0h ;2108 ld r,r
- defb 040h ;2109
- defb 056h ;210a
- defw l22fch ;210b
+ defb 040h
+ defb 056h
+ defw l22fch
defb 0f8h ;210d add a,r
- defb 080h ;210e
- defb 003h ;210f
- defw l2305h ;2110
+ defb 080h
+ defb 003h
+ defw l2305h
defb 0f8h ;2112 adc a,r
- defb 088h ;2113
- defb 000h ;2114
- defw l2305h ;2115
-
- defb 0f8h ;2117
- defb 090h ;2118
- defb 0c9h ;2119
- defw l24ebh ;211a
-
- defb 0f8h ;211c
- defb 098h ;211d
- defb 0b7h ;211e
- defw l2305h ;211f
-
- defb 0f8h ;2121
- defb 0a0h ;2122
- defb 006h ;2123
- defw l24ebh ;2124
-
- defb 0f8h ;2126
- defb 0a8h ;2127
- defb 0cch ;2128
- defw l24ebh ;2129
-
- defb 0f8h ;212b
- defb 0b0h ;212c
- defb 06ch ;212d
- defw l24ebh ;212e
-
- defb 0f8h ;2130
- defb 0b8h ;2131
- defb 013h ;2132
- defw l24ebh ;2133
-
- defb 0c7h ;2135
+ defb 088h
+ defb 000h
+ defw l2305h
+
+ defb 0f8h
+ defb 090h
+ defb 0c9h
+ defw l24ebh
+
+ defb 0f8h
+ defb 098h
+ defb 0b7h
+ defw l2305h
+
+ defb 0f8h
+ defb 0a0h
+ defb 006h
+ defw l24ebh
+
+ defb 0f8h
+ defb 0a8h
+ defb 0cch
+ defw l24ebh
+
+ defb 0f8h
+ defb 0b0h
+ defb 06ch
+ defw l24ebh
+
+ defb 0f8h
+ defb 0b8h
+ defb 013h
+ defw l24ebh
+
+ defb 0c7h
defb 0c0h ;2136 ret cc
- defb 08bh ;2137
- defw l2561h ;2138
+ defb 08bh
+ defw l2561h
defb 0c7h ;213a rst
- defb 0c7h ;213b
- defb 0b4h ;213c
- defw l231eh ;213d
+ defb 0c7h
+ defb 0b4h
+ defw l231eh
defb 0ffh ;213f ret
- defb 0c9h ;2140
- defb 08bh ;2141
- defw l230bh ;2142
+ defb 0c9h
+ defb 08bh
+ defw l230bh
defb 0cfh ;2144 pop rr
- defb 0c1h ;2145
- defb 081h ;2146
- defw l2546h ;2147
+ defb 0c1h
+ defb 081h
+ defw l2546h
defb 0cfh ;2149 push rr
- defb 0c5h ;214a
- defb 084h ;214b
- defw l2546h ;214c
+ defb 0c5h
+ defb 084h
+ defw l2546h
defb 0ffh ;214e ex (sp),hl
- defb 0e3h ;214f
- defb 034h ;2150
- defw l232ah ;2151
+ defb 0e3h
+ defb 034h
+ defw l232ah
defb 0ffh ;2153 jp (hl)
- defb 0e9h ;2154
- defb 052h ;2155
- defw l2338h ;2156
+ defb 0e9h
+ defb 052h
+ defw l2338h
defb 0ffh ;2158 ex de,hl
- defb 0ebh ;2159
- defb 034h ;215a
- defw l2345h ;215b
+ defb 0ebh
+ defb 034h
+ defw l2345h
defb 0ffh ;215d ld sp,hl
- defb 0f9h ;215e
- defb 056h ;215f
- defw l234bh ;2160
+ defb 0f9h
+ defb 056h
+ defw l234bh
defb 0cfh ;2162 inc rr
- defb 003h ;2163
- defb 041h ;2164
- defw l254bh ;2165
+ defb 003h
+ defb 041h
+ defw l254bh
defb 0cfh ;2167 dec rr
- defb 00bh ;2168
- defb 029h ;2169
- defw l254bh ;216a
+ defb 00bh
+ defb 029h
+ defw l254bh
defb 0c7h ;216c inc r
- defb 004h ;216d
- defb 041h ;216e
- defw l24dfh ;216f
+ defb 004h
+ defb 041h
+ defw l24dfh
defb 0c7h ;2171 dec r
- defb 005h ;2172
- defb 029h ;2173
- defw l24dfh ;2174
+ defb 005h
+ defb 029h
+ defw l24dfh
defb 0ffh ;2176 ex af,af'
- defb 008h ;2177
- defb 034h ;2178
- defw l2357h ;2179
+ defb 008h
+ defb 034h
+ defw l2357h
defb 0cfh ;217b add hl,rr
- defb 009h ;217c
- defb 003h ;217d
- defw l235dh ;217e
+ defb 009h
+ defb 003h
+ defw l235dh
defb 0efh ;2180 ld (rr),a ;rr=bc,de
- defb 002h ;2181
- defb 056h ;2182
- defw l2366h ;2183
+ defb 002h
+ defb 056h
+ defw l2366h
defb 0efh ;2185 ld a,(rr) ;rr=bc,de
- defb 00ah ;2186
- defb 056h ;2187
- defw l236fh ;2188
+ defb 00ah
+ defb 056h
+ defw l236fh
defb 000h ;218a EOT
b_0x218B_start: ; 2 byte opdodes
defb 0c7h ;218b ld r,nn
- defb 006h ;218c
- defb 056h ;218d
- defw l2384h ;218e
+ defb 006h
+ defb 056h
+ defw l2384h
defb 0ffh ;2190 add a,nn
- defb 0c6h ;2191
- defb 003h ;2192
- defw l237fh ;2193
+ defb 0c6h
+ defb 003h
+ defw l237fh
defb 0ffh ;2195 adc a,nn
- defb 0ceh ;2196
- defb 000h ;2197
- defw l237fh ;2198
+ defb 0ceh
+ defb 000h
+ defw l237fh
defb 0ffh ;219a sub a,nn
- defb 0d6h ;219b
- defb 0c9h ;219c
- defw l2397h ;219d
+ defb 0d6h
+ defb 0c9h
+ defw l2397h
- defb 0ffh ;219f
- defb 0deh ;21a0
- defb 0b7h ;21a1
- defw l237fh ;21a2
+ defb 0ffh
+ defb 0deh
+ defb 0b7h
+ defw l237fh
defb 0ffh ;21a4 and a,nn
- defb 0e6h ;21a5
- defb 006h ;21a6
- defw l2397h ;21a7
+ defb 0e6h
+ defb 006h
+ defw l2397h
- defb 0ffh ;21a9
- defb 0eeh ;21aa
- defb 0cch ;21ab
- defw l2397h ;21ac
+ defb 0ffh
+ defb 0eeh
+ defb 0cch
+ defw l2397h
- defb 0ffh ;21ae
- defb 0f6h ;21af
- defb 06ch ;21b0
- defw l2397h ;21b1
+ defb 0ffh
+ defb 0f6h
+ defb 06ch
+ defw l2397h
defb 0ffh ;21b3 cp a,nn
- defb 0feh ;21b4
- defb 013h ;21b5
- defw l2397h ;21b6
+ defb 0feh
+ defb 013h
+ defw l2397h
defb 0ffh ;21b8 djnz
- defb 010h ;21b9
- defb 02eh ;21ba
- defw l23b0h ;21bb
+ defb 010h
+ defb 02eh
+ defw l23b0h
defb 0ffh ;21bd jr
- defb 018h ;21be
- defb 054h ;21bf
- defw l23b0h ;21c0
+ defb 018h
+ defb 054h
+ defw l23b0h
defb 0e7h ;21c2 jr,cc
- defb 020h ;21c3
- defb 054h ;21c4
- defw l23a1h ;21c5
+ defb 020h
+ defb 054h
+ defw l23a1h
- defb 0ffh ;21c7
+ defb 0ffh
defb 0d3h ;21c8 out (nn),a
- defb 076h ;21c9
- defw l23d5h ;21ca
+ defb 076h
+ defw l23d5h
defb 0ffh ;21cc in a,(nn)
- defb 0dbh ;21cd
- defb 03fh ;21ce
- defw l23c3h ;21cf
+ defb 0dbh
+ defb 03fh
+ defw l23c3h
defb 000h ;21d1 EOT
b_0x21D2_start: ; 3 byte opcodes
- defb 0c7h ;21d2
- defb 0c2h ;21d3
- defb 052h ;21d4
- defw l23e0h ;21d5
-
- defb 0c7h ;21d7
- defb 0c4h ;21d8
- defb 00ch ;21d9
- defw l23e0h ;21da
-
- defb 0cfh ;21dc
- defb 001h ;21dd
- defb 056h ;21de
- defw l23fch ;21df
-
- defb 0ffh ;21e1
- defb 0c3h ;21e2
- defb 052h ;21e3
- defw l23e6h ;21e4
-
- defb 0ffh ;21e6
- defb 0cdh ;21e7
- defb 00ch ;21e8
- defw l23e6h ;21e9
-
- defb 0ffh ;21eb
- defb 022h ;21ec
- defb 056h ;21ed
- defw l2404h ;21ee
-
- defb 0ffh ;21f0
- defb 02ah ;21f1
- defb 056h ;21f2
- defw l240dh ;21f3
-
- defb 0ffh ;21f5
- defb 032h ;21f6
- defb 056h ;21f7
- defw l2416h ;21f8
-
- defb 0ffh ;21fa
- defb 03ah ;21fb
- defb 056h ;21fc
- defw l2421h ;21fd
-
- defb 000h ;21ff
+ defb 0c7h
+ defb 0c2h
+ defb 052h
+ defw l23e0h
+
+ defb 0c7h
+ defb 0c4h
+ defb 00ch
+ defw l23e0h
+
+ defb 0cfh
+ defb 001h
+ defb 056h
+ defw l23fch
+
+ defb 0ffh
+ defb 0c3h
+ defb 052h
+ defw l23e6h
+
+ defb 0ffh
+ defb 0cdh
+ defb 00ch
+ defw l23e6h
+
+ defb 0ffh
+ defb 022h
+ defb 056h
+ defw l2404h
+
+ defb 0ffh
+ defb 02ah
+ defb 056h
+ defw l240dh
+
+ defb 0ffh
+ defb 032h
+ defb 056h
+ defw l2416h
+
+ defb 0ffh
+ defb 03ah
+ defb 056h
+ defw l2421h
+
+ defb 000h
b_0x2200_start: ; prefix ED + 1 byte opcode
defb 044h ;2200 neg
- defb 066h ;2201
+ defb 066h
defb 045h ;2202 retn
- defb 092h ;2203
+ defb 092h
defb 04dh ;2204 reti
- defb 08eh ;2205
+ defb 08eh
defb 067h ;2206 rrd
- defb 0b1h ;2207
+ defb 0b1h
defb 06fh ;2208 rld
- defb 0a2h ;2209
+ defb 0a2h
defb 0a0h ;220a ldi
- defb 05fh ;220b
- defb 0a1h ;220c
- defb 01ch ;220d
- defb 0a2h ;220e
- defb 04bh ;220f
- defb 0a3h ;2210
- defb 07dh ;2211
+ defb 05fh
+ defb 0a1h
+ defb 01ch
+ defb 0a2h
+ defb 04bh
+ defb 0a3h
+ defb 07dh
defb 0a8h ;2212 ldd
- defb 058h ;2213
- defb 0a9h ;2214
- defb 015h ;2215
- defb 0aah ;2216
- defb 044h ;2217
- defb 0abh ;2218
- defb 079h ;2219
+ defb 058h
+ defb 0a9h
+ defb 015h
+ defb 0aah
+ defb 044h
+ defb 0abh
+ defb 079h
defb 0b0h ;221a ldir
- defb 062h ;221b
- defb 0b1h ;221c
- defb 01fh ;221d
- defb 0b2h ;221e
- defb 04eh ;221f
- defb 0b3h ;2220
- defb 072h ;2221
+ defb 062h
+ defb 0b1h
+ defb 01fh
+ defb 0b2h
+ defb 04eh
+ defb 0b3h
+ defb 072h
defb 0b8h ;2222 lddr
- defb 05bh ;2223
- defb 0b9h ;2224
- defb 018h ;2225
- defb 0bah ;2226
- defb 047h ;2227
- defb 0bbh ;2228
- defb 06eh ;2229
+ defb 05bh
+ defb 0b9h
+ defb 018h
+ defb 0bah
+ defb 047h
+ defb 0bbh
+ defb 06eh
defb 08bh ;222a otdm
- defb 0d5h ;222b
+ defb 0d5h
defb 09bh ;222c otdmr
- defb 0d9h ;222d
+ defb 0d9h
defb 083h ;222e otim
- defb 0deh ;222f
+ defb 0deh
defb 093h ;2230 otimr
- defb 0e2h ;2231
+ defb 0e2h
defb 076h ;2232 slp
- defb 0ebh ;2233
+ defb 0ebh
defb 0ffh ;2234 EOT
-
+
l2235h:
defb 0e7h ;2235 in r,(c) ;r=bcde
- defb 040h ;2236
- defb 03fh ;2237
- defw l2455h ;2238
+ defb 040h
+ defb 03fh
+ defw l2455h
defb 0f7h ;223a in r,(c) ;r=hl
- defb 060h ;223b
- defb 03fh ;223c
- defw l2455h ;223d
+ defb 060h
+ defb 03fh
+ defw l2455h
defb 0ffh ;223f in r,(c) ;r=a
- defb 078h ;2240
- defb 03fh ;2241
- defw l2455h ;2242
+ defb 078h
+ defb 03fh
+ defw l2455h
- defb 0e7h ;2244
- defb 041h ;2245
- defb 076h ;2246
- defw l2461h ;2247
+ defb 0e7h
+ defb 041h
+ defb 076h
+ defw l2461h
- defb 0f7h ;2249
- defb 061h ;224a
- defb 076h ;224b
- defw l2461h ;224c
+ defb 0f7h
+ defb 061h
+ defb 076h
+ defw l2461h
defb 0ffh ;224e out (c),r ;r=a
- defb 079h ;224f
- defb 076h ;2250
- defw l2461h ;2251
+ defb 079h
+ defb 076h
+ defw l2461h
defb 0cfh ;2253 sbc hl,rr
- defb 042h ;2254
- defb 0b7h ;2255
- defw l246dh ;2256
+ defb 042h
+ defb 0b7h
+ defw l246dh
defb 0cfh ;2258 adc hl,rr
- defb 04ah ;2259
- defb 000h ;225a
- defw l246dh ;225b
+ defb 04ah
+ defb 000h
+ defw l246dh
defb 0ffh ;225d im 0
- defb 046h ;225e
- defb 03dh ;225f
- defw l2427h ;2260
+ defb 046h
+ defb 03dh
+ defw l2427h
defb 0ffh ;2262 im 1
- defb 056h ;2263
- defb 03dh ;2264
- defw l242bh ;2265
+ defb 056h
+ defb 03dh
+ defw l242bh
defb 0ffh ;2267 im 2
- defb 05eh ;2268
- defb 03dh ;2269
- defw l242fh ;226a
+ defb 05eh
+ defb 03dh
+ defw l242fh
defb 0ffh ;226c ld i,a
- defb 047h ;226d
- defb 056h ;226e
- defw l2434h ;226f
+ defb 047h
+ defb 056h
+ defw l2434h
- defb 0ffh ;2271
- defb 057h ;2272
- defb 056h ;2273
- defw l2439h ;2274
+ defb 0ffh
+ defb 057h
+ defb 056h
+ defw l2439h
- defb 0ffh ;2276
- defb 04fh ;2277
- defb 056h ;2278
- defw l243eh ;2279
+ defb 0ffh
+ defb 04fh
+ defb 056h
+ defw l243eh
- defb 0ffh ;227b
- defb 05fh ;227c
- defb 056h ;227d
- defw l2443h ;227e
+ defb 0ffh
+ defb 05fh
+ defb 056h
+ defw l2443h
defb 0cfh ;2280 mlt rr
- defb 04ch ;2281
- defb 0d2h ;2282
- defw l254bh ;2283
+ defb 04ch
+ defb 0d2h
+ defw l254bh
defb 0c7h ;2285 tst r
- defb 004h ;2286
- defb 0eeh ;2287
- defw l24dfh ;2288
+ defb 004h
+ defb 0eeh
+ defw l24dfh
- defb 000h ;228a
+ defb 000h
l228bh:
- defb 0e7h ;228b
- defb 000h ;228c
- defb 0cfh ;228d
+ defb 0e7h
+ defb 000h
+ defb 0cfh
b_0x228E_start:
- defw l230ch ;228e
+ defw l230ch
b_0x2290_start:
- defb 0f7h ;2290
- defb 020h ;2291
- defb 0cfh ;2292
+ defb 0f7h
+ defb 020h
+ defb 0cfh
b_0x2293_start:
- defw l230ch ;2293
+ defw l230ch
b_0x2295_start:
- defb 0ffh ;2295
- defb 038h ;2296
- defb 0cfh ;2297
+ defb 0ffh
+ defb 038h
+ defb 0cfh
b_0x2298_start:
- defw l230ch ;2298
+ defw l230ch
b_0x229A_start:
- defb 0e7h ;229a
- defb 001h ;229b
- defb 0e7h ;229c
+ defb 0e7h
+ defb 001h
+ defb 0e7h
b_0x229D_start:
- defw l2315h ;229d
+ defw l2315h
b_0x229F_start:
- defb 0f7h ;229f
- defb 021h ;22a0
- defb 0e7h ;22a1
+ defb 0f7h
+ defb 021h
+ defb 0e7h
b_0x22A2_start:
- defw l2315h ;22a2
+ defw l2315h
b_0x22A4_start:
- defb 0ffh ;22a4
- defb 039h ;22a5
- defb 0e7h ;22a6
+ defb 0ffh
+ defb 039h
+ defb 0e7h
b_0x22A7_start:
- defw l2315h ;22a7
+ defw l2315h
b_0x22A9_start:
- defb 0ffh ;22a9
- defb 064h ;22aa
- defb 0eeh ;22ab
+ defb 0ffh
+ defb 064h
+ defb 0eeh
b_0x22AC_start:
- defw l2397h ;22ac
+ defw l2397h
b_0x22AE_start:
- defb 0ffh ;22ae
- defb 074h ;22af
- defb 0f1h ;22b0
+ defb 0ffh
+ defb 074h
+ defb 0f1h
b_0x22B1_start:
- defw l2397h ;22b1
+ defw l2397h
b_0x22B3_start:
- defb 000h ;22b3
+ defb 000h
l22b4h:
- defb 0efh ;22b4
- defb 043h ;22b5
- defb 056h ;22b6
+ defb 0efh
+ defb 043h
+ defb 056h
b_0x22B7_start:
- defw l2476h ;22b7
+ defw l2476h
b_0x22B9_start:
- defb 0ffh ;22b9
- defb 073h ;22ba
- defb 056h ;22bb
+ defb 0ffh
+ defb 073h
+ defb 056h
b_0x22BC_start:
- defw l2476h ;22bc
+ defw l2476h
b_0x22BE_start:
- defb 0efh ;22be
- defb 04bh ;22bf
- defb 056h ;22c0
+ defb 0efh
+ defb 04bh
+ defb 056h
b_0x22C1_start:
- defw l247fh ;22c1
+ defw l247fh
b_0x22C3_start:
- defb 0ffh ;22c3
- defb 07bh ;22c4
- defb 056h ;22c5
+ defb 0ffh
+ defb 07bh
+ defb 056h
b_0x22C6_start:
- defw l247fh ;22c6
+ defw l247fh
b_0x22C8_start:
- defb 000h ;22c8
+ defb 000h
l22c9h:
- defb 0f8h ;22c9
- defb 000h ;22ca
- defb 09bh ;22cb
+ defb 0f8h
+ defb 000h
+ defb 09bh
b_0x22CC_start:
- defw l24aeh ;22cc
+ defw l24aeh
b_0x22CE_start:
- defb 0f8h ;22ce
- defb 008h ;22cf
- defb 0aah ;22d0
+ defb 0f8h
+ defb 008h
+ defb 0aah
b_0x22D1_start:
- defw l24aeh ;22d1
+ defw l24aeh
b_0x22D3_start:
- defb 0f8h ;22d3
- defb 010h ;22d4
- defb 096h ;22d5
+ defb 0f8h
+ defb 010h
+ defb 096h
b_0x22D6_start:
- defw l24aeh ;22d6
+ defw l24aeh
b_0x22D8_start:
- defb 0f8h ;22d8
- defb 018h ;22d9
- defb 0a5h ;22da
+ defb 0f8h
+ defb 018h
+ defb 0a5h
b_0x22DB_start:
- defw l24aeh ;22db
+ defw l24aeh
b_0x22DD_start:
- defb 0f8h ;22dd
- defb 020h ;22de
- defb 0c0h ;22df
+ defb 0f8h
+ defb 020h
+ defb 0c0h
b_0x22E0_start:
- defw l24aeh ;22e0
+ defw l24aeh
b_0x22E2_start:
- defb 0f8h ;22e2
- defb 028h ;22e3
- defb 0c3h ;22e4
+ defb 0f8h
+ defb 028h
+ defb 0c3h
b_0x22E5_start:
- defw l24aeh ;22e5
+ defw l24aeh
b_0x22E7_start:
- defb 0f8h ;22e7
- defb 038h ;22e8
- defb 0c6h ;22e9
+ defb 0f8h
+ defb 038h
+ defb 0c6h
b_0x22EA_start:
- defw l24aeh ;22ea
+ defw l24aeh
b_0x22EC_start:
- defb 0c0h ;22ec
- defb 040h ;22ed
- defb 009h ;22ee
+ defb 0c0h
+ defb 040h
+ defb 009h
b_0x22EF_start:
- defw l2487h ;22ef
+ defw l2487h
b_0x22F1_start:
- defb 0c0h ;22f1
- defb 080h ;22f2
- defb 088h ;22f3
+ defb 0c0h
+ defb 080h
+ defb 088h
b_0x22F4_start:
- defw l2487h ;22f4
+ defw l2487h
b_0x22F6_start:
- defb 0c0h ;22f6
- defb 0c0h ;22f7
- defb 0bdh ;22f8
+ defb 0c0h
+ defb 0c0h
+ defb 0bdh
b_0x22F9_start:
- defw l2487h ;22f9
+ defw l2487h
b_0x22FB_start:
- defb 000h ;22fb
+ defb 000h
l22fch:
- call l24dfh ;22fc
- call sub_257ch ;22ff
- jp l24ebh ;2302
+ call l24dfh
+ call sub_257ch
+ jp l24ebh
l2305h:
- call sub_2579h ;2305
- jp l24ebh ;2308
+ call sub_2579h
+ jp l24ebh
l230bh:
- ret ;230b
+ ret
l230ch:
- call l24dfh ;230c
- call sub_257ch ;230f
- jp l23c6h ;2312
+ call l24dfh
+ call sub_257ch
+ jp l23c6h
l2315h:
- call l23c6h ;2315
- call sub_257ch ;2318
- jp l24dfh ;231b
+ call l23c6h
+ call sub_257ch
+ jp l24dfh
l231eh:
- comst ;231e
- ld a,(iy+000h) ;2322
+ comst
+ ld a,(iy+000h)
comend
- and 038h ;2325
- jp out.hex ;2327
+ and 038h
+ jp out.hex
l232ah:
- ld hl,b_0x2333_start ;232a
- call PSTR ;232d
- jp l253eh ;2330
+ ld hl,b_0x2333_start
+ call PSTR
+ jp l253eh
b_0x2333_start:
DC '(SP),'
l2338h:
- ld a,'(' ;2338
- call OUTCHAR ;233a
- call l253eh ;233d
- ld a,')' ;2340
- jp OUTCHAR ;2342
+ ld a,'('
+ call OUTCHAR
+ call l253eh
+ ld a,')'
+ jp OUTCHAR
l2345h:
- ld hl,l1d86h ;2345
- jp PSTR ;2348
+ ld hl,l1d86h
+ jp PSTR
l234bh:
- ld hl,b_0x2354_start ;234b
- call PSTR ;234e
- jp l253eh ;2351
+ ld hl,b_0x2354_start
+ call PSTR
+ jp l253eh
b_0x2354_start:
DC 'SP,'
l2357h:
- ld hl,b_0x1D80_start ;2357
- jp PSTR ;235a
+ ld hl,b_0x1D80_start
+ jp PSTR
l235dh:
- call l253eh ;235d
- call sub_257ch ;2360
- jp l254bh ;2363
+ call l253eh
+ call sub_257ch
+ jp l254bh
l2366h:
- call sub_2372h ;2366
- call sub_257ch ;2369
- jp l23dbh ;236c
+ call sub_2372h
+ call sub_257ch
+ jp l23dbh
l236fh:
- call sub_2579h ;236f
+ call sub_2579h
sub_2372h:
- ld a,'(' ;2372
- call OUTCHAR ;2374
- call l254bh ;2377
- ld a,')' ;237a
- jp OUTCHAR ;237c
+ ld a,'('
+ call OUTCHAR
+ call l254bh
+ ld a,')'
+ jp OUTCHAR
l237fh:
- call sub_2579h ;237f
- jr l2397h ;2382
+ call sub_2579h
+ jr l2397h
l2384h:
- call l24dfh ;2384
- call sub_257ch ;2387
- ld a,(is.pfx.IXY) ;238a
- and a ;238d
- comst ;238e
- ld a,(iy+002h) ;2392
+ call l24dfh
+ call sub_257ch
+ ld a,(is.pfx.IXY)
+ and a
+ comst
+ ld a,(iy+002h)
comend
- jr nz,l239eh ;2395
+ jr nz,l239eh
l2397h:
- comst ;2397
- ld a,(iy+001h) ;239b
+ comst
+ ld a,(iy+001h)
comend
l239eh:
- jp out.hex ;239e
+ jp out.hex
l23a1h:
- comst ;23a1
- ld a,(iy+000h) ;23a5
+ comst
+ ld a,(iy+000h)
comend
- and 018h ;23a8
- call sub_2568h ;23aa
- call sub_257ch ;23ad
+ and 018h
+ call sub_2568h
+ call sub_257ch
l23b0h:
- comst ;23b0
- ld c,(iy+001h) ;23b4
+ comst
+ ld c,(iy+001h)
comend
- ld a,c ;23b7
- rla ;23b8
- sbc a,a ;23b9
- ld b,a ;23ba
- push iy ;23bb
- pop hl ;23bd
- add hl,bc ;23be
- inc hl ;23bf
- inc hl ;23c0
- jr l23f0h ;23c1
+ ld a,c
+ rla
+ sbc a,a
+ ld b,a
+ push iy
+ pop hl
+ add hl,bc
+ inc hl
+ inc hl
+ jr l23f0h
l23c3h:
- call sub_2579h ;23c3
+ call sub_2579h
l23c6h:
- ld a,028h ;23c6
- call OUTCHAR ;23c8
- comst ;23cb
- ld a,(iy+001h) ;23cf
+ ld a,028h
+ call OUTCHAR
+ comst
+ ld a,(iy+001h)
comend
- jp l252bh ;23d2
+ jp l252bh
l23d5h:
- call l23c6h ;23d5
- call sub_257ch ;23d8
+ call l23c6h
+ call sub_257ch
l23dbh:
- ld a,041h ;23db
- jp OUTCHAR ;23dd
+ ld a,041h
+ jp OUTCHAR
l23e0h:
- call l2561h ;23e0
- call sub_257ch ;23e3
+ call l2561h
+ call sub_257ch
l23e6h:
- comst ;23e6
- ld l,(iy+001h) ;23ea
- ld h,(iy+002h) ;23ed
+ comst
+ ld l,(iy+001h)
+ ld h,(iy+002h)
comend
l23f0h:
- ld a,002h ;23f0
+ ld a,002h
sub_23f2h:
- ld (XBE03),a ;23f2
- ld (XBE01),hl ;23f5
- call out.hl ;23f8
- ret ;23fb
+ ld (XBE03),a
+ ld (XBE01),hl
+ call out.hl
+ ret
l23fch:
- call l254bh ;23fc
- call sub_257ch ;23ff
- jr l23e6h ;2402
+ call l254bh
+ call sub_257ch
+ jr l23e6h
l2404h:
- call sub_24c6h ;2404
- call sub_257ch ;2407
- jp l253eh ;240a
+ call sub_24c6h
+ call sub_257ch
+ jp l253eh
l240dh:
- call l253eh ;240d
- call sub_257ch ;2410
- jp sub_24c6h ;2413
+ call l253eh
+ call sub_257ch
+ jp sub_24c6h
l2416h:
- call sub_24c6h ;2416
- call sub_257ch ;2419
- ld a,041h ;241c
- jp OUTCHAR ;241e
+ call sub_24c6h
+ call sub_257ch
+ ld a,041h
+ jp OUTCHAR
l2421h:
- call sub_2579h ;2421
- jp sub_24c6h ;2424
+ call sub_2579h
+ jp sub_24c6h
l2427h:
- ld a,030h ;2427
- jr l2431h ;2429
+ ld a,030h
+ jr l2431h
l242bh:
- ld a,031h ;242b
- jr l2431h ;242d
+ ld a,031h
+ jr l2431h
l242fh:
- ld a,032h ;242f
+ ld a,032h
l2431h:
- jp OUTCHAR ;2431
+ jp OUTCHAR
l2434h:
- ld hl,b_0x2449_start ;2434
- jr l2446h ;2437
+ ld hl,b_0x2449_start
+ jr l2446h
l2439h:
- ld hl,l244ch ;2439
- jr l2446h ;243c
+ ld hl,l244ch
+ jr l2446h
l243eh:
- ld hl,l244fh ;243e
- jr l2446h ;2441
+ ld hl,l244fh
+ jr l2446h
l2443h:
- ld hl,l2452h ;2443
+ ld hl,l2452h
l2446h:
- jp PSTR ;2446
+ jp PSTR
b_0x2449_start:
DC 'I,A'
@@ -5402,124 +5420,124 @@ l2452h:
DC 'A,R'
l2455h:
- call l24dfh ;2455
- call sub_257ch ;2458
- ld hl,t__C_ ;245b
- jp PSTR ;245e
+ call l24dfh
+ call sub_257ch
+ ld hl,t__C_
+ jp PSTR
l2461h:
- ld hl,t__C_ ;2461
- call PSTR ;2464
- call sub_257ch ;2467
- jp l24dfh ;246a
+ ld hl,t__C_
+ call PSTR
+ call sub_257ch
+ jp l24dfh
l246dh:
- call l253eh ;246d
- call sub_257ch ;2470
- jp l254bh ;2473
+ call l253eh
+ call sub_257ch
+ jp l254bh
l2476h:
- call sub_24c6h ;2476
- call sub_257ch ;2479
- jp l254bh ;247c
+ call sub_24c6h
+ call sub_257ch
+ jp l254bh
l247fh:
- call l254bh ;247f
- call sub_257ch ;2482
- jr sub_24c6h ;2485
+ call l254bh
+ call sub_257ch
+ jr sub_24c6h
l2487h:
- ld a,(is.pfx.IXY) ;2487
- and a ;248a
- jr nz,l2496h ;248b
- comst ;248d
- ld a,(iy+001h) ;2491
+ ld a,(is.pfx.IXY)
+ and a
+ jr nz,l2496h
+ comst
+ ld a,(iy+001h)
comend
- jr l249dh ;2494
+ jr l249dh
l2496h:
- comst ;2496
- ld a,(iy+002h) ;249a
+ comst
+ ld a,(iy+002h)
comend
l249dh:
- push af ;249d
- rra ;249e
- rra ;249f
- rra ;24a0
- and 007h ;24a1
- add a,'0' ;24a3
- call OUTCHAR ;24a5
- call sub_257ch ;24a8
- pop af ;24ab
- jr l24f2h ;24ac
+ push af
+ rra
+ rra
+ rra
+ and 007h
+ add a,'0'
+ call OUTCHAR
+ call sub_257ch
+ pop af
+ jr l24f2h
l24aeh:
- ld a,(is.pfx.IXY) ;24ae
- and a ;24b1
- jr nz,l24bdh ;24b2
- comst ;24b4
- ld a,(iy+001h) ;24b8
+ ld a,(is.pfx.IXY)
+ and a
+ jr nz,l24bdh
+ comst
+ ld a,(iy+001h)
comend
- jr l24c4h ;24bb
+ jr l24c4h
l24bdh:
- comst ;24bd
- ld a,(iy+002h) ;24c1
+ comst
+ ld a,(iy+002h)
comend
l24c4h:
- jr l24f2h ;24c4
+ jr l24f2h
sub_24c6h:
- ld a,'(' ;24c6
- call OUTCHAR ;24c8
- comst ;24cb
- ld l,(iy+001h) ;24cf
- ld h,(iy+002h) ;24d2
+ ld a,'('
+ call OUTCHAR
+ comst
+ ld l,(iy+001h)
+ ld h,(iy+002h)
comend
- ld a,001h ;24d5
- call sub_23f2h ;24d7
- ld a,')' ;24da
- jp OUTCHAR ;24dc
+ ld a,001h
+ call sub_23f2h
+ ld a,')'
+ jp OUTCHAR
l24dfh:
- comst ;24df
- ld a,(iy+000h) ;24e3
+ comst
+ ld a,(iy+000h)
comend
- rra ;24e6
- rra ;24e7
- rra ;24e8
- jr l24f2h ;24e9
+ rra
+ rra
+ rra
+ jr l24f2h
l24ebh:
- comst ;24eb
- ld a,(iy+000h) ;24ef
+ comst
+ ld a,(iy+000h)
comend
l24f2h:
- and 007h ;24f2
- cp 006h ;24f4
- jr nz,l2533h ;24f6
- ld a,(is.pfx.IXY) ;24f8
- and a ;24fb
- ld a,006h ;24fc
- jr z,l2533h ;24fe
- ld hl,b_0x2538_start ;2500
- ld a,(is.pfx.IXY) ;2503
- dec a ;2506
- jr z,l250ch ;2507
- ld hl,b_0x253B_start ;2509
+ and 007h
+ cp 006h
+ jr nz,l2533h
+ ld a,(is.pfx.IXY)
+ and a
+ ld a,006h
+ jr z,l2533h
+ ld hl,b_0x2538_start
+ ld a,(is.pfx.IXY)
+ dec a
+ jr z,l250ch
+ ld hl,b_0x253B_start
l250ch:
- call PSTR ;250c
- comst ;250f
- ld a,(iy+001h) ;2513
+ call PSTR
+ comst
+ ld a,(iy+001h)
comend
- and a ;2516
- push af ;2517
- jp m,l2523h ;2518
- ld a,'+' ;251b
- call OUTCHAR ;251d
- pop af ;2520
- jr l252bh ;2521
+ and a
+ push af
+ jp m,l2523h
+ ld a,'+'
+ call OUTCHAR
+ pop af
+ jr l252bh
l2523h:
- ld a,'-' ;2523
- call OUTCHAR ;2525
- pop af ;2528
- neg ;2529
+ ld a,'-'
+ call OUTCHAR
+ pop af
+ neg
l252bh:
- call out.hex ;252b
- ld a,')' ;252e
- jp OUTCHAR ;2530
+ call out.hex
+ ld a,')'
+ jp OUTCHAR
l2533h:
- ld hl,t_BCDEHL_HL_A ;2533
- jr l2572h ;2536
+ ld hl,t_BCDEHL_HL_A
+ jr l2572h
b_0x2538_start:
DC '(IX'
@@ -5527,55 +5545,55 @@ b_0x253B_start:
DC '(IY'
l253eh:
- ld a,(is.pfx.IXY) ;253e
- ld hl,t_HL.IX.IY ;2541
- jr l2572h ;2544
+ ld a,(is.pfx.IXY)
+ ld hl,t_HL.IX.IY
+ jr l2572h
l2546h:
- ld hl,t_BC.DE.HL.AF ;2546
- jr l254eh ;2549
+ ld hl,t_BC.DE.HL.AF
+ jr l254eh
l254bh:
- ld hl,t_BC.DE.HL.SP ;254b
+ ld hl,t_BC.DE.HL.SP
l254eh:
- comst ;254e
- ld a,(iy+000h) ;2552
+ comst
+ ld a,(iy+000h)
comend
- rra ;2555
- rra ;2556
- rra ;2557
- rra ;2558
- and 003h ;2559
- cp 002h ;255b
- jr z,l253eh ;255d
- jr l2572h ;255f
+ rra
+ rra
+ rra
+ rra
+ and 003h
+ cp 002h
+ jr z,l253eh
+ jr l2572h
l2561h:
- comst ;2561
- ld a,(iy+000h) ;2565
+ comst
+ ld a,(iy+000h)
comend
sub_2568h:
- rra ;2568
- rra ;2569
- rra ;256a
- and 007h ;256b
- ld hl,t_tstfl_ZCPS ;256d
- jr l2572h ;2570
+ rra
+ rra
+ rra
+ and 007h
+ ld hl,t_tstfl_ZCPS
+ jr l2572h
l2572h:
- ld b,a ;2572
- call sub_0a48h ;2573
- jp PSTR ;2576
+ ld b,a
+ call sub_0a48h
+ jp PSTR
sub_2579h:
- call l23dbh ;2579
+ call l23dbh
sub_257ch:
- ld a,',' ;257c
- jp OUTCHAR ;257e
+ ld a,','
+ jp OUTCHAR
sub_2581h:
- call PSTR ;2581
+ call PSTR
l2584h:
- call OUTBL ;2584
- inc c ;2587
- ld a,c ;2588
- cp 006h ;2589
- jr nz,l2584h ;258b
- ret ;258d
+ call OUTBL
+ inc c
+ ld a,c
+ cp 006h
+ jr nz,l2584h
+ ret
t_MNEMONICS:
DC 'ADC'
@@ -5656,7 +5674,7 @@ t_MNEMONICS:
DC 'TST'
DC 'TSTIO'
DB 0
-
+
t_BCDEHL_HL_A:
DC 'B'
DC 'C'
@@ -5729,563 +5747,491 @@ t__C_:
DB 0
sub_26e7h:
- ld hl,(REG.PC) ;26e7
- ld a,h ;26ea
- or l ;26eb
- jr z,l2715h ;26ec
- ld iy,(REG.PC) ;26ee
- call sub_1f9eh ;26f2
- jp nc,ERROR ;26f5
- ld c,b ;26f8
- ld b,000h ;26f9
- ld hl,(REG.PC) ;26fb
- add hl,bc ;26fe
- call sub_1117h ;26ff
- ld iy,(REG.PC) ;2702
- ld hl,b_0x2717_start ;2706
- call lookup_opc ;2709
- ccf ;270c
- ret c ;270d
- ex de,hl ;270e
- call CALL.HL ;270f
- call c,sub_1117h ;2712
+ ld hl,(REG.PC)
+ ld a,h
+ or l
+ jr z,l2715h
+ ld iy,(REG.PC)
+ call sub_1f9eh
+ jp nc,ERROR
+ ld c,b
+ ld b,000h
+ ld hl,(REG.PC)
+ add hl,bc
+ call sub_1117h
+ ld iy,(REG.PC)
+ ld hl,b_0x2717_start
+ call lookup_opc
+ ccf
+ ret c
+ ex de,hl
+ call CALL.HL
+ call c,sub_1117h
l2715h:
- scf ;2715
- ret ;2716
+ scf
+ ret
b_0x2717_start:
- db 0ffh ;2717
- db 0ddh ;2718
- db 000h ;2719
+ db 0ffh
+ db 0ddh
+ db 000h
dw x278d
- db 0ffh ;271c
- db 0fdh ;271d
- db 000h ;271e
+ db 0ffh
+ db 0fdh
+ db 000h
dw x2792
- db 0ffh ;2721
- db 0edh ;2722
- db 000h ;2723
+ db 0ffh
+ db 0edh
+ db 000h
dw x27a2
l2726h:
- db 0ffh ;2726
- db 0cdh ;2727
- db 000h ;2728
+ db 0ffh
+ db 0cdh
+ db 000h
dw x275e
- db 0ffh ;272b
- db 0c3h ;272c
- db 000h ;272d
+ db 0ffh
+ db 0c3h
+ db 000h
dw x2769
- db 0ffh ;2730
- db 0e9h ;2731
- db 000h ;2732
+ db 0ffh
+ db 0e9h
+ db 000h
dw x2788
- db 0ffh ;2735
- db 0c9h ;2736
- db 000h ;2737
+ db 0ffh
+ db 0c9h
+ db 000h
dw x27c9
- db 0ffh ;273a
- db 0cfh ;273b
- db 000h ;273c
+ db 0ffh
+ db 0cfh
+ db 000h
dw x280e
- db 0c7h ;273f
- db 0c7h ;2740
- db 000h ;2741
+ db 0c7h
+ db 0c7h
+ db 000h
dw x27ea
- db 0c7h ;2744
- db 0c4h ;2745
- db 000h ;2746
+ db 0c7h
+ db 0c4h
+ db 000h
dw x275e
- db 0f7h ;2749
- db 010h ;274a
- db 000h ;274b
+ db 0f7h
+ db 010h
+ db 000h
dw x2775
- db 0e7h ;274e
- db 020h ;274f
- db 000h ;2750
+ db 0e7h
+ db 020h
+ db 000h
dw x2775
- db 0c7h ;2753
- db 0c2h ;2754
- db 000h ;2755
+ db 0c7h
+ db 0c2h
+ db 000h
dw x2769
- db 0c7h ;2758
- db 0c0h ;2759
- db 000h ;275a
+ db 0c7h
+ db 0c0h
+ db 000h
dw x27b3
- db 000h ;275d
+ db 000h
x275e:
- ld a,(XBFE8) ;275e
- and a ;2761
- jr nz,x2769 ;2762
- ld a,(TCFLG) ;2764
- and a ;2767
- ret nz ;2768
+ ld a,(XBFE8)
+ and a
+ jr nz,x2769
+ ld a,(TCFLG)
+ and a
+ ret nz
x2769:
- comst ;2769
- ld l,(iy+001h) ;276d
- ld h,(iy+002h) ;2770
+ comst
+ ld l,(iy+001h)
+ ld h,(iy+002h)
comend
- scf ;2773
- ret ;2774
+ scf
+ ret
x2775:
- comst ;2775
- ld c,(iy+001h) ;2779
+ comst
+ ld c,(iy+001h)
comend
- ld a,c ;277c
- rla ;277d
- sbc a,a ;277e
- ld b,a ;277f
- ld hl,(REG.PC) ;2780
- add hl,bc ;2783
- inc hl ;2784
- inc hl ;2785
- scf ;2786
- ret ;2787
+ ld a,c
+ rla
+ sbc a,a
+ ld b,a
+ ld hl,(REG.PC)
+ add hl,bc
+ inc hl
+ inc hl
+ scf
+ ret
x2788:
- ld hl,(REG.L) ;2788
- scf ;278b
- ret ;278c
+ ld hl,(REG.L)
+ scf
+ ret
x278d:
- ld hl,(reg.ix) ;278d
- jr l2795h ;2790
+ ld hl,(reg.ix)
+ jr l2795h
x2792:
- ld hl,(reg.iy) ;2792
+ ld hl,(reg.iy)
l2795h:
- comst ;2795
- ld a,(iy+001h) ;2799
+ comst
+ ld a,(iy+001h)
comend
- cp 0e9h ;279c
- scf ;279e
- ret z ;279f
- and a ;27a0
- ret ;27a1
+ cp 0e9h
+ scf
+ ret z
+ and a
+ ret
x27a2:
- comst ;27a2
- ld a,(iy+001h) ;27a6
+ comst
+ ld a,(iy+001h)
comend
- cp 04dh ;27a9
- jr z,x27c9 ;27ab
- cp 045h ;27ad
- jr z,x27c9 ;27af
- and a ;27b1
- ret ;27b2
+ cp 04dh
+ jr z,x27c9
+ cp 045h
+ jr z,x27c9
+ and a
+ ret
x27b3:
- comst ;27b3
- ld a,(iy+000h) ;27b7
+ comst
+ ld a,(iy+000h)
comend
- ld (XBEDD),a ;27ba
- ld hl,(REG.F) ;27bd
- push hl ;27c0
- pop af ;27c1
- call XBEDD ;27c2
- scf ;27c5
- jr c,x27c9 ;27c6
- ret ;27c8
+ ld (XBEDD),a
+ ld hl,(REG.F)
+ push hl
+ pop af
+ call XBEDD
+ scf
+ jr c,x27c9
+ ret
x27c9:
- ld a,(XBFE8) ;27c9
- and a ;27cc
- jr nz,l27dah ;27cd
- ld a,(TCFLG) ;27cf
- and a ;27d2
- jr z,l27dah ;27d3
- call l27dah ;27d5
- pop hl ;27d8
- ret ;27d9
+ ld a,(XBFE8)
+ and a
+ jr nz,l27dah
+ ld a,(TCFLG)
+ and a
+ jr z,l27dah
+ call l27dah
+ pop hl
+ ret
l27dah:
- ld hl,(REG.SP) ;27da
- comst ;27dd
- ld e,(hl) ;27e1
- inc hl ;27e2
- ld d,(hl) ;27e3
+ ld hl,(REG.SP)
+ comst
+ ld e,(hl)
+ inc hl
+ ld d,(hl)
comend
- ex de,hl ;27e4
- call sub_1117h ;27e5
- and a ;27e8
- ret ;27e9
+ ex de,hl
+ call sub_1117h
+ and a
+ ret
x27ea:
- ld a,(ddtrst) ;27ea
- comst ;27ed
- cp (iy+000h) ;27f1
+ ld a,(ddtzrst)
+ comst
+ cp (iy+000h)
comend
- ret z ;27f4
- comst ;27f5
- ld a,(iy+000h) ;27f9
+ ret z
+ comst
+ ld a,(iy+000h)
comend
- and 038h ;27fc
- ld l,a ;27fe
- ld h,000h ;27ff
- ld a,(XBFE8) ;2801
- and a ;2804
- jr nz,l280ch ;2805
- ld a,(TCFLG) ;2807
- and a ;280a
- ret nz ;280b
+ and 038h
+ ld l,a
+ ld h,000h
+ ld a,(XBFE8)
+ and a
+ jr nz,l280ch
+ ld a,(TCFLG)
+ and a
+ ret nz
l280ch:
- scf ;280c
- ret ;280d
+ scf
+ ret
x280e:
- and a ;280e
- ret ;280f
+ and a
+ ret
CMD.C:
- ld hl,CMD.C ;2810
- ld a,001h ;2813
- jr l281bh ;2815
+ ld hl,CMD.C
+ ld a,001h
+ jr l281bh
CMD.T:
- xor a ;2817
- ld hl,CMD.T ;2818
+ xor a
+ ld hl,CMD.T
l281bh:
- ld (CMD_RPT),hl ;281b
- ld (TCFLG),a ;281e
- ld a,(de) ;2821
- sub 'N' ;2822
- jr nz,l2827h ;2824
- inc de ;2826
+ ld (CMD_RPT),hl
+ ld (TCFLG),a
+ ld a,(de)
+ sub 'N'
+ jr nz,l2827h
+ inc de
l2827h:
- ld (TCNFLG),a ;2827
- ld a,(de) ;282a
- sub 'J' ;282b
- jr nz,l2830h ;282d
- inc de ;282f
+ ld (TCNFLG),a
+ ld a,(de)
+ sub 'J'
+ jr nz,l2830h
+ inc de
l2830h:
- ld (TRJFLG),a ;2830
- call sub_289fh ;2833
- jr z,l283eh ;2836
- ld hl,1 ;2838
- call get_lastarg_def ;283b
+ ld (TRJFLG),a
+ call sub_289fh
+ jr z,l283eh
+ ld hl,1
+ call get_lastarg_def
l283eh:
- ld (TCCSTR),hl ;283e
- sub a ;2841
- ld (XA747),a ;2842
+ ld (TCCSTR),hl
+ sub a
+ ld (XA747),a
l2845h:
- call sub_26e7h ;2845
- jr l289ch ;2848
+ call sub_26e7h
+ jr l289ch
l284ah:
- call sub_0e68h ;284a
- ld a,(TRJFLG) ;284d
- and a ;2850
- jr nz,l2864h ;2851
- ld iy,(REG.PC) ;2853
- call sub_28c1h ;2857
- jr z,l2864h ;285a
- ld hl,l2726h ;285c
- call lookup_opc ;285f
- jr nc,l2845h ;2862
+ call sub_0e68h
+ ld a,(TRJFLG)
+ and a
+ jr nz,l2864h
+ ld iy,(REG.PC)
+ call sub_28c1h
+ jr z,l2864h
+ ld hl,l2726h
+ call lookup_opc
+ jr nc,l2845h
l2864h:
- ld a,(XBFEA) ;2864
- and a ;2867
- jr z,l2881h ;2868
- ld de,(TCCSTR) ;286a
- call EXPR ;286e
- ld a,h ;2871
- or l ;2872
- add a,0ffh ;2873
- sbc a,a ;2875
- ld hl,XBFEA ;2876
- xor (hl) ;2879
- bit 1,a ;287a
- jr z,l288ch ;287c
+ ld a,(XBFEA)
+ and a
+ jr z,l2881h
+ ld de,(TCCSTR)
+ call EXPR
+ ld a,h
+ or l
+ add a,0ffh
+ sbc a,a
+ ld hl,XBFEA
+ xor (hl)
+ bit 1,a
+ jr z,l288ch
l287eh:
- jp l102eh ;287e
+ jp l102eh
l2881h:
- ld hl,(TCCSTR) ;2881
- dec hl ;2884
- ld (TCCSTR),hl ;2885
- ld a,h ;2888
- or l ;2889
- jr z,l287eh ;288a
+ ld hl,(TCCSTR)
+ dec hl
+ ld (TCCSTR),hl
+ ld a,h
+ or l
+ jr z,l287eh
l288ch:
- call sub_26e7h ;288c
- jr nc,l287eh ;288f
- ld a,(TCNFLG) ;2891
- ld b,a ;2894
- ld a,(XA747) ;2895
- or b ;2898
- ld (XA747),a ;2899
+ call sub_26e7h
+ jr nc,l287eh
+ ld a,(TCNFLG)
+ ld b,a
+ ld a,(XA747)
+ or b
+ ld (XA747),a
l289ch:
- jp l1183h ;289c
+ jp l1183h
sub_289fh:
- call SKIPBL ;289f
- xor a ;28a2
- ld (XBFEA),a ;28a3
- ld a,(de) ;28a6
- cp 'U' ;28a7
- jr z,l28aeh ;28a9
- cp 'W' ;28ab
- ret nz ;28ad
+ call SKIPBL
+ xor a
+ ld (XBFEA),a
+ ld a,(de)
+ cp 'U'
+ jr z,l28aeh
+ cp 'W'
+ ret nz
l28aeh:
- inc de ;28ae
- push af ;28af
- push de ;28b0
- call EXPR ;28b1
- jp c,ERROR ;28b4
- call assert_eol ;28b7
- pop hl ;28ba
- pop af ;28bb
- ld (XBFEA),a ;28bc
- sub a ;28bf
- ret ;28c0
+ inc de
+ push af
+ push de
+ call EXPR
+ jp c,ERROR
+ call assert_eol
+ pop hl
+ pop af
+ ld (XBFEA),a
+ sub a
+ ret
sub_28c1h:
- comst
- ld a,(iy+000h)
+ comst
+ ld a,(iy+000h)
ld b,(iy+0001)
comend
- cp 0edh
- jr z,l28dbh
- and 0dfh
- cp 0ddh
- ret nz
+ cp 0edh
+ jr z,l28dbh
+ and 0dfh
+ cp 0ddh
+ ret nz
ld a,b
- cp 0e9h
- ret
+ cp 0e9h
+ ret
l28dbh:
ld a,b
- and 0f7h
- cp 045h
- ret
+ and 0f7h
+ cp 045h
+ ret
?excom:
- ex (sp),hl ;28e7
- push af ;28e8
- push bc ;28e9
- push de ;28ea
- ld c,(hl) ;28eb
- ld b,000h ;28ec
- inc hl ;28ee
+ ex (sp),hl
+ push af
+ push bc
+ push de
+ ld c,(hl)
+ ld b,000h
+ inc hl
ld a,?lcmax
sub c
- ld de,?exeit ;28ef
+ ld de,?exeit
ldir
ex de,hl
ld (hl),018h
inc hl
ld (hl),a
ex de,hl
- pop de ;28f7
- pop bc ;28f8
- pop af ;28f9
- ex (sp),hl ;28fa
-?exclst:
- push hl ;28fb
- ld hl,(ubbr) ;2900
+ pop de
+ pop bc
+ pop af
+ ex (sp),hl
+ if CPU_Z180
+ push hl
+ ld hl,(ubbr)
+ else
+ push af
+ ld a,(ubnk)
+ endif
if ROMSYS
- push af ;28fc
- ld a,(uromen) ;28fd
+ push af
+ ld a,(uromen)
endif
- jp ?comcod ;2903
-
+ jp ?comcod
+
;------------------------------------------
; ddtram
;------------------------------------------
vartab:
- dseg
-ddtram:
+; dseg
+ cseg
+ddtram:
;todo:
; The following 2 params are changeable by user.
; Should these moved to top ram?
;
-ddtrst: inidat ;
- rst DRSTNUM ;rst used by ddtz
- inidate ;
-ddtei: inidat ;
- ei ;ints enabled/disabled while ddtz is running
+ddtzrst:
+ rst DDTZRSTVEC ;rst used by ddtz
+ddtei: ei ;ints enabled/disabled while ddtz is running
ret ;
- inidate ;
offs.pc:
- inidat
- dw TPA
- inidate
+ dw TPA
offs.@:
- inidat
- dw 0
- inidate
+ dw 0
CMD_ERR:
- inidat
- dw 0
- inidate
+ dw 0
CMD_RPT:
- inidat
- dw DDTZML
- inidate
+ dw DDTZML
ci.buf:
- inidat
- db 80
+ db 80
rept 83
db 0
endm
- inidate
CON.COL:
- inidat
- db 0
- inidate
+ db 0
XA747:
- inidat
- db 0
- inidate
+ db 0
bp_tab:
- inidat
- rept BP_CNT
+ rept BP_CNT
db 0,0
dw 0,0,0
endm
BP_SIZE equ 8
- inidate
sexp1:
- inidat
- dw sexpbuf
- inidate
+ dw sexpbuf
sexp2:
- inidat
- dw sexpbuf
- inidate
+ dw sexpbuf
sexpbuf:
- inidat
- rept 128
+ rept 128
db 0
endm
- inidate
sexpbufe:
msg.Y:
- inidat
- dc 'Y0'
- inidate
+ dc 'Y0'
reg.Y:
- inidat
- rept 10
+ rept 10
dw 0
endm
- inidate
lst.S:
- inidat
- dw 0
- inidate
+ dw 0
lst.IP:
- inidat
- dw 0
- inidate
+ dw 0
lst.OP:
- inidat
- dw 0
- inidate
+ dw 0
lst.OD:
- inidat
db 0
- inidate
lst.Qj:
- inidat
db 0
- inidate
lst.D:
- inidat
- dw 0
- inidate
+ dw 0
HILOD:
- inidat
- dw 0
- inidate
+ dw 0
MAXLOD:
- inidat
- dw 0
- inidate
+ dw 0
XB068:
- inidat
- dw 0
- inidate
+ dw 0
lst.A:
- inidat
- dw 0
- inidate
+ dw 0
XB06C:
- inidat
- dw 0
- inidate
+ dw 0
pfx.IXY:
- inidat
- db 000h
- inidate
+ db 000h
is.pfx.IXY:
- inidat
- db 000h
- inidate
+ db 000h
lst.L:
- inidat
- dw 0
- inidate
+ dw 0
XBE01:
- inidat
- dw 0
- inidate
+ dw 0
XBE03:
- inidat
- db 000h
- inidate
+ db 000h
XBEDD:
- inidat
ret ;ret cc
- and a
- pop hl
- inc hl
- jp (hl)
- inidate
+ and a
+ pop hl
+ inc hl
+ jp (hl)
XBFE8:
- inidat
- db 0
- inidate
+ db 0
TCFLG:
- inidat
- db 0
- inidate
+ db 0
XBFEA:
- inidat
- db 0
- inidate
+ db 0
TCCSTR:
- inidat
- dw 0
- inidate
+ dw 0
TCNFLG:
- inidat
- db 0
- inidate
+ db 0
TRJFLG:
- inidat
- db 0
- inidate
+ db 0
wstrtflg:
- inidat
db 1
- inidate
cseg
vartabe:
@@ -6322,8 +6268,13 @@ reg.b: db 0 ; 0fe61h
udcntl: db CWAITIO ; 0fe62h (mem-, io- wait)
uromen: db ROM_DIS ; 0fe63h
endif
+ if CPU_Z180
ubbr: db 0 ; 0fe64h
ucbar: db USR$CBAR ; 0fe65h
+ else
+ db 0 ; 0fe64h
+ubnk: db 0 ; 0fe65h
+ endif
reg.f: db 0 ; 0fe66h
reg.a: db 0 ; 0fe67h
reg.l: db 0 ; 0fe68h
@@ -6333,68 +6284,93 @@ reg.sp: dw TOPRAM ; 0fe6ah
$go:
if ROMSYS
out (000h),a ;064c fe6c
- out0 (dcntl),l ;064e
- pop hl ;0651
+ out0 (dcntl),l
+ pop hl
+ endif
+ if CPU_Z180
+ out0 (cbar),h
+ out0 (bbr),l
+ else
+ ld a,h
+ call selbnk
endif
- out0 (cbar),h ;0652
- out0 (bbr),l ;0655
- pop af ;0658
- pop hl ;0659
- ld sp,(reg.sp) ;065a
+ pop af
+ pop hl
+ ld sp,(reg.sp)
reg.iff:
- ei ;065e
+ ei
db 0C3h ;jp TPA ;065f feff ($+1): reg.pc
reg.pc:
dw TPA
-
+
bpent:
ld (reg.l),hl ;0662 fe82: bpent:
- pop hl ;0665
- dec hl ;0666
- ld (reg.pc),hl ;0667
- ld (reg.sp),sp ;066a
- ld sp,reg.l ;066e
- push af ;0671
- in0 h,(cbar) ;0672
- in0 l,(bbr) ;0675
- push hl ;0678
- ld a,SYS$CBAR ;0679
- out0 (cbar),a ;067b
+ pop hl
+ dec hl
+ ld (reg.pc),hl
+ ld (reg.sp),sp
+ ld sp,reg.l
+ push af
+ if CPU_Z180
+;;; TODO: cbar on trap?
+ in0 h,(cbar)
+ in0 l,(bbr)
+ ld a,SYS$CBAR
+ out0 (cbar),a
+ else
+ ld a,(@cbnk)
+ ld h,a
+ xor a
+ ld l,a
+ call selbnk
+ endif
+ push hl
if ROMSYS
- in0 l,(dcntl) ;067e
- ld a,CWAITROM+CWAITIO ;0681
- out0 (dcntl),a ;0683
- ld a,($crom) ;0686
- cp c$rom ;0689
- ld a,ROM_EN ;068b
- out (000h),a ;068d
+ in0 l,(dcntl)
+ ld a,CWAITROM+CWAITIO
+ out0 (dcntl),a
+ ld a,($crom)
+ cp c$rom
+ ld a,ROM_EN
+ out (000h),a
endif
- jp bpddtz ;068f
+ jp bpddtz
?comcod:
if ROMSYS
out (000h),a ;0692 feb2
- pop af ;069a
+ pop af
endif
- out0 (cbar),h ;0694
- out0 (bbr),l ;0697
- pop hl ;069b
+ if CPU_Z180
+ out0 (cbar),h
+ out0 (bbr),l
+ pop hl
+ else
+ call selbnk
+ pop af
+ endif
?exeit:
ds ?lcmax+2
- push af ;069f
- ld a,SYS$CBAR ;06a0
- out0 (cbar),a ;06a2
+ push af
+ if CPU_Z180
+ ld a,SYS$CBAR
+ out0 (cbar),a
+;;; TODO: bbr?
+ else
+ xor a
+ call selbnk
+ endif
if ROMSYS
- ld a,ROM_EN ;06a5
- out (000h),a ;06a7
+ ld a,ROM_EN
+ out (000h),a
endif
-
- pop af ;06a9
- ret ;06aa
+
+ pop af
+ ret
topcodend:
curph defl $
@@ -6402,4 +6378,3 @@ curph defl $
sysrame:
end
-
diff --git a/z180/fifoio.180 b/z180/fifoio.180
index dd99c53..cbcece9 100644
--- a/z180/fifoio.180
+++ b/z180/fifoio.180
@@ -1,6 +1,6 @@
page 255
.z80
-
+
;
; FIFO channels for communication with stm32
;
@@ -15,10 +15,10 @@
;--------------------------------------------------------------
dseg
-
- mkbuf rx.buf,rx.buf_len
- mkbuf tx.buf,tx.buf_len
+
+ mkbuf ci.fifo_id, rx.buf,rx.buf_len
+ mkbuf co.fifo_id, tx.buf,tx.buf_len
;--------------------------------------------------------------
@@ -48,7 +48,7 @@ buf.empty:
ret z
or 0ffh
ret
-
+
f.in:
push ix
@@ -69,12 +69,12 @@ bg.wait:
inc h
bg.nc:
ld l,(hl)
-
+
ld a,(ix+o.out_idx) ;
inc a
and (ix+o.mask)
ld (ix+o.out_idx),a
-
+
ld a,l
pop hl
pop ix
@@ -118,7 +118,7 @@ bp.wait:
jr z,bp.wait
ld (hl),b
ld (ix+o.in_idx),a
-
+
ld a,b
pop bc
pop hl
@@ -126,4 +126,3 @@ bp.wait:
ret
end
-
diff --git a/z180/init-80.180 b/z180/init-80.180
new file mode 100644
index 0000000..8b71993
--- /dev/null
+++ b/z180/init-80.180
@@ -0,0 +1,591 @@
+ page 255
+ .z80
+
+ extrn ddtz,bpent
+ extrn $stack
+ extrn charini,?const,?conin
+ extrn ?cono,?conos
+
+ extrn romend
+
+ global iobyte
+ global isv_sw
+
+ include config.inc
+
+
+
+
+;----------------------------------------------------------------------
+
+ cseg
+romstart equ $
+
+ org romstart+0
+ jp start
+
+iobyte: db 0
+
+; restart vectors
+
+rsti defl 1
+ rept 7
+
+ org 8*rsti + romstart
+ jp bpent
+rsti defl rsti+1
+ endm
+
+;----------------------------------------------------------------------
+
+ org romstart+40h
+
+ dw 0
+ db 0
+
+ cseg
+
+ if ROMSYS
+$crom: defb c$rom ;
+ else
+ db 0 ;
+ endif
+
+
+hwini0:
+ db 0 ;count
+; db rcr,CREFSH ;configure DRAM refresh
+; db dcntl,INIWAITS ;wait states
+; db cbar,SYS$CBAR
+
+
+;----------------------------------------------------------------------
+
+ org romstart+50h
+
+start:
+ jp cstart
+ jp wstart
+ jp ?const
+ jp ?conin
+ jp ?cono
+ jp ?conos
+ jp charini
+
+cstart:
+ di
+
+ xor a
+ ld (@cbnk),a
+
+; search warm start mark
+
+ ld ix,mark_55AA ; top of common area
+ ld a,0aah ;
+ cp (ix+000h) ;
+ jr nz,kstart ;
+ cp (ix+002h) ;
+ jr nz,kstart ;
+ cpl ;
+ cp (ix+001h) ;
+ jr nz,kstart ;
+ cp (ix+003h) ;
+ jr nz,kstart ;
+ ld sp,$stack ; mark found, check
+; call checkcrc_alv ;
+ jp z,wstart ; check ok,
+
+;
+; ram not ok, initialize -- kstart --
+
+kstart:
+ ld sp,$stack ;01e1
+
+; Clear RAM
+
+; Init bank manager
+
+;----------------------------------------------------------------------
+;
+
+ ld hl,055AAh ;set warm start mark
+ ld (mark_55AA),hl ;
+ ld (mark_55AA+2),hl;
+
+;
+; -- wstart --
+;
+wstart:
+ call sysram_init ;027f
+ call ivtab_init
+
+ call charini
+ call bufferinit
+
+ ld c,0
+ call selbnk
+
+
+ im 2 ;?030e
+ ei ;0282
+
+ call ?const ;0284
+ call ?const ;0287
+ or a ;028a
+ call nz,?conin ;028d
+
+;;; ld a,(banktab) ;
+;;; ld e,a ;
+ jp ddtz ;0290
+
+
+;----------------------------------------------------------------------
+;
+
+;TODO: Make a ringbuffer module.
+
+ global buf.init
+
+buf.init:
+ ld (ix+o.in_idx),0
+ ld (ix+o.out_idx),0
+ ld (ix+o.mask),a
+ ret
+
+;----------------------------------------------------------------------
+
+
+ extrn msginit,msg.sout
+ extrn mtx.fifo,mrx.fifo
+ extrn co.fifo,ci.fifo
+
+
+bufferinit:
+ call msginit
+
+ ld hl,buffers
+ ld b,buftablen
+bfi_1:
+ ld a,(hl)
+ inc hl
+ ld (bufdat+0),a
+ ld e,(hl)
+ inc hl
+ ld d,(hl)
+ inc hl
+ ex de,hl
+
+ or a
+ jr nz,bfi_2
+
+ ld a,(@cbnk)
+ call bnk2phys
+
+ ld (40h+0),hl
+ ld (40h+2),a
+ out (AVRINT5),a
+ jr bfi_3
+bfi_2:
+
+ ld a,(@cbnk)
+ call bnk2phys
+
+ ld (bufdat+1),hl
+ ld (bufdat+3),a
+ ld hl,inimsg
+ call msg.sout
+bfi_3:
+ ex de,hl
+ djnz bfi_1
+ ret
+
+
+buffers:
+ db 0
+ dw mtx.fifo
+ db 1
+ dw mrx.fifo
+ db 2
+ dw co.fifo
+ db 3
+ dw ci.fifo
+buftablen equ ($ - buffers)/3
+
+inimsg:
+ db inimsg_e - $ -1
+ db 0AEh
+ db inimsg_e - $ -1
+ db 0
+bufdat:
+ db 0
+ dw 0
+ db 0
+inimsg_e:
+
+
+;
+;----------------------------------------------------------------------
+;
+
+bnk2phys:
+ sla h
+ jr nc,b2p_1 ;A15=1 --> common
+ ld a,3
+b2p_1:
+ srl a
+ rr h
+ ret
+
+;
+;----------------------------------------------------------------------
+;
+
+sysram_init:
+ ld hl,sysramw
+ ld de,topcodsys
+ ld bc,sysrame-sysramw
+ ldir
+
+ ret
+
+;----------------------------------------------------------------------
+
+ivtab_init:
+ ld hl,ivtab ;
+ ld a,h ;
+ ld i,a ;
+; out0 (il),l ;
+
+; Let all vectors point to spurious int routines.
+
+ ld d,high sp.int0
+ ld a,low sp.int0
+ ld b,9
+ivt_i1:
+ ld (hl),a
+ inc l
+ ld (hl),d
+ inc l
+ add a,sp.int.len
+ djnz ivt_i1
+ ret
+
+;----------------------------------------------------------------------
+;
+
+ global io.ini
+
+io.ini:
+ push bc
+
+ if CPU_Z180
+
+ ld b,0 ;high byte port adress
+ ld a,(hl) ;count
+ inc hl
+ or a
+ jr z,ioi_e
+ioi_1:
+ ld c,(hl) ;port address
+ inc hl
+ outi
+ inc b ;outi decrements b
+ dec a
+ jr nz,ioi_1
+
+ else
+ jr ioi_nxt
+ioi_l:
+ ld c,(hl) ;port address
+ inc hl
+ otir
+ioi_nxt:
+ ld b,(hl) ;count
+ inc hl
+ inc b
+ djnz ioi_l
+ endif
+ioi_e:
+ pop bc
+ ret
+
+ if CPU_Z180
+io.ini.m:
+ push bc
+ ld b,(hl)
+ inc hl
+ ld c,(hl)
+ inc hl
+ otimr
+ pop bc
+ ret
+ endif
+
+io.ini.l:
+;
+
+
+;----------------------------------------------------------------------
+;
+;return:
+; hl = hl + a
+; Flags undefined
+;
+
+add_hl_a:
+ add a,l
+ ld l,a
+ ret nc
+ inc h
+ ret
+
+; ---------------------------------------------------------
+
+sysramw:
+
+ .phase isvsw_loc
+topcodsys:
+
+; Trampoline for interrupt routines in banked ram.
+; Switch stack pointer to "system" stack in top ram
+
+; todo: z80 bank switch
+
+isv_sw: ;
+ ex (sp),hl ; save hl, return adr in hl
+ push de ;
+ push af ;
+ ex de,hl ;
+ ld hl,0 ;
+ add hl,sp ;
+ ld a,h ;
+ cp 0f8h ;
+ jr nc,isw_1 ;
+ ld sp,$stack ;
+isw_1:
+ push hl ;
+ ; save current bank
+; in0 h,(cbar) ;
+ push hl ;
+ ; switch to system bank
+; ld a,SYS$CBAR ;
+; out0 (cbar),a ;
+ ex de,hl ;
+ ld e,(hl) ;
+ inc hl ;
+ ld d,(hl) ;
+ ex de,hl ;
+ push bc ;
+ call jphl ;
+
+ pop bc ;
+ pop hl ; restore bank
+; out0 (cbar),h ;
+ pop hl ;
+ ld sp,hl ;
+ pop af ;
+ pop de ;
+ pop hl ;
+ ei ;
+ ret ;
+jphl:
+ jp (hl) ;
+
+; ---------------------------------------------------------
+
+sp.int0:
+ ld a,0d0h
+ jr sp.i.1
+sp.int.len equ $-sp.int0
+ ld a,0d1h
+ jr sp.i.1
+ ld a,0d2h
+ jr sp.i.1
+ ld a,0d3h
+ jr sp.i.1
+ ld a,0d4h
+ jr sp.i.1
+ ld a,0d5h
+ jr sp.i.1
+ ld a,0d6h
+ jr sp.i.1
+ ld a,0d7h
+ jr sp.i.1
+ ld a,0d8h
+sp.i.1:
+; out (80h),a
+ halt
+
+; ---------------------------------------------------------
+
+; Get IFF2
+; This routine may not be loaded in page zero
+;
+; return Carry clear, if INTs are enabled.
+;
+ global getiff
+getiff:
+ xor a ;clear accu and carry
+ push af ;stack bottom := 00xxh
+ pop af
+ ld a,i ;P flag := IFF2
+ ret pe ;exit carry clear, if enabled
+ dec sp
+ dec sp ;has stack bottom been overwritten?
+ pop af
+ and a ;if not 00xxh, INTs were
+ ret nz ;actually enabled
+ scf ;Otherwise, they really are disabled
+ ret
+
+;----------------------------------------------------------------------
+
+ global selbnk
+
+; a: bank (0..2)
+
+selbnk:
+ push bc
+ ld c,a
+ call getiff
+ push af
+
+ ld a,c
+ di
+ ld (@cbnk),a
+ ld a,5
+ out (SIOAC),a
+ ld a,(mm_sio0)
+ rla
+ srl c
+ rra
+ out (SIOAC),a
+ ld (mm_sio0),a
+
+ ld a,5
+ out (SIOBC),a
+ ld a,(mm_sio1)
+ rla
+ srl c
+ rra
+ out (SIOBC),a
+ ld (mm_sio1),a
+ pop af
+ pop bc
+ ret c ;INTs were disabled
+ ei
+ ret
+
+;----------------------------------------------------------------------
+
+; c: bank (0..2)
+
+ if 0
+
+selbnk:
+ ld a,(@cbnk)
+ xor c
+ and 3
+ ret z ;no change
+
+ call getiff
+ push af
+ ld a,c
+ di
+ ld (@cbnk),a
+ ld a,5
+ out (SIOAC),a
+ ld a,(mm_sio0)
+ rla
+ srl c
+ rra
+ out (SIOAC),a
+ ld (mm_sio0),a
+
+ ld a,5
+ out (SIOBC),a
+ ld a,(mm_sio1)
+ rla
+ srl c
+ rra
+ out (SIOBC),a
+ ld (mm_sio1),a
+ pop af
+ ret nc ;INTs were disabled
+ ei
+ ret
+
+ endif
+
+;----------------------------------------------------------------------
+
+ if 0
+ ex af,af'
+ push af
+ ex af,af'
+
+ rra
+ jr nc,stbk1
+ ex af,af'
+ ld a,5
+ out (SIOAC),a
+ ld a,(mm_sio0)
+ rla
+ srl c
+ rra
+ out (SIOAC),a
+ ld (mm_sio1),a
+ ex af,af'
+
+stbk1:
+ rra
+ jr nc,stbk2
+ ex af,af'
+ ld a,5
+ out (SIOBC),a
+ ld a,(mm_sio1)
+ rla
+ srl c
+ rra
+ out (SIOBC),a
+ ld (mm_sio1),a
+ ex af,af'
+
+stbk2:
+ endif
+
+ global @cbnk
+ global mm_sio0, mm_sio1
+
+@cbnk: db 0 ; current bank (0..2)
+mm_sio0:
+ ds 1
+mm_sio1:
+ ds 1
+
+;----------------------------------------------------------------------
+
+curph defl $
+ .dephase
+sysrame:
+ .phase curph
+tim_ms: db 0
+tim_s: dw 0
+ .dephase
+
+;-----------------------------------------------------
+
+ cseg
+
+ ;.phase 0ffc0h
+;ivtab equ 0ffc0h ; 0ffc0h ;int vector table
+ ;.dephase
+
+ ;.phase 0fffch
+mark_55AA equ 0fffch
+ ;ds 4 ; 0fffch
+ ;.dephase
+
+
+ end
+
diff --git a/z180/init.180 b/z180/init.180
new file mode 100644
index 0000000..11f45ec
--- /dev/null
+++ b/z180/init.180
@@ -0,0 +1,950 @@
+ page 255
+ .z80
+
+ extrn ddtz,bpent
+ extrn $stack
+ extrn charini,?const,?conin
+ extrn ?cono,?conos
+ extrn romend
+
+
+ global iobyte
+ global isv_sw
+
+ include config.inc
+ if CPU_Z180
+ include z180reg.inc
+ include z180.lib
+ endif
+
+
+
+
+;----------------------------------------------------------------------
+
+ cseg
+romstart equ $
+
+ org romstart+0
+ jp start
+
+iobyte: db 2
+
+; restart vectors
+
+rsti defl 1
+ rept 7
+ org 8*rsti + romstart
+ jp bpent
+rsti defl rsti+1
+ endm
+
+;----------------------------------------------------------------------
+; Config space
+;
+
+ org romstart+40h
+
+ dw 0
+ db 0
+
+
+ if ROMSYS
+$crom: defb c$rom ;
+ else
+ db 0 ;
+ endif
+
+INIWAITS defl CWAITIO
+ if ROMSYS
+INIWAITS defl INIWAITS+CWAITROM
+ endif
+
+;----------------------------------------------------------------------
+
+ org romstart+50h
+start:
+ jp cstart
+ jp wstart
+ jp ?const
+ jp ?conin
+ jp ?cono
+ jp ?conos
+ jp charini
+
+;----------------------------------------------------------------------
+
+hwini0:
+ if CPU_Z180
+ db 3 ;count
+ db rcr,CREFSH ;configure DRAM refresh
+ db dcntl,INIWAITS ;wait states
+ db cbr,SYS$CBR
+ db cbar,SYS$CBAR
+ endif
+ db 0
+
+ if CPU_Z180
+dmclrt: ;clear ram per dma
+ db dmct_e-dmclrt-2 ;
+ db sar0l ;first port
+ dw nullbyte ;src (fixed)
+nullbyte:
+ db 000h ;src
+ dw romend ;dst (inc), start after "rom" code
+ db 00h ;dst
+ dw 0-romend ;count (64k)
+dmct_e:
+ db 0
+ endif
+
+
+cstart:
+ if CPU_Z180
+
+ push af
+ in0 a,(itc) ;Illegal opcode trap?
+ jp m,??st01
+ ld a,i ;I register == 0 ?
+ jr z,hw_reset ; yes, harware reset
+
+??st01:
+ ; TODO: SYS$CBR
+ ld a,(syscbr)
+ out0 (cbr),a
+ pop af ;restore registers
+ jp bpent ;
+
+hw_reset:
+ di ;0058
+ ld a,CREFSH
+ out0 (rcr),a ; configure DRAM refresh
+ ld a,CWAITIO
+ out0 (dcntl),a ; wait states
+
+ ld a,M_NCD ;No Clock Divide
+ out0 (ccr),a
+; ld a,M_X2CM ;X2 Clock Multiplier
+; out0 (cmr),a
+ else
+ di
+ xor a
+ ld (@cbnk),a
+ endif
+
+; check warm start mark
+
+ ld ix,mark_55AA ; top of common area
+ ld a,0aah ;
+ cp (ix+000h) ;
+ jr nz,kstart ;
+ cp (ix+002h) ;
+ jr nz,kstart ;
+ cpl ;
+ cp (ix+001h) ;
+ jr nz,kstart ;
+ cp (ix+003h) ;
+ jr nz,kstart ;
+ ld sp,$stack ; mark found, check
+ jp z,wstart ; check ok,
+
+; ram not ok, initialize -- kstart --
+
+kstart:
+ if CPU_Z180
+ ld a,SYS$CBR
+ out0 (cbr),a
+ ld a,SYS$CBAR
+ out0 (cbar),a
+ endif
+
+ ld sp,$stack ;01e1
+
+; Clear RAM using DMA0
+
+ if CPU_Z180
+ if 0
+
+ ld hl,dmclrt ;load DMA registers
+ call ioiniml
+ ld a,0cbh ;01ef dst +1, src fixed, burst
+ out0 (dmode),a ;01f1
+
+ ld b,512/64
+ ld a,062h ;01f4 enable dma0,
+??cl_1:
+ out0 (dstat),a ;01f9 clear (up to) 64k
+ djnz ??cl_1 ; end of RAM?
+
+ endif
+ endif
+
+ ld hl,055AAh ;set warm start mark
+ ld (mark_55AA),hl
+ ld (mark_55AA+2),hl
+
+; -- wstart --
+
+wstart:
+ call sysram_init
+ call ivtab_init
+ if CPU_Z180
+; call prt0_init
+ endif
+
+ call charini
+ call bufferinit
+
+ if CPU_Z80
+ ld a,0
+ call selbnk
+ endif
+
+ ld a,INIDONEVAL ;tell others (CP/M) that hardware and fifos
+ ld (INIDONE),a ; are allready initialized
+
+ im 2
+ ei
+
+ call ?const
+ call ?const
+ or a
+ call nz,?conin
+
+ if CPU_Z180
+ ld e,0 ;Sys$Bank
+ else
+; TODO:
+ endif
+ jp ddtz
+
+
+ if CPU_Z180
+; TODO: SYS$CBR
+syscbr: db 0
+ endif
+
+;
+;----------------------------------------------------------------------
+;
+
+ global buf.init
+
+buf.init:
+ ld (ix+o.in_idx),0
+ ld (ix+o.out_idx),0
+ ld (ix+o.mask),a
+
+ ld a,(ix+o.id)
+ cp 4
+ ret nc
+
+ push de
+ push hl
+ ld hl,fifo_list
+ push hl ;save fifo_list
+ ld e,a
+ ld d,0
+ add hl,de
+ add hl,de
+ add hl,de
+ push ix
+ pop de
+; TODO: address translation
+ ld (hl),e
+ inc hl
+ ld (hl),d
+ pop hl ;get fifo_list back
+ or a
+ jr nz,bufi_ex
+
+ ld (040h),hl
+ ld (040h+2),a
+bufi_ex:
+ pop hl
+ pop de
+
+ ret
+
+
+fifo_list:
+ rept 4
+ dw 0
+ db 0
+ endm
+
+;----------------------------------------------------------------------
+
+ extrn msginit,msg.sout
+ extrn mtx.fifo,mrx.fifo
+ extrn co.fifo,ci.fifo
+
+
+bufferinit:
+ if CPU_Z180
+ call msginit
+
+ ld hl,buffers
+ ld b,buftablen
+bfi_1:
+ ld a,(hl)
+ inc hl
+ ld (bufdat+0),a
+ ld e,(hl)
+ inc hl
+ ld d,(hl)
+ inc hl
+ ex de,hl
+
+ or a
+ jr nz,bfi_2
+; call hwl2phy
+; ld (40h+0),hl
+; ld (40h+2),a
+ out (AVRINT5),a
+ jr bfi_3
+bfi_2:
+ call hwl2phy
+ ld (bufdat+1),hl
+ ld (bufdat+3),a
+ ld hl,inimsg
+ call msg.sout
+bfi_3:
+ ex de,hl
+ djnz bfi_1
+ ret
+
+ else ;CPU_Z180
+
+ call msginit
+
+ ld hl,buffers
+ ld b,buftablen
+bfi_1:
+ ld a,(hl)
+ inc hl
+ ld (bufdat+0),a
+ ld e,(hl)
+ inc hl
+ ld d,(hl)
+ inc hl
+ ex de,hl
+
+ or a
+ jr nz,bfi_2
+
+ ld a,(@cbnk)
+ call bnk2phy
+
+ ld (40h+0),hl
+ ld (40h+2),a
+ out (AVRINT5),a
+ jr bfi_3
+bfi_2:
+
+ ld a,(@cbnk)
+ call bnk2phy
+
+ ld (bufdat+1),hl
+ ld (bufdat+3),a
+ ld hl,inimsg
+ call msg.sout
+bfi_3:
+ ex de,hl
+ djnz bfi_1
+ ret
+ endif
+
+buffers:
+ db 0
+ dw mtx.fifo
+ db 1
+ dw mrx.fifo
+ db 2
+ dw co.fifo
+ db 3
+ dw ci.fifo
+buftablen equ ($ - buffers)/3
+
+inimsg:
+ db inimsg_e - $ -1
+ db 0AEh
+ db inimsg_e - $ -1
+ db 0
+bufdat:
+ db 0
+ dw 0
+ db 0
+inimsg_e:
+
+
+;
+;----------------------------------------------------------------------
+;
+
+sysram_init:
+ ld hl,sysramw
+ ld de,topcodsys
+ ld bc,sysrame-sysramw
+ ldir
+
+ ret
+
+;----------------------------------------------------------------------
+
+ivtab_init:
+ ld hl,ivtab ;
+ ld a,h ;
+ ld i,a ;
+ if CPU_Z180
+ out0 (il),l ;
+ endif
+
+; Let all vectors point to spurious int routines.
+
+ ld d,high sp.int0
+ ld a,low sp.int0
+ ld b,9
+ivt_i1:
+ ld (hl),a
+ inc l
+ ld (hl),d
+ inc l
+ add a,sp.int.len
+ djnz ivt_i1
+ ret
+
+;----------------------------------------------------------------------
+
+ if CPU_Z180
+prt0_init:
+ ld a,i
+ ld h,a
+ in0 a,(il)
+ and 0E0h
+ or IV$PRT0
+ ld l,a
+ ld (hl),low iprt0
+ inc hl
+ ld (hl),high iprt0
+ ld hl,prt0itab
+ call ioiniml
+ ret
+
+prt0itab:
+ db prt0it_e-prt0itab-2
+ db tmdr0l
+ dw PRT_TC10MS
+ dw PRT_TC10MS
+ db M_TIE0+M_TDE0 ;enable timer 0 interrupt and down count.
+prt0it_e:
+ db 0
+ endif
+
+
+;
+;----------------------------------------------------------------------
+;
+
+ if CPU_Z180
+io.ini:
+ if 0
+ push bc
+ ld b,0 ;high byte port adress
+ioi_nxt:
+ ld a,(hl) ;count
+ inc hl
+ or a
+ jr z,ioi_e
+
+ ld c,(hl) ;port address
+ inc hl
+ioi_r:
+ outi
+ inc b ;outi decrements b
+ dec a
+ jr nz,ioi_r
+ jr ioi_nxt
+ioi_e:
+ pop bc
+ ret
+
+ else ;(if 1/0)
+
+ push bc
+ jr ioi_nxt
+ioi_l:
+ ld c,(hl) ;port address
+ inc hl
+ inc c
+ioi_r:
+ dec c ;otim increments c
+ otim
+ jr z,ioi_r
+ioi_nxt:
+ ld b,(hl) ;count
+ inc hl
+ inc b ;stop if count == 0
+ djnz ioi_l
+ pop bc
+ ret
+
+ endif ;(1/0)
+
+ else
+
+io.ini:
+ push bc
+ jr ioi_nxt
+ioi_l:
+ ld c,(hl) ;port address
+ inc hl
+ otir
+ioi_nxt:
+ ld b,(hl) ;count
+ inc hl
+ inc b
+ djnz ioi_l
+ endif
+ pop bc
+ ret
+
+;----------------------------------------------------------------------
+
+ if CPU_Z180
+
+ global ioiniml
+
+ioiniml:
+ push bc
+ xor a
+ioml_lp:
+ ld b,(hl)
+ inc hl
+ cp b
+ jr z,ioml_e
+
+ ld c,(hl)
+ inc hl
+ otimr
+ jr ioml_lp
+ioml_e:
+ pop bc
+ ret z
+ endif
+
+io.ini.l:
+;
+
+
+
+;----------------------------------------------------------------------
+;
+ if CPU_Z180
+
+;--------------------------------------------------------------------
+; Return the BBR value for the given bank number
+;
+; in a: Bank number
+; out a: bbr value
+
+bnk2log:
+ or a ;
+ ret z ; Bank 0 is at physical address 0
+
+ push bc ;
+ ld b,a ;
+ ld c,CA ;
+ mlt bc ;
+ ld a,c ;
+ add a,10h ;
+ pop bc ;
+ ret ;
+
+;--------------------------------------------------------------
+
+;in hl: Log. Address
+; a: Bank number
+;
+;out ahl: Phys. (linear) Address
+
+
+bnk2phy:
+ call bnk2log
+ ; fall thru
+
+;--------------------------------------------------------------
+;
+; hl: Log. Address
+; a: Bank base (bbr)
+;
+; 2 0 0
+; 0 6 8 0
+; hl hhhhhhhhllllllll
+; a + bbbbbbbb
+;
+; OP: ahl = (a<<12) + (h<<8) + l
+;
+;out ahl: Phys. (linear) Address
+
+log2phy:
+ push bc ;
+l2p_i:
+ ld c,a ;
+ ld b,16 ;
+ mlt bc ; bc = a<<4
+ ld a,c ;
+ add a,h ;
+ ld h,a ;
+ ld a,b ;
+ adc a,0 ;
+ pop bc ;
+ ret ;
+
+;--------------------------------------------------------------
+;
+; hl: Log. Address
+;
+;
+; OP: ahl = (bankbase<<12) + (d<<8) + e
+;
+;out ahl: Phys. (linear) Address
+
+
+hwl2phy:
+ push bc ;
+ in0 c,(cbar) ;
+ ld a,h ;
+ or 00fh ; log. addr in common1?
+ cp c
+ jr c,hlp_1
+
+ in0 a,(cbr) ; yes, cbr is address base
+ jr hl2p_x
+hlp_1:
+ ld b,16 ; log. address in baked area?
+ mlt bc
+ ld a,h
+ cp c
+ jr c,hlp_2
+ in0 a,(bbr) ; yes, bbr is address base
+ jr hl2p_x
+hlp_2:
+ xor a ; common1
+hl2p_x:
+ jr nz,l2p_i
+
+ pop bc ; bank part is 0, no translation
+ ret ;
+
+
+
+ else ;CPU_Z180
+
+;----------------------------------------------------------------------
+;
+
+bnk2phy:
+ sla h
+ jr nc,b2p_1 ;A15=1 --> common
+ ld a,3
+b2p_1:
+ srl a
+ rr h
+ ret
+
+ endif
+
+;--------------------------------------------------------------
+;
+;return:
+; hl = hl + a
+; Flags undefined
+;
+
+add_hl_a:
+ add a,l
+ ld l,a
+ ret nc
+ inc h
+ ret
+
+; ---------------------------------------------------------
+
+sysramw:
+
+ .phase isvsw_loc
+topcodsys:
+
+; Trampoline for interrupt routines in banked ram.
+; Switch stack pointer to "system" stack in top ram
+; Save cbar
+
+isv_sw: ;
+ ex (sp),hl ;save hl, 'return adr' in hl
+ push de ;
+ push af ;
+ ex de,hl ;'return address' in de
+ ld hl,0 ;
+ add hl,sp ;
+ ld a,h ;
+ cp 0f8h ;
+ jr nc,isw_1 ;stack allready in top ram
+ ld sp,$stack ;
+isw_1:
+ push hl ;save user stack pointer
+ in0 h,(cbar) ;
+ push hl ;
+ ld a,SYS$CBAR ;
+ out0 (cbar),a ;
+ ex de,hl ;
+ ld e,(hl) ;
+ inc hl ;
+ ld d,(hl) ;
+ ex de,hl ;
+ push bc ;
+ call jphl ;
+
+ pop bc ;
+ pop hl ;
+ out0 (cbar),h ;
+ pop hl ;
+ ld sp,hl ;
+ pop af ;
+ pop de ;
+ pop hl ;
+ ei ;
+ ret ;
+jphl:
+ jp (hl) ;
+
+; ---------------------------------------------------------
+
+ if CPU_Z180
+
+iprt0:
+ push af
+ push hl
+ in0 a,(tcr)
+ in0 a,(tmdr0l)
+ in0 a,(tmdr0h)
+ ld a,(tim_ms)
+ inc a
+ cp 100
+ jr nz,iprt_1
+ xor a
+ ld hl,(tim_s)
+ inc hl
+ ld (tim_s),hl
+iprt_1:
+ ld (tim_ms),a
+ pop hl
+ pop af
+ ei
+ ret
+
+ endif
+
+; ---------------------------------------------------------
+
+sp.int0:
+ ld a,0d0h
+ jr sp.i.1
+sp.int.len equ $-sp.int0
+ ld a,0d1h
+ jr sp.i.1
+ ld a,0d2h
+ jr sp.i.1
+ ld a,0d3h
+ jr sp.i.1
+ ld a,0d4h
+ jr sp.i.1
+ ld a,0d5h
+ jr sp.i.1
+ ld a,0d6h
+ jr sp.i.1
+ ld a,0d7h
+ jr sp.i.1
+ ld a,0d8h
+sp.i.1:
+; out (80h),a
+ halt
+
+; ---------------------------------------------------------
+
+ if CPU_Z80
+
+; Get IFF2
+; This routine may not be loaded in page zero
+;
+; return Carry clear, if INTs are enabled.
+;
+ global getiff
+getiff:
+ xor a ;clear accu and carry
+ push af ;stack bottom := 00xxh
+ pop af
+ ld a,i ;P flag := IFF2
+ ret pe ;exit carry clear, if enabled
+ dec sp
+ dec sp ;has stack bottom been overwritten?
+ pop af
+ and a ;if not 00xxh, INTs were
+ ret nz ;actually enabled
+ scf ;Otherwise, they really are disabled
+ ret
+
+;----------------------------------------------------------------------
+
+ global selbnk
+
+; a: bank (0..2)
+
+selbnk:
+ push bc
+ ld c,a
+ call getiff
+ push af
+
+ ld a,c
+ di
+ ld (@cbnk),a
+ ld a,5
+ out (SIOAC),a
+ ld a,(mm_sio0)
+ rla
+ srl c
+ rra
+ out (SIOAC),a
+ ld (mm_sio0),a
+
+ ld a,5
+ out (SIOBC),a
+ ld a,(mm_sio1)
+ rla
+ srl c
+ rra
+ out (SIOBC),a
+ ld (mm_sio1),a
+ pop af
+ pop bc
+ ret c ;INTs were disabled
+ ei
+ ret
+
+;----------------------------------------------------------------------
+
+; c: bank (0..2)
+
+ if 0
+
+selbnk:
+ ld a,(@cbnk)
+ xor c
+ and 3
+ ret z ;no change
+
+ call getiff
+ push af
+ ld a,c
+ di
+ ld (@cbnk),a
+ ld a,5
+ out (SIOAC),a
+ ld a,(mm_sio0)
+ rla
+ srl c
+ rra
+ out (SIOAC),a
+ ld (mm_sio0),a
+
+ ld a,5
+ out (SIOBC),a
+ ld a,(mm_sio1)
+ rla
+ srl c
+ rra
+ out (SIOBC),a
+ ld (mm_sio1),a
+ pop af
+ ret nc ;INTs were disabled
+ ei
+ ret
+
+ endif
+
+;----------------------------------------------------------------------
+
+ if 0
+ ex af,af'
+ push af
+ ex af,af'
+
+ rra
+ jr nc,stbk1
+ ex af,af'
+ ld a,5
+ out (SIOAC),a
+ ld a,(mm_sio0)
+ rla
+ srl c
+ rra
+ out (SIOAC),a
+ ld (mm_sio1),a
+ ex af,af'
+
+stbk1:
+ rra
+ jr nc,stbk2
+ ex af,af'
+ ld a,5
+ out (SIOBC),a
+ ld a,(mm_sio1)
+ rla
+ srl c
+ rra
+ out (SIOBC),a
+ ld (mm_sio1),a
+ ex af,af'
+
+stbk2:
+ endif
+
+ global @cbnk
+ global mm_sio0, mm_sio1
+
+@cbnk: db 0 ; current bank (0..2)
+mm_sio0:
+ ds 1
+mm_sio1:
+ ds 1
+
+
+ endif
+
+;----------------------------------------------------------------------
+
+curph defl $
+ .dephase
+sysrame:
+ .phase curph
+tim_ms: db 0
+tim_s: dw 0
+ .dephase
+
+;-----------------------------------------------------
+
+
+ cseg
+
+ ;.phase 0ffc0h
+;ivtab equ 0ffc0h ; 0ffc0h ;int vector table
+ ;.dephase
+
+ ;.phase 0fffah
+mark_55AA equ 0 - 2 - 4 ;2 byte for trap stack
+ ;ds 4
+ ;.dephase
+
+
+ end
diff --git a/z180/msgbuf-a.180 b/z180/msgbuf-a.180
index 36e0871..7e8c9cc 100644
--- a/z180/msgbuf-a.180
+++ b/z180/msgbuf-a.180
@@ -1,22 +1,24 @@
page 255
.z80
-
+
global mrx.fifo,mtx.fifo
global msginit,msgi.st,msg.in,msgo.st,msg.out
global msg.sout
-
+
extrn buf.init
include config.inc
+ if CPU_Z180
include z180reg.inc
+ endif
;--------------------------------------------------------------
dseg
- mkbuf mrx.fifo,mrx.fifo_len
- mkbuf mtx.fifo,mtx.fifo_len
+ mkbuf mtx.fifo_id, mtx.fifo, mtx.fifo_len
+ mkbuf mrx.fifo_id, mrx.fifo, mrx.fifo_len
;--------------------------------------------------------------
@@ -25,13 +27,13 @@
;
; Init buffer
;
-
+
msginit:
- ld ix,mrx.fifo
- ld a,mrx.fifo.mask
- call buf.init
ld ix,mtx.fifo
ld a,mtx.fifo.mask
+ call buf.init
+ ld ix,mrx.fifo
+ ld a,mrx.fifo.mask
jp buf.init
;--------------------------------------------------------------
@@ -47,7 +49,7 @@ buf.empty:
ret z
or 0ffh
ret
-
+
;--------------------------------------------------------------
msg.in:
@@ -69,12 +71,12 @@ bg.wait:
inc h
bg.nc:
ld l,(hl)
-
+
ld a,(ix+o.out_idx) ;
inc a
and (ix+o.mask)
ld (ix+o.out_idx),a
-
+
ld a,l
pop hl
pop ix
@@ -98,6 +100,8 @@ buf.full:
;--------------------------------------------------------------
+ if 0
+
msg.out:
push ix
ld ix,mtx.fifo ;
@@ -120,58 +124,162 @@ bp.wait:
jr z,bp.wait
ld (hl),b
ld (ix+o.in_idx),a
-
+
ld a,b
- out0 (AVRINT5),a
+ out (AVRINT5),a
pop bc
pop hl
pop ix
ret
+ endif
;--------------------------------------------------------------
-;
-; (hl): data
-msg.sout:
+
+
+msg.out:
push ix
ld ix,mtx.fifo ;
+buf.put:
push bc
- push de
- ld b,(hl) ;
- inc hl
- ex de,hl
-
-ms.ol:
- push ix
- pop hl
ld c,(ix+o.in_idx) ;
- ld a,c
- add l
- ld l,a
- jr nc,ms.on
- inc h
-ms.on:
+ ld b,0
+ push ix ;14
+ add ix,bc ;10
+ ld (ix+0),a ;15
+ pop ix ;12 / 51
+ ld b,a ; 4
ld a,c ;
- inc a
- and (ix+o.mask)
-ms.wait:
+ inc a ;
+ and (ix+o.mask) ;
+bp.wait:
+ cp (ix+o.out_idx) ;
+ jr z,bp.wait ;
+ ld (ix+o.in_idx),a ;
+
+ ld a,b
+ out (AVRINT5),a
+ pop bc
+ pop ix
+ ret
+
+
+;--------------------------------------------------------------
+
+ if 0
+ ; Works only, if buffer size < (128 - 3)
+ ; --> mask must be 03fh or less
+
+msg.out:
+ push ix
+ ld ix,mtx.fifo ;
+
+buf.put:
+ push bc
+ ld b,a ; 4
+ ld a,(ix+o.in_idx) ;14
+ ld ($ + 3 + 2),a ;15
+ ld (ix+0),b ;15
+ inc a ;
+ and (ix+o.mask) ;
+bp.wait:
cp (ix+o.out_idx) ;
- jr z,ms.wait
- ld c,a
- ld a,(de)
- inc de
- ld (hl),a
- ld (ix+o.in_idx),c
- djnz ms.ol
- out0 (AVRINT5),a
- ex de,hl
- pop de
+ jr z,bp.wait ;
+ ld (ix+o.in_idx),a ;
+
+ ld a,b
+ out (AVRINT5),a
pop bc
pop ix
ret
+ endif
+
+;--------------------------------------------------------------
+;
+; (hl): data
+
+msg.sout:
+ push ix ;14
+ ld ix,mtx.fifo ;12
+ push bc ;11
+ push de ;11
+ ld c,(hl) ; 6
+ ld b,0 ; 6
+ inc hl ; 7
+ms.ol: ; \
+ ld a,low mtx.fifo ; 6
+ add a,(ix+o.in_idx) ;14
+ ld e,a ; 4
+ ld a,high mtx.fifo ; 6
+ adc a,b ; 4
+ ld d,a ; 4
+
+ ld a,(ix+o.in_idx) ;14
+ inc a ; 4
+ and (ix+o.mask) ;14
+ms.wait:
+ cp (ix+o.out_idx) ;14
+ jr z,ms.wait ; 6/8
+
+ ldi ;12
+ ld (ix+o.in_idx),a ;15
+ jp pe,ms.ol ; 6/9 -- 126
+
+ out (AVRINT5),a ;10
+ pop de ; 9
+ pop bc ; 9
+ pop ix ;12
+ ret ; 9
+
+;--------------------------------------------------------------
+;
+; (hl): data
+
+ if 0
+
+msg.sout:
+ push ix ;14
+ ld ix,mtx.fifo ;12
+ push bc ;11
+ push de ;11
+ ld b,(hl) ; 6
+ inc hl ; 4
+ ex de,hl ; 3
+ms.ol: ; \
+ push ix ;14
+ pop hl ; 9
+ ld c,(ix+o.in_idx) ;14
+ ld a,c ; 4
+ add l ; 4
+ ld l,a ; 4
+ jr nc,ms.on ; 6/8
+ inc h ; 4
+ms.on:
+ ld a,c ; 4
+ inc a ; 4
+ and (ix+o.mask) ;14
+ms.wait:
+ cp (ix+o.out_idx) ;14
+ jr z,ms.wait ; 6/8
+ ld c,a ; 4
+ ld a,(de) ; 6
+ inc de ; 4
+ ld (hl),a ; 7
+ ld (ix+o.in_idx),c ;15
+ djnz ms.ol ; 7/9 -- 130
+
+ out (AVRINT5),a ;10
+ ex de,hl ; 3
+ pop de ; 9
+ pop bc ; 9
+ pop ix ;12
+ ret ; 9
+
+ endif
+
;--------------------------------------------------------------
msg.co:
@@ -183,8 +291,8 @@ msg.co:
pop hl
pop af
ret
-
-
+
+
buf:
db buf_end - $ - 1 ;output string length
db 0AEh ; message start token
@@ -198,4 +306,3 @@ buf_end:
;----------------------------------------------------------------------
end
-
diff --git a/z180/msgfifo.180 b/z180/msgfifo.180
index 582c219..cf1ae2a 100644
--- a/z180/msgfifo.180
+++ b/z180/msgfifo.180
@@ -1,11 +1,11 @@
page 255
.z80
-
+
global msg_rx_fifo,msg_tx_fifo
global msginit,msgi.st,msg.in,msgo.st,msg.out
global msg.sout,msg.co
-
+
extrn buf.init
include config.inc
@@ -15,8 +15,8 @@
dseg
- mkbuf msg_rx_fifo,msg_rx_fifo_len
- mkbuf msg_tx_fifo,msg_tx_fifo_len
+ mkbuf mtx.fifo_id, msg_tx_fifo, msg_tx_fifo_len
+ mkbuf mrx.fifo_id, msg_rx_fifo, msg_rx_fifo_len
@@ -27,7 +27,7 @@
;
; Init buffer
;
-
+
msginit:
ld ix,msg_rx_fifo
ld a,msg_rx_fifo.mask
@@ -49,7 +49,7 @@ buf.empty:
ret z
or 0ffh
ret
-
+
;--------------------------------------------------------------
msg.in:
@@ -71,12 +71,12 @@ bg.wait:
inc h
bg.nc:
ld l,(hl)
-
+
ld a,(ix+o.out_idx) ;
inc a
and (ix+o.mask)
ld (ix+o.out_idx),a
-
+
ld a,l
pop hl
pop ix
@@ -122,7 +122,7 @@ bp.wait:
jr z,bp.wait
ld (hl),b
ld (ix+o.in_idx),a
-
+
ld a,b
out0 (AVRINT5),a
pop bc
@@ -152,7 +152,7 @@ bp.wait:
ld a,b
out (PMSG),a
ld (ix+o.in_idx),c
-
+
pop bc
pop ix
ret
@@ -171,7 +171,7 @@ msg.sout:
ld b,(hl) ;
inc hl
ex de,hl
-
+
ms.ol:
push ix
pop hl
@@ -242,8 +242,8 @@ msg.co:
pop hl
pop af
ret
-
-
+
+
buf:
db buf_end - $ - 1 ;output string length
db 081h ; message start token
@@ -257,4 +257,3 @@ buf_end:
;----------------------------------------------------------------------
end
-
diff --git a/z180/r3init.180 b/z180/r3init.180
deleted file mode 100644
index 9edeaf2..0000000
--- a/z180/r3init.180
+++ /dev/null
@@ -1,957 +0,0 @@
- page 255
- .z80
-
- extrn ddtz,bpent
- extrn $stack
- extrn charini,?const,?conin
-
- extrn romend
-
-
- global isv_sw
-
- include config.inc
- include z180reg.inc
- include z180.lib
-
-;CR equ 0dh
-
-
-
-;----------------------------------------------------------------------
-
- cseg
-
- jp start
-
-; restart vectors
-
-rsti defl 1
- rept 7
- db 0, 0, 0, 0, 0
- jp bpent
-rsti defl rsti+1
- endm
- db 0, 0, 0, 0, 0
-
-;----------------------------------------------------------------------
-
- ;org 40h
-
- dw 0
- db 0
-
-
- if ROMSYS
-$crom: defb c$rom ;
- else
- db 0 ;
- endif
-
-dmclrt: ;clear ram per dma
- db dmct_e-dmclrt-2 ;
- db sar0l ;first port
- dw nullbyte ;src (fixed)
-nullbyte:
- db 000h ;src
- dw romend ;dst (inc), start after "rom" code
- db 00h ;dst
- dw 0-romend ;count (64k)
-dmct_e:
-
-INIWAITS defl CWAITIO
- if ROMSYS
-INIWAITS defl INIWAITS+CWAITROM
- endif
-
-hwini0:
- db 3 ;count
- db rcr,CREFSH ;configure DRAM refresh
- db dcntl,INIWAITS ;wait states
- db cbar,SYS$CBAR
-
-;----------------------------------------------------------------------
-
-start:
- ld (tmpstack),sp
- ld sp,tmpstack
- push af
- in0 a,(itc) ;Illegal opcode trap?
- jp m,??st01
- ld a,i ;I register == 0 ?
- jr z,??st02 ; yes, harware reset
-
-??st01:
- ld a,(syscbr)
- out0 (cbr),a
- pop af ;restore registers
- ld sp,(tmpstack) ;
- jp bpent ;
-
-??st02:
- di ;0058
- ld a,CREFSH
- out0 (rcr),a ; configure DRAM refresh
- ld a,CWAITIO
- out0 (dcntl),a ; wait states
-
- ld a,M_NCD ;No Clock Divide
- out0 (ccr),a
-; ld a,M_X2CM ;X2 Clock Multiplier
-; out0 (cmr),a
-
-; search warm start mark
-
- ld ix,mark_55AA ;00b8 ; top of common area
- ld a,SYS$CBAR ;
- out0 (cbar),a ;
- ld a,071h ;00bc
- ex af,af' ;00be ;for cbr = 0x70 downto 0x40
-swsm_l:
- ex af,af' ;00bf
- dec a ;00c0
- cp 03fh ;00c1
- jr z,kstart ;00c3 ; break (mark not found)
- out0 (cbr),a ;00c5
- ex af,af' ;00c8
- ld a,0aah ;00c9
- cp (ix+000h) ;00cb
- jr nz,swsm_l ;00ce
- cp (ix+002h) ;00d0
- jr nz,swsm_l ;00d3
- cpl ;00d5
- cp (ix+001h) ;00d6
- jr nz,swsm_l ;00d9
- cp (ix+003h) ;00db
- jr nz,swsm_l ;00de
- ld sp,$stack ;00e0 mark found, check
- call checkcrc_alv ;00e3
- jp z,wstart ;00e6 check ok,
-
-;
-; ram not ok, initialize -- kstart --
-
-kstart:
-
- ld a,088h ;00e9 0000-7fff: common 0
- out0 (cbar),a ;00eb 8000-ffff: common 1
- ld ix,08000h ;00f3
- ld a,0 ;00f1 start at 008000 (2. phys. 32k block)
-??f_0:
- out0 (cbr),a ;00f9
-
- ld (ix+0),a ;0103
- cpl
- ld (ix+1),a ;0103
- cpl
- add a,8 ;010a next 'bank'
- cp 078h ;010c stop at 078000
- jr nz,??f_0 ;010e
-
- ld de,8000h ;0114 first block not tested, but mark as ok
- ld a,0 ;00f1 start at 008000 (2. phys. 32k block)
-??cp_0:
- out0 (cbr),a ;011c
- ld c,a
- xor (ix+0)
- ld b,a
- ld a,c
- cpl
- xor (ix+1)
- or b
- jr nz,??cp_1
- scf
-??cp_1:
- rr d
- rr e
- ld a,c
- add a,8
- cp 078h ; stop at 078000
- jr nz,??cp_0
-
-;
-; ram test found 1 or more error free blocks (32k)
-;
-
-ramok:
- ld a,SYS$CBAR ;01c8
- out0 (cbar),a ;01ca
- ld h,d
- ld l,e
- ld c,070h ;01ce highest block
- ld b,15 ;01d0
-??sr_1:
- add hl,hl
- jr c,alloc ;01d4 highest "error free" block
- ld a,c ;01d6
- sub 008h ;01d7
- ld c,a ;01d9
- djnz ??sr_1 ;01da
-
- slp ;01dc should never be reached
-
-alloc:
- out0 (cbr),c ;01de
- ld a,c
- ld (syscbr),a
- ld sp,$stack ;01e1
-
-; Clear RAM using DMA0
-
- ld hl,dmclrt ;load DMA registers
- call io.ini.m
- ld a,0cbh ;01ef dst +1, src fixed, burst
- out0 (dmode),a ;01f1
-
- ld b,512/64
- ld a,062h ;01f4 enable dma0,
-??cl_1:
- out0 (dstat),a ;01f9 clear (up to) 64k
- djnz ??cl_1 ; end of RAM?
-
-; Init bank manager
-
- ld hl,banktabsys ;020f
- ld (hl),c ; Common area
- inc hl ;0213
- ld (hl),c ; System work area
- inc hl ;0215 Point to bank 0 entry
- ld b,BANKS ;0216
-l0218h:
- ld (hl),0ffh ;0218 Mark all banks as unassigned
- inc hl ;021a
- djnz l0218h ;021b
-
- ld hl,memalv ;
- ld b,8 ; 8*4k ie. first 32k
-??a_0:
- ld (hl),0e0h ; mark as sys ("rom"/monitor)
- inc hl
- djnz ??a_0
-
- rr d ; shift out bit for block 0
- rr e ;
- ld c,15 ;022c 15*32k remaining blocks
-l022eh:
- ld a,0feh ; 0xfe == block with error(s)
- rr d ;
- rr e
- adc a,0 ; ==> 0xff : block ok
- ld b,32/4 ; 32k == 8 * 4k
-l0236h:
- ld (hl),a ;
- inc hl ;
- djnz l0236h ;
- dec c ;
- jr nz,l022eh ;next 32k block
-
- ld hl,memalv+0ch ;memalv+0ch
- ld a,(banktabsys) ;
- call add_hl_a
- ld b,3 ;
-l024ah:
- ld (hl),0ech ;alloc system ram
- inc hl ;
- djnz l024ah ;
- ld (hl),0efh ;alloc common
- call gencrc_alv
-
- ld hl,0000h ;bank #
- ld bc,0f0fh ; size (?) (4k blocks)
- xor a ;
- call sub_0420h ;alloc mem for bank 0
- ld c,l ;
- or a ;
- call z,sub_04b5h ;
-
- ld hl,0101h ;
- ld bc,0f0fh ;
- xor a ;
- call sub_0420h ;
- ld c,l ;
- or a ;
- call z,sub_04b5h ;
-
- ld hl,055AAh ;set warm start mark
- ld (mark_55AA),hl ;
- ld (mark_55AA+2),hl;
-
-;
-; crc ok -- wstart --
-;
-wstart:
- call sysram_init ;027f
- call ivtab_init
-
- call prt0_init
-
- call charini
-
- call bufferinit
-
-
-
- im 2 ;?030e
- ei ;0282
-
- call ?const ;0284
- call ?const ;0287
- or a ;028a
- call nz,?conin ;028d
-
- ld a,(banktab) ;
- ld e,a ;
- jp ddtz ;0290
-
-
- ds 8
-tmpstack:
- dw 2
-syscbr: db 1
-
-;
-;----------------------------------------------------------------------
-;
-
-;TODO: Make a ringbuffer module.
-
- global buf.init
-
-buf.init:
- ld (ix+o.in_idx),0
- ld (ix+o.out_idx),0
- ld (ix+o.mask),a
- ret
-
-;----------------------------------------------------------------------
-if 0
- extrn msginit,msg_tx_fifo,msg_rx_fifo
- extrn msg.sout
-
-bufferinit:
-
- ld de,msg_tx_fifo
- in0 a,cbr
- call log2phys
- ld (40h+0),hl
- ld (40h+2),a
-
-; ld (bufdat+1),hl
-; ld (bufdat+3),a
-; ld a,1
-; ld (bufdat+0),a
-; ld hl,inimsg
-; call msg.sout
-
- ld de,msg_rx_fifo
- in0 a,cbr
- call log2phys
- ld (bufdat+1),hl
- ld (bufdat+3),a
- ld a,2
- ld (bufdat+0),a
- ld hl,inimsg
- call msg.sout
-
- ret
-
-inimsg:
- db inimsg_e - $ - 1
- db 0AEh
- db inimsg_e - $ - 1
- db 0
-bufdat:
- db 0
- dw 0
- db 0
-inimsg_e:
-
-endif
-;----------------------------------------------------------------------
-;
-
- extrn msginit,msg.sout
- extrn mtx.fifo,mrx.fifo
- extrn co.fifo,ci.fifo
-
-
-bufferinit:
- call msginit
-
- ld hl,buffers
- ld b,buftablen
-bfi_1:
- ld a,(hl)
- inc hl
- ld (bufdat+0),a
- ld e,(hl)
- inc hl
- ld d,(hl)
- inc hl
- push hl
-
- or a
- jr nz,bfi_2
- in0 a,cbr
- call log2phys
- ld (40h+0),hl
- ld (40h+2),a
- out0 (AVRINT5),a
- jr bfi_3
-bfi_2:
- in0 a,cbr
- call log2phys
- ld (bufdat+1),hl
- ld (bufdat+3),a
- ld hl,inimsg
- call msg.sout
-bfi_3:
- pop hl
- djnz bfi_1
- ret
-
-buffers:
- db 0
- dw mtx.fifo
- db 1
- dw mrx.fifo
- db 2
- dw co.fifo
- db 3
- dw ci.fifo
-buftablen equ ($ - buffers)/3
-
-inimsg:
- db inimsg_e - $ -1
- db 0AEh
- db inimsg_e - $ -1
- db 0
-bufdat:
- db 0
- dw 0
- db 0
-inimsg_e:
-
-
-;
-;----------------------------------------------------------------------
-;
-
-sysram_init:
- ld hl,sysramw
- ld de,topcodsys
- ld bc,sysrame-sysramw
- ldir
-
- ret
-
-;----------------------------------------------------------------------
-
-ivtab_init:
- ld hl,ivtab ;
- ld a,h ;
- ld i,a ;
- out0 (il),l ;
-
-; Let all vectors point to spurious int routines.
-
- ld d,high sp.int0
- ld a,low sp.int0
- ld b,9
-ivt_i1:
- ld (hl),a
- inc l
- ld (hl),d
- inc l
- add a,sp.int.len
- djnz ivt_i1
- ret
-
-;----------------------------------------------------------------------
-
-prt0_init:
- ld a,i
- ld h,a
- in0 a,(il)
- and 0E0h
- or IV$PRT0
- ld l,a
- ld (hl),low iprt0
- inc hl
- ld (hl),high iprt0
- ld hl,prt0itab
- call io.ini.m
- ret
-
-prt0itab:
- db prt0it_e-prt0itab-2
- db tmdr0l
- dw PRT_TC10MS
- dw PRT_TC10MS
- db M_TIE0+M_TDE0 ;enable timer 0 interrupt and down count.
-prt0it_e:
-
-
-;
-;----------------------------------------------------------------------
-;
-
-io.ini:
- push bc
- ld b,0 ;high byte port adress
- ld a,(hl) ;count
- inc hl
-ioi_1:
- ld c,(hl) ;port address
- inc hl
- outi
- inc b ;outi decrements b
- dec a
- jr nz,ioi_1
- pop bc
- ret
-
-io.ini.m:
- push bc
- ld b,(hl)
- inc hl
- ld c,(hl)
- inc hl
- otimr
- pop bc
- ret
-
-io.ini.l:
-;
-
-;----------------------------------------------------------------------
-;
-
-; compute crc
-; hl: start adr
-; bc: len
-; bc returns crc val
-
-do_crc16:
- ld de,0FFFFh
-crc1:
- ld a,(hl)
- xor e
- ld e,a
- rrca
- rrca
- rrca
- rrca
- and 0Fh
- xor e
- ld e,a
- rrca
- rrca
- rrca
- push af
- and 1Fh
- xor d
- ld d,a
- pop af
- push af
- rrca
- and 0F0h
- xor d
- ld d,a
- pop af
- and 0E0h
- xor e
- ld e,d
- ld d,a
- cpi
- jp pe,crc1
- or e ;z-flag
- ret
-
-
-gencrc_alv:
- push hl ;03f6
- push de ;03f7
- push bc
- push af ;03f8
- ld hl,banktabsys ;03f9
- ld bc,crc_len ;03fc
- call do_crc16 ;03ff
- ld (hl),e
- inc hl
- ld (hl),d
- pop af ;0406
- pop bc
- pop de ;0407
- pop hl ;0408
- ret ;0409
-
-checkcrc_alv:
- push hl ;040a
- push de
- push bc ;040b
- ld hl,banktabsys ;040d
- ld bc,crc_len+2 ;0410
- call do_crc16 ;0413
- pop bc ;041d
- pop de
- pop hl ;041e
- ret ;041f
-
-;----------------------------------------------------------------------
-
-;
-; alloc
-;
-; h: max bank #
-; l: min bank #
-; b: max size
-; c: min size
-;
-; ret:
-; a: 0 == ok
-; 1 ==
-; 2 == no bank # in requested range
-; ff == crc error
-;
-
-sub_0420h:
- call checkcrc_alv ;0420
- jr nz,l049ch ;0424 crc error, tables corrupt
-
- call sub_049dh ;0427 bank # in req. range available?
- jr c,l0499h ;042a
- push ix ;042c
- push iy ;042e
- push de ;0430
- push hl ;0431
- push bc ;0432
- ld c,b ;0433
- ld b,alv_len+1 ;0434
- ld d,0 ;0436
- ld hl,memalv-1 ;0438
- jr l0441h ;043b
-
-; find free blocks
-
-l043dh:
- ld a,(hl) ;043d
- inc a ;043e free blocks are marked 0ffh
- jr z,l0446h ;043f
-l0441h:
- inc hl ;0441
- djnz l043dh ;0442
- jr l0464h ;0444
-l0446h:
- push hl ;0446
- pop ix ;0447 free blocks start here
- ld e,000h ;0449
- jr l0451h ;044b
-l044dh: ; count free blocks
- ld a,(hl) ;044d
- inc a ;044e
- jr nz,l0457h ;044f
-l0451h:
- inc e ;0451
- inc hl ;0452
- djnz l044dh ;0453
- jr l0464h ;0455
-
-; end of free blocks run.
-
-l0457h:
- ld a,d ;0457
- cp e ;0458 nr of blocks >= requested ?
- jr nc,l0441h ;0459
-
- ld d,e ;045b
- push ix ;045c
- pop iy ;045e
- ld a,d ;0460
- cp c ;0461
- jr c,l0441h ;0462
-l0464h:
- pop bc ;0464
- ld a,d ;0465
- cp b ;0466
- jr c,l046ch ;0467
- ld d,b ;0469
- jr l0471h ;046a
-l046ch:
- cp c ;046c
- jr nc,l0471h ;046d
- ld d,000h ;046f
-l0471h:
- ld a,d ;0471
- push iy ;0472
- pop hl ;0474
- ld de,memalv ;0475
- or a ;0478
- sbc hl,de ;0479
- ld b,l ;047b
- ld c,a ;047c
- pop hl ;047d
-l047eh:
- or a ;047e
- jr z,l0489h ;047f
- ld (iy+0),l ;0481
- inc iy ;0484
- dec a ;0486
- jr l047eh ;0487
-l0489h:
- pop de ;0489
- pop iy ;048a
- pop ix ;048c
- call gencrc_alv ;048e
- ld a,c ;0491
- or a ;0492
- ld a,000h ;0493
- ret nz ;0495
- or 001h ;0496
- ret ;0498
-
-l0499h:
- ld a,2 ;0499
-l049ch:
- or a
- ret ;049c
-
-
-; search a free bank number in range
-; h: max #
-; l: min #
-; ret:
-; l: bank number available
-; nc, if found, bank nr. in l
-; cy, if none found
-
-sub_049dh:
- push de ;049d
- push bc ;049e
- ex de,hl ;049f
- dec e ;04a0
-l04a1h:
- inc e ;04a1 test next #
- ld a,d ;04a2
- cp e ;04a3
- jr c,l04b1h ;04a4
- ld a,e ;04a6
- ld hl,memalv ;04a7
- ld bc,alv_len ;04aa
- cpir ;04ad bank# allready allocated?
- jr z,l04a1h ;04af if yes, search for next
-l04b1h:
- ex de,hl ;04b1
- pop bc ;04b2
- pop de ;04b3
- ret ;04b4
-
-
-sub_04b5h:
- ld a,l ;04b5
- cp 012h ;04b6
- ccf ;04b8
- ret c ;04b9
- push hl ;04ba
- ld hl,banktab ;04bb
- call add_hl_a
- ld (hl),b ;04c3
- call gencrc_alv ;04c4
- pop hl ;04c7
- or a ;04c8 clear carry
- ret ;04c9
-
-
-;--------------------------------------------------------------
-;
-; de: Log. Address
-; a: Bank number
-;
-;out ahl: Phys. (linear) Address
-
-
-bnk2phys:
- push hl
- ld hl,banktab
- call add_hl_a
- ld a,(hl)
- pop hl
-
- ; fall thru
-;--------------------------------------------------------------
-;
-; de: Log. Address
-; a: Bank (bbr)
-;
-; OP: ahl = (a<<12) + (d<<8) + e
-;
-;out ahl: Phys. (linear) Address
-
-
-log2phys:
- push bc ;
- ld c,a ;
- ld b,16 ;
- mlt bc ;bc = a<<4
- ld l,d ;
- ld h,0 ;
- add hl,bc ;bc + d == a<<4 + d
- ld a,h ;
- ld h,l ;
- ld l,e ;
- pop bc ;
- ret ;
-
-
-;--------------------------------------------------------------
-;
-;return:
-; hl = hl + a
-; Flags undefined
-;
-
-add_hl_a:
- add a,l
- ld l,a
- ret nc
- inc h
- ret
-
-; ---------------------------------------------------------
-
-sysramw:
-
- .phase isvsw_loc
-topcodsys:
-
-; Trampoline for interrupt routines in banked ram.
-; Switch stack pointer to "system" stack in top ram
-; Save cbar
-
-isv_sw: ;
- ex (sp),hl ; save hl, return adr in hl
- push de ;
- push af ;
- ex de,hl ;
- ld hl,0 ;
- add hl,sp ;
- ld a,h ;
- cp 0f8h ;
- jr nc,isw_1 ;
- ld sp,$stack ;
-isw_1:
- push hl ;
- in0 h,(cbar) ;
- push hl ;
- ld a,SYS$CBAR ;
- out0 (cbar),a ;
- ex de,hl ;
- ld e,(hl) ;
- inc hl ;
- ld d,(hl) ;
- ex de,hl ;
- push bc ;
- call jphl ;
-
- pop bc ;
- pop hl ;
- out0 (cbar),h ;
- pop hl ;
- ld sp,hl ;
- pop af ;
- pop de ;
- pop hl ;
- ei ;
- ret ;
-jphl:
- jp (hl) ;
-
-; ---------------------------------------------------------
-
-
-iprt0:
- push af
- push hl
- in0 a,(tcr)
- in0 a,(tmdr0l)
- in0 a,(tmdr0h)
- ld a,(tim_ms)
- inc a
- cp 100
- jr nz,iprt_1
- xor a
- ld hl,(tim_s)
- inc hl
- ld (tim_s),hl
-iprt_1:
- ld (tim_ms),a
- pop hl
- pop af
- ei
- ret
-
-; ---------------------------------------------------------
-
-sp.int0:
- ld a,0d0h
- jr sp.i.1
-sp.int.len equ $-sp.int0
- ld a,0d1h
- jr sp.i.1
- ld a,0d2h
- jr sp.i.1
- ld a,0d3h
- jr sp.i.1
- ld a,0d4h
- jr sp.i.1
- ld a,0d5h
- jr sp.i.1
- ld a,0d6h
- jr sp.i.1
- ld a,0d7h
- jr sp.i.1
- ld a,0d8h
-sp.i.1:
-; out (80h),a
- halt
-
-curph defl $
- .dephase
-sysrame:
- .phase curph
-tim_ms: db 0
-tim_s: dw 0
- .dephase
-
-;-----------------------------------------------------
-
- dseg
-
- ds 1
-banktabsys:
- ds 1 ;0c001h
- ds 1 ;0c002h
-banktab:
- ds BANKS ;0c003h
-memalv:
- ds 512/4 ;Number of 4k blocks
-alv_len equ $-memalv
-crc_len equ $-banktabsys
-
-crc_memalv:
- ds 2 ;
-
- cseg
-
- ;.phase 0ffc0h
-;ivtab equ 0ffc0h ; 0ffc0h ;int vector table
- ;.dephase
-
- ;.phase 0fffch
-mark_55AA equ 0fffch
- ;ds 4 ; 0fffch
- ;.dephase
-
-
- end
-
diff --git a/z180/z180reg.inc b/z180/z180reg.inc
index 5bbd088..271a446 100644
--- a/z180/z180reg.inc
+++ b/z180/z180reg.inc
@@ -76,6 +76,13 @@ tcr equ IOBASE+10h ;Timer Control Register
asext0 equ IOBASE+12h ;ASCI Extension Control Register
asext1 equ IOBASE+13h ;ASCI Extension Control Register
+ b2m DCD0DIS,6 ;DCD0 Disable
+ b2m CTS0DIS,5 ;CTS0 Disable
+ b2m X1,4 ;CKA * 1 Clock/Samle Rate Divider
+ b2m BRGMOD,3 ;BRG Mode (Baud rate generator)
+ b2m BREAKEN,2 ;Break Enable
+ b2m BREAK,1 ;Break detected
+ b2m SENDBREAK,0 ;Send Break
tmdr1l equ IOBASE+14h ;Timer Data Register Channel 1
tmdr1h equ IOBASE+15h ;