-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathport.inc
117 lines (95 loc) · 1.83 KB
/
port.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
portinitialization MACRO
pusha
;Set Divisor Latch Access Bit
mov dx,3fbh ; Line Control Register
mov al,10000000b ;Set Divisor Latch Access Bit
out dx,al ;Out it
;Set LSB byte of the Baud Rate Divisor Latch register.
mov dx,3f8h
mov al,0ch
out dx,al
;Set MSB byte of the Baud Rate Divisor Latch register.
mov dx,3f9h
mov al,00h
out dx,al
;Set port configuration
mov dx,3fbh
mov al,00011011b
;0:Access to Receiver buffer, Transmitter buffer
;0:Set Break disabled
;011:Even Parity
;0:One Stop Bit
;11:8bits
out dx,al
popa
ENDM portinitialization
;send a value
send MACRO value
LOCAL AGAIN
pusha
;Check that Transmitter Holding Register is Empty
mov dx,3FDH ; Line Status Register
AGAIN:
In al,dx ;Read Line Status
AND al,00100000b
JZ AGAIN
;If empty put the VALUE in Transmit data register
mov dx,3F8H ; Transmit data register
mov al,value
out dx,al
popa
ENDM send
;recieve a value
receive MACRO value, flag
LOCAL read
LOCAL finish
pusha
;Check that Data Ready
mov dx,3FDH ; Line Status Register
in al,dx
AND al,1
jnz read
mov flag,0
jmp finish
read:
;If Ready read the VALUE in Receive data register
mov flag,1
mov dx,03F8H
in al,dx
mov value,al
finish:
popa
ENDM receive
receive3ady MACRO value
LOCAL CHK
pusha
mov dx , 3FDH ; Line Status Register
CHK:
in al , dx
AND al , 1
JZ CHK
;If Ready read the VALUE in Receive data register
mov dx , 03F8H
in al , dx
mov VALUE , al
popa
ENDM receive3ady
;recieve a value
receiveChat MACRO value
LOCAL read
LOCAL finish
pusha
;Check that Data Ready
mov dx,3FDH ; Line Status Register
in al,dx
AND al,1
jnz read
jmp finish
read:
;If Ready read the VALUE in Receive data register
mov dx,03F8H
in al,dx
mov value,al
finish:
popa
ENDM receiveChat