summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo C2015-06-01 23:29:55 +0200
committerLeo C2015-06-01 23:29:55 +0200
commitad9bc17c8ecab1f0bbd26f2270d4d396f4bc5e52 (patch)
tree0ce8f07e46c5447f7e3d1abd28a53904a431c8d4
parenta8eb521f94848a627a3fe470e34f62b13c157d34 (diff)
downloadz180-stamp-hexrel-6.2.zip
switch fifos conin,conouthexrel-6.2
-rw-r--r--avr/cmd_loadcpm3.c1
-rw-r--r--avr/cmd_mem.c4
-rw-r--r--avr/command_tbl.c12
-rw-r--r--avr/debug.c88
-rw-r--r--avr/z180-serv.c3
-rw-r--r--include/z80-if.h2
-rw-r--r--z180/conbuf-a.1802
-rw-r--r--z180/config.inc9
-rw-r--r--z180/ddtz.18019
-rw-r--r--z180/init.1804
10 files changed, 125 insertions, 19 deletions
diff --git a/avr/cmd_loadcpm3.c b/avr/cmd_loadcpm3.c
index fd685b2..3f1bbe1 100644
--- a/avr/cmd_loadcpm3.c
+++ b/avr/cmd_loadcpm3.c
@@ -55,6 +55,7 @@ int load(FIL *File, uint16_t addr, uint8_t len)
return 0;
}
+#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
command_ret_t do_loadcpm3(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
diff --git a/avr/cmd_mem.c b/avr/cmd_mem.c
index 53b1842..101b912 100644
--- a/avr/cmd_mem.c
+++ b/avr/cmd_mem.c
@@ -152,8 +152,8 @@ mod_mem(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])
if (incrflag)
addr += nbytes ? -1 : 1;
nbytes = 1;
- }
- else {
+
+ } else {
char *endp;
data = strtoul(console_buffer, &endp, 16);
nbytes = endp - console_buffer;
diff --git a/avr/command_tbl.c b/avr/command_tbl.c
index eb0d84f..a9cc2bd 100644
--- a/avr/command_tbl.c
+++ b/avr/command_tbl.c
@@ -25,6 +25,8 @@ 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 []);
extern command_ret_t do_dump_mem(cmd_tbl_t *, int, int, char * const []);
+extern command_ret_t do_mem_mm_avr(cmd_tbl_t *, int, int, char * const []);
+extern command_ret_t do_mem_nm_avr(cmd_tbl_t *, int, int, char * const []);
extern command_ret_t do_eep_cp(cmd_tbl_t *, int, int, char * const []);
extern command_ret_t do_busreq_pulse(cmd_tbl_t *, int, int, char * const []);
extern command_ret_t do_date(cmd_tbl_t *, int, int, char * const []);
@@ -75,6 +77,16 @@ CMD_TBL_ITEM(
"EEPROM copy",
"source target count"
),
+CMD_TBL_ITEM(
+ !mm, 2, 1, do_mem_mm_avr,
+ "avr memory modify (auto-incrementing address)",
+ "address"
+),
+CMD_TBL_ITEM(
+ !nm, 2, 1, do_mem_nm_avr,
+ "avr memory modify (constant address)",
+ "address"
+),
#endif
CMD_TBL_ITEM(
mstep, 2, 1, do_busreq_pulse,
diff --git a/avr/debug.c b/avr/debug.c
index d4ae1f4..f3632c2 100644
--- a/avr/debug.c
+++ b/avr/debug.c
@@ -11,6 +11,7 @@
#include <avr/eeprom.h>
#include "command.h"
+#include "cli_readline.h"
#include "print-utils.h"
#include "debug.h"
@@ -39,7 +40,7 @@ void dump_heap(void)
*/
command_ret_t do_dump_mem(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
- void (*readhow)(uint8_t *buf, uint32_t addr, uint8_t count);
+ void (*readwhat)(uint8_t *buf, uint32_t addr, uint8_t count);
(void) cmdtp; (void) flag;
@@ -51,13 +52,13 @@ command_ret_t do_dump_mem(cmd_tbl_t *cmdtp, int flag, int argc, char * const arg
switch (argv[0][3]) {
case 'r':
- readhow = ram_read_buf;
+ readwhat = ram_read_buf;
break;
case 'e':
- readhow = eeprom_read_buf;
+ readwhat = eeprom_read_buf;
break;
case 'f':
- readhow = flash_read_buf;
+ readwhat = flash_read_buf;
break;
default:
return CMD_RET_USAGE;
@@ -71,7 +72,7 @@ command_ret_t do_dump_mem(cmd_tbl_t *cmdtp, int flag, int argc, char * const arg
length = (uint16_t) strtoul(argv[2], NULL, 16);
/* Print the lines. */
- dump_mem(addr, addr, length, readhow, NULL);
+ dump_mem(addr, addr, length, readwhat, NULL);
return CMD_RET_SUCCESS;
}
@@ -127,6 +128,83 @@ command_ret_t do_eep_cp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[
}
+/* Modify memory.
+ *
+ * Syntax:
+ * !mm {addr}
+ * !nm {addr}
+ */
+
+ static uint8_t *mm_last_addr;
+
+static command_ret_t
+mod_mem_avr(cmd_tbl_t *cmdtp, int incrflag, int flag, int argc, char * const argv[])
+{
+ uint8_t *addr;
+ uint8_t data;
+ int nbytes;
+
+ (void) cmdtp;
+
+ if (argc != 2)
+ return CMD_RET_USAGE;
+
+ /* We use the last specified parameters, unless new ones are
+ * entered.
+ */
+ addr = mm_last_addr;
+
+ if ((flag & CMD_FLAG_REPEAT) == 0) {
+ /* New command specified.
+ */
+
+ /* Address is specified since argc > 1
+ */
+ addr = (uint8_t *) (size_t) strtoul(argv[1], NULL, 16);
+ }
+
+ /* Print the address, followed by value. Then accept input for
+ * the next value. A non-converted value exits.
+ */
+ do {
+ data = *addr;
+ printf_P(PSTR("%04x: %02x"), addr, data);
+
+ nbytes = cli_readline(PSTR(" ? "));
+ if (nbytes == 0 || (nbytes == 1 && console_buffer[0] == '-')) {
+ /* <CR> pressed as only input, don't modify current
+ * location and move to next. "-" pressed will go back.
+ */
+ if (incrflag)
+ addr += nbytes ? -1 : 1;
+ nbytes = 1;
+
+ } else {
+ char *endp;
+ data = strtoul(console_buffer, &endp, 16);
+ nbytes = endp - console_buffer;
+ if (nbytes) {
+ *addr = data;
+ if (incrflag)
+ addr++;
+ }
+ }
+ } while (nbytes);
+
+ mm_last_addr = addr;
+ return CMD_RET_SUCCESS;
+}
+
+
+command_ret_t do_mem_mm_avr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+ return mod_mem_avr (cmdtp, 1, flag, argc, argv);
+}
+command_ret_t do_mem_nm_avr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+ return mod_mem_avr (cmdtp, 0, flag, argc, argv);
+}
+
/*------------------------------------------------------------------------------*/
#if 1
diff --git a/avr/z180-serv.c b/avr/z180-serv.c
index af1d8e0..7193495 100644
--- a/avr/z180-serv.c
+++ b/avr/z180-serv.c
@@ -491,6 +491,9 @@ int msg_handling(int state)
pending = (Stat & S_MSG_PENDING) != 0;
Stat &= ~S_MSG_PENDING;
}
+/*
+ * TODO: if pending but no message chr --> special condition. ie init,...
+ */
if (pending) {
switch (state) {
diff --git a/include/z80-if.h b/include/z80-if.h
index 58790bd..676d37d 100644
--- a/include/z80-if.h
+++ b/include/z80-if.h
@@ -43,7 +43,7 @@ void z80_read_block (uint8_t *dest, uint32_t src, size_t length);
typedef enum fifo_t {
fifo_msgin, fifo_msgout,
- fifo_conout, fifo_conin,
+ fifo_conin, fifo_conout,
NUM_FIFOS
} fifo_t;
diff --git a/z180/conbuf-a.180 b/z180/conbuf-a.180
index e86b8b2..0a35195 100644
--- a/z180/conbuf-a.180
+++ b/z180/conbuf-a.180
@@ -19,8 +19,8 @@
dseg
- mkbuf co.fifo_id, co.fifo, co.fifo_len
mkbuf ci.fifo_id, ci.fifo, ci.fifo_len
+ mkbuf co.fifo_id, co.fifo, co.fifo_len
;--------------------------------------------------------------
diff --git a/z180/config.inc b/z180/config.inc
index 7b6d7ac..2a8a842 100644
--- a/z180/config.inc
+++ b/z180/config.inc
@@ -151,7 +151,7 @@ AVRINT6 equ 5Fh
; Definition of (logical) top 2 memory pages
sysram_start equ 0FE00h
-stacksize equ 80
+bs$stack$size equ 80
isvsw_loc equ 0FEE0h
@@ -198,3 +198,10 @@ inidate macro
dseg
ds ??ps.len
endm
+
+;-----------------------------------------------------
+
+b0call macro address
+ call _b0call
+ dw address
+ endm
diff --git a/z180/ddtz.180 b/z180/ddtz.180
index aa4e977..4411549 100644
--- a/z180/ddtz.180
+++ b/z180/ddtz.180
@@ -958,11 +958,11 @@ do_op_mod:
jr l0b58h
; divide x/y
-; x: hl
-; y: de
+; hl: x
+; de: y
; return:
-; x/y: hl
-; rem: de
+; hl: q (x/y)
+; de: r (x%y)
DIV_HL_DE:
push bc
@@ -971,6 +971,11 @@ DIV_HL_DE:
ld c,l
ld hl,0 ;r = 0
ld a,16 ;count
+
+; de: x (x shifted out, q shifted in)
+; bc: y
+; hl: r (initially 0)
+
l0b89h:
ex de,hl ;x
add hl,hl ;x <<= 1
@@ -986,7 +991,7 @@ l0b89h:
div_no_restore:
dec a
jr nz,l0b89h
- ex de,hl
+ ex de,hl ;hl: q de: r
pop bc
ret
@@ -6240,9 +6245,9 @@ vartabe:
;------------------------------------------
- .phase sysram_start+stacksize
+ .phase sysram_start+bs$stack$size
$stack:
-$stcka equ $ - stacksize
+$stcka equ $ - bs$stack$size
curphse defl $
.dephase
diff --git a/z180/init.180 b/z180/init.180
index 11f45ec..b0b4b21 100644
--- a/z180/init.180
+++ b/z180/init.180
@@ -361,9 +361,9 @@ buffers:
db 1
dw mrx.fifo
db 2
- dw co.fifo
- db 3
dw ci.fifo
+ db 3
+ dw co.fifo
buftablen equ ($ - buffers)/3
inimsg: