1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
1 ;--------------------------------------------------------
2 ; File Created by SDCC : free open source ANSI-C Compiler
3 ; Version 3.6.0 #9615 (Linux)
4 ;--------------------------------------------------------
5 .module pio
6 .optsdcc -mz80
7
8 ;--------------------------------------------------------
9 ; Public variables in this module
10 ;--------------------------------------------------------
11 .globl __pio_data
12 .globl __pio_control
13 .globl _pio_set_mode
14 .globl _pio_set_interrupts
15 .globl _pio_set_interrupts_mask
16 .globl _pio_read
17 .globl _pio_write
18 ;--------------------------------------------------------
19 ; special function registers
20 ;--------------------------------------------------------
21 ;--------------------------------------------------------
22 ; ram data
23 ;--------------------------------------------------------
24 .area _DATA
25 ;--------------------------------------------------------
26 ; ram data
27 ;--------------------------------------------------------
28 .area _INITIALIZED
0000 29 _pio_port:
0000 30 .ds 2
0002 31 _pio_ctrl:
0002 32 .ds 2
33 ;--------------------------------------------------------
34 ; absolute external ram data
35 ;--------------------------------------------------------
36 .area _DABS (ABS)
37 ;--------------------------------------------------------
38 ; global & static initialisations
39 ;--------------------------------------------------------
40 .area _HOME
41 .area _GSINIT
42 .area _GSFINAL
43 .area _GSINIT
44 ;--------------------------------------------------------
45 ; Home
46 ;--------------------------------------------------------
47 .area _HOME
48 .area _HOME
49 ;--------------------------------------------------------
50 ; code
51 ;--------------------------------------------------------
52 .area _CODE
53 ;pio.c:6: inline void _pio_data(int port, uint8_t data)
54 ; ---------------------------------
55 ; Function _pio_data
56 ; ---------------------------------
0000 57 __pio_data::
58 ;pio.c:8: *(pio_port + port) = data;
0000 21 02 00 [10] 59 ld hl,#2
0003 39 [11] 60 add hl,sp
0004 FD 21r00r00 [14] 61 ld iy,#_pio_port
0008 FD 7E 00 [19] 62 ld a,0 (iy)
000B 86 [ 7] 63 add a, (hl)
000C 4F [ 4] 64 ld c,a
000D FD 7E 01 [19] 65 ld a,1 (iy)
0010 23 [ 6] 66 inc hl
0011 8E [ 7] 67 adc a, (hl)
0012 47 [ 4] 68 ld b,a
0013 21 04 00 [10] 69 ld hl, #4+0
0016 39 [11] 70 add hl, sp
0017 7E [ 7] 71 ld a, (hl)
0018 02 [ 7] 72 ld (bc),a
0019 C9 [10] 73 ret
74 ;pio.c:11: inline void _pio_control(int port, uint8_t cmd)
75 ; ---------------------------------
76 ; Function _pio_control
77 ; ---------------------------------
001A 78 __pio_control::
79 ;pio.c:13: *(pio_ctrl + port) = cmd;
001A 21 02 00 [10] 80 ld hl,#2
001D 39 [11] 81 add hl,sp
001E FD 21r02r00 [14] 82 ld iy,#_pio_ctrl
0022 FD 7E 00 [19] 83 ld a,0 (iy)
0025 86 [ 7] 84 add a, (hl)
0026 4F [ 4] 85 ld c,a
0027 FD 7E 01 [19] 86 ld a,1 (iy)
002A 23 [ 6] 87 inc hl
002B 8E [ 7] 88 adc a, (hl)
002C 47 [ 4] 89 ld b,a
002D 21 04 00 [10] 90 ld hl, #4+0
0030 39 [11] 91 add hl, sp
0031 7E [ 7] 92 ld a, (hl)
0032 02 [ 7] 93 ld (bc),a
0033 C9 [10] 94 ret
95 ;pio.c:16: void pio_set_mode(int port, int mode, uint8_t io)
96 ; ---------------------------------
97 ; Function pio_set_mode
98 ; ---------------------------------
0034 99 _pio_set_mode::
100 ;pio.c:19: _pio_control(port, ((mode << 6) | 0x0F));
0034 21 04 00 [10] 101 ld hl, #4+0
0037 39 [11] 102 add hl, sp
0038 7E [ 7] 103 ld a, (hl)
0039 0F [ 4] 104 rrca
003A 0F [ 4] 105 rrca
003B E6 C0 [ 7] 106 and a,#0xc0
003D F6 0F [ 7] 107 or a, #0x0f
003F 4F [ 4] 108 ld c,a
0040 D1 [10] 109 pop de
0041 E1 [10] 110 pop hl
0042 E5 [11] 111 push hl
0043 D5 [11] 112 push de
113 ;pio.c:13: *(pio_ctrl + port) = cmd;
0044 FD 2Ar02r00 [20] 114 ld iy,(_pio_ctrl)
0048 5D [ 4] 115 ld e, l
0049 54 [ 4] 116 ld d, h
004A FD 19 [15] 117 add iy, de
004C FD 71 00 [19] 118 ld 0 (iy), c
119 ;pio.c:23: if (mode == PIO_MODE_BIT_IO) {
004F FD 21 04 00 [14] 120 ld iy,#4
0053 FD 39 [15] 121 add iy,sp
0055 FD 7E 00 [19] 122 ld a,0 (iy)
0058 D6 03 [ 7] 123 sub a, #0x03
005A C0 [11] 124 ret NZ
005B FD 7E 01 [19] 125 ld a,1 (iy)
005E B7 [ 4] 126 or a, a
005F C0 [11] 127 ret NZ
128 ;pio.c:24: _pio_control(port, io);
0060 FD 21 06 00 [14] 129 ld iy,#6
0064 FD 39 [15] 130 add iy,sp
0066 FD 4E 00 [19] 131 ld c,0 (iy)
132 ;pio.c:13: *(pio_ctrl + port) = cmd;
0069 ED 5Br02r00 [20] 133 ld de,(_pio_ctrl)
006D 19 [11] 134 add hl,de
006E 71 [ 7] 135 ld (hl),c
136 ;pio.c:24: _pio_control(port, io);
006F C9 [10] 137 ret
138 ;pio.c:28: void pio_set_interrupts(int port, int control)
139 ; ---------------------------------
140 ; Function pio_set_interrupts
141 ; ---------------------------------
0070 142 _pio_set_interrupts::
143 ;pio.c:31: _pio_control(port, (control | 0x07));
0070 21 04 00 [10] 144 ld hl, #4+0
0073 39 [11] 145 add hl, sp
0074 7E [ 7] 146 ld a, (hl)
0075 F6 07 [ 7] 147 or a, #0x07
0077 4F [ 4] 148 ld c,a
0078 D1 [10] 149 pop de
0079 E1 [10] 150 pop hl
007A E5 [11] 151 push hl
007B D5 [11] 152 push de
153 ;pio.c:13: *(pio_ctrl + port) = cmd;
007C ED 5Br02r00 [20] 154 ld de,(_pio_ctrl)
0080 19 [11] 155 add hl,de
0081 71 [ 7] 156 ld (hl),c
157 ;pio.c:31: _pio_control(port, (control | 0x07));
0082 C9 [10] 158 ret
159 ;pio.c:34: void pio_set_interrupts_mask(int port, int control, uint8_t mask)
160 ; ---------------------------------
161 ; Function pio_set_interrupts_mask
162 ; ---------------------------------
0083 163 _pio_set_interrupts_mask::
164 ;pio.c:38: _pio_control(port, (control | 0x17));
0083 21 04 00 [10] 165 ld hl, #4+0
0086 39 [11] 166 add hl, sp
0087 7E [ 7] 167 ld a, (hl)
0088 F6 17 [ 7] 168 or a, #0x17
008A 4F [ 4] 169 ld c,a
008B D1 [10] 170 pop de
008C E1 [10] 171 pop hl
008D E5 [11] 172 push hl
008E D5 [11] 173 push de
174 ;pio.c:13: *(pio_ctrl + port) = cmd;
008F FD 2Ar02r00 [20] 175 ld iy,(_pio_ctrl)
0093 5D [ 4] 176 ld e, l
0094 54 [ 4] 177 ld d, h
0095 FD 19 [15] 178 add iy, de
0097 FD 71 00 [19] 179 ld 0 (iy), c
180 ;pio.c:39: _pio_control(port, mask);
009A FD 21 06 00 [14] 181 ld iy,#6
009E FD 39 [15] 182 add iy,sp
00A0 FD 4E 00 [19] 183 ld c,0 (iy)
184 ;pio.c:13: *(pio_ctrl + port) = cmd;
00A3 ED 5Br02r00 [20] 185 ld de,(_pio_ctrl)
00A7 19 [11] 186 add hl,de
00A8 71 [ 7] 187 ld (hl),c
188 ;pio.c:39: _pio_control(port, mask);
00A9 C9 [10] 189 ret
190 ;pio.c:42: uint8_t pio_read(int port)
191 ; ---------------------------------
192 ; Function pio_read
193 ; ---------------------------------
00AA 194 _pio_read::
195 ;pio.c:44: return *(pio_port + port);
00AA 21 02 00 [10] 196 ld hl,#2
00AD 39 [11] 197 add hl,sp
00AE FD 21r00r00 [14] 198 ld iy,#_pio_port
00B2 FD 7E 00 [19] 199 ld a,0 (iy)
00B5 86 [ 7] 200 add a, (hl)
00B6 4F [ 4] 201 ld c,a
00B7 FD 7E 01 [19] 202 ld a,1 (iy)
00BA 23 [ 6] 203 inc hl
00BB 8E [ 7] 204 adc a, (hl)
00BC 47 [ 4] 205 ld b,a
00BD 0A [ 7] 206 ld a,(bc)
00BE 6F [ 4] 207 ld l,a
00BF C9 [10] 208 ret
209 ;pio.c:47: void pio_write(int port, uint8_t data)
210 ; ---------------------------------
211 ; Function pio_write
212 ; ---------------------------------
00C0 213 _pio_write::
214 ;pio.c:49: _pio_data(port, data);
00C0 21 04 00 [10] 215 ld hl, #4+0
00C3 39 [11] 216 add hl, sp
00C4 4E [ 7] 217 ld c, (hl)
00C5 D1 [10] 218 pop de
00C6 E1 [10] 219 pop hl
00C7 E5 [11] 220 push hl
00C8 D5 [11] 221 push de
222 ;pio.c:8: *(pio_port + port) = data;
00C9 ED 5Br00r00 [20] 223 ld de,(_pio_port)
00CD 19 [11] 224 add hl,de
00CE 71 [ 7] 225 ld (hl),c
226 ;pio.c:49: _pio_data(port, data);
00CF C9 [10] 227 ret
228 .area _CODE
229 .area _INITIALIZER
0000 230 __xinit__pio_port:
0000 00 42 231 .dw #0x4200
0002 232 __xinit__pio_ctrl:
0002 02 42 233 .dw #0x4202
234 .area _CABS (ABS)
|