]> cloudbase.mooo.com Git - z180-stamp-cpm3.git/blob - cbios/conbuf.180
file reorg. move routines, that are mainly used in initialization to banked area
[z180-stamp-cpm3.git] / cbios / conbuf.180
1 page 255
2 .z80
3
4 ;
5 ; FIFO channels for communication with avr
6 ;
7 global ff.init,ff.in,ff.ist,ff.out,ff.ost
8
9 extrn bufinit,fifolst
10
11 include config.inc
12 if CPU_Z180
13 include z180reg.inc
14 endif
15
16
17 mkbuf ci.fifo_id, ci.fifo, ci.fifo_len
18 mkbuf co.fifo_id, co.fifo, co.fifo_len
19
20 ici equ ci.fifo_id * 3
21 ico equ co.fifo_id * 3
22
23
24 ;--------------------------------------------------------------
25
26 ; Init Serial I/O for console input and output
27 ;
28 dseg
29 ff.init:
30 ld a,(INIDONE)
31 cp INIDONEVAL
32 ret z
33
34 ld ix,ci.fifo
35 call bufinit
36 ld ix,co.fifo
37 jp bufinit
38
39 ;--------------------------------------------------------------
40
41 cseg
42 ff.ist:
43 push ix
44 ld ix,(fifolst+ici) ;
45
46 buf.empty:
47 ld a,(ix+o.in_idx) ;
48 sub (ix+o.out_idx) ;
49 pop ix
50 ret z
51 or 0ffh
52 ret
53
54
55 ff.in:
56 push ix
57 ld ix,(fifolst+ici) ;
58
59 buf.get:
60 ld a,(ix+o.out_idx) ;
61 bg.wait:
62 cp (ix+o.in_idx) ;
63 jr z,bg.wait
64
65 push hl ;
66 push ix
67 pop hl
68 add a,l
69 ld l,a
70 jr nc,bg.nc
71 inc h
72 bg.nc:
73 ld l,(hl)
74
75 ld a,(ix+o.out_idx) ;
76 inc a
77 and (ix+o.mask)
78 ld (ix+o.out_idx),a
79
80 ld a,l
81 pop hl
82 pop ix
83 ret
84
85 ;--------------------------------------------------------------
86
87 ff.ost:
88 push ix
89 ld ix,(fifolst+ico) ;
90
91 buf.full:
92 ld a,(ix+o.in_idx) ;
93 inc a
94 and (ix+o.mask)
95 sub (ix+o.out_idx) ;
96 pop ix
97 ret z
98 or 0ffh
99 ret
100
101
102 if 1
103 ff.out:
104 push ix ;15
105 ld ix,(fifolst+ico) ;
106
107 buf.put:
108 push hl ;11
109 push bc ;11
110 push ix ;15
111 pop hl ;10
112 ld a,c ;4
113 ld c,(ix+o.in_idx) ;19
114 ld b,0 ;7
115 add hl,bc ;11
116 ld (hl),a ;7
117 ld b,a ;4
118
119 ld a,c ;4
120 inc a ;4
121 and (ix+o.mask) ;19
122 bp.wait:
123 cp (ix+o.out_idx) ;19
124 jr z,bp.wait ;12/7
125 ld (ix+o.in_idx),a ;19
126
127 out (AVRINT6),a ;11
128 ld a,b ;4
129 pop bc ;10
130 pop hl ;10
131 pop ix ;14
132 ret ;10
133
134 else
135
136 ff.out:
137 push ix ;15
138 ld ix,co.fifo ;14
139
140 buf.put:
141 push hl ;11
142 push ix ;15
143 pop hl ;10
144 ld a,(ix+o.in_idx) ;19
145 add a,l ;4
146 ld l,a ;4
147 jr nc,bp.1 ;12/7
148 inc l ;4
149 ld (hl),c ;7
150 ld a,(ix+o.in_idx) ;19
151 inc a ;4
152 and (ix+o.mask) ;19
153 bp.wait:
154 cp (ix+o.out_idx) ;19
155 jr z,bp.wait ;12/7
156 ld (ix+o.in_idx),a ;19
157
158 out (AVRINT6),a ;11
159 ld a,c ;4
160 pop hl ;10
161 pop ix ;14
162 ret ;10 |
163
164 endif
165
166 ;--------------------------------------------------------------
167
168 end