]> cloudbase.mooo.com Git - z180-stamp.git/blame - z180/conbuf-a.180
new fifos msg in, msg out, console in, console out
[z180-stamp.git] / z180 / conbuf-a.180
CommitLineData
6a4e9540
L
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\r
8\r
9 extrn buf.init\r
10\r
11 include config.inc\r
12 include z180reg.inc\r
13\r
14\r
15;--------------------------------------------------------------\r
16\r
17 dseg\r
18 \r
19\r
20 mkbuf co.fifo,co.fifo_len\r
21 mkbuf ci.fifo,ci.fifo_len\r
22\r
23\r
24;--------------------------------------------------------------\r
25\r
26 cseg\r
27\r
28; Init Serial I/O for console input and output\r
29;\r
30\r
31ff.init:\r
32 ld ix,ci.fifo\r
33 ld a,ci.fifo.mask\r
34 call buf.init\r
35 ld ix,co.fifo\r
36 ld a,co.fifo.mask\r
37 jp buf.init\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
99ff.out:\r
100 push ix\r
101 ld ix,co.fifo ;\r
102\r
103buf.put:\r
104 push hl ;\r
105 push bc\r
106 push ix\r
107 pop hl\r
108 ld c,(ix+o.in_idx) ;\r
109 ld b,0\r
110 add hl,bc\r
111 ld b,a\r
112\r
113 ld a,c ;\r
114 inc a\r
115 and (ix+o.mask)\r
116bp.wait:\r
117 cp (ix+o.out_idx) ;\r
118 jr z,bp.wait\r
119 ld (hl),b\r
120 ld (ix+o.in_idx),a\r
121 \r
122 out (AVRINT6),a\r
123 ld a,b\r
124 pop bc\r
125 pop hl\r
126 pop ix\r
127 ret\r
128\r
129 end\r
130\r