2 * Copyright 1993 Robert J. Amstadt
3 * Copyright 1995 Alexandre Julliard
4 * Copyright 1995 Martin von Loewis
16 /* ELF symbols do not have an underscore in front */
17 #if defined (__ELF__) || defined (__svr4__)
23 #define TYPE_INVALID 0
27 #define TYPE_PASCAL_16 4
29 #define TYPE_REGISTER 6
33 #define TYPE_STDCALL 10
36 #define MAX_ORDINALS 1299
38 /* Callback function used for stub functions */
39 #define STUB_CALLBACK "RELAY_Unimplemented"
41 typedef struct ordinal_definition_s
46 void *additional_data
;
49 typedef struct ordinal_variable_definition_s
55 typedef struct ordinal_function_definition_s
59 char internal_name
[80];
62 typedef struct ordinal_return_definition_s
68 static ORDDEF OrdinalDefinitions
[MAX_ORDINALS
];
70 char LowerDLLName
[80];
71 char UpperDLLName
[80];
77 char *ParseBuffer
= NULL
;
82 static int debugging
= 1;
84 /* Offset of register relative to the end of the context struct */
85 #define CONTEXTOFFSET(reg) \
86 ((int)&(((struct sigcontext_struct *)1)->reg) - 1 \
87 - sizeof(struct sigcontext_struct))
89 #define sc_eax uc_mcontext.gregs[EAX]
90 #define sc_ebx uc_mcontext.gregs[EBX]
91 #define sc_ecx uc_mcontext.gregs[ECX]
92 #define sc_edx uc_mcontext.gregs[EDX]
93 #define sc_esi uc_mcontext.gregs[ESI]
94 #define sc_edi uc_mcontext.gregs[EDI]
95 #define sc_ds uc_mcontext.gregs[DS]
96 #define sc_es uc_mcontext.gregs[ES]
97 #define sc_eflags uc_mcontext.gregs[EFL]
100 static void *xmalloc (size_t size
)
104 res
= malloc (size
? size
: 1);
107 fprintf (stderr
, "Virtual memory exhausted.\n");
114 static void *xrealloc (void *ptr
, size_t size
)
116 void *res
= realloc (ptr
, size
);
119 fprintf (stderr
, "Virtual memory exhausted.\n");
126 static int IsNumberString(char *s
)
135 static char *strlower(char *s
)
139 for(p
= s
; *p
!= '\0'; p
++)
145 static char *strupper(char *s
)
149 for(p
= s
; *p
!= '\0'; p
++)
155 static char * GetTokenInLine(void)
160 if (ParseNext
!= ParseBuffer
)
162 if (ParseSaveChar
== '\0')
164 *ParseNext
= ParseSaveChar
;
168 * Remove initial white space.
170 for (p
= ParseNext
; isspace(*p
); p
++)
173 if ((*p
== '\0') || (*p
== '#'))
180 if (*token
!= '(' && *token
!= ')')
181 while (*p
!= '\0' && *p
!= '(' && *p
!= ')' && !isspace(*p
))
191 static char * GetToken(void)
195 if (ParseBuffer
== NULL
)
197 ParseBuffer
= xmalloc(512);
198 ParseNext
= ParseBuffer
;
202 if (fgets(ParseBuffer
, 511, SpecFp
) == NULL
)
204 if (ParseBuffer
[0] != '#')
209 while ((token
= GetTokenInLine()) == NULL
)
211 ParseNext
= ParseBuffer
;
215 if (fgets(ParseBuffer
, 511, SpecFp
) == NULL
)
217 if (ParseBuffer
[0] != '#')
225 static int ParseVariable(int ordinal
, int type
)
229 char export_name
[80];
234 int value_array_size
;
236 strcpy(export_name
, GetToken());
241 fprintf(stderr
, "%d: Expected '(' got '%s'\n", Line
, token
);
246 value_array_size
= 25;
247 value_array
= xmalloc(sizeof(*value_array
) * value_array_size
);
249 while ((token
= GetToken()) != NULL
)
254 value_array
[n_values
++] = strtol(token
, &endptr
, 0);
255 if (n_values
== value_array_size
)
257 value_array_size
+= 25;
258 value_array
= xrealloc(value_array
,
259 sizeof(*value_array
) * value_array_size
);
262 if (endptr
== NULL
|| *endptr
!= '\0')
264 fprintf(stderr
, "%d: Expected number value, got '%s'\n", Line
,
272 fprintf(stderr
, "%d: End of file in variable declaration\n", Line
);
276 if (ordinal
>= MAX_ORDINALS
)
278 fprintf(stderr
, "%d: Ordinal number too large\n", Line
);
282 odp
= &OrdinalDefinitions
[ordinal
];
284 strcpy(odp
->export_name
, export_name
);
286 vdp
= xmalloc(sizeof(*vdp
));
287 odp
->additional_data
= vdp
;
289 vdp
->n_values
= n_values
;
290 vdp
->values
= xrealloc(value_array
, sizeof(*value_array
) * n_values
);
295 static int ParseExportFunction(int ordinal
, int type
)
302 odp
= &OrdinalDefinitions
[ordinal
];
303 strcpy(odp
->export_name
, GetToken());
305 fdp
= xmalloc(sizeof(*fdp
));
306 odp
->additional_data
= fdp
;
311 fprintf(stderr
, "%d: Expected '(' got '%s'\n", Line
, token
);
315 for (i
= 0; i
< 16; i
++)
321 if (!strcmp(token
, "byte") || !strcmp(token
, "word"))
322 fdp
->arg_types
[i
] = 'w';
323 else if (!strcmp(token
, "s_byte") || !strcmp(token
, "s_word"))
324 fdp
->arg_types
[i
] = 's';
325 else if (!strcmp(token
, "long") || !strcmp(token
, "segptr"))
326 fdp
->arg_types
[i
] = 'l';
327 else if (!strcmp(token
, "ptr"))
328 fdp
->arg_types
[i
] = 'p';
329 else if (!strcmp(token
, "..."))
330 fdp
->arg_types
[i
] = '.';
333 fprintf(stderr
, "%d: Unknown variable type '%s'\n", Line
, token
);
337 fdp
->arg_types
[i
] = '\0';
339 strcpy(fdp
->internal_name
, GetToken());
343 static int ParseEquate(int ordinal
)
350 odp
= &OrdinalDefinitions
[ordinal
];
351 strcpy(odp
->export_name
, GetToken());
354 value
= strtol(token
, &endptr
, 0);
355 if (endptr
== NULL
|| *endptr
!= '\0')
357 fprintf(stderr
, "%d: Expected number value, got '%s'\n", Line
,
362 odp
->type
= TYPE_ABS
;
363 odp
->additional_data
= (void *) value
;
368 static int ParseReturn(int ordinal
)
375 rdp
= xmalloc(sizeof(*rdp
));
377 odp
= &OrdinalDefinitions
[ordinal
];
378 strcpy(odp
->export_name
, GetToken());
379 odp
->type
= TYPE_RETURN
;
380 odp
->additional_data
= rdp
;
383 rdp
->arg_size
= strtol(token
, &endptr
, 0);
384 if (endptr
== NULL
|| *endptr
!= '\0')
386 fprintf(stderr
, "%d: Expected number value, got '%s'\n", Line
,
392 rdp
->ret_value
= strtol(token
, &endptr
, 0);
393 if (endptr
== NULL
|| *endptr
!= '\0')
395 fprintf(stderr
, "%d: Expected number value, got '%s'\n", Line
,
404 static int ParseStub( int ordinal
)
409 odp
= &OrdinalDefinitions
[ordinal
];
410 strcpy( odp
->export_name
, GetToken() );
411 odp
->type
= TYPE_STUB
;
412 fdp
= xmalloc(sizeof(*fdp
));
413 odp
->additional_data
= fdp
;
414 fdp
->arg_types
[0] = '\0';
415 strcpy( fdp
->internal_name
, STUB_CALLBACK
);
420 static int ParseOrdinal(int ordinal
)
424 if (ordinal
>= MAX_ORDINALS
)
426 fprintf(stderr
, "%d: Ordinal number too large\n", Line
);
429 if (ordinal
> Limit
) Limit
= ordinal
;
434 fprintf(stderr
, "%d: Expected type after ordinal\n", Line
);
438 if (strcmp(token
, "byte") == 0)
439 return ParseVariable(ordinal
, TYPE_BYTE
);
440 else if (strcmp(token
, "word") == 0)
441 return ParseVariable(ordinal
, TYPE_WORD
);
442 else if (strcmp(token
, "long") == 0)
443 return ParseVariable(ordinal
, TYPE_LONG
);
444 else if (strcmp(token
, "p") == 0)
445 return ParseExportFunction(ordinal
, TYPE_PASCAL
);
446 else if (strcmp(token
, "pascal") == 0)
447 return ParseExportFunction(ordinal
, TYPE_PASCAL
);
448 else if (strcmp(token
, "pascal16") == 0)
449 return ParseExportFunction(ordinal
, TYPE_PASCAL_16
);
450 else if (strcmp(token
, "register") == 0)
451 return ParseExportFunction(ordinal
, TYPE_REGISTER
);
452 else if (strcmp(token
, "stdcall") == 0)
453 return ParseExportFunction(ordinal
, TYPE_STDCALL
);
454 else if (strcmp(token
, "cdecl") == 0)
455 return ParseExportFunction(ordinal
, TYPE_CDECL
);
456 else if (strcmp(token
, "equate") == 0)
457 return ParseEquate(ordinal
);
458 else if (strcmp(token
, "return") == 0)
459 return ParseReturn(ordinal
);
460 else if (strcmp(token
, "stub") == 0)
461 return ParseStub(ordinal
);
465 "%d: Expected type after ordinal, found '%s' instead\n",
471 static int ParseTopLevel(void)
475 while ((token
= GetToken()) != NULL
)
477 if (strcmp(token
, "name") == 0)
479 strcpy(LowerDLLName
, GetToken());
480 strlower(LowerDLLName
);
482 strcpy(UpperDLLName
, LowerDLLName
);
483 strupper(UpperDLLName
);
485 else if (strcmp(token
, "id") == 0)
488 if (!IsNumberString(token
))
490 fprintf(stderr
, "%d: Expected number after id\n", Line
);
496 else if (strcmp(token
, "base") == 0)
499 if (!IsNumberString(token
))
501 fprintf(stderr
, "%d: Expected number after base\n", Line
);
507 else if (IsNumberString(token
))
512 ordinal
= atoi(token
);
513 if ((rv
= ParseOrdinal(ordinal
)) < 0)
519 "%d: Expected name, id, length or ordinal\n", Line
);
528 static int OutputVariableCode( char *storage
, ORDDEF
*odp
)
533 vdp
= odp
->additional_data
;
534 printf( "\t.data\n" );
535 for (i
= 0; i
< vdp
->n_values
; i
++)
538 printf( "\t%s\t", storage
);
540 printf( "%d", vdp
->values
[i
]);
542 if ((i
& 7) == 7 || i
== vdp
->n_values
- 1) printf( "\n");
546 printf( "\t.text\n" );
547 return vdp
->n_values
;
551 /*******************************************************************
554 * Build the in-memory representation of the module, and dump it
555 * as a byte stream into the assembly code.
557 static void BuildModule( int max_code_offset
, int max_data_offset
)
563 SEGTABLEENTRY
*pSegment
;
570 * OFSTRUCT File information
571 * SEGTABLEENTRY Segment 1 (code)
572 * SEGTABLEENTRY Segment 2 (data)
573 * WORD[2] Resource table (empty)
574 * BYTE[2] Imported names (empty)
575 * BYTE[n] Resident names table
576 * BYTE[n] Entry table
579 buffer
= xmalloc( 0x10000 );
581 pModule
= (NE_MODULE
*)buffer
;
582 pModule
->magic
= NE_SIGNATURE
;
585 pModule
->flags
= NE_FFLAGS_SINGLEDATA
| NE_FFLAGS_BUILTIN
| NE_FFLAGS_LIBMODULE
;
587 pModule
->heap_size
= 0xffff;
588 pModule
->stack_size
= 0;
593 pModule
->seg_count
= 2;
594 pModule
->modref_count
= 0;
595 pModule
->nrname_size
= 0;
596 pModule
->modref_table
= 0;
597 pModule
->nrname_fpos
= 0;
598 pModule
->moveable_entries
= 0;
599 pModule
->alignment
= 0;
600 pModule
->truetype
= 0;
601 pModule
->os_flags
= NE_OSFLAGS_WINDOWS
;
602 pModule
->misc_flags
= 0;
603 pModule
->dlls_to_init
= 0;
604 pModule
->nrname_handle
= 0;
605 pModule
->min_swap_area
= 0;
606 pModule
->expected_version
= 0x030a;
608 /* File information */
610 pFileInfo
= (OFSTRUCT
*)(pModule
+ 1);
611 pModule
->fileinfo
= (int)pFileInfo
- (int)pModule
;
612 memset( pFileInfo
, 0, sizeof(*pFileInfo
) - sizeof(pFileInfo
->szPathName
) );
613 pFileInfo
->cBytes
= sizeof(*pFileInfo
) - sizeof(pFileInfo
->szPathName
)
614 + strlen(UpperDLLName
) + 4;
615 sprintf( pFileInfo
->szPathName
, "%s.DLL", UpperDLLName
);
616 pstr
= (char *)pFileInfo
+ pFileInfo
->cBytes
+ 1;
620 pSegment
= (SEGTABLEENTRY
*)pstr
;
621 pModule
->seg_table
= (int)pSegment
- (int)pModule
;
622 pSegment
->filepos
= 0;
623 pSegment
->size
= max_code_offset
;
625 pSegment
->minsize
= max_code_offset
;
626 pSegment
->selector
= 0;
629 pModule
->dgroup_entry
= (int)pSegment
- (int)pModule
;
630 pSegment
->filepos
= 0;
631 pSegment
->size
= max_data_offset
;
632 pSegment
->flags
= NE_SEGFLAGS_DATA
;
633 pSegment
->minsize
= max_data_offset
;
634 pSegment
->selector
= 0;
639 pword
= (WORD
*)pSegment
;
640 pModule
->res_table
= (int)pword
- (int)pModule
;
644 /* Imported names table */
646 pstr
= (char *)pword
;
647 pModule
->import_table
= (int)pstr
- (int)pModule
;
651 /* Resident names table */
653 pModule
->name_table
= (int)pstr
- (int)pModule
;
654 /* First entry is module name */
655 *pstr
= strlen(UpperDLLName
);
656 strcpy( pstr
+ 1, UpperDLLName
);
659 pstr
+= sizeof(WORD
);
660 /* Store all ordinals */
661 odp
= OrdinalDefinitions
+ 1;
662 for (i
= 1; i
<= Limit
; i
++, odp
++)
664 if (!odp
->export_name
[0]) continue;
665 *pstr
= strlen( odp
->export_name
);
666 strcpy( pstr
+ 1, odp
->export_name
);
667 strupper( pstr
+ 1 );
670 pstr
+= sizeof(WORD
);
676 pModule
->entry_table
= (int)pstr
- (int)pModule
;
678 odp
= OrdinalDefinitions
+ 1;
679 for (i
= 1; i
<= Limit
; i
++, odp
++)
686 selector
= 0; /* Invalid selector */
694 selector
= 1; /* Code selector */
700 selector
= 2; /* Data selector */
704 selector
= 0xfe; /* Constant selector */
708 /* create a new bundle if necessary */
709 if (!bundle
|| (bundle
[0] >= 254) || (bundle
[1] != selector
))
713 bundle
[1] = selector
;
721 *(WORD
*)pstr
= odp
->offset
;
722 pstr
+= sizeof(WORD
);
727 /* Dump the module content */
729 printf( "\t.data\n" );
730 printf( "\t.globl " PREFIX
"%s_Module_Start\n", UpperDLLName
);
731 printf( PREFIX
"%s_Module_Start:\n", UpperDLLName
);
732 size
= (int)pstr
- (int)pModule
;
733 for (i
= 0, pstr
= buffer
; i
< size
; i
++, pstr
++)
735 if (!(i
& 7)) printf( "\t.byte " );
736 printf( "%d%c", *pstr
, ((i
& 7) != 7) ? ',' : '\n' );
738 if (i
& 7) printf( "0\n" );
739 printf( "\t.globl " PREFIX
"%s_Module_End\n", UpperDLLName
);
740 printf( PREFIX
"%s_Module_End:\n", UpperDLLName
);
744 static void BuildSpec32Files( char *specname
)
752 SpecFp
= fopen( specname
, "r");
755 fprintf(stderr
, "Could not open specification file, '%s'\n", specname
);
761 printf( "/* File generated automatically, do not edit! */\n" );
762 printf( "#include <sys/types.h>\n");
763 printf( "#include <stdarg.h>\n");
764 printf( "#include \"windows.h\"\n");
765 printf( "#include \"dlls.h\"\n");
766 printf( "#include \"pe_image.h\"\n");
767 printf( "#include \"winerror.h\"\n");
768 printf( "#include \"relay32.h\"\n");
769 printf( "#include \"stddebug.h\"\n");
770 printf( "#include \"debug.h\"\n");
772 odp
= OrdinalDefinitions
;
773 for (i
= 0; i
<= Limit
; i
++, odp
++)
776 fdp
= odp
->additional_data
;
777 rdp
= odp
->additional_data
;
783 printf( "int %s_%d()\n{\n\t", UpperDLLName
, i
);
784 printf( "RELAY32_Unimplemented(\"%s\",%d);\n", UpperDLLName
, i
);
785 printf( "\t/*NOTREACHED*/\n\treturn 0;\n}\n\n");
790 argc
=strlen(fdp
->arg_types
);
792 if(odp
->type
== TYPE_STDCALL
)
794 /* Output a function prototype with stdcall attribute */
795 printf( "void %s_%d(", UpperDLLName
, i
);
796 for(argno
=0;argno
<argc
;argno
++)
798 switch(fdp
->arg_types
[argno
])
800 case 'p': printf( "void *");break;
801 case 'l': printf( "int ");break;
802 case '.': printf( "... ");varargs
=argno
;break;
804 fprintf(stderr
, "Not supported argument type %c\n",
805 fdp
->arg_types
[argno
]);
808 if(fdp
->arg_types
[argno
]!='.') putchar( 'a'+argno
);
809 if (argno
!=argc
-1) putchar( ',' );
811 printf( ") __attribute((stdcall));\n" );
814 printf( "void %s_%d(", UpperDLLName
, i
);
815 for(argno
=0;argno
<argc
;argno
++)
817 if(odp
->type
== TYPE_STDCALL
) {
818 switch(fdp
->arg_types
[argno
])
820 case 'p': printf( "void *");break;
821 case 'l': printf( "int ");break;
823 fprintf(stderr
, "Not supported argument type %c\n",
824 fdp
->arg_types
[argno
]);
828 switch(fdp
->arg_types
[argno
])
830 case 'p': printf( "void *");break;
831 case 'l': printf( "int ");break;
832 case '.': printf( "... ");varargs
=argno
;break;
834 fprintf(stderr
, "Not supported argument type %c\n",
835 fdp
->arg_types
[argno
]);
839 if(fdp
->arg_types
[argno
]!='.') putchar( 'a'+argno
);
840 if (argno
!=argc
-1) putchar( ',' );
844 if (varargs
) printf( "\tva_list valist;\n\n\tva_start(valist, %c);",
846 printf( "\tdprintf_relay(stddeb,\"Call %%s.%%s(");
847 for (argno
=0;argno
<argc
;argno
++)
848 if(fdp
->arg_types
[argno
]!='.')
851 putchar( (fdp
->arg_types
[argno
] == 'p') ? 'p' : 'x' );
852 if (argno
< argc
-1) putchar( ',' );
854 printf( ")\\n\", \"%s\", \"%s\"", UpperDLLName
, odp
->export_name
);
855 for(argno
=0;argno
<argc
;argno
++)
856 if(fdp
->arg_types
[argno
]!='.') printf( ",%c", 'a'+argno
);
857 printf( ");\n\t%s(", fdp
->internal_name
);
858 for(argno
=0;argno
<argc
;argno
++)
860 if (fdp
->arg_types
[argno
]=='.') printf("valist");
861 else putchar('a'+argno
);
862 if (argno
!=argc
-1) putchar(',');
865 if(odp
->type
== TYPE_STDCALL
) {
866 printf( "\t__asm__ __volatile__ (\"movl %%ebp,%%esp\");\n");
867 printf( "\t__asm__ __volatile__ (\"popl %%ebp\");\n");
868 printf( "\t__asm__ __volatile__ (\"addl $%d,%%esp\");\n", argc
*4+4);
869 printf( "\t__asm__ __volatile__ (\"jmp -%d(%%esp)\");\n", argc
*4+4);
874 printf( "void %s_%d()\n{\n\t", UpperDLLName
, i
);
875 printf( "RELAY32_DebugEnter(\"%s\",\"%s\");\n\t",
876 UpperDLLName
, odp
->export_name
);
877 printf( "WIN32_LastError=ERROR_CALL_NOT_IMPLEMENTED;\n");
878 printf( "\t__asm__ __volatile__ (\"movl $%d,%%eax\");\n",
880 printf( "\t__asm__ __volatile__ (\"movl %%ebp,%%esp;popl %%ebp;"
881 "ret $%d\");\n}\n\n", rdp
->arg_size
);
884 fprintf(stderr
,"build: function type %d not available for Win32\n",
890 printf( "static WIN32_function functions[%d+1]={\n", Limit
);
892 odp
= OrdinalDefinitions
;
893 for (i
= 0; i
<= Limit
; i
++, odp
++)
895 fdp
= odp
->additional_data
;
896 rdp
= odp
->additional_data
;
901 printf( "{0,%s_%d},\n",UpperDLLName
, i
);
907 printf( "{\"%s\",%s_%d},\n", odp
->export_name
, UpperDLLName
, i
);
910 fprintf(stderr
, "build: implementation error: missing %d\n",
917 printf( "static WIN32_builtin dll={\"%s\",functions,%d,%d,0};\n",
918 UpperDLLName
, Limit
+1, Base
);
920 printf( "void %s_Init(void)\n{\n",UpperDLLName
);
921 printf( "\tdll.next=WIN32_builtin_list;\n");
922 printf( "\tWIN32_builtin_list=&dll;\n\tRELAY32_MakeFakeModule(&dll);\n}");
926 static void BuildSpec16Files( char *specname
)
932 int code_offset
, data_offset
;
934 SpecFp
= fopen( specname
, "r");
937 fprintf(stderr
, "Could not open specification file, '%s'\n", specname
);
943 printf( "/* File generated automatically; do not edit! */\n" );
944 printf( "\t.data\n" );
945 printf( "\t.globl " PREFIX
"%s_Data_Start\n", UpperDLLName
);
946 printf( PREFIX
"%s_Data_Start:\n", UpperDLLName
);
948 printf( "\t.4byte 0,0,0,0,0,0,0,0\n" );
950 printf( "\t.word 0,0,0,0,0,0,0,0\n" );
953 printf( "\t.text\n" );
954 printf( "\t.globl " PREFIX
"%s_Code_Start\n", UpperDLLName
);
955 printf( PREFIX
"%s_Code_Start:\n", UpperDLLName
);
958 odp
= OrdinalDefinitions
;
959 for (i
= 0; i
<= Limit
; i
++, odp
++)
961 fdp
= odp
->additional_data
;
962 rdp
= odp
->additional_data
;
967 odp
->offset
= 0xffff;
971 odp
->offset
= (int)odp
->additional_data
& 0xffff;
975 printf( "/* %s.%d */\n", UpperDLLName
, i
);
976 odp
->offset
= data_offset
;
977 data_offset
+= OutputVariableCode( ".byte", odp
);
981 printf( "/* %s.%d */\n", UpperDLLName
, i
);
982 odp
->offset
= data_offset
;
984 data_offset
+= 2 * OutputVariableCode( ".4byte", odp
);
986 data_offset
+= 2 * OutputVariableCode( ".word", odp
);
991 printf( "/* %s.%d */\n", UpperDLLName
, i
);
992 odp
->offset
= data_offset
;
993 data_offset
+= 4 * OutputVariableCode( ".long", odp
);
997 printf( "/* %s.%d */\n", UpperDLLName
, i
);
998 printf( "\tmovw $%d,%%ax\n", rdp
->ret_value
& 0xffff );
999 printf( "\tmovw $%d,%%dx\n", (rdp
->ret_value
>> 16) & 0xffff);
1000 printf( "\t.byte 0x66\n");
1001 if (rdp
->arg_size
!= 0)
1002 printf( "\tlret $%d\n", rdp
->arg_size
);
1004 printf( "\tlret\n");
1005 odp
->offset
= code_offset
;
1006 code_offset
+= 10; /* Assembly code is 10 bytes long */
1007 if (rdp
->arg_size
!= 0) code_offset
+= 2;
1012 case TYPE_PASCAL_16
:
1014 printf( "/* %s.%d */\n", UpperDLLName
, i
);
1015 printf( "\tpushw %%bp\n" );
1016 printf( "\tpushl $0x%08x\n", (DLLId
<< 16) | i
);
1017 printf( "\tpushl $" PREFIX
"%s\n", fdp
->internal_name
);
1018 printf( "\tljmp $0x%04x, $" PREFIX
"CallTo32_%s_%s\n\n",
1020 (odp
->type
== TYPE_REGISTER
) ? "regs" :
1021 (odp
->type
== TYPE_PASCAL
) ? "long" : "word",
1023 printf( "\tnop\n" );
1024 printf( "\tnop\n" );
1025 printf( "\tnop\n" );
1026 printf( "\tnop\n" );
1027 printf( "\tnop\n" );
1028 odp
->offset
= code_offset
;
1029 code_offset
+= 24; /* Assembly code is 24 bytes long */
1033 fprintf( stderr
, "build: Unknown function type; please report.\n");
1038 if (!code_offset
) /* Make sure the code segment is not empty */
1040 printf( "\t.byte 0\n" );
1044 BuildModule( code_offset
, data_offset
);
1048 /*******************************************************************
1049 * BuildCall32LargeStack
1051 * Build the function used to switch to the original 32-bit stack
1052 * before calling a 32-bit function from 32-bit code. This is used for
1053 * functions that need a large stack, like X bitmaps functions.
1055 * The generated function has the following prototype:
1056 * int CallTo32_LargeStack( int (*func)(), int nbargs, ... )
1067 static void BuildCall32LargeStack(void)
1069 /* Function header */
1071 printf( "/**********\n" );
1072 printf( " * " PREFIX
"CallTo32_LargeStack\n" );
1073 printf( " **********/\n" );
1074 printf( "\t.align 4\n" );
1075 printf( "\t.globl " PREFIX
"CallTo32_LargeStack\n\n" );
1076 printf( PREFIX
"CallTo32_LargeStack:\n" );
1080 printf( "\tpushl %%ebp\n" );
1081 printf( "\tmovl %%esp,%%ebp\n" );
1083 /* Save registers */
1085 printf( "\tpushl %%ecx\n" );
1086 printf( "\tpushl %%esi\n" );
1087 printf( "\tpushl %%edi\n" );
1089 /* Retrieve the original 32-bit stack pointer and switch to it if any */
1091 printf( "\tmovl " PREFIX
"IF1632_Original32_esp, %%eax\n" );
1092 printf( "\torl %%eax,%%eax\n" );
1093 printf( "\tje no_orig_esp\n" );
1094 printf( "\tmovl %%eax,%%esp\n" );
1095 printf( "no_orig_esp:\n" );
1097 /* Transfer the arguments */
1099 printf( "\tmovl 12(%%ebp),%%ecx\n" );
1100 printf( "\torl %%ecx,%%ecx\n" );
1101 printf( "\tje no_args\n" );
1102 printf( "\tleal 16(%%ebp),%%esi\n" );
1103 printf( "\tshll $2,%%ecx\n" );
1104 printf( "\tsubl %%ecx,%%esp\n" );
1105 printf( "\tmovl %%esp,%%edi\n" );
1106 printf( "\tshrl $2,%%ecx\n" );
1107 printf( "\tcld\n" );
1108 printf( "\trep; movsl\n" );
1109 printf( "no_args:\n" );
1111 /* Call the function */
1113 printf( "\tcall 8(%%ebp)\n" );
1115 /* Switch back to the normal stack */
1117 printf( "\tleal -12(%%ebp),%%esp\n" );
1119 /* Restore registers and return */
1121 printf( "\tpopl %%edi\n" );
1122 printf( "\tpopl %%esi\n" );
1123 printf( "\tpopl %%ecx\n" );
1124 printf( "\tpopl %%ebp\n" );
1125 printf( "\tret\n" );
1129 /*******************************************************************
1130 * TransferArgs16To32
1132 * Get the arguments from the 16-bit stack and push them on the 32-bit stack.
1133 * The 16-bit stack layout is:
1141 static int TransferArgs16To32( char *args
)
1143 int i
, pos16
, pos32
;
1145 /* Save ebx first */
1147 printf( "\tpushl %%ebx\n" );
1149 /* Get the 32-bit stack pointer */
1151 printf( "\tmovl " PREFIX
"IF1632_Saved32_esp,%%ebx\n" );
1153 /* Copy the arguments */
1155 pos16
= 6; /* skip bp and return address */
1158 for (i
= strlen(args
); i
> 0; i
--)
1163 case 'w': /* word */
1164 printf( "\tmovzwl %d(%%ebp),%%eax\n", pos16
);
1165 printf( "\tmovl %%eax,%d(%%ebx)\n", pos32
);
1169 case 's': /* s_word */
1170 printf( "\tmovswl %d(%%ebp),%%eax\n", pos16
);
1171 printf( "\tmovl %%eax,%d(%%ebx)\n", pos32
);
1175 case 'l': /* long */
1176 printf( "\tmovl %d(%%ebp),%%eax\n", pos16
);
1177 printf( "\tmovl %%eax,%d(%%ebx)\n", pos32
);
1182 /* Get the selector */
1183 printf( "\tmovw %d(%%ebp),%%ax\n", pos16
+ 2 );
1184 /* Get the selector base */
1185 printf( "\tandl $0xfff8,%%eax\n" );
1186 printf( "\tmovl " PREFIX
"ldt_copy(%%eax),%%eax\n" );
1187 printf( "\tmovl %%eax,%d(%%ebx)\n", pos32
);
1188 /* Add the offset */
1189 printf( "\tmovzwl %d(%%ebp),%%eax\n", pos16
);
1190 printf( "\taddl %%eax,%d(%%ebx)\n", pos32
);
1195 fprintf( stderr
, "Unknown arg type '%c'\n", args
[i
-1] );
1201 printf( "\tpopl %%ebx\n" );
1203 return pos16
- 6; /* Return the size of the 16-bit args */
1207 /*******************************************************************
1210 * Build the context structure on the 32-bit stack.
1211 * The only valid registers in the context structure are:
1212 * eax, ebx, ecx, edx, esi, edi, ds, es, (some of the) flags
1214 static void BuildContext(void)
1216 /* Save ebx first */
1218 printf( "\tpushl %%ebx\n" );
1220 /* Get the 32-bit stack pointer */
1222 printf( "\tmovl " PREFIX
"IF1632_Saved32_esp,%%ebx\n" );
1224 /* Store the registers */
1226 printf( "\tpopl %d(%%ebx)\n", CONTEXTOFFSET(sc_ebx
) ); /* Get ebx from stack */
1227 printf( "\tmovl %%eax,%d(%%ebx)\n", CONTEXTOFFSET(sc_eax
) );
1228 printf( "\tmovl %%ecx,%d(%%ebx)\n", CONTEXTOFFSET(sc_ecx
) );
1229 printf( "\tmovl %%edx,%d(%%ebx)\n", CONTEXTOFFSET(sc_edx
) );
1230 printf( "\tmovl %%esi,%d(%%ebx)\n", CONTEXTOFFSET(sc_esi
) );
1231 printf( "\tmovl %%edi,%d(%%ebx)\n", CONTEXTOFFSET(sc_edi
) );
1232 printf( "\tmovw -10(%%ebp),%%ax\n" ); /* Get saved ds from stack */
1233 printf( "\tmovw %%ax,%d(%%ebx)\n", CONTEXTOFFSET(sc_ds
) );
1234 printf( "\tmovw -12(%%ebp),%%ax\n" ); /* Get saved es from stack */
1235 printf( "\tmovw %%ax,%d(%%ebx)\n", CONTEXTOFFSET(sc_es
) );
1236 printf( "\tpushfl\n" );
1238 printf( "\tpopl %d(%%ebx)\n", CONTEXTOFFSET(sc_eflags
) );
1240 printf( "\tpopl %d(%%ebx)\n", CONTEXTOFFSET(sc_efl
) );
1245 /*******************************************************************
1248 * Restore the registers from the context structure
1250 static void RestoreContext(void)
1252 /* Get the 32-bit stack pointer */
1254 printf( "\tmovl " PREFIX
"IF1632_Saved32_esp,%%ebx\n" );
1256 /* Restore the registers */
1258 printf( "\tmovl %d(%%ebx),%%ecx\n", CONTEXTOFFSET(sc_ecx
) );
1259 printf( "\tmovl %d(%%ebx),%%edx\n", CONTEXTOFFSET(sc_edx
) );
1260 printf( "\tmovl %d(%%ebx),%%esi\n", CONTEXTOFFSET(sc_esi
) );
1261 printf( "\tmovl %d(%%ebx),%%edi\n", CONTEXTOFFSET(sc_edi
) );
1262 printf( "\tpopl %%eax\n" ); /* Remove old ds and es from stack */
1263 printf( "\tpushw %d(%%ebx)\n", CONTEXTOFFSET(sc_ds
) ); /* Push new ds */
1264 printf( "\tpushw %d(%%ebx)\n", CONTEXTOFFSET(sc_es
) ); /* Push new es */
1266 printf( "\tpushl %d(%%ebx)\n", CONTEXTOFFSET(sc_eflags
) );
1268 printf( "\tpushl %d(%%ebx)\n", CONTEXTOFFSET(sc_efl
) );
1270 printf( "\tpopfl\n" );
1271 printf( "\tmovl %d(%%ebx),%%eax\n", CONTEXTOFFSET(sc_eax
) );
1272 printf( "\tmovl %d(%%ebx),%%ebx\n", CONTEXTOFFSET(sc_ebx
) );
1276 /*******************************************************************
1279 * Build a 32-bit callback function. The syntax of the function
1280 * profile is: type_xxxxx, where 'type' is one of 'regs', 'word' or
1281 * 'long' and each 'x' is an argument ('w'=word, 's'=signed word,
1282 * 'l'=long, 'p'=pointer).
1283 * For register functions, the arguments are ignored, but they are still
1284 * removed from the stack upon return.
1286 * Stack layout upon entry to the callback function:
1288 * (sp+14) first 16-bit arg
1292 * (sp+4) dll_id+ordinal (long)
1293 * (sp) entrypoint (long)
1296 static void BuildCall32Func( char *profile
)
1301 char *args
= profile
+ 5;
1303 /* Parse function type */
1305 if (!strncmp( "word_", profile
, 5 )) short_ret
= 1;
1306 else if (!strncmp( "regs_", profile
, 5 )) reg_func
= 1;
1307 else if (strncmp( "long_", profile
, 5 ))
1309 fprintf( stderr
, "Invalid function name '%s', ignored\n", profile
);
1313 /* Function header */
1315 printf( "/**********\n" );
1316 printf( " * " PREFIX
"CallTo32_%s\n", profile
);
1317 printf( " **********/\n" );
1318 printf( "\t.align 4\n" );
1319 printf( "\t.globl " PREFIX
"CallTo32_%s\n\n", profile
);
1320 printf( PREFIX
"CallTo32_%s:\n", profile
);
1322 /* Setup bp to point to its copy on the stack */
1324 printf( "\tmovzwl %%sp,%%ebp\n" );
1325 printf( "\taddw $8,%%bp\n" );
1327 /* Save 16-bit ds and es */
1329 printf( "\tpushw %%ds\n" );
1330 printf( "\tpushw %%es\n" );
1332 /* Restore 32-bit ds and es */
1334 printf( "\tpushl $0x%04x%04x\n", WINE_DATA_SELECTOR
, WINE_DATA_SELECTOR
);
1335 printf( "\tpopw %%ds\n" );
1336 printf( "\tpopw %%es\n" );
1339 /* Save the 16-bit stack */
1341 printf( "\tpushw " PREFIX
"IF1632_Saved16_sp\n" );
1342 printf( "\tpushw " PREFIX
"IF1632_Saved16_ss\n" );
1344 printf("\tdata16\n");
1346 printf( "\tmovw %%ss," PREFIX
"IF1632_Saved16_ss\n" );
1347 printf( "\tmovw %%sp," PREFIX
"IF1632_Saved16_sp\n" );
1349 /* Transfer the arguments */
1351 if (reg_func
) BuildContext();
1352 else if (*args
) argsize
= TransferArgs16To32( args
);
1354 /* Get the address of the API function */
1356 printf( "\tmovl -8(%%ebp),%%eax\n" );
1358 /* If necessary, save %edx over the API function address */
1360 if (!reg_func
&& short_ret
)
1361 printf( "\tmovl %%edx,-8(%%ebp)\n" );
1363 /* Switch to the 32-bit stack */
1365 printf( "\tmovl " PREFIX
"IF1632_Saved32_esp,%%ebp\n" );
1366 printf( "\tpushw %%ds\n" );
1367 printf( "\tpopw %%ss\n" );
1368 printf( "\tleal -%d(%%ebp),%%esp\n",
1369 reg_func
? sizeof(struct sigcontext_struct
) : 4 * strlen(args
) );
1371 /* Setup %ebp to point to the previous stack frame (built by CallTo16) */
1373 printf( "\taddl $24,%%ebp\n" );
1375 /* Print the debug information before the call */
1379 printf( "\tpushl %%eax\n" );
1380 printf( "\tpushl $CALL32_Str_%s\n", profile
);
1381 printf( "\tpushl $%d\n", reg_func
? 2 : (short_ret
? 1 : 0) );
1382 printf( "\tcall " PREFIX
"RELAY_DebugCall32\n" );
1383 printf( "\tpopl %%eax\n" );
1384 printf( "\tpopl %%eax\n" );
1385 printf( "\tpopl %%eax\n" );
1388 /* Call the entry point */
1390 printf( "\tcall %%eax\n" );
1392 /* Print the debug information after the call */
1396 printf( "\tpushl %%eax\n" );
1397 printf( "\tpushl $%d\n", reg_func
? 2 : (short_ret
? 1 : 0) );
1398 printf( "\tcall " PREFIX
"RELAY_DebugReturn\n" );
1399 printf( "\tpopl %%eax\n" );
1400 printf( "\tpopl %%eax\n" );
1403 /* Restore the 16-bit stack */
1406 printf( "\tdata16\n");
1408 printf( "\tmovw " PREFIX
"IF1632_Saved16_ss,%%ss\n" );
1409 printf( "\tmovw " PREFIX
"IF1632_Saved16_sp,%%sp\n" );
1411 printf( "\tdata16\n");
1413 printf( "\tpopw " PREFIX
"IF1632_Saved16_ss\n" );
1415 printf( "\tdata16\n");
1417 printf( "\tpopw " PREFIX
"IF1632_Saved16_sp\n" );
1421 /* Restore registers from the context structure */
1424 /* Calc the arguments size */
1438 fprintf( stderr
, "Unknown arg type '%c'\n", *args
);
1444 /* Restore ds and es */
1446 printf( "\tpopw %%es\n" );
1447 printf( "\tpopw %%ds\n" );
1449 /* Get the return value into dx:ax and clean up the stack */
1455 printf( "\tpopl %%edx\n" ); /* Restore %edx */
1456 printf( "\taddl $4,%%esp\n" ); /* Remove DLL id and ordinal */
1460 printf( "\tpushl %%eax\n" );
1461 printf( "\tpopw %%ax\n" );
1462 printf( "\tpopw %%dx\n" );
1463 /* Remove API entry point, DLL id and ordinal from the stack */
1464 printf( "\taddl $8,%%esp\n" );
1469 /* Remove API entry point, DLL id and ordinal from the stack, */
1470 /* but take care not to change the value of the carry flag. */
1472 printf( "\tpopl %%ebp\n" );
1473 printf( "\tpopl %%ebp\n" );
1478 printf( "\tpopw %%bp\n" );
1480 /* Remove the arguments and return */
1484 printf( "\t.byte 0x66\n" );
1485 printf( "\tlret $%d\n", argsize
);
1489 printf( "\t.byte 0x66\n" );
1490 printf( "\tlret\n" );
1495 /*******************************************************************
1498 * Build a 16-bit callback function.
1500 * Stack frame of the callback function:
1504 * (ebp+16) 16-bit ds
1505 * (ebp+12) func to call
1506 * (ebp+8) code selector
1507 * (ebp+4) return address
1508 * (ebp) previous ebp
1510 * Prototypes for the CallTo16 functions:
1511 * extern WORD CallTo16_word_xxx( FARPROC func, WORD ds, args... );
1512 * extern LONG CallTo16_long_xxx( FARPROC func, WORD ds, args... );
1513 * extern void CallTo16_regs_( FARPROC func, WORD ds, WORD es, WORD bp,
1514 * WORD ax, WORD bx, WORD cx, WORD dx,
1515 * WORD si, WORD di );
1517 static void BuildCall16Func( char *profile
)
1521 char *args
= profile
+ 5;
1523 if (!strncmp( "word_", profile
, 5 )) short_ret
= 1;
1524 else if (!strncmp( "regs_", profile
, 5 )) reg_func
= short_ret
= 1;
1525 else if (strncmp( "long_", profile
, 5 ))
1527 fprintf( stderr
, "Invalid function name '%s', ignored\n", profile
);
1531 /* Function header */
1533 printf( "/**********\n" );
1534 printf( " * " PREFIX
"CallTo16_%s\n", profile
);
1535 printf( " **********/\n" );
1536 printf( "\t.align 4\n" );
1537 printf( "\t.globl " PREFIX
"CallTo16_%s\n\n", profile
);
1538 printf( PREFIX
"CallTo16_%s:\n", profile
);
1540 /* Push code selector before return address to simulate a lcall */
1542 printf( "\tpopl %%eax\n" );
1543 printf( "\tpushl $0x%04x\n", WINE_CODE_SELECTOR
);
1544 printf( "\tpushl %%eax\n" );
1548 printf( "\tpushl %%ebp\n" );
1549 printf( "\tmovl %%esp,%%ebp\n" );
1551 /* Save the 32-bit registers */
1553 printf( "\tpushl %%ebx\n" );
1554 printf( "\tpushl %%ecx\n" );
1555 printf( "\tpushl %%edx\n" );
1556 printf( "\tpushl %%esi\n" );
1557 printf( "\tpushl %%edi\n" );
1559 /* Save the 32-bit stack */
1561 printf( "\tpushl " PREFIX
"IF1632_Saved32_esp\n" );
1562 printf( "\tmovl %%esp," PREFIX
"IF1632_Saved32_esp\n" );
1563 printf( "\tmovl %%ebp,%%ebx\n" );
1565 /* Print debugging info */
1569 /* Push the address of the first argument */
1570 printf( "\tmovl %%ebx,%%eax\n" );
1571 printf( "\taddl $12,%%eax\n" );
1572 printf( "\tpushl $%d\n", reg_func
? 8 : strlen(args
) );
1573 printf( "\tpushl %%eax\n" );
1574 printf( "\tcall " PREFIX
"RELAY_DebugCall16\n" );
1575 printf( "\tpopl %%eax\n" );
1576 printf( "\tpopl %%eax\n" );
1579 /* Switch to the 16-bit stack */
1582 printf("\tdata16\n");
1584 printf( "\tmovw " PREFIX
"IF1632_Saved16_ss,%%ss\n" );
1585 printf( "\tmovw " PREFIX
"IF1632_Saved16_sp,%%sp\n" );
1587 /* Transfer the arguments */
1591 /* Get the registers. ebx is handled later on. */
1592 printf( "\tpushw 20(%%ebx)\n" );
1593 printf( "\tpopw %%es\n" );
1594 printf( "\tmovl 24(%%ebx),%%ebp\n" );
1595 printf( "\tmovl 28(%%ebx),%%eax\n" );
1596 printf( "\tmovl 36(%%ebx),%%ecx\n" );
1597 printf( "\tmovl 40(%%ebx),%%edx\n" );
1598 printf( "\tmovl 44(%%ebx),%%esi\n" );
1599 printf( "\tmovl 48(%%ebx),%%edi\n" );
1601 else /* not a register function */
1603 int pos
= 20; /* first argument position */
1605 /* Make %bp point to the previous stackframe (built by CallTo32) */
1606 printf( "\tmovw %%sp,%%bp\n" );
1607 printf( "\taddw $16,%%bp\n" );
1613 case 'w': /* word */
1614 printf( "\tpushw %d(%%ebx)\n", pos
);
1616 case 'l': /* long */
1617 printf( "\tpushl %d(%%ebx)\n", pos
);
1624 /* Push the return address */
1626 printf( "\tpushl " PREFIX
"CALL16_RetAddr_%s\n",
1627 short_ret
? "word" : "long" );
1629 /* Push the called routine address */
1631 printf( "\tpushl 12(%%ebx)\n" );
1633 /* Get the 16-bit ds */
1637 printf( "\tpushw 16(%%ebx)\n" );
1638 printf( "\tmovl 32(%%ebx),%%ebx\n" ); /*Get ebx from the 32-bit stack*/
1639 printf( "\tpopw %%ds\n" );
1643 /* Set ax equal to ds for window procedures */
1644 printf( "\tmovw 16(%%ebx),%%ax\n" );
1646 printf( "\tdata16\n");
1648 printf( "\tmovw %%ax,%%ds\n" );
1651 /* Jump to the called routine */
1653 printf( "\t.byte 0x66\n" );
1654 printf( "\tlret\n" );
1658 /*******************************************************************
1661 * Build the return code for 16-bit callbacks
1663 static void BuildRet16Func()
1665 printf( "\t.globl " PREFIX
"CALL16_Ret_word\n" );
1666 printf( "\t.globl " PREFIX
"CALL16_Ret_long\n" );
1668 /* Put return value into eax */
1670 printf( PREFIX
"CALL16_Ret_long:\n" );
1671 printf( "\tpushw %%dx\n" );
1672 printf( "\tpushw %%ax\n" );
1673 printf( "\tpopl %%eax\n" );
1674 printf( PREFIX
"CALL16_Ret_word:\n" );
1676 /* Restore 32-bit segment registers */
1678 printf( "\tmovw $0x%04x,%%bx\n", WINE_DATA_SELECTOR
);
1680 printf( "\tdata16\n");
1682 printf( "\tmovw %%bx,%%ds\n" );
1684 printf( "\tdata16\n");
1686 printf( "\tmovw %%bx,%%es\n" );
1688 printf( "\tdata16\n");
1690 printf( "\tmovw %%bx,%%ss\n" );
1692 /* Restore the 32-bit stack */
1694 printf( "\tmovl " PREFIX
"IF1632_Saved32_esp,%%esp\n" );
1695 printf( "\tpopl " PREFIX
"IF1632_Saved32_esp\n" );
1697 /* Restore the 32-bit registers */
1699 printf( "\tpopl %%edi\n" );
1700 printf( "\tpopl %%esi\n" );
1701 printf( "\tpopl %%edx\n" );
1702 printf( "\tpopl %%ecx\n" );
1703 printf( "\tpopl %%ebx\n" );
1705 /* Return to caller */
1707 printf( "\tpopl %%ebp\n" );
1708 printf( "\tlret\n" );
1710 /* Declare the return address variables */
1712 printf( "\t.data\n" );
1713 printf( "\t.globl " PREFIX
"CALL16_RetAddr_word\n" );
1714 printf( "\t.globl " PREFIX
"CALL16_RetAddr_long\n" );
1715 printf( PREFIX
"CALL16_RetAddr_word:\t.long 0\n" );
1716 printf( PREFIX
"CALL16_RetAddr_long:\t.long 0\n" );
1717 printf( "\t.text\n" );
1721 static void usage(void)
1723 fprintf(stderr
, "usage: build -spec SPECNAMES\n"
1724 " build -call32 FUNCTION_PROFILES\n"
1725 " build -call16 FUNCTION_PROFILES\n" );
1730 int main(int argc
, char **argv
)
1734 if (argc
<= 2) usage();
1736 if (!strcmp( argv
[1], "-spec16" ))
1738 for (i
= 2; i
< argc
; i
++) BuildSpec16Files( argv
[i
] );
1740 else if (!strcmp( argv
[1], "-spec32" ))
1742 for (i
= 2; i
< argc
; i
++) BuildSpec32Files( argv
[i
] );
1744 else if (!strcmp( argv
[1], "-call32" )) /* 32-bit callbacks */
1748 printf( "/* File generated automatically. Do not edit! */\n\n" );
1749 printf( "\t.text\n" );
1751 /* Build the 32-bit large stack callback */
1753 BuildCall32LargeStack();
1755 /* Build the callback functions */
1757 for (i
= 2; i
< argc
; i
++) BuildCall32Func( argv
[i
] );
1759 /* Output the argument debugging strings */
1763 printf( "/* Argument strings */\n" );
1764 for (i
= 2; i
< argc
; i
++)
1766 printf( "CALL32_Str_%s:\n", argv
[i
] );
1767 printf( "\t.ascii \"%s\\0\"\n", argv
[i
] + 5 );
1771 else if (!strcmp( argv
[1], "-call16" )) /* 16-bit callbacks */
1775 printf( "/* File generated automatically. Do not edit! */\n\n" );
1776 printf( "\t.text\n" );
1777 printf( "\t.globl " PREFIX
"CALL16_Start\n" );
1778 printf( PREFIX
"CALL16_Start:\n" );
1780 /* Build the callback functions */
1782 for (i
= 2; i
< argc
; i
++) BuildCall16Func( argv
[i
] );
1784 /* Output the 16-bit return code */
1788 printf( "\t.globl " PREFIX
"CALL16_End\n" );
1789 printf( PREFIX
"CALL16_End:\n" );