]> cloudbase.mooo.com Git - z180-stamp.git/blob - z180/conbuf-a.180
switch fifos conin,conout
[z180-stamp.git] / z180 / conbuf-a.180
1 page 255
2 .z80
3
4 ;
5 ; FIFO channels for communication with avr
6 ;
7 global ff.init,ff.in,ff.out,ff.i.st,ff.o.st
8
9 extrn buf.init
10
11 include config.inc
12 if CPU_Z180
13 include z180reg.inc
14 endif
15
16
17 ;--------------------------------------------------------------
18
19 dseg
20
21
22 mkbuf ci.fifo_id, ci.fifo, ci.fifo_len
23 mkbuf co.fifo_id, co.fifo, co.fifo_len
24
25
26 ;--------------------------------------------------------------
27
28 cseg
29
30 ; Init Serial I/O for console input and output
31 ;
32
33 ff.init:
34 ld ix,ci.fifo
35 ld a,ci.fifo.mask
36 call buf.init
37 ld ix,co.fifo
38 ld a,co.fifo.mask
39 jp buf.init
40
41
42 ff.i.st:
43 push ix
44 ld ix,ci.fifo ;
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,ci.fifo ;
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 ff.o.st:
87 push ix
88 ld ix,co.fifo ;
89
90 buf.full:
91 ld a,(ix+o.in_idx) ;
92 inc a
93 and (ix+o.mask)
94 sub (ix+o.out_idx) ;
95 pop ix
96 ret z
97 or 0ffh
98 ret
99
100
101 if 1
102 ff.out:
103 push ix ;15
104 ld ix,co.fifo ;14
105
106 buf.put:
107 push hl ;11
108 push bc ;11
109 push ix ;15
110 pop hl ;10
111 ld a,c ;4
112 ld c,(ix+o.in_idx) ;19
113 ld b,0 ;7
114 add hl,bc ;11
115 ld (hl),a ;7
116 ld b,a ;4
117
118 ld a,c ;4
119 inc a ;4
120 and (ix+o.mask) ;19
121 bp.wait:
122 cp (ix+o.out_idx) ;19
123 jr z,bp.wait ;12/7
124 ld (ix+o.in_idx),a ;19
125
126 out (AVRINT6),a ;11
127 ld a,b ;4
128 pop bc ;10
129 pop hl ;10
130 pop ix ;14
131 ret ;10
132
133 else
134
135 ff.out:
136 push ix ;15
137 ld ix,co.fifo ;14
138
139 buf.put:
140 push hl ;11
141 push ix ;15
142 pop hl ;10
143 ld a,(ix+o.in_idx) ;19
144 add a,l ;4
145 ld l,a ;4
146 jr nc,bp.1 ;12/7
147 inc l ;4
148 ld (hl),c ;7
149 ld a,(ix+o.in_idx) ;19
150 inc a ;4
151 and (ix+o.mask) ;19
152 bp.wait:
153 cp (ix+o.out_idx) ;19
154 jr z,bp.wait ;12/7
155 ld (ix+o.in_idx),a ;19
156
157 out (AVRINT6),a ;11
158 ld a,c ;4
159 pop hl ;10
160 pop ix ;14
161 ret ;10 |
162
163 endif
164
165 end