summaryrefslogtreecommitdiffstats
path: root/private/mvdm/wow16/win87em/emulator.inc
blob: f0f5ed7e61c57fdd0adcc5c0a5e71e1a3e4292da (plain) (blame)
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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
	subttl	emulator.inc - Emulator macros.
;*** 
;emulator.inc - Emulator history.
;
;	Copyright (c) 1989-89, Microsoft Corporation
;
;Purpose:
;	Defines macros for emulator.
;
;Revision History
;
;   See emulator.hst
;
;*******************************************************************************



;*******************************************************************************
;
;   EMver  - defines version tag put in code segment.
;
;*******************************************************************************


EMver	macro
	db	'MSEM87',major_ver,minor_ver
	endm


;*******************************************************************************
;
;   Define pub and glb macros to make labels public for debugging.
;
;*******************************************************************************


ifdef  DEBUG

    lab     macro   name
    public  name
    name:
	    endm

    pub     macro   name
    public  name
    name:
	    endm

    glb     macro   name
	    irp     nm,<name>
	    public  nm
	    endm
	    endm

elseifdef  WINDOWS		; If windows, make these public for the map file.

    lab     macro   name
    public  name
    name:
	    endm

    pub     macro   name
    public  name
    name:
	    endm

    glb     macro   name
	    irp     nm,<name>
	    public  nm
	    endm
	    endm

else	;DEFAULT
    lab     macro   name
    name:
	    endm

    pub     macro   name
    name:
	    endm

    glb     macro   name
	    endm

endif	;DEFAULT



;*******************************************************************************
;
;   Macros and register aliases to keep the 386/8086 versions close.
;
;*******************************************************************************

ifdef	i386

eWORD	macro	nam				; 386 macros
nam	label	dword
	endm

nedw	macro	nam,contents
nam	dd	contents
	endm

nedd	macro	nam,contents
nam	df	contents
	endm

edw	macro	contents
	dd	contents
	endm

edd	macro	contents
	df	contents
	endm


else	; not i386

eWORD	macro	nam				; 286 macros
nam	label	word
	endm

nedw	macro	nam,contents
nam	dw	contents
	endm

nedd	macro	nam,contents
nam	dd	contents
	endm

edw	macro	contents
	dw	contents
	endm

edd	macro	contents
	dd	contents
	endm

eax	equ	ax
ecx	equ	cx
edx	equ	dx
ebx	equ	bx
esp	equ	sp
ebp	equ	bp
esi	equ	si
edi	equ	di

iretd   equ     iret

endif	;not i386


;*******************************************************************************
;
;   Processor opcode byte definitions.
;
;*******************************************************************************

fINT	equ	0cdh
fFWAIT	equ	9bh
fESCAPE equ	0d8h

iNOP	equ	90h	    ; byte nop

fES	equ	26h	    ; segment prefix opcodes
fCS	equ	2eh
fSS	equ	36h
fDS	equ	3eh

bIRET	equ	0cfh	    ; "iret"

bRETF	equ	0cah	    ; first byte of "retf 2".  Followed by word operand.
wNOP	equ	0c08bh	    ; word nop.  "mov  ax, ax"

bEscMask equ	0f8h	    ; masks all bits but escape
bMOD	equ	0c0h	    ; MOD bits are the two highest bits
bRM	equ	7h	    ; R/M bits are the three lowest bits.


;*******************************************************************************
;
;   Define os2extrn and os2call for dual mode emulators
;
;*******************************************************************************


ifdef	DOS3and5

    os2call macro name
	    call    __&name
	    endm

    os2extrn macro name
	    extrn   __&name : far
	    endm

endif	;DOS3and5

ifdef	DOS5only

    os2call macro name
	    call    name
	    endm

    os2extrn macro name
	    extrn   name : far
	    endm

endif	;DOS5only


;*******************************************************************************
;
;   Define ProfBegin ProfEnd macros for when profiling emulator.
;
;*******************************************************************************

ProfBegin  macro   name

ifdef  PROFILE
	nop

public EM_&name&_BEGIN
EM_&name&_BEGIN  label	far
endif
	endm


ProfEnd macro	name

ifdef  PROFILE
public EM_&name&_END
EM_&name&_END  label  far

	nop
endif
	endm


;*******************************************************************************
;
;   Define IntDOS macro for handling "int 21h" and "call DOS3CALL".
;
;*******************************************************************************


IntDOS	macro

ifdef  WINDOWSP
	call	DOS3CALL
else
	int	21h
endif
	endm


;*******************************************************************************
;
;   Define constants for DOS int 21h
;
;*******************************************************************************


DOS_getvector	equ	35H



INT_GetEquipList equ	 11h		 ; PC BIOS equipment list call.
GEL_80x87	 equ	  2h		 ; Mask for Coprocessor sense switch.


;*******************************************************************************
;
;   Define structures for __WinInfo(), __WinSave(), and __WinRestore().
;
;*******************************************************************************

WinInfoStruct	struc

    WI_Version	    dw	    ?	    ; High byte is major version.
    WI_SizeSaveArea dw	    ?	    ; Size of save area.
    WI_WinDataSeg   dw	    ?
    WI_WinCodeSeg   dw	    ?
    WI_Have80x87    dw	    ?
    WI_Unused	    dw	    ?	    ; Coprocessor type will go here.

WinInfoStruct	ends


Size80x87Area	equ	94


WinSaveArea struc

    WSA_Save80x87   db	    Size80x87Area dup(?)   ; Where 80x87 info will go.
    WSA_SaveEm	    db	    ?			   ; Where emulator data will go.

WinSaveArea ends



;*******************************************************************************
;
;   Define constants for checking "extrn __WINFLAGS:asb"
;
;*******************************************************************************


WF_PMODE    equ     1
WF_CPU286   equ     2
WF_CPU386   equ     4
WF_WIN286   equ     10h
WF_WIN386   equ     20h
WF_80x87    equ     400h