Release 980301
[wine.git] / miscemu / emulate.c
blob9261eaad67972320568217644c32d50afd11b4a8
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include "miscemu.h"
4 #include "debug.h"
6 struct Win87EmInfoStruct
8 unsigned short Version;
9 unsigned short SizeSaveArea;
10 unsigned short WinDataSeg;
11 unsigned short WinCodeSeg;
12 unsigned short Have80x87;
13 unsigned short Unused;
16 /* Implementing this is easy cause Linux and *BSD* ALWAYS have a numerical
17 * coprocessor. (either real or emulated on kernellevel)
19 /* win87em.dll also sets interrupt vectors: 2 (NMI), 0x34 - 0x3f (emulator
20 * calls of standard libraries, see Ralph Browns interrupt list), 0x75
21 * (int13 error reporting of coprocessor)
24 /* have a look at /usr/src/linux/arch/i386/math-emu/ *.[ch] for more info
25 * especially control_w.h and status_w.h
27 /* FIXME: Only skeletal implementation for now */
29 void WINAPI WIN87_fpmath( CONTEXT *context )
31 dprintf_info(int, "_fpmath: (cs:eip=%x:%lx es=%x bx=%04x ax=%04x dx==%04x)\n",
32 (WORD)CS_reg(context), EIP_reg(context),
33 (WORD)ES_reg(context), BX_reg(context),
34 AX_reg(context), DX_reg(context) );
36 switch(BX_reg(context))
38 case 0: /* install (increase instanceref) emulator, install NMI vector */
39 AX_reg(context) = 0;
40 break;
42 case 1: /* Init Emulator */
43 AX_reg(context) = 0;
44 break;
46 case 2: /* deinstall emulator (decrease instanceref), deinstall NMI vector
47 * if zero. Every '0' call should have a matching '2' call.
49 AX_reg(context) = 0;
50 break;
52 case 3:
53 /*INT_SetHandler(0x3E,MAKELONG(AX,DX));*/
54 break;
56 case 4: /* set control word (& ~(CW_Denormal|CW_Invalid)) */
57 /* OUT: newset control word in AX */
58 break;
60 case 5: /* return internal control word in AX */
61 break;
63 case 6: /* round top of stack to integer using method AX & 0x0C00 */
64 /* returns current controlword */
65 break;
67 case 7: /* POP top of stack as integer into DX:AX */
68 /* IN: AX&0x0C00 rounding protocol */
69 /* OUT: DX:AX variable popped */
71 DWORD dw=0;
72 /* I don't know much about asm() programming. This could be
73 * wrong.
75 /* FIXME: could someone who really understands asm() fix this please? --AJ */
76 /* __asm__("fistp %0;wait" : "=m" (dw) : : "memory"); */
77 dprintf_info(int,"emulate.c:On top of stack was %ld\n",dw);
78 AX_reg(context) = LOWORD(dw);
79 DX_reg(context) = HIWORD(dw);
81 break;
83 case 8: /* restore internal control words from emulator control word */
84 break;
86 case 9: /* clear emu control word and some other things */
87 break;
89 case 10: /* dunno. but looks like returning nr. of things on stack in AX */
90 AX_reg(context) = 0;
91 break;
93 case 11: /* just returns the installed flag in DX:AX */
94 DX_reg(context) = 0;
95 AX_reg(context) = 1;
96 break;
98 case 12: /* save AX in some internal state var */
99 break;
101 default: /* error. Say that loud and clear */
102 AX_reg(context) = DX_reg(context) = 0xFFFF;
103 break;
108 void WINAPI WIN87_WinEm87Info(struct Win87EmInfoStruct *pWIS,
109 int cbWin87EmInfoStruct)
111 dprintf_info(int, "__WinEm87Info(%p,%d)\n",pWIS,cbWin87EmInfoStruct);
114 void WINAPI WIN87_WinEm87Restore(void *pWin87EmSaveArea,
115 int cbWin87EmSaveArea)
117 dprintf_info(int, "__WinEm87Restore(%p,%d)\n",
118 pWin87EmSaveArea,cbWin87EmSaveArea);
121 void WINAPI WIN87_WinEm87Save(void *pWin87EmSaveArea, int cbWin87EmSaveArea)
123 dprintf_info(int, "__WinEm87Save(%p,%d)\n",
124 pWin87EmSaveArea,cbWin87EmSaveArea);