2 * Copyright Robert J. Amstadt, 1993
9 /**********************************************************************
10 * Places to keep info about the current 32-bit stack frame.
19 /**********************************************************************
20 * Places to keep info about the current 16-bit stack frame.
22 .globl _IF1632_Saved16_esp,_IF1632_Saved16_ebp,_IF1632_Saved16_ss
39 /**********************************************************************
40 * int CallToInit16(unsigned long csip, unsigned long sssp,
73 * Put stack registers where we can get them after stack switch.
80 * Load initial registers
82 movw _WIN_StackSize,%bx
83 movw _WIN_HeapSize,%cx
106 * Restore old stack and segment registers.
109 * 1. Trust that fs or gs hasn't changed.
110 * 2. Rely on knowledge of Linux use of segments.
112 * I'll opt for choice 2 because who knows what programs we
113 * going to run. Linux should be fairly stable in terms of
128 * Restore registers, but do not destroy return value.
133 movl %eax,return_value
135 movl return_value,%eax
140 /**********************************************************************
141 * int CallTo16(unsigned long csip, unsigned short ds)
156 * Get target address and new ds
159 movl %eax,jump_target
164 * Switch to 16-bit stack
174 movw _IF1632_Saved16_ss,%ss
175 movl _IF1632_Saved16_esp,%esp
176 movl _IF1632_Saved16_ebp,%ebp
186 * Restore old stack and segment registers.
189 * 1. Trust that fs or gs hasn't changed.
190 * 2. Rely on knowledge of Linux use of segments.
192 * I'll opt for choice 2 because who knows what programs we
193 * going to run. Linux should be fairly stable in terms of
204 movw %ss,_IF1632_Saved16_ss
205 movl %esp,_IF1632_Saved16_esp
206 movl %ebp,_IF1632_Saved16_ebp
216 movl %eax,return_value
217 movw return_value+2,%dx
222 /**********************************************************************
225 * This function is called as a relay point to the built function
226 * handler. KERNEL, USER and GDI calls are dealt with by this
227 * handler. Calls to these DLLs will be mapped to a call handler
228 * which will set EAX to a number indicating which DLL and which
229 * function within that DLL.
231 * This function will pass to the function handler two arguments.
232 * The first argument will be the contents of EAX, the second
233 * argument will be a segment:offset pair that points to the
243 * Save registers. 286 mode does not have fs or gs.
249 * Restore segment registers.
258 * Save old stack save variables, save stack registers, reload
261 pushl _IF1632_Saved16_esp
262 pushl _IF1632_Saved16_ebp
263 pushw _IF1632_Saved16_ss
265 movw %ss,_IF1632_Saved16_ss
266 movl %esp,_IF1632_Saved16_esp
267 movl %ebp,_IF1632_Saved16_ebp
276 pushw _IF1632_Saved16_ss
277 pushw _IF1632_Saved16_esp
282 * Restore registers, but do not destroy return value.
284 movw _IF1632_Saved16_ss,%ss
285 movl _IF1632_Saved16_esp,%esp
286 movl _IF1632_Saved16_ebp,%ebp
288 popw _IF1632_Saved16_ss
289 popl _IF1632_Saved16_ebp
290 popl _IF1632_Saved16_esp
298 * Now we need to ditch the parameter bytes that were left on the
299 * stack. We do this by effectively popping the number of bytes,
300 * and the return address, removing the parameters and then putting
301 * the return address back on the stack.
302 * Normally this field is filled in by the relevant function in
303 * the emulation library, since it should know how many bytes to
317 * Last, but not least we need to move the high word from eax to dx
326 /**********************************************************************
327 * ReturnFromRegisterFunc()
329 .globl _ReturnFromRegisterFunc
330 _ReturnFromRegisterFunc:
332 * Restore 16-bit stack
334 movw _IF1632_Saved16_ss,%ss
335 movl _IF1632_Saved16_esp,%esp
336 movl _IF1632_Saved16_ebp,%ebp
338 popw _IF1632_Saved16_ss
339 popl _IF1632_Saved16_ebp
340 popl _IF1632_Saved16_esp
348 * This leaves us with a stack that has number of arguments,
349 * the return address, the saved registers, and the return
352 popw %ax /* Throw away the number of arguments */
353 popl %eax /* Throw away first copy of return address */
359 popw %ax /* Throw away pushed stack pointer */
366 * Return to original caller.