summaryrefslogtreecommitdiff
path: root/z180
diff options
context:
space:
mode:
authorLeo C2015-06-09 09:31:33 +0200
committerLeo C2015-06-09 09:31:33 +0200
commit8bbf185ed81c12534c0ad9b26f0049035fde8df4 (patch)
treee250b318b3486acd854cf831138cba42fafdadd3 /z180
parentb08e079d1541c80028e3a11affec3f863eb9129d (diff)
downloadz180-stamp-8bbf185ed81c12534c0ad9b26f0049035fde8df4.zip
message buffer init changes. cp/m r/w for new memory map
Diffstat (limited to 'z180')
-rw-r--r--z180/conbuf-a.1808
-rw-r--r--z180/config.inc22
-rw-r--r--z180/ddtz.180480
-rw-r--r--z180/init.180113
-rw-r--r--z180/msgbuf-a.18084
5 files changed, 372 insertions, 335 deletions
diff --git a/z180/conbuf-a.180 b/z180/conbuf-a.180
index 0a35195..f69b86d 100644
--- a/z180/conbuf-a.180
+++ b/z180/conbuf-a.180
@@ -6,7 +6,7 @@
;
global ff.init,ff.in,ff.out,ff.i.st,ff.o.st
- extrn buf.init
+ extrn bufinit
include config.inc
if CPU_Z180
@@ -32,11 +32,9 @@
ff.init:
ld ix,ci.fifo
- ld a,ci.fifo.mask
- call buf.init
+ call bufinit
ld ix,co.fifo
- ld a,co.fifo.mask
- jp buf.init
+ jp bufinit
ff.i.st:
diff --git a/z180/config.inc b/z180/config.inc
index ffab6e6..1d0709d 100644
--- a/z180/config.inc
+++ b/z180/config.inc
@@ -48,22 +48,34 @@ PRT_PRE equ 20 ;PRT prescaler
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
+CMN_SIZE equ COMMON_SIZE/1000h ;4K units
+BNK_SIZE equ 64/4 - CMN_SIZE ;bank size (4K units)
+BANKS equ (512/4 - CMN_SIZE)/BNK_SIZE ;max nr. of banks
+
+; Logical address space, CBAR values
-CSK equ COMMON_SIZE/1000h ;
-CA equ 10h - CSK ;common area start
-BA equ 0 ;banked area start
+CA equ 10h - CMN_SIZE ;common area start (64K - common size)
+BA equ 0 ;banked area start
+
+ if 0
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)
+ endif
+ if 1
+
+SYS$CBR equ BNK_SIZE
+SYS$CBAR equ CA*16 + CA ;CBAR in system mode
+USR$CBAR equ CA*16 + BA ;CBAR in user mode (CP/M)
+
+ endif
-BANKS equ 18 ;max nr. of banks
;-----------------------------------------------------
diff --git a/z180/ddtz.180 b/z180/ddtz.180
index 4411549..d5b921b 100644
--- a/z180/ddtz.180
+++ b/z180/ddtz.180
@@ -2197,294 +2197,294 @@ b_0x132A_start:
DC 'F'
DB 0
b_0x136C_start:
- if ROMSYS
- defb 000h
- defw uromen
+ if ROMSYS
+ defb 000h
+ defw uromen
endif
if CPU_Z180
- defb 000h
- defw ucbar
- defb 000h
- defw ubbr
+ defb 000h
+ defw ucbar
+ defb 000h
+ defw ubbr
else
- defb 000h
- defw ubnk
+ 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
+ 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)
- call get_lastarg_def
+ ld hl,(lst.S)
+ call get_lastarg_def
l13d8h:
- ld (lst.S),hl
- call out.hl.@
- call OUTBL
+ ld (lst.S),hl
+ call out.hl.@
+ call OUTBL
comst
- ld a,(hl)
+ ld a,(hl)
comend
- 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
+ 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
- call get_bytes_m
- jr l13d8h
+ dec de
+ call get_bytes_m
+ jr l13d8h
CMD.@:
- call assert_eol
- ld hl,MSG_at
- ld de,offs.@
- ld c,001h
- jp l1279h
+ call assert_eol
+ ld hl,MSG_at
+ ld de,offs.@
+ ld c,001h
+ jp l1279h
MSG_at:
dc '@'
CMD.I:
- 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
+ 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
+ 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)
- jr l1444h
+ ld a,(hl)
+ jr l1444h
l1442h:
endif
- in a,(c)
+ in a,(c)
l1444h:
- push af
- call out.hex
- call outbl4
- pop af
- call out.bin.b
- jp CRLF
+ push af
+ call out.hex
+ call outbl4
+ pop af
+ call out.bin.b
+ jp CRLF
CMD.O:
- 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
+ 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
+ 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:
endif
- pop af
- out (c),a
+ pop af
+ out (c),a
ret
if CPU_Z180
l148dh:
- pop af
- ld (hl),a
- ret
+ pop af
+ ld (hl),a
+ ret
endif
CMD.V:
- call get_arg3 ;1490 get from, size, to
+ call get_arg3 ;1490 get from, size, to
cmp_mem:
- push bc
+ push bc
comst
- ld a,(de)
- ld b,(hl)
+ ld a,(de)
+ ld b,(hl)
comend
- 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
+ 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
- inc hl
- inc de
- dec bc
- ld a,b
- or c
- jr nz,cmp_mem
+ pop bc
+ inc hl
+ inc de
+ dec bc
+ ld a,b
+ or c
+ jr nz,cmp_mem
ret
CMD.M:
- ld a,(de)
- cp 'V'
- jr nz,bm_nv
- inc de
+ ld a,(de)
+ cp 'V'
+ jr nz,bm_nv
+ inc de
bm_nv:
- push af ;14c9 save 'V' flag
- 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
+ push af ;14c9 save 'V' flag
+ 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
+ lddr
comend
- jr bm_done
+ jr bm_done
bm_mvdown:
comst
ldir
comend
bm_done:
- pop bc
- pop de
- pop hl
- pop af
- jr z,cmp_mem ;14ed validate?
+ pop bc
+ pop de
+ pop hl
+ pop af
+ jr z,cmp_mem ;14ed validate?
ret
CMD.H:
- 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
+ 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
- call sub_0928h ;1517 -val
- call outbl4
- call out.hl.dec ;151d dec
- call outbl2
- call out.hl.decm ;1523 -dec
- call outbl4
- call out.bin.w ;1529 bin
- call outbl2
- ld a,l
- call out.ascii
- jp CRLF
+ call out.hl ;1511 val
+ call outbl2
+ call sub_0928h ;1517 -val
+ call outbl4
+ call out.hl.dec ;151d dec
+ call outbl2
+ call out.hl.decm ;1523 -dec
+ call outbl4
+ call out.bin.w ;1529 bin
+ call outbl2
+ ld a,l
+ call out.ascii
+ jp CRLF
CMD.Q:
ld a,(de)
diff --git a/z180/init.180 b/z180/init.180
index 4c7bd77..05c24ff 100644
--- a/z180/init.180
+++ b/z180/init.180
@@ -76,7 +76,7 @@ start:
hwini0:
if CPU_Z180
- db 3 ;count
+ db ;count
db rcr,CREFSH ;configure DRAM refresh
db dcntl,INIWAITS ;wait states
db cbr,SYS$CBR
@@ -152,7 +152,7 @@ hw_reset:
kstart:
if CPU_Z180
- ld a,SYS$CBR
+ ld a,SYS$CBR ;TODO:
out0 (cbr),a
ld a,SYS$CBAR
out0 (cbar),a
@@ -192,8 +192,8 @@ wstart:
; call prt0_init
endif
+ call msginit
call charini
- call bufferinit
if CPU_Z80
ld a,0
@@ -228,86 +228,66 @@ syscbr: db 0
;----------------------------------------------------------------------
;
- global buf.init
+ global bufinit
-buf.init:
- ld (ix+o.in_idx),0
+bufinit:
+ ld (ix+o.in_idx),0 ;reset pointers (empty fifo)
ld (ix+o.out_idx),0
-
ld a,(ix+o.id)
- cp 4
- ret nc
-
- push de
- push hl
- ld hl,fifo_list
- push hl ;save fifo_list
+ ld hl,fifolst
ld e,a
ld d,0
add hl,de
add hl,de
push ix
pop de
+ cp 4
+ jr nc,bfi_skip
+
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
+bfi_skip:
+ ex de,hl
+ call hwl2phy ;get phys. address of fifo
+ ld c,a
+ ld a,(ix+o.id) ;fifo id
+ or a ;test if fifo 0
+ ret z
+ ld b,a
+ push bc ;c: bank-addr, b: ignored
+ push hl ;address
+ ld c,0
+ push bc ;c: function, b:subf
+ ld b,5
+ ld h,c
+ ld l,c
+ add hl,sp
+ call msg.sm
+ pop hl
+ pop hl
+ pop hl
ret
-
-fifo_list:
+ public fifolst
+fifolst :
rept 4
dw 0
endm
;----------------------------------------------------------------------
+ extrn msg.sm
extrn msginit,msg.sout
extrn mtx.fifo,mrx.fifo
- extrn co.fifo,ci.fifo
+ extrn ff.init,co.fifo,ci.fifo
-bufferinit:
+fifoinit:
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
@@ -351,27 +331,7 @@ bfi_3:
ret
endif
-buffers:
- db 0
- dw mtx.fifo
- db 1
- dw mrx.fifo
- db 2
- dw ci.fifo
- db 3
- dw co.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:
+
;
@@ -612,6 +572,7 @@ l2p_i:
;
;out ahl: Phys. (linear) Address
+ public hwl2phy
hwl2phy:
push bc ;
diff --git a/z180/msgbuf-a.180 b/z180/msgbuf-a.180
index 7e8c9cc..3575569 100644
--- a/z180/msgbuf-a.180
+++ b/z180/msgbuf-a.180
@@ -1,12 +1,13 @@
page 255
.z80
- global mrx.fifo,mtx.fifo
+ public mrx.fifo,mtx.fifo
- global msginit,msgi.st,msg.in,msgo.st,msg.out
- global msg.sout
+ public msginit,msgi.st,msg.in,msgo.st
+ public msg.sm,msg.sout
- extrn buf.init
+ extrn bufinit,hwl2phy
+ extrn fifolst
include config.inc
if CPU_Z180
@@ -29,12 +30,25 @@
;
msginit:
+ ld a,(043h)
+;TODO: value should be 0
ld ix,mtx.fifo
- ld a,mtx.fifo.mask
- call buf.init
+ call bufinit
+ push ix
+ pop hl
+ call hwl2phy
+ ld (040h),hl
+ ld (040h+2),a
+ ld a,0ffh
+ ld (043h),a
+ out (AVRINT5),a
+wait:
+ ld a,(043h)
+ or a
+ jr nz,wait
+
ld ix,mrx.fifo
- ld a,mrx.fifo.mask
- jp buf.init
+ jp bufinit
;--------------------------------------------------------------
@@ -136,7 +150,7 @@ bp.wait:
;--------------------------------------------------------------
-
+ if 0
msg.out:
push ix
@@ -165,6 +179,36 @@ bp.wait:
pop ix
ret
+ endif
+
+;----------------------------------------------------------------------
+;
+; Put char in message buffer:
+; ix: buffer to put into
+; c: char
+
+buf.put:
+ push ix ;15
+ push bc ;11
+ ld a,(ix+o.in_idx) ;19
+ ld c,a ;4
+ ld b,0 ;7
+ add ix,bc ;11
+ pop bc ;10
+ ld (ix),c ;7
+ pop ix ;14
+
+ inc a ;4
+ and (ix+o.mask) ;19 =121
+bufp.wait:
+ cp (ix+o.out_idx) ;19
+ jr z,bufp.wait ;12/7
+ ld (ix+o.in_idx),a ;19
+
+ out (AVRINT5),a ;11
+ ld a,c ;4
+ ret ;10 =191
+
;--------------------------------------------------------------
@@ -305,4 +349,26 @@ buf_end:
;----------------------------------------------------------------------
+;----------------------------------------------------------------------
+; Send message MEMORY
+;
+; hl: pointer to message (netto)
+; b: msg length
+
+msg.sm:
+ push ix
+ ld ix,mtx.fifo
+ ld c,0AEh
+ call buf.put
+ ld c,b
+ call buf.put
+msm_l:
+ ld c,(hl)
+ inc hl
+ call buf.put
+ djnz msm_l
+ pop ix
+ ret
+
+
end