/*1* Relay calls helper routines2*3* Copyright 1993 Robert J. Amstadt4* Copyright 1995 Martin von Loewis5* Copyright 1995, 1996, 1997 Alexandre Julliard6* Copyright 1997 Eric Youngdale7* Copyright 1999 Ulrich Weigand8*9* This library is free software; you can redistribute it and/or10* modify it under the terms of the GNU Lesser General Public11* License as published by the Free Software Foundation; either12* version 2.1 of the License, or (at your option) any later version.13*14* This library is distributed in the hope that it will be useful,15* but WITHOUT ANY WARRANTY; without even the implied warranty of16* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU17* Lesser General Public License for more details.18*19* You should have received a copy of the GNU Lesser General Public20* License along with this library; if not, write to the Free Software21* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA22*/2324#include "config.h"2526#include <ctype.h>27#include <stdarg.h>2829#include "build.h"3031/* offset of the stack pointer relative to %fs:(0) */32#define STACKOFFSET 0x10c /* FIELD_OFFSET(TEB,SystemReserved1) */3334/* fix this if the x86_thread_data structure is changed */35#define GS_OFFSET 0x1d8 /* FIELD_OFFSET(TEB,SystemReserved2) + FIELD_OFFSET(struct x86_thread_data,gs) */3637/* offset of the ldt pointer */38#define LDT_OFFSET 0x220 /* FIELD_OFFSET(PEB,SpareUlongs[0]) */394041/*******************************************************************42* BuildCallFrom16Core43*44* This routine builds the core routines used in 16->32 thunks:45* CallFrom16Word, CallFrom16Long, CallFrom16Register, and CallFrom16Thunk.46*47* These routines are intended to be called via a far call (with 32-bit48* operand size) from 16-bit code. The 16-bit code stub must push %bp,49* the 32-bit entry point to be called, and the argument conversion50* routine to be used (see stack layout below).51*52* The core routine completes the STACK16FRAME on the 16-bit stack and53* switches to the 32-bit stack. Then, the argument conversion routine54* is called; it gets passed the 32-bit entry point and a pointer to the55* 16-bit arguments (on the 16-bit stack) as parameters. (You can either56* use conversion routines automatically generated by BuildCallFrom16,57* or write your own for special purposes.)58*59* The conversion routine must call the 32-bit entry point, passing it60* the converted arguments, and return its return value to the core.61* After the conversion routine has returned, the core switches back62* to the 16-bit stack, converts the return value to the DX:AX format63* (CallFrom16Long), and returns to the 16-bit call stub. All parameters,64* including %bp, are popped off the stack.65*66* The 16-bit call stub now returns to the caller, popping the 16-bit67* arguments if necessary (pascal calling convention).68*69* In the case of a 'register' function, CallFrom16Register fills a70* CONTEXT86 structure with the values all registers had at the point71* the first instruction of the 16-bit call stub was about to be72* executed. A pointer to this CONTEXT86 is passed as third parameter73* to the argument conversion routine, which typically passes it on74* to the called 32-bit entry point.75*76* CallFrom16Thunk is a special variant used by the implementation of77* the Win95 16->32 thunk functions C16ThkSL and C16ThkSL01 and is78* implemented as follows:79* On entry, the EBX register is set up to contain a flat pointer to the80* 16-bit stack such that EBX+22 points to the first argument.81* Then, the entry point is called, while EBP is set up to point82* to the return address (on the 32-bit stack).83* The called function returns with CX set to the number of bytes84* to be popped of the caller's stack.85*86* Stack layout upon entry to the core routine (STACK16FRAME):87* ... ...88* (sp+24) word first 16-bit arg89* (sp+22) word cs90* (sp+20) word ip91* (sp+18) word bp92* (sp+14) long 32-bit entry point (reused for Win16 mutex recursion count)93* (sp+12) word ip of actual entry point (necessary for relay debugging)94* (sp+8) long relay (argument conversion) function entry point95* (sp+4) long cs of 16-bit entry point96* (sp) long ip of 16-bit entry point97*98* Added on the stack:99* (sp-2) word saved gs100* (sp-4) word saved fs101* (sp-6) word saved es102* (sp-8) word saved ds103* (sp-12) long saved ebp104* (sp-16) long saved ecx105* (sp-20) long saved edx106* (sp-24) long saved previous stack107*/108static void BuildCallFrom16Core( int reg_func, int thunk )109{110/* Function header */111if (thunk) output_function_header( "__wine_call_from_16_thunk", 1 );112else if (reg_func) output_function_header( "__wine_call_from_16_regs", 1 );113else output_function_header( "__wine_call_from_16", 1 );114115/* Create STACK16FRAME (except STACK32FRAME link) */116output( "\tpushw %%gs\n" );117output( "\tpushw %%fs\n" );118output( "\tpushw %%es\n" );119output( "\tpushw %%ds\n" );120output( "\tpushl %%ebp\n" );121output( "\tpushl %%ecx\n" );122output( "\tpushl %%edx\n" );123124/* Save original EFlags register */125if (reg_func) output( "\tpushfl\n" );126127if ( UsePIC )128{129output( "\tcall 1f\n" );130output( "1:\tpopl %%ecx\n" );131output( "\tmovl %%cs:%s-1b(%%ecx),%%edx\n", asm_name("CallTo16_DataSelector") );132}133else134output( "\tmovl %%cs:%s,%%edx\n", asm_name("CallTo16_DataSelector") );135136/* Load 32-bit segment registers */137output( "\tmovw %%dx, %%ds\n" );138output( "\tmovw %%dx, %%es\n" );139140if ( UsePIC )141output( "\tmovw %s-1b(%%ecx), %%fs\n", asm_name("CallTo16_TebSelector") );142else143output( "\tmovw %s, %%fs\n", asm_name("CallTo16_TebSelector") );144145output( "\tmov %%fs:(%d),%%gs\n", GS_OFFSET );146147/* Translate STACK16FRAME base to flat offset in %edx */148output( "\tmovw %%ss, %%dx\n" );149output( "\tandl $0xfff8, %%edx\n" );150output( "\tshrl $1, %%edx\n" );151output( "\tmovl %%fs:(0x30), %%ecx\n" ); /* peb */152output( "\tmovl %u(%%ecx), %%ecx\n", LDT_OFFSET ); /* ldt_copy */153output( "\tmovl (%%ecx,%%edx), %%edx\n" );154output( "\tmovzwl %%sp, %%ebp\n" );155output( "\tleal %d(%%ebp,%%edx), %%edx\n", reg_func ? 0 : -4 );156157/* Get saved flags into %ecx */158if (reg_func) output( "\tpopl %%ecx\n" );159160/* Get the 32-bit stack pointer from the TEB and complete STACK16FRAME */161output( "\tmovl %%fs:(%d), %%ebp\n", STACKOFFSET );162output( "\tpushl %%ebp\n" );163164/* Switch stacks */165output( "\tmovw %%ss, %%fs:(%d)\n", STACKOFFSET + 2 );166output( "\tmovw %%sp, %%fs:(%d)\n", STACKOFFSET );167output( "\tpushl %%ds\n" );168output( "\tpopl %%ss\n" );169output( "\tmovl %%ebp, %%esp\n" );170output( "\taddl $0x20,%%ebp\n"); /* FIELD_OFFSET(STACK32FRAME,ebp) */171172173/* At this point:174STACK16FRAME is completely set up175DS, ES, SS: flat data segment176FS: current TEB177ESP: points to last STACK32FRAME178EBP: points to ebp member of last STACK32FRAME179EDX: points to current STACK16FRAME180ECX: contains saved flags181all other registers: unchanged */182183/* Special case: C16ThkSL stub */184if ( thunk )185{186/* Set up registers as expected and call thunk */187output( "\tleal 0x1a(%%edx),%%ebx\n" ); /* sizeof(STACK16FRAME)-22 */188output( "\tleal -4(%%esp), %%ebp\n" );189190output( "\tcall *0x26(%%edx)\n"); /* FIELD_OFFSET(STACK16FRAME,entry_point) */191192/* Switch stack back */193output( "\tmovw %%fs:(%d), %%ss\n", STACKOFFSET+2 );194output( "\tmovzwl %%fs:(%d), %%esp\n", STACKOFFSET );195output( "\tpopl %%fs:(%d)\n", STACKOFFSET );196197/* Restore registers and return directly to caller */198output( "\taddl $8, %%esp\n" );199output( "\tpopl %%ebp\n" );200output( "\tpopw %%ds\n" );201output( "\tpopw %%es\n" );202output( "\tpopw %%fs\n" );203output( "\tpopw %%gs\n" );204output( "\taddl $20, %%esp\n" );205206output( "\txorb %%ch, %%ch\n" );207output( "\tpopl %%ebx\n" );208output( "\taddw %%cx, %%sp\n" );209output( "\tpush %%ebx\n" );210211output( "\t.byte 0x66\n" );212output( "\tlret\n" );213214output_function_size( "__wine_call_from_16_thunk" );215return;216}217218219/* Build register CONTEXT */220if ( reg_func )221{222output( "\tsubl $0x2cc,%%esp\n" ); /* sizeof(CONTEXT86) */223224output( "\tmovl %%ecx,0xc0(%%esp)\n" ); /* EFlags */225226output( "\tmovl %%eax,0xb0(%%esp)\n" ); /* Eax */227output( "\tmovl %%ebx,0xa4(%%esp)\n" ); /* Ebx */228output( "\tmovl %%esi,0xa0(%%esp)\n" ); /* Esi */229output( "\tmovl %%edi,0x9c(%%esp)\n" ); /* Edi */230231output( "\tmovl 0x0c(%%edx),%%eax\n"); /* FIELD_OFFSET(STACK16FRAME,ebp) */232output( "\tmovl %%eax,0xb4(%%esp)\n" ); /* Ebp */233output( "\tmovl 0x08(%%edx),%%eax\n"); /* FIELD_OFFSET(STACK16FRAME,ecx) */234output( "\tmovl %%eax,0xac(%%esp)\n" ); /* Ecx */235output( "\tmovl 0x04(%%edx),%%eax\n"); /* FIELD_OFFSET(STACK16FRAME,edx) */236output( "\tmovl %%eax,0xa8(%%esp)\n" ); /* Edx */237238output( "\tmovzwl 0x10(%%edx),%%eax\n"); /* FIELD_OFFSET(STACK16FRAME,ds) */239output( "\tmovl %%eax,0x98(%%esp)\n" ); /* SegDs */240output( "\tmovzwl 0x12(%%edx),%%eax\n"); /* FIELD_OFFSET(STACK16FRAME,es) */241output( "\tmovl %%eax,0x94(%%esp)\n" ); /* SegEs */242output( "\tmovzwl 0x14(%%edx),%%eax\n"); /* FIELD_OFFSET(STACK16FRAME,fs) */243output( "\tmovl %%eax,0x90(%%esp)\n" ); /* SegFs */244output( "\tmovzwl 0x16(%%edx),%%eax\n"); /* FIELD_OFFSET(STACK16FRAME,gs) */245output( "\tmovl %%eax,0x8c(%%esp)\n" ); /* SegGs */246247output( "\tmovzwl 0x2e(%%edx),%%eax\n"); /* FIELD_OFFSET(STACK16FRAME,cs) */248output( "\tmovl %%eax,0xbc(%%esp)\n" ); /* SegCs */249output( "\tmovzwl 0x2c(%%edx),%%eax\n"); /* FIELD_OFFSET(STACK16FRAME,ip) */250output( "\tmovl %%eax,0xb8(%%esp)\n" ); /* Eip */251252output( "\tmovzwl %%fs:(%d), %%eax\n", STACKOFFSET+2 );253output( "\tmovl %%eax,0xc8(%%esp)\n" ); /* SegSs */254output( "\tmovzwl %%fs:(%d), %%eax\n", STACKOFFSET );255output( "\taddl $0x2c,%%eax\n"); /* FIELD_OFFSET(STACK16FRAME,ip) */256output( "\tmovl %%eax,0xc4(%%esp)\n" ); /* Esp */257#if 0258output( "\tfsave 0x1c(%%esp)\n" ); /* FloatSave */259#endif260261/* Push address of CONTEXT86 structure -- popped by the relay routine */262output( "\tmovl %%esp,%%eax\n" );263output( "\tandl $~15,%%esp\n" );264output( "\tsubl $4,%%esp\n" );265output( "\tpushl %%eax\n" );266}267else268{269output( "\tsubl $8,%%esp\n" );270output( "\tandl $~15,%%esp\n" );271output( "\taddl $8,%%esp\n" );272}273274/* Call relay routine (which will call the API entry point) */275output( "\tleal 0x30(%%edx),%%eax\n" ); /* sizeof(STACK16FRAME) */276output( "\tpushl %%eax\n" );277output( "\tpushl 0x26(%%edx)\n"); /* FIELD_OFFSET(STACK16FRAME,entry_point) */278output( "\tcall *0x20(%%edx)\n"); /* FIELD_OFFSET(STACK16FRAME,relay) */279280if ( reg_func )281{282output( "\tleal -748(%%ebp),%%ebx\n" ); /* sizeof(CONTEXT) + FIELD_OFFSET(STACK32FRAME,ebp) */283284/* Switch stack back */285output( "\tmovw %%fs:(%d), %%ss\n", STACKOFFSET+2 );286output( "\tmovzwl %%fs:(%d), %%esp\n", STACKOFFSET );287output( "\tpopl %%fs:(%d)\n", STACKOFFSET );288289/* Get return address to CallFrom16 stub */290output( "\taddw $0x14,%%sp\n" ); /* FIELD_OFFSET(STACK16FRAME,callfrom_ip)-4 */291output( "\tpopl %%eax\n" );292output( "\tpopl %%edx\n" );293294/* Restore all registers from CONTEXT */295output( "\tmovw 0xc8(%%ebx),%%ss\n"); /* SegSs */296output( "\tmovl 0xc4(%%ebx),%%esp\n"); /* Esp */297output( "\taddl $4, %%esp\n" ); /* room for final return address */298299output( "\tpushw 0xbc(%%ebx)\n"); /* SegCs */300output( "\tpushw 0xb8(%%ebx)\n"); /* Eip */301output( "\tpushl %%edx\n" );302output( "\tpushl %%eax\n" );303output( "\tpushl 0xc0(%%ebx)\n"); /* EFlags */304output( "\tpushl 0x98(%%ebx)\n"); /* SegDs */305306output( "\tpushl 0x94(%%ebx)\n"); /* SegEs */307output( "\tpopl %%es\n" );308output( "\tpushl 0x90(%%ebx)\n"); /* SegFs */309output( "\tpopl %%fs\n" );310output( "\tpushl 0x8c(%%ebx)\n"); /* SegGs */311output( "\tpopl %%gs\n" );312313output( "\tmovl 0xb4(%%ebx),%%ebp\n"); /* Ebp */314output( "\tmovl 0xa0(%%ebx),%%esi\n"); /* Esi */315output( "\tmovl 0x9c(%%ebx),%%edi\n"); /* Edi */316output( "\tmovl 0xb0(%%ebx),%%eax\n"); /* Eax */317output( "\tmovl 0xa8(%%ebx),%%edx\n"); /* Edx */318output( "\tmovl 0xac(%%ebx),%%ecx\n"); /* Ecx */319output( "\tmovl 0xa4(%%ebx),%%ebx\n"); /* Ebx */320321output( "\tpopl %%ds\n" );322output( "\tpopfl\n" );323output( "\tlret\n" );324325output_function_size( "__wine_call_from_16_regs" );326}327else328{329/* Switch stack back */330output( "\tmovw %%fs:(%d), %%ss\n", STACKOFFSET+2 );331output( "\tmovzwl %%fs:(%d), %%esp\n", STACKOFFSET );332output( "\tpopl %%fs:(%d)\n", STACKOFFSET );333334/* Restore registers */335output( "\tpopl %%edx\n" );336output( "\tpopl %%ecx\n" );337output( "\tpopl %%ebp\n" );338output( "\tpopw %%ds\n" );339output( "\tpopw %%es\n" );340output( "\tpopw %%fs\n" );341output( "\tpopw %%gs\n" );342343/* Return to return stub which will return to caller */344output( "\tlret $12\n" );345346output_function_size( "__wine_call_from_16" );347}348}349350351/*******************************************************************352* BuildCallTo16Core353*354* This routine builds the core routines used in 32->16 thunks:355*356* extern DWORD WINAPI wine_call_to_16( FARPROC16 target, DWORD cbArgs, PEXCEPTION_HANDLER handler );357* extern void WINAPI wine_call_to_16_regs( CONTEXT86 *context, DWORD cbArgs, PEXCEPTION_HANDLER handler );358*359* These routines can be called directly from 32-bit code.360*361* All routines expect that the 16-bit stack contents (arguments) and the362* return address (segptr to CallTo16_Ret) were already set up by the363* caller; nb_args must contain the number of bytes to be conserved. The364* 16-bit SS:SP will be set accordingly.365*366* All other registers are either taken from the CONTEXT86 structure367* or else set to default values. The target routine address is either368* given directly or taken from the CONTEXT86.369*/370static void BuildCallTo16Core( int reg_func )371{372const char *name = reg_func ? "wine_call_to_16_regs" : "wine_call_to_16";373const char *func_name = is_pe() ? strmake( "%s@12", name ) : name;374375/* Function header */376output_function_header( func_name, 1 );377378/* Function entry sequence */379output_cfi( ".cfi_startproc" );380output( "\tpushl %%ebp\n" );381output_cfi( ".cfi_adjust_cfa_offset 4" );382output_cfi( ".cfi_rel_offset %%ebp,0" );383output( "\tmovl %%esp, %%ebp\n" );384output_cfi( ".cfi_def_cfa_register %%ebp" );385386/* Save the 32-bit registers */387output( "\tpushl %%ebx\n" );388output_cfi( ".cfi_rel_offset %%ebx,-4" );389output( "\tpushl %%esi\n" );390output_cfi( ".cfi_rel_offset %%esi,-8" );391output( "\tpushl %%edi\n" );392output_cfi( ".cfi_rel_offset %%edi,-12" );393output( "\tmov %%gs,%%fs:(%d)\n", GS_OFFSET );394395/* Setup exception frame */396output( "\tpushl %%fs:(%d)\n", STACKOFFSET );397output( "\tpushl 16(%%ebp)\n" ); /* handler */398output( "\tpushl %%fs:(0)\n" );399output( "\tmovl %%esp,%%fs:(0)\n" );400401/* Call the actual CallTo16 routine (simulate a lcall) */402output( "\tpushl %%cs\n" );403output( "\tcall .L%s\n", name );404405/* Remove exception frame */406output( "\tpopl %%fs:(0)\n" );407output( "\taddl $4, %%esp\n" );408output( "\tpopl %%fs:(%d)\n", STACKOFFSET );409410if ( !reg_func )411{412/* Convert return value */413output( "\tandl $0xffff,%%eax\n" );414output( "\tshll $16,%%edx\n" );415output( "\torl %%edx,%%eax\n" );416}417else418{419/*420* Modify CONTEXT86 structure to contain new values421*422* NOTE: We restore only EAX, EBX, ECX, EDX, EBP, and ESP.423* The segment registers as well as ESI and EDI should424* not be modified by a well-behaved 16-bit routine in425* any case. [If necessary, we could restore them as well,426* at the cost of a somewhat less efficient return path.]427*/428429output( "\tmovl 0x14(%%esp),%%edi\n" ); /* FIELD_OFFSET(STACK32FRAME,target) - FIELD_OFFSET(STACK32FRAME,edi) */430/* everything above edi has been popped already */431432output( "\tmovl %%eax,0xb0(%%edi)\n"); /* Eax */433output( "\tmovl %%ebx,0xa4(%%edi)\n"); /* Ebx */434output( "\tmovl %%ecx,0xac(%%edi)\n"); /* Ecx */435output( "\tmovl %%edx,0xa8(%%edi)\n"); /* Edx */436output( "\tmovl %%ebp,0xb4(%%edi)\n"); /* Ebp */437output( "\tmovl %%esi,0xc4(%%edi)\n"); /* Esp */438/* The return glue code saved %esp into %esi */439}440441/* Restore the 32-bit registers */442output( "\tpopl %%edi\n" );443output_cfi( ".cfi_same_value %%edi" );444output( "\tpopl %%esi\n" );445output_cfi( ".cfi_same_value %%esi" );446output( "\tpopl %%ebx\n" );447output_cfi( ".cfi_same_value %%ebx" );448449/* Function exit sequence */450output( "\tpopl %%ebp\n" );451output_cfi( ".cfi_def_cfa %%esp,4" );452output_cfi( ".cfi_same_value %%ebp" );453output( "\tret $12\n" );454output_cfi( ".cfi_endproc" );455456457/* Start of the actual CallTo16 routine */458459output( ".L%s:\n", name );460461/* Switch to the 16-bit stack */462output( "\tmovl %%esp,%%edx\n" );463output( "\tmovw %%fs:(%d),%%ss\n", STACKOFFSET + 2);464output( "\tmovw %%fs:(%d),%%sp\n", STACKOFFSET );465output( "\tmovl %%edx,%%fs:(%d)\n", STACKOFFSET );466467/* Make %bp point to the previous stackframe (built by CallFrom16) */468output( "\tmovzwl %%sp,%%ebp\n" );469output( "\tleal 0x2a(%%ebp),%%ebp\n"); /* FIELD_OFFSET(STACK16FRAME,bp) */470471/* Add the specified offset to the new sp */472output( "\tsubw 0x2c(%%edx), %%sp\n"); /* FIELD_OFFSET(STACK32FRAME,nb_args) */473474if (reg_func)475{476/* Push the called routine address */477output( "\tmovl 0x28(%%edx),%%edx\n"); /* FIELD_OFFSET(STACK32FRAME,target) */478output( "\tpushw 0xbc(%%edx)\n"); /* SegCs */479output( "\tpushw 0xb8(%%edx)\n"); /* Eip */480481/* Get the registers */482output( "\tpushw 0x98(%%edx)\n"); /* SegDs */483output( "\tpushl 0x94(%%edx)\n"); /* SegEs */484output( "\tpopl %%es\n" );485output( "\tmovl 0xb4(%%edx),%%ebp\n"); /* Ebp */486output( "\tmovl 0xa0(%%edx),%%esi\n"); /* Esi */487output( "\tmovl 0x9c(%%edx),%%edi\n"); /* Edi */488output( "\tmovl 0xb0(%%edx),%%eax\n"); /* Eax */489output( "\tmovl 0xa4(%%edx),%%ebx\n"); /* Ebx */490output( "\tmovl 0xac(%%edx),%%ecx\n"); /* Ecx */491output( "\tmovl 0xa8(%%edx),%%edx\n"); /* Edx */492493/* Get the 16-bit ds */494output( "\tpopw %%ds\n" );495}496else /* not a register function */497{498/* Push the called routine address */499output( "\tpushl 0x28(%%edx)\n"); /* FIELD_OFFSET(STACK32FRAME,target) */500501/* Set %fs and %gs to the value saved by the last CallFrom16 */502output( "\tpushw -22(%%ebp)\n" ); /* FIELD_OFFSET(STACK16FRAME,fs)-FIELD_OFFSET(STACK16FRAME,bp) */503output( "\tpopw %%fs\n" );504output( "\tpushw -20(%%ebp)\n" ); /* FIELD_OFFSET(STACK16FRAME,gs)-FIELD_OFFSET(STACK16FRAME,bp) */505output( "\tpopw %%gs\n" );506507/* Set %ds and %es (and %ax just in case) equal to %ss */508output( "\tmovw %%ss,%%ax\n" );509output( "\tmovw %%ax,%%ds\n" );510output( "\tmovw %%ax,%%es\n" );511}512513/* Jump to the called routine */514output( "\tlretw\n" );515516/* Function footer */517output_function_size( func_name );518}519520521/*******************************************************************522* BuildRet16Func523*524* Build the return code for 16-bit callbacks525*/526static void BuildRet16Func(void)527{528output_function_header( "__wine_call_to_16_ret", 1 );529530/* Save %esp into %esi */531output( "\tmovl %%esp,%%esi\n" );532533/* Restore 32-bit segment registers */534535output( "\tmovl %%cs:%s", asm_name("CallTo16_DataSelector") );536output( "-%s,%%edi\n", asm_name("__wine_call16_start") );537output( "\tmovw %%di,%%ds\n" );538output( "\tmovw %%di,%%es\n" );539540output( "\tmov %%cs:%s", asm_name("CallTo16_TebSelector") );541output( "-%s,%%fs\n", asm_name("__wine_call16_start") );542543output( "\tmov %%fs:(%d),%%gs\n", GS_OFFSET );544545/* Restore the 32-bit stack */546547output( "\tmovw %%di,%%ss\n" );548output( "\tmovl %%fs:(%d),%%esp\n", STACKOFFSET );549550/* Return to caller */551552output( "\tlret\n" );553output_function_size( "__wine_call_to_16_ret" );554}555556557/*******************************************************************558* output_asm_relays16559*560* Build all the 16-bit relay callbacks561*/562void output_asm_relays16(void)563{564/* File header */565566output( "\t.text\n" );567output( "%s:\n\n", asm_name("__wine_spec_thunk_text_16") );568569output( "%s\n", asm_globl("__wine_call16_start") );570571/* Standard CallFrom16 routine */572BuildCallFrom16Core( 0, 0 );573574/* Register CallFrom16 routine */575BuildCallFrom16Core( 1, 0 );576577/* C16ThkSL CallFrom16 routine */578BuildCallFrom16Core( 0, 1 );579580/* Standard CallTo16 routine */581BuildCallTo16Core( 0 );582583/* Register CallTo16 routine */584BuildCallTo16Core( 1 );585586/* Standard CallTo16 return stub */587BuildRet16Func();588589output( "%s\n", asm_globl("__wine_call16_end") );590output_function_size( "__wine_spec_thunk_text_16" );591592/* Declare the return address and data selector variables */593output( "\n\t.data\n\t.balign 4\n" );594output( "%s\n\t.long 0\n", asm_globl("CallTo16_DataSelector") );595output( "%s\n\t.long 0\n", asm_globl("CallTo16_TebSelector") );596}597598599