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