From 6a4e9540b950d871ea8fa072b195490a231b251d Mon Sep 17 00:00:00 2001 From: Leo C Date: Thu, 23 Oct 2014 02:22:01 +0200 Subject: new fifos msg in, msg out, console in, console out --- z180/Tupfile | 3 +- z180/conbuf-a.180 | 130 +++++++++++++++++++++++++++++++++++ z180/config.inc | 6 +- z180/console.180 | 14 ++-- z180/fifoio.180 | 9 +-- z180/msgbuf-a.180 | 201 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ z180/msgbuf-s.180 | 129 +++++++++++++++++++++++++++++++++++ z180/msgbuf.180 | 129 ----------------------------------- z180/r3init.180 | 62 ++++++++++------- 9 files changed, 515 insertions(+), 168 deletions(-) create mode 100644 z180/conbuf-a.180 create mode 100644 z180/msgbuf-a.180 create mode 100644 z180/msgbuf-s.180 delete mode 100644 z180/msgbuf.180 diff --git a/z180/Tupfile b/z180/Tupfile index fc926de..8b50b8a 100644 --- a/z180/Tupfile +++ b/z180/Tupfile @@ -5,7 +5,8 @@ PROG = hdrom SRC = r3init.180 SRC += ddtz.180 #SRC += fifoio.180 msgbuf.180 ser1-i.180 console.180 -SRC += msgfifo.180 ser1-i.180 console.180 +SRC += msgbuf-a.180 conbuf-a.180 ser1-i.180 console.180 +# serial (asci1) console only: #SRC += ser1-i.180 console.180 SRC += romend.180 diff --git a/z180/conbuf-a.180 b/z180/conbuf-a.180 new file mode 100644 index 0000000..3ec84d4 --- /dev/null +++ b/z180/conbuf-a.180 @@ -0,0 +1,130 @@ + page 255 + .z80 + +; +; FIFO channels for communication with avr +; + global ff.init,ff.in,ff.out,ff.i.st + + extrn buf.init + + include config.inc + include z180reg.inc + + +;-------------------------------------------------------------- + + dseg + + + mkbuf co.fifo,co.fifo_len + mkbuf ci.fifo,ci.fifo_len + + +;-------------------------------------------------------------- + + cseg + +; Init Serial I/O for console input and output +; + +ff.init: + ld ix,ci.fifo + ld a,ci.fifo.mask + call buf.init + ld ix,co.fifo + ld a,co.fifo.mask + jp buf.init + + +ff.i.st: + push ix + ld ix,ci.fifo ; + +buf.empty: + ld a,(ix+o.in_idx) ; + sub (ix+o.out_idx) ; + pop ix + ret z + or 0ffh + ret + + +ff.in: + push ix + ld ix,ci.fifo ; + +buf.get: + ld a,(ix+o.out_idx) ; +bg.wait: + cp (ix+o.in_idx) ; + jr z,bg.wait + + push hl ; + push ix + pop hl + add a,l + ld l,a + jr nc,bg.nc + 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 + ret + + +ff.o.st: + push ix + ld ix,co.fifo ; + +buf.full: + ld a,(ix+o.in_idx) ; + inc a + and (ix+o.mask) + sub (ix+o.out_idx) ; + pop ix + ret z + or 0ffh + ret + + +ff.out: + push ix + ld ix,co.fifo ; + +buf.put: + push hl ; + push bc + push ix + pop hl + ld c,(ix+o.in_idx) ; + ld b,0 + add hl,bc + ld b,a + + ld a,c ; + inc a + and (ix+o.mask) +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 + + end + diff --git a/z180/config.inc b/z180/config.inc index 652b5ae..9cef051 100644 --- a/z180/config.inc +++ b/z180/config.inc @@ -41,9 +41,11 @@ CWAITROM equ 2 shl MWI0 DRSTNUM equ 30h ;DDTZ Restart vector (breakpoints) -msg_rx_fifo_len equ 256 -msg_tx_fifo_len equ 256 +mrx.fifo_len equ 256 +mtx.fifo_len equ 256 +ci.fifo_len equ 128 +co.fifo_len equ 256 s1.rx_len equ 256 ;Serial 1 (ASCI1) buffers s1.tx_len equ 256 ; diff --git a/z180/console.180 b/z180/console.180 index 9b0d519..07fb570 100644 --- a/z180/console.180 +++ b/z180/console.180 @@ -8,8 +8,8 @@ extrn ser.init,ser.instat,ser.in,ser.out - extrn msginit,msg.in,msg.out,msgi.st - extrn msg.co + extrn ff.init,ff.i.st,ff.in,ff.out + extrn ff.out include config.inc @@ -20,19 +20,19 @@ ; $coninit: - call msginit + call ff.init call ser.init ret $cists: - call msgi.st + call ff.i.st ret nz call ser.instat ret $ci: - call msgi.st - jp nz,msg.in + call ff.i.st + jp nz,ff.in call ser.instat jp nz,ser.in jr $ci @@ -41,7 +41,7 @@ $ci: ; jp f.o.st $co: - call msg.co + call ff.out jp ser.out end diff --git a/z180/fifoio.180 b/z180/fifoio.180 index 27745d4..dd99c53 100644 --- a/z180/fifoio.180 +++ b/z180/fifoio.180 @@ -1,6 +1,9 @@ page 255 .z80 +; +; FIFO channels for communication with stm32 +; global f.init,f.in,f.out,f.i.st extrn buf.init @@ -21,12 +24,10 @@ ;-------------------------------------------------------------- cseg -; -; FIFO channels for communication with stm32 -; + ; Init Serial I/O for console input and output ; - + f.init: ld ix,rx.buf ld a,rx.buf.mask diff --git a/z180/msgbuf-a.180 b/z180/msgbuf-a.180 new file mode 100644 index 0000000..f52074e --- /dev/null +++ b/z180/msgbuf-a.180 @@ -0,0 +1,201 @@ + 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 + include z180reg.inc + +;-------------------------------------------------------------- + + dseg + + mkbuf mrx.fifo,mrx.fifo_len + mkbuf mtx.fifo,mtx.fifo_len + +;-------------------------------------------------------------- + + cseg + +; +; Init buffer +; + +msginit: + ld ix,mrx.fifo + ld a,mrx.fifo.mask + call buf.init + ld ix,mtx.fifo + ld a,mtx.fifo.mask + jp buf.init + +;-------------------------------------------------------------- + +msgi.st: + push ix + ld ix,mrx.fifo ; + +buf.empty: + ld a,(ix+o.in_idx) ; + sub (ix+o.out_idx) ; + pop ix + ret z + or 0ffh + ret + +;-------------------------------------------------------------- + +msg.in: + push ix + ld ix,mrx.fifo ; + +buf.get: + ld a,(ix+o.out_idx) ; +bg.wait: + cp (ix+o.in_idx) ; + jr z,bg.wait + + push hl ; + push ix + pop hl + add a,l + ld l,a + jr nc,bg.nc + 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 + ret + +;-------------------------------------------------------------- + +msgo.st: + push ix + ld ix,mtx.fifo ; + +buf.full: + ld a,(ix+o.in_idx) ; + inc a + and (ix+o.mask) + sub (ix+o.out_idx) ; + pop ix + ret z + or 0ffh + ret + +;-------------------------------------------------------------- + +msg.out: + push ix + ld ix,mtx.fifo ; + +buf.put: + push hl ; + push bc + push ix + pop hl + ld c,(ix+o.in_idx) ; + ld b,0 + add hl,bc + ld b,a + + ld a,c ; + inc a + and (ix+o.mask) +bp.wait: + cp (ix+o.out_idx) ; + jr z,bp.wait + ld (hl),b + ld (ix+o.in_idx),a + + ld a,b + out0 (AVRINT5),a + pop bc + pop hl + pop ix + ret + + +;-------------------------------------------------------------- +; +; (hl): data + +msg.sout: + push ix + ld ix,mtx.fifo ; + + 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 a,c ; + inc a + and (ix+o.mask) +ms.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 + pop bc + pop ix + ret + +;-------------------------------------------------------------- + +msg.co: + push af + push hl + ld (buf_char),a + ld hl,buf + call msg.sout + pop hl + pop af + ret + + +buf: + db buf_end - $ - 1 ;output string length + db 081h ; message start token + db buf_end - $ - 1 ; message length + db 1 ; command + db 1 ; subcommand +buf_char: + db 0 ; pay load +buf_end: + +;---------------------------------------------------------------------- + + end + diff --git a/z180/msgbuf-s.180 b/z180/msgbuf-s.180 new file mode 100644 index 0000000..2c67527 --- /dev/null +++ b/z180/msgbuf-s.180 @@ -0,0 +1,129 @@ + page 255 + .z80 + + global msg_fifo + global msginit + global msg.out,msg.sout,msg.co + + extrn buf.init + + include config.inc + include z180reg.inc + +;-------------------------------------------------------------- + + dseg + + mkbuf msg_fifo, 0 + + +;-------------------------------------------------------------- + + cseg + +; +; Init buffer +; + +msginit: + ld ix,msg_fifo + ld a,msg_fb_len-1 + jp buf.init + + +;-------------------------------------------------------------- + +msg.sts: + push ix + ld ix,msg_fifo ; + + ld a,(ix+o.in_idx) ; + inc a + and (ix+o.mask) + sub (ix+o.out_idx) ; + pop ix + ret z + or 0ffh + ret + +;-------------------------------------------------------------- + +msg.out: + push ix + ld ix,msg_fifo ; + + push bc + ld b,a ;save char + ld a,(ix+o.in_idx) ; + inc a + and (ix+o.mask) +bp.wait: + cp (ix+o.out_idx) ; + jr z,bp.wait + ld c,a + ld a,b + out (PMSG),a + ld (ix+o.in_idx),c + + pop bc + pop ix + ret + +;-------------------------------------------------------------- +; +; (hl): data + +msg.sout: + push ix + ld ix,msg_fifo ; + push bc + + ld b,(hl) ;count + inc hl +obs_1: + ld a,(ix+o.out_idx) ; + sub (ix+o.in_idx) ; + dec a + and (ix+o.mask) + cp b + jr c,obs_1 + + ld c,(hl) ;port address + inc hl + ld a,b + otir + add (ix+o.in_idx) + and (ix+o.mask) + ld (ix+o.in_idx),a + pop bc + pop ix + ret + +;---------------------------------------------------------------------- + +msg.co: + push af + push hl + ld (buf_char),a + ld hl,buf + call msg.sout + pop hl + pop af + ret + + +buf: + db buf_end - $ - 2 ;output string length + db PMSG ;output port + db 081h ; message start token + db buf_end - $ - 1 ; message length + db 1 ; command + db 1 ; subcommand +buf_char: + db 0 ; pay load +buf_end: + +;---------------------------------------------------------------------- + + end + diff --git a/z180/msgbuf.180 b/z180/msgbuf.180 deleted file mode 100644 index 2c67527..0000000 --- a/z180/msgbuf.180 +++ /dev/null @@ -1,129 +0,0 @@ - page 255 - .z80 - - global msg_fifo - global msginit - global msg.out,msg.sout,msg.co - - extrn buf.init - - include config.inc - include z180reg.inc - -;-------------------------------------------------------------- - - dseg - - mkbuf msg_fifo, 0 - - -;-------------------------------------------------------------- - - cseg - -; -; Init buffer -; - -msginit: - ld ix,msg_fifo - ld a,msg_fb_len-1 - jp buf.init - - -;-------------------------------------------------------------- - -msg.sts: - push ix - ld ix,msg_fifo ; - - ld a,(ix+o.in_idx) ; - inc a - and (ix+o.mask) - sub (ix+o.out_idx) ; - pop ix - ret z - or 0ffh - ret - -;-------------------------------------------------------------- - -msg.out: - push ix - ld ix,msg_fifo ; - - push bc - ld b,a ;save char - ld a,(ix+o.in_idx) ; - inc a - and (ix+o.mask) -bp.wait: - cp (ix+o.out_idx) ; - jr z,bp.wait - ld c,a - ld a,b - out (PMSG),a - ld (ix+o.in_idx),c - - pop bc - pop ix - ret - -;-------------------------------------------------------------- -; -; (hl): data - -msg.sout: - push ix - ld ix,msg_fifo ; - push bc - - ld b,(hl) ;count - inc hl -obs_1: - ld a,(ix+o.out_idx) ; - sub (ix+o.in_idx) ; - dec a - and (ix+o.mask) - cp b - jr c,obs_1 - - ld c,(hl) ;port address - inc hl - ld a,b - otir - add (ix+o.in_idx) - and (ix+o.mask) - ld (ix+o.in_idx),a - pop bc - pop ix - ret - -;---------------------------------------------------------------------- - -msg.co: - push af - push hl - ld (buf_char),a - ld hl,buf - call msg.sout - pop hl - pop af - ret - - -buf: - db buf_end - $ - 2 ;output string length - db PMSG ;output port - db 081h ; message start token - db buf_end - $ - 1 ; message length - db 1 ; command - db 1 ; subcommand -buf_char: - db 0 ; pay load -buf_end: - -;---------------------------------------------------------------------- - - end - diff --git a/z180/r3init.180 b/z180/r3init.180 index 1936c9b..2dd1bb8 100644 --- a/z180/r3init.180 +++ b/z180/r3init.180 @@ -313,7 +313,7 @@ buf.init: ret ;---------------------------------------------------------------------- - +if 0 extrn msginit,msg_tx_fifo,msg_rx_fifo extrn msg.sout @@ -325,19 +325,19 @@ bufferinit: ld (40h+0),hl ld (40h+2),a - ld (bufdat+1),hl - ld (bufdat+3),a - xor a - ld (bufdat+0),a - ld hl,inimsg - call msg.sout +; 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,1 + ld a,2 ld (bufdat+0),a ld hl,inimsg call msg.sout @@ -355,50 +355,63 @@ bufdat: db 0 inimsg_e: +endif ;---------------------------------------------------------------------- ; -if 0 - extrn msginit,msg.sout,msg_fifo - extrn tx.buf,rx.buf + extrn msginit,msg.sout + extrn mtx.fifo,mrx.fifo + extrn co.fifo,ci.fifo bufferinit: call msginit ld hl,buffers - ld bc,0300h ; b:count, c:buffer nr + 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 a,c - ld (bufdat+0),a ld hl,inimsg call msg.sout +bfi_3: pop hl - inc c djnz bfi_1 ret - rept 20 - db 0 - endm - buffers: - dw msg_fifo - dw tx.buf - dw rx.buf + 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 - $ -2 - db PMSG + db inimsg_e - $ -1 db 81h db inimsg_e - $ -1 db 0 @@ -408,7 +421,6 @@ bufdat: db 0 inimsg_e: -endif ; ;---------------------------------------------------------------------- -- cgit v1.2.3