summaryrefslogtreecommitdiff
path: root/z180/init.180
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/init.180
parentbf5870430d2d1903b6dcdf1431d80b261f9a5d45 (diff)
downloadz180-stamp-2fa1a7069a9709f8d61a198cec1b1d9b2e275fe1.zip
Z180 banking updates
Diffstat (limited to 'z180/init.180')
-rw-r--r--z180/init.180191
1 files changed, 70 insertions, 121 deletions
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 ;