Added cmd line in new_process request.
[wine.git] / miscemu / emulate.c
blobbd587dfef578f8c94694fd741e7971fdaa834854
1 #include <stdlib.h>
2 #include "miscemu.h"
3 #include "debug.h"
5 struct Win87EmInfoStruct
7 unsigned short Version;
8 unsigned short SizeSaveArea;
9 unsigned short WinDataSeg;
10 unsigned short WinCodeSeg;
11 unsigned short Have80x87;
12 unsigned short Unused;
15 /* Implementing this is easy cause Linux and *BSD* ALWAYS have a numerical
16 * coprocessor. (either real or emulated on kernellevel)
18 /* win87em.dll also sets interrupt vectors: 2 (NMI), 0x34 - 0x3f (emulator
19 * calls of standard libraries, see Ralph Browns interrupt list), 0x75
20 * (int13 error reporting of coprocessor)
23 /* have a look at /usr/src/linux/arch/i386/math-emu/ *.[ch] for more info
24 * especially control_w.h and status_w.h
26 /* FIXME: Only skeletal implementation for now */
28 void WINAPI WIN87_fpmath( CONTEXT *context )
30 TRACE(int, "(cs:eip=%x:%lx es=%x bx=%04x ax=%04x dx==%04x)\n",
31 (WORD)CS_reg(context), EIP_reg(context),
32 (WORD)ES_reg(context), BX_reg(context),
33 AX_reg(context), DX_reg(context) );
35 switch(BX_reg(context))
37 case 0: /* install (increase instanceref) emulator, install NMI vector */
38 AX_reg(context) = 0;
39 break;
41 case 1: /* Init Emulator */
42 AX_reg(context) = 0;
43 break;
45 case 2: /* deinstall emulator (decrease instanceref), deinstall NMI vector
46 * if zero. Every '0' call should have a matching '2' call.
48 AX_reg(context) = 0;
49 break;
51 case 3:
52 /*INT_SetHandler(0x3E,MAKELONG(AX,DX));*/
53 break;
55 case 4: /* set control word (& ~(CW_Denormal|CW_Invalid)) */
56 /* OUT: newset control word in AX */
57 break;
59 case 5: /* return internal control word in AX */
60 break;
62 case 6: /* round top of stack to integer using method AX & 0x0C00 */
63 /* returns current controlword */
65 DWORD dw=0;
66 /* I don't know much about asm() programming. This could be
67 * wrong.
69 __asm__ __volatile__("frndint");
70 __asm__ __volatile__("fist %0;wait" : "=m" (dw) : : "memory");
71 TRACE(int,"On top of stack is %ld\n",dw);
73 break;
75 case 7: /* POP top of stack as integer into DX:AX */
76 /* IN: AX&0x0C00 rounding protocol */
77 /* OUT: DX:AX variable popped */
79 DWORD dw=0;
80 /* I don't know much about asm() programming. This could be
81 * wrong.
83 /* FIXME: could someone who really understands asm() fix this please? --AJ */
84 /* __asm__("fistp %0;wait" : "=m" (dw) : : "memory"); */
85 TRACE(int,"On top of stack was %ld\n",dw);
86 AX_reg(context) = LOWORD(dw);
87 DX_reg(context) = HIWORD(dw);
89 break;
91 case 8: /* restore internal control words from emulator control word */
92 break;
94 case 9: /* clear emu control word and some other things */
95 break;
97 case 10: /* dunno. but looks like returning nr. of things on stack in AX */
98 AX_reg(context) = 0;
99 break;
101 case 11: /* just returns the installed flag in DX:AX */
102 DX_reg(context) = 0;
103 AX_reg(context) = 1;
104 break;
106 case 12: /* save AX in some internal state var */
107 break;
109 default: /* error. Say that loud and clear */
110 FIXME(int,"unhandled switch %d\n",BX_reg(context));
111 AX_reg(context) = DX_reg(context) = 0xFFFF;
112 break;
117 void WINAPI WIN87_WinEm87Info(struct Win87EmInfoStruct *pWIS,
118 int cbWin87EmInfoStruct)
120 TRACE(int, "(%p,%d)\n",pWIS,cbWin87EmInfoStruct);
123 void WINAPI WIN87_WinEm87Restore(void *pWin87EmSaveArea,
124 int cbWin87EmSaveArea)
126 TRACE(int, "(%p,%d)\n",
127 pWin87EmSaveArea,cbWin87EmSaveArea);
130 void WINAPI WIN87_WinEm87Save(void *pWin87EmSaveArea, int cbWin87EmSaveArea)
132 TRACE(int, "(%p,%d)\n",
133 pWin87EmSaveArea,cbWin87EmSaveArea);