summaryrefslogtreecommitdiffstats
path: root/private/mvdm/wow16/win87em/emlstmp.asm
blob: e7a87b5c2782431d92545d8f0d99cea97fabd7d8 (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
	page	,132
	subttl	emlstmp.asm - Load/Store Temp Real Numbers
;***
;emlstmp.asm - Load/Store Temp Real Numbers
;
;	Copyright (c) 1986-89, Microsoft Corporation
;
;Purpose:
;	Load/Store Temp Real Numbers
;
;	This Module contains Proprietary Information of Microsoft
;	Corporation and should be treated as Confidential.
;
;Revision History:
;	See emulator.hst
;
;*******************************************************************************


ProfBegin LSTMP

;*********************************************************************;
;								      ;
;		 Load 80 Bit Temp Real				      ;
;								      ;
;*********************************************************************;
;
; ES:SI: memory address of 80 bit tempreal

pub	eFLDtemp
	MOV	edi,esi 	; Get a new stack element and leave
	PUSHST
	XCHG	edi,esi

	mov	ax,es
	mov	dx,ds
	mov	es,dx
	mov	ds,ax
	MVUS2DI 		; Move 8 bytes of mantissa to TOS
	MVUS2DI
	MVUS2DI
	MVUS2DI
	mov	ax,es
	mov	dx,ds
	mov	es,dx
	mov	ds,ax
	LDUS2AX 		; Fetch exponent
	SUB	edi,8		; Reset pointer to TOS
	XCHG	esi,edi 	; Now DS:SI points to TOS

	MOV	DH,AH		; Exponent and Sign to DX
	AND	DH,Sign 	; Mask to Sign only
	MOV	Flag[esi],DH
	AND	AH,7FH		; Mask out sign
	XOR	DH,DH		; Set Tag to valid non-zero
	CMP	AX,IexpMax
	JE	short TNANorInf
	CMP	AX,IexpMin
	JE	short TZeroOrDenorm
	SUB	AX,IexpBias

pub	TStoreExpnTag
	MOV	Expon[esi],AX
	MOV	Tag[esi],DH
	RET

pub	TNANorInf
	MOV	AX,IexpMax - IexpBias
	MOV	DH,Special
	CMP	MB6[esi],8000H	     ; Test for Infinity
	JNE	short TStoreExpnTag
	MOV	BP,MB4[esi]
	OR	BP,MB2[esi]
	OR	BP,MB0[esi]
	JNZ	TStoreExpnTag
	OR	DH,ZROorINF
	JMP	TStoreExpnTag

pub	TZeroOrDenorm
	MOV	BP,MB6[esi]
	OR	BP,MB4[esi]
	OR	BP,MB2[esi]
	OR	BP,MB0[esi]
	JNZ	short TDenormal

pub	TZero
	MOV	AX,IexpMin - IexpBias
	MOV	DH,ZROorINF
	JMP	TStoreExpnTag

pub	TDenormal
	OR	[CURerr],Underflow+Precision ; Say it underflowed - set it to 0
	XOR	BP,BP
	MOV	MB0[esi],BP
	MOV	MB2[esi],BP
	MOV	MB4[esi],BP
	MOV	MB6[esi],BP
	JMP	TZero

PAGE
;*********************************************************************;
;								      ;
;   Store 80 Bit Temp Real (& POP since only FSTP supported for temp) ;
;								      ;
;*********************************************************************;
;
; ES:SI: memory address of 80 bit tempreal

pub	TNANorINFST
	TEST	BH,ZROorINF
	JNZ	short TInfST

pub	TNANST
	MVSI2US 		; copy mantissa
	MVSI2US
	MVSI2US
	MVSI2US
	MOV	AX,IexpMax	; Set maximum mantissa
	OR	AH,DH		; Overstore proper sign
	STAX2US
	POPST
	RET

pub	TInfST
	XOR	AX,AX
	STAX2US
	STAX2US
	STAX2US
	MOV	AX,8000H
	STAX2US
	MOV	AX,IexpMax	; Set maximum mantissa
	OR	AH,DH		; Overstore proper sign
	STAX2US
	POPST
	RET

pub	TSpecialST
	TEST	BH,Special
	JNZ	TNANorINFST

pub	TzeroST
	XOR	AX,AX
	STAX2US
	STAX2US
	STAX2US
	STAX2US
	STAX2US
	POPST
	RET

pub	eFSTtemp
	MOV	edi,esi
	MOV	esi,[CURstk]

	MOV	AX,Expon[esi]	; Adjust exponent of TOS
	ADD	AX,IexpBias
	MOV	DH,Flag[esi]
if	fastSP
	TEST	DH,Single
	JZ	TD1
	MOV	word ptr MB0[esi],0
	MOV	word ptr MB2[esi],0
	MOV	byte ptr MB4[esi],0
TD1:
endif
	AND	DH,Sign 	; Mask to sign only
	OR	AH,DH
	MOV	BH,Tag[esi]	 ; See if it is a special case
	OR	BH,BH
	JNZ	TSpecialST

	MVSI2US 		; Move Mantissa
	MVSI2US
	MVSI2US
	MVSI2US
	STAX2US 		; Move Exponent & Sign

	SUB	esi,8		; Reset pointer to TOS
	POPSTsi

	RET

ProfEnd  LSTMP