Skip to content

Commit ca2db61

Browse files
committed
Initial commit.
0 parents  commit ca2db61

File tree

6 files changed

+1990
-0
lines changed

6 files changed

+1990
-0
lines changed

Changelog.txt

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
Changelog
2+
---------
3+
4+
27/07/18
5+
6+
- COUTdone removed (not necessary to wait for character to be output
7+
before switching I/O page).
8+
9+
- Code optimizations, e.g.
10+
ex de,hl instead of ld l,e + ld h,d
11+
or a instead of cp 0
12+
jr xxx instead of jp xxx (where applicable)
13+
djnz ... where applicable
14+
15+
- Better HEXOUT routine.
16+
17+
- HEX file checksum check done by 'add b' instead of 'neg a + cp b'
18+
19+
- CIN calls COUT to echo the character, instead of sending it directly to
20+
the UART TX port (TX might be busy, although unlikely).
21+
22+
23+
03/04/20
24+
25+
- Boot RSX280 option.
26+
27+
- G command calls (instead of jumping to) the user program.
28+
29+
30+
04/04/20
31+
32+
- Prevent endless loop of D command when end adress is FFFF.
33+
34+
- Allow ending E command with a dot as well as with an 'X'.
35+
36+
37+
12/04/20
38+
39+
- Boot UZI280 option (requires installing a suitable bootloader on block 0
40+
of the UZI partition).
41+

Install.txt

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
ZZmon installation
2+
------------------
3+
4+
- Remove the boot jumper on the Z280RC board.
5+
6+
- Connect the Z280RC to the PC via the USB adapter and power it with 5V
7+
supply as usual.
8+
9+
- Start your favorite terminal program and connect to the Z280RC serial
10+
adapter (under Linux it will be /dev/ttyUSB0 or so).
11+
12+
- Press the reset button on the Z280RC board to ensure the Z280 CPU is
13+
ready to accept the serial boot program. Nothing will appear on the
14+
screen.
15+
16+
- From your favorite terminal program, send the loadngo.run file using
17+
binary mode:
18+
19+
TinyLoad 1.1
20+
G xxxx when done
21+
........................................................................
22+
........................................................................
23+
........................................................X
24+
25+
TinyZZ Monitor v2.0 12-Apr-2020
26+
27+
28+
>
29+
30+
- Use the C command to copy the boot loader and ZZmon to the Compact Flash.
31+
32+
- Restore the boot jumper and reset the board.
33+
34+
35+
Notes:
36+
37+
- Sometimes the CF hangs when removing/replacing the boot jumper and either
38+
ZZmon cannot be saved with the C command or the board will not boot again
39+
even after pressing the reset button. In that case recycling power restores
40+
operation.
41+
42+
- Sometimes sending the loadngo.run file is too fast for the z280rc to handle;
43+
in that case you can try adding a small delay after each byte sent (if your
44+
terminal program supports such option), or you can do the transfer in two
45+
steps:
46+
47+
1) send the loadngo.bin file.
48+
2) at the 'TinyLoad' prompt, send the zzmon.hex file.
49+

Makefile

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
all: zzmon.hex loadngo.run
2+
3+
test: zzmon0.hex
4+
5+
# build release version
6+
zzmon.rel: zzmon.mac
7+
zxcc zsm4 -"=zzmon/dtest=0/l"
8+
9+
zzmon.hex: zzmon.rel mkhex
10+
zxcc drlink -"zzmon.bin=zzmon[nr,lB200]"
11+
mkhex -l 0xb200 -e 0xb400 zzmon.bin zzmon.hex
12+
13+
# build test version (loads at 0000h)
14+
zzmon0.rel: zzmon.mac
15+
zxcc zsm4 -"=zzmon/dtest=1/l"
16+
17+
zzmon0.hex: zzmon0.rel mkhex
18+
zxcc drlink -"zzmon0.bin=zzmon[nr,l0]"
19+
mkhex zzmon0.bin zzmon0.hex
20+
21+
# build serial bootstrap loader
22+
loadngo.rel: loadngo.mac
23+
zxcc zsm4 -"=loadngo/l"
24+
25+
loadngo.bin: loadngo.rel
26+
zxcc drlink -"loadngo.bin=loadngo[nr,l0]"
27+
28+
loadngo.run: loadngo.bin zzmon.hex
29+
cat loadngo.bin zzmon.hex > loadngo.run
30+
31+
# build the bin to hex converter
32+
mkhex: mkhex.c
33+
cc -o $@ $<
34+
35+
clean:
36+
rm -f mkhex *.rel *.prn *.bin *.hex *.run *~

loadngo.mac

+138
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
; Loader program for the serial bootstrap mode of the Z280 CPU.
2+
3+
; The program is load at address 0, and then waits for an Intel HEX
4+
; file to be loaded.
5+
6+
.z280
7+
8+
CR equ 0Dh
9+
LF equ 0Ah
10+
11+
cseg
12+
13+
LOADER: ld sp,0 ; set stack to top of memory
14+
ld c,8 ; I/O page reg
15+
ld l,0FEh ; UART I/O page
16+
ldctl (c),hl
17+
ld a,11100010b
18+
out (10h),a ; UART config reg
19+
ld a,10000000b
20+
out (12h),a ; UART TX status/ctrl reg
21+
out (14h),a ; UART RX status/ctrl reg
22+
IF 1
23+
ld hl,LOGMSG
24+
call PUTSTR
25+
ENDIF
26+
LOOP: call GETC ; get char
27+
cp ':'
28+
jr z,HEXREC ; branch if start of Intel HEX record
29+
call UCASE
30+
cp 'G'
31+
jr nz,LOOP ; ignore if not a 'G'o command
32+
call PUTC
33+
ld a,' '
34+
call PUTC
35+
call GETHEX ; get start address
36+
ld h,a
37+
call GETHEX
38+
ld l,a
39+
jp (hl) ; exec program
40+
41+
HEXREC: call GETHEX ; get record length
42+
ld b,a ; into reg B
43+
ld c,a ; checksum in reg C
44+
call GETHEX ; get hi addr
45+
ld h,a ; into reg H
46+
add a,c
47+
ld c,a
48+
call GETHEX ; get lo addr
49+
ld l,a ; into reg L
50+
add a,c
51+
ld c,a
52+
call GETHEX ; get record type
53+
or a
54+
jr z,DATA ; branch if data
55+
dec a
56+
ld a,'U'
57+
jr nz,next ; error if not EOF (unknown)
58+
call GETHEX ; get checksum
59+
ld a,'X'
60+
call PUTC ; indicate we're done
61+
ld a,CR
62+
call PUTC
63+
ld a,LF
64+
call PUTC
65+
jp (hl) ; exec program
66+
67+
DATA: add a,c ; update checksum
68+
ld c,a
69+
inc b
70+
dec b
71+
jr z,endrec ; branch if record length is zero
72+
load: call GETHEX ; get data byte
73+
ld (hl),a ; store it
74+
add a,c
75+
ld c,a ; update checksum
76+
inc hl
77+
djnz load
78+
endrec: call GETHEX
79+
add a,c ; checksum must be zero
80+
ld a,'?'
81+
jr nz,next ; else display error
82+
ld a,'.' ; display progress
83+
next: call PUTC
84+
jp LOOP
85+
86+
GETHEX: call GETC
87+
call ASCHEX
88+
rlca
89+
rlca
90+
rlca
91+
rlca
92+
ld e,a
93+
call GETC
94+
call ASCHEX
95+
or e
96+
ret
97+
98+
ASCHEX: call UCASE
99+
sub '0'
100+
cp 10
101+
ret c
102+
sub 7
103+
and 0Fh
104+
ret
105+
106+
UCASE: cp 'a'
107+
ret c
108+
cp 'z'+1
109+
ret nc
110+
and 5Fh
111+
ret
112+
113+
PUTSTR: ld a,(hl)
114+
or a
115+
ret z
116+
call PUTC
117+
inc hl
118+
jr PUTSTR
119+
120+
GETC: in a,(14h) ; UART RX status/ctrl reg
121+
and 10h
122+
jr z,GETC
123+
in a,(16h) ; UART RX data reg
124+
ret
125+
126+
PUTC: ld e,a
127+
twait: in a,(12h) ; UART TX status/ctrl reg
128+
and 01h
129+
jr z,twait
130+
ld a,e
131+
out (18h),a ; UART TX data reg
132+
ret
133+
134+
LOGMSG: db CR,LF,'TinyLoad 1.1'
135+
db CR,LF,'G xxxx when done'
136+
db CR,LF,0
137+
138+
end LOADER

mkhex.c

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#include <stdio.h>
2+
#include <string.h>
3+
#include <stdlib.h>
4+
#include <errno.h>
5+
6+
int usage(char *progname) {
7+
fprintf(stderr, "Usage: %s [-l addr] [-e addr] input_file output file\n", progname);
8+
return -1;
9+
}
10+
11+
int main(int argc, char *argv[]) {
12+
char *srcfn = NULL, *dstfn = NULL;
13+
FILE *src, *dst;
14+
int i, nb, addr = 0, ept = 0;
15+
unsigned cks, b;
16+
unsigned char bfr[16];
17+
18+
if (argc < 3) {
19+
return usage(argv[0]);
20+
}
21+
22+
for (i = 1; i < argc; ++i) {
23+
if (strcmp(argv[i], "-l") == 0) {
24+
if (++i == argc) return usage(argv[0]);
25+
addr = strtol(argv[i], NULL, 0);
26+
} else if (strcmp(argv[i], "-e") == 0) {
27+
if (++i == argc) return usage(argv[0]);
28+
ept = strtol(argv[i], NULL, 0);
29+
} else {
30+
if (!srcfn) {
31+
srcfn = argv[i];
32+
} else if (!dstfn) {
33+
dstfn = argv[i];
34+
} else {
35+
return usage(argv[0]);
36+
}
37+
}
38+
}
39+
40+
src = fopen(srcfn, "rb");
41+
if (src == NULL) {
42+
fprintf(stderr, "Could not open source file \"%s\": %s\n\n",
43+
srcfn, strerror(errno));
44+
return -1;
45+
}
46+
47+
dst = fopen(dstfn, "w");
48+
if (dst == NULL) {
49+
fprintf(stderr, "Could not create destination file \"%s\": %s\n\n",
50+
dstfn, strerror(errno));
51+
fclose(src);
52+
return -1;
53+
}
54+
55+
while (!feof(src)) {
56+
nb = fread(&bfr, 1, 16, src);
57+
if (nb == 0) break;
58+
fprintf(dst, ":%02X%04X00", nb, addr);
59+
cks = nb + ((addr >> 8) & 0xFF) + (addr & 0xFF);
60+
for (i = 0; i < nb; ++i) {
61+
cks += bfr[i];
62+
fprintf(dst, "%02X", (unsigned char) bfr[i]);
63+
}
64+
fprintf(dst, "%02X\n", (unsigned char) ((256-cks) & 0xFF));
65+
addr += nb;
66+
}
67+
68+
#if 0
69+
fprintf(dst, ":0000000000\n");
70+
#else
71+
cks = 0x01 + ((ept >> 8) & 0xFF) + (ept & 0xFF);
72+
fprintf(dst, ":00%04X01%02X\n", ept, (unsigned char) ((256-cks) & 0xFF));
73+
#endif
74+
75+
fclose(src);
76+
fclose(dst);
77+
}

0 commit comments

Comments
 (0)