-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAUXOUT.INC
122 lines (105 loc) · 1.64 KB
/
AUXOUT.INC
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
;--- input/output COMx
;--- very simple implementation.
_XONXOFF_ = 1
XON = 11h
XOFF = 13h
EOT = 03H
.data
wPort dw 0 ; 0=COM1, 1=COM2, ...
wCsrPos dw 0
.code
;--- display a char in AL
AuxPutChar proc
pusha
push ds
mov bx, cs:[wPort]
shl bx, 1
mov ds, cs:[wFlat]
mov bx, ds:[bx+400h]
lea dx, [bx+5] ;LSR - Line Status Register
mov cx, -1
xchg al, ah
@@:
in al, dx
test al, 40h ;TEMT - transmitter empty?
loopz @B
if _XONXOFF_
test al, 1 ;char received
jz noxoff
mov dx, bx
in al, dx
cmp al, XOFF
jnz noxoff
waitxon:
add dx, 5
@@: ;wait till new char arrived
in al, dx
test al, 1
jz @B
mov dx, bx
in al, dx
cmp al, XON ;wait till XON received
jnz waitxon
noxoff:
endif
xchg al, ah
mov dx, bx
out dx, al
mov ds, cs:[wKDDS]
call setcsrpos
pop ds
popa
ret
setcsrpos:
cmp al, 13
jz col00
cmp al, 10
jz nochg
cmp al, 8
jz back
inc byte ptr [wCsrPos]
retn
back:
dec byte ptr [wCsrPos]
retn
col00:
mov byte ptr [wCsrPos], 0
nochg:
retn
AuxPutChar endp
AuxGetCsrPos proc
mov dx, cs:[wCsrPos]
ret
AuxGetCsrPos endp
;--- get a char in AL
AuxGetChar proc
push bx
push cx
push dx
push ds
mov bx, cs:[wPort]
mov ds, cs:[wFlat]
shl bx, 1
mov bx, [bx+400h]
pop ds
lea dx, [bx+6] ;MSR - modem status register
in al, dx ;DSR - modem(=DCE) ready?
and al, 20h
jz error
dec dx ;LSR - Line Status Register
@@:
in al, dx
test al, 01h ;DR - Data ready?
jz @B
mov dx, bx
in al, dx
mov ah, 00
jmp exit
error:
xor ax, ax
exit:
pop dx
pop cx
pop bx
ret
AuxGetChar endp