summaryrefslogtreecommitdiff
path: root/z180
diff options
context:
space:
mode:
authorLeo C2015-05-05 15:42:49 +0200
committerLeo C2015-05-05 15:42:49 +0200
commit2fa1a7069a9709f8d61a198cec1b1d9b2e275fe1 (patch)
tree9b3bab40decfe7552f257706f6a9d41852fc7773 /z180
parentbf5870430d2d1903b6dcdf1431d80b261f9a5d45 (diff)
downloadz180-stamp-2fa1a7069a9709f8d61a198cec1b1d9b2e275fe1.zip
Z180 banking updates
Diffstat (limited to 'z180')
-rw-r--r--z180/config.inc5
-rw-r--r--z180/init.180191
-rw-r--r--z180/msgbuf-a.180183
3 files changed, 217 insertions, 162 deletions
diff --git a/z180/config.inc b/z180/config.inc
index ed98656..33152de 100644
--- a/z180/config.inc
+++ b/z180/config.inc
@@ -2,6 +2,8 @@
FALSE equ 0
TRUE equ NOT FALSE
+banked equ true
+
;-----------------------------------------------------
; CPU and BANKING types
@@ -35,7 +37,7 @@ PRT_TC10MS equ PHI / (PRT_PRE/10)
COMMON_SIZE equ 4*1024 ;Common Area size in bytes
;must be multiple of 4K
-if (COMMON_SIZE mod 1000h)
+if (COMMON_SIZE mod 1000h)
.printx COMMON_SIZE not multiple of 4K!
end ;stop assembly
endif
@@ -168,4 +170,3 @@ inidate macro
dseg
ds ??ps.len
endm
-
diff --git a/z180/init.180 b/z180/init.180
index 73a77bb..f43aaeb 100644
--- a/z180/init.180
+++ b/z180/init.180
@@ -235,51 +235,6 @@ buf.init:
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
@@ -300,27 +255,27 @@ bfi_1:
inc hl
ld d,(hl)
inc hl
- push hl
+ ex de,hl
or a
jr nz,bfi_2
- call hw_log2phys
+ call hwl2phy
ld (40h+0),hl
ld (40h+2),a
- out0 (AVRINT5),a
+ out (AVRINT5),a
jr bfi_3
bfi_2:
- call hw_log2phys
+ call hwl2phy
ld (bufdat+1),hl
ld (bufdat+3),a
ld hl,inimsg
call msg.sout
bfi_3:
- pop hl
+ ex de,hl
djnz bfi_1
ret
- else
+ else ;CPU_Z180
call msginit
@@ -340,7 +295,7 @@ bfi_1:
jr nz,bfi_2
ld a,(@cbnk)
- call bnk2phys
+ call bnk2phy
ld (40h+0),hl
ld (40h+2),a
@@ -349,7 +304,7 @@ bfi_1:
bfi_2:
ld a,(@cbnk)
- call bnk2phys
+ call bnk2phy
ld (bufdat+1),hl
ld (bufdat+3),a
@@ -548,115 +503,109 @@ io.ini.l:
;
if CPU_Z180
-; a: Bank number
+;--------------------------------------------------------------------
+; Return the BBR value for the given bank number
;
+; in a: Bank number
; out a: bbr value
bnk2log:
- push bc
- ld b,a
- ld c,CA
- mlt bc
- add a,10h
- pop bc
- ret
+ or a ;
+ ret z ; Bank 0 is at physical address 0
-; de: Log. Address
-; a: Bank number
+ 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
-bnk2phys:
+bnk2phy:
call bnk2log
-
; fall thru
+
;--------------------------------------------------------------
;
-; de: Log. Address
+; hl: Log. Address
; a: Bank base (bbr)
;
-; OP: ahl = (a<<12) + (d<<8) + e
+; 2 0 0
+; 0 6 8 0
+; hl hhhhhhhhllllllll
+; a + bbbbbbbb
+;
+; OP: ahl = (a<<12) + (h<<8) + l
;
;out ahl: Phys. (linear) Address
-
-log2phys:
+log2phy:
push bc ;
+l2p_i:
ld c,a ;
ld b,16 ;
- mlt bc ; bc = a<<4
- ld l,d ;4
- ld h,0 ;6
- add hl,bc ;7 bc + d == a<<4 + d
- ld a,h ;4
- ld h,l ;4
- ld l,e ;4
- pop bc ;
- ret ;
-
- if 0
-
-log2phys:
- push bc ;
- ld b,a ;
- ld c,16 ;
mlt bc ; bc = a<<4
- ld a,c ;4
- add a,h ;4
- ld h,a ;4
- ld a,b ;4
- adc a,0 ;6
+ ld a,c ;
+ add a,h ;
+ ld h,a ;
+ ld a,b ;
+ adc a,0 ;
pop bc ;
ret ;
- endif
;--------------------------------------------------------------
;
-; de: Log. Address
-;
+; hl: Log. Address
+;
;
; OP: ahl = (bankbase<<12) + (d<<8) + e
;
;out ahl: Phys. (linear) Address
-hw_log2phys:
+hwl2phy:
push bc ;
- in0 c,(cbar)
- ld a,d
- or 00fh
+ in0 c,(cbar) ;
+ ld a,h ;
+ or 00fh ; log. addr in common1?
cp c
jr c,hlp_1
- in0 c,(cbr)
- jr hlp_e
+
+ in0 a,(cbr) ; yes, cbr is address base
+ jr hl2p_x
hlp_1:
- ld b,16
+ ld b,16 ; log. address in baked area?
mlt bc
- ld a,d
+ ld a,h
cp c
- ld c,0
- jr c,hlp_e
- in0 c,(bbr)
-hlp_e:
- 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 ;
+ 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
-;
+
+ else ;CPU_Z180
+
;----------------------------------------------------------------------
;
-bnk2phys:
+bnk2phy:
sla h
jr nc,b2p_1 ;A15=1 --> common
ld a,3
@@ -693,18 +642,18 @@ topcodsys:
; Save cbar
isv_sw: ;
- ex (sp),hl ; save hl, return adr in hl
+ ex (sp),hl ;save hl, 'return adr' in hl
push de ;
push af ;
- ex de,hl ;
+ ex de,hl ;'return address' in de
ld hl,0 ;
add hl,sp ;
ld a,h ;
cp 0f8h ;
- jr nc,isw_1 ;
+ jr nc,isw_1 ;stack allready in top ram
ld sp,$stack ;
isw_1:
- push hl ;
+ push hl ;save user stack pointer
in0 h,(cbar) ;
push hl ;
ld a,SYS$CBAR ;
diff --git a/z180/msgbuf-a.180 b/z180/msgbuf-a.180
index 1bdd826..ddb2d93 100644
--- a/z180/msgbuf-a.180
+++ b/z180/msgbuf-a.180
@@ -1,11 +1,11 @@
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
@@ -27,7 +27,7 @@
;
; Init buffer
;
-
+
msginit:
ld ix,mrx.fifo
ld a,mrx.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
@@ -100,6 +100,8 @@ buf.full:
;--------------------------------------------------------------
+ if 0
+
msg.out:
push ix
ld ix,mtx.fifo ;
@@ -122,7 +124,7 @@ bp.wait:
jr z,bp.wait
ld (hl),b
ld (ix+o.in_idx),a
-
+
ld a,b
out (AVRINT5),a
pop bc
@@ -130,50 +132,154 @@ bp.wait:
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,ms.wait
- ld c,a
- ld a,(de)
- inc de
- ld (hl),a
- ld (ix+o.in_idx),c
- djnz ms.ol
+ jr z,bp.wait ;
+ ld (ix+o.in_idx),a ;
+
+ ld a,b
out (AVRINT5),a
- ex de,hl
- pop de
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,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:
@@ -185,8 +291,8 @@ msg.co:
pop hl
pop af
ret
-
-
+
+
buf:
db buf_end - $ - 1 ;output string length
db 0AEh ; message start token
@@ -200,4 +306,3 @@ buf_end:
;----------------------------------------------------------------------
end
-