-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPORT.ASM
222 lines (157 loc) · 4.34 KB
/
PORT.ASM
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
PortHandler proc near
cmp ah,0EEh
je OutDX_AL
cmp ah,0E6h
je Out@@_AL
cmp ah,0ECh
je InAL_DX
cmp ah,0E4h
je InAL_@@
jmp TooBad
OutDX_AL: push dx
CheckPort: cbw
add [ebp],ax
mov al,byte ptr [ebp-4]
cmp dx,0C7h ;Tandy ports C0h-C7h
jbe @TandyPort
cmp dx,205h ;PS/1 sound port 205h
je @PS1
cmp dx,388h ;Adlib address port
je @Adlib
cmp dx,389h ;Adlib data port
je @Adlib
cmp dx,220h ;SB Pro left FM address port
je @Adlib
cmp dx,221h ;..and left data port
je @Adlib
cmp dx,222h ;SB Pro right FM address port
je @Adlib
cmp dx,223h ;..and right data port
je @Adlib
cmp dx,226h ;SB DSP control ports
je @SB
cmp dx,22Ah
je @SB
cmp dx,22Ch
je @SB
cmp dx,22Eh
je @SB
@Other:
out dx,al
jmp @@AllRight
@@AllRight: pop dx
pop ebp
pop ds
pop ebx
pop eax
iretd
@TandyPort:
cmp [ss:InPort],0 ;No redirecting?
je @Other
cmp [ss:OutPort],0
je @Other
cmp dx,0C0h
je .CheckC0
cmp dx,0C0h
ja .CheckC0C7
jmp @Other
.CheckC0:
cmp [ss:InPort],205h
je @Other
jmp .doit
.CheckC0C7:
cmp [ss:InPort],0C7h
jne @Other
cmp [ss:LPT],1
je .doit
sub dx,0C0h ;Für Matze - !!!
add dx,[ss:OutPort]
out dx,al
jmp @@AllRight
.doit:
cmp [ss:LPT],1 ;Redirect to LPT port?
je .doLPT
mov dx,[ss:OutPort]
out dx,al
jmp @@AllRight
.doLPT:
pusha
mov dx,[ss:OutPort]
out dx,al
inc dx ;Ctrl Port
inc dx
mov al,0Ch
out dx,al
dec dx ;Status port
mov cx,18h
Wait_not_ready:
in al,dx
test al,01000000b
loopnz Wait_not_ready
cmp cx,0
je LPT_timed_out
mov cx,18h
Wait_ready:
in al,dx
test al,01000000b
loopz Wait_ready
LPT_timed_out:
inc dx
mov al,9
out dx,al
popa
jmp @@AllRight
@PS1: cmp [ss:InPort],205h
je .doit
jmp @Other
@Adlib:
cmp [ss:OPLOFF],1 ;OPL disabled?
je @@AllRight ;Then do nothing
jmp .doit ;If not, write to port
@SB:
cmp [ss:SBOFF],1
je @@AllRight
jmp .doit
Out@@_AL: push dx
movzx dx,byte ptr [ebx]
inc al
jmp CheckPort
InAL_DX: push dx
ReadPort:
cmp dx,0388h ;Adlib
je @ReadAdlib
cmp dx,0389h
je @ReadAdlib
cmp dx,226h ;SB cmd port
je @ReadSB
cmp dx,22Eh ;SB data port
je @ReadSB
jmp .Readit
@ReadAdlib:
cmp [ss:OPLOFF],1
jne .Readit
cbw
add [ebp],ax
mov al,0FFh ;return FF (bus float) if disabled
mov byte ptr [ebp-4],al
jmp @@AllRight
@ReadSB:
cmp [ss:SBOFF],1
jne .Readit
cbw
add [ebp],ax
mov al,0FFh ;return FF (bus float) if disabled
mov byte ptr [ebp-4],al
jmp @@AllRight
.Readit:
cbw
add [ebp],ax
in al,dx
mov byte ptr [ebp-4],al
jmp @@AllRight
InAL_@@: push dx
inc al
movzx dx,byte ptr [ebx]
jmp ReadPort
TooBad:
PortHandler endp