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
|
/************************************************************************/
/* This file contains the BCC compiler helper functions */
/* Miscellaneous obsolete junk
* __inport.o __inportb.o __outport.o __outportb.o __peekb.o __peekw.o
* __pokeb.o __pokew.o
*/
#ifdef __AS368_16__
#if !__FIRST_ARG_IN_AX__
#asm
.text ! This is common to all.
.even
#endasm
/************************************************************************/
/* Function inport */
#ifdef L___inport
#asm
| int inport( int port );
| reads a word from the i/o port port and returns it
.globl _inport
_inport:
pop bx
pop dx
dec sp
dec sp
inw
jmp bx
#endasm
#endif
/************************************************************************/
/* Function inportb */
#ifdef L___inportb
#asm
| int inportb( int port );
| reads a byte from the i/o port port and returns it
.globl _inportb
_inportb:
pop bx
pop dx
dec sp
dec sp
in
sub ah,ah
jmp bx
#endasm
#endif
/************************************************************************/
/* Function outport */
#ifdef L___outport
#asm
| void outport( int port, int value );
| writes the word value to the i/o port port
.globl _outport
_outport:
pop bx
pop dx
pop ax
sub sp,*4
outw
jmp bx
#endasm
#endif
/************************************************************************/
/* Function outportb */
#ifdef L___outportb
#asm
| void oportb( int port, char value );
| writes the byte value to the i/o port port
| this would be outportb except for feeble linkers
.globl _oportb
_oportb:
pop bx
pop dx
pop ax
sub sp,*4
out
jmp bx
#endasm
#endif
/************************************************************************/
/* Function peekb */
#ifdef L___peekb
#asm
| int peekb( unsigned segment, char *offset );
| returns the (unsigned) byte at the far pointer segment:offset
.define _peekb
_peekb:
mov cx,ds
pop dx
pop ds
pop bx
sub sp,*4
movb al,(bx)
subb ah,ah
mov ds,cx
jmp dx
#endasm
#endif
/************************************************************************/
/* Function peekw */
#ifdef L___peekw
#asm
| int peekw( unsigned segment, int *offset );
| returns the word at the far pointer segment:offset
.define _peekw
_peekw:
mov cx,ds
pop dx
pop ds
pop bx
sub sp,*4
mov ax,(bx)
mov ds,cx
jmp dx
#endasm
#endif
/************************************************************************/
/* Function pokeb */
#ifdef L___pokeb
#asm
| void pokeb( unsigned segment, char *offset, char value );
| writes the byte value at the far pointer segment:offset
.define _pokeb
_pokeb:
mov cx,ds
pop dx
pop ds
pop bx
pop ax
sub sp,*6
movb (bx),al
mov ds,cx
jmp dx
#endasm
#endif
/************************************************************************/
/* Function pokew */
#ifdef L___pokew
#asm
| void pokew( unsigned segment, int *offset, int value );
| writes the word value at the far pointer segment:offset
.define _pokew
_pokew:
mov cx,ds
pop dx
pop ds
pop bx
pop ax
sub sp,*6
mov (bx),ax
mov ds,cx
jmp dx
#endasm
#endif
#endif /* !__FIRST_ARG_IN_AX__ */
#endif
|