xref: /openbsd-src/lib/libcrypto/perlasm/x86asm.pl (revision db3296cf5c1dd9058ceecc3a29fe4aaa0bd26000)
1#!/usr/local/bin/perl
2
3# require 'x86asm.pl';
4# &asm_init("cpp","des-586.pl");
5# XXX
6# XXX
7# main'asm_finish
8
9sub main'asm_finish
10	{
11	&file_end();
12	&asm_finish_cpp() if $cpp;
13	print &asm_get_output();
14	}
15
16sub main'asm_init
17	{
18	($type,$fn,$i386)=@_;
19	$filename=$fn;
20
21	$elf=$cpp=$sol=$aout=$win32=$gaswin=0;
22	if (	($type eq "elf"))
23		{ $elf=1; require "x86unix.pl"; }
24	elsif (	($type eq "a.out"))
25		{ $aout=1; require "x86unix.pl"; }
26	elsif (	($type eq "gaswin"))
27		{ $gaswin=1; $aout=1; require "x86unix.pl"; }
28	elsif (	($type eq "sol"))
29		{ $sol=1; require "x86unix.pl"; }
30	elsif (	($type eq "cpp"))
31		{ $cpp=1; require "x86unix.pl"; }
32	elsif (	($type eq "win32"))
33		{ $win32=1; require "x86ms.pl"; }
34	elsif (	($type eq "win32n"))
35		{ $win32=1; require "x86nasm.pl"; }
36	else
37		{
38		print STDERR <<"EOF";
39Pick one target type from
40	elf	- linux, FreeBSD etc
41	a.out	- old linux
42	sol	- x86 solaris
43	cpp	- format so x86unix.cpp can be used
44	win32	- Windows 95/Windows NT
45	win32n	- Windows 95/Windows NT NASM format
46EOF
47		exit(1);
48		}
49
50	$pic=0;
51	for (@ARGV) {	$pic=1 if (/\-[fK]PIC/i);	}
52
53	&asm_init_output();
54
55&comment("Don't even think of reading this code");
56&comment("It was automatically generated by $filename");
57&comment("Which is a perl program used to generate the x86 assember for");
58&comment("any of elf, a.out, BSDI, Win32, gaswin (for GNU as on Win32) or Solaris");
59&comment("eric <eay\@cryptsoft.com>");
60&comment("");
61
62	$filename =~ s/\.pl$//;
63	&file($filename);
64	}
65
66sub asm_finish_cpp
67	{
68	return unless $cpp;
69
70	local($tmp,$i);
71	foreach $i (&get_labels())
72		{
73		$tmp.="#define $i _$i\n";
74		}
75	print <<"EOF";
76/* Run the C pre-processor over this file with one of the following defined
77 * ELF - elf object files,
78 * OUT - a.out object files,
79 * BSDI - BSDI style a.out object files
80 * SOL - Solaris style elf
81 */
82
83#define TYPE(a,b)       .type   a,b
84#define SIZE(a,b)       .size   a,b
85
86#if defined(OUT) || (defined(BSDI) && !defined(ELF))
87$tmp
88#endif
89
90#ifdef OUT
91#define OK	1
92#define ALIGN	4
93#if defined(__CYGWIN__) || defined(__DJGPP__)
94#undef SIZE
95#undef TYPE
96#define SIZE(a,b)
97#define TYPE(a,b)	.def a; .scl 2; .type 32; .endef
98#endif /* __CYGWIN || __DJGPP */
99#endif
100
101#if defined(BSDI) && !defined(ELF)
102#define OK              1
103#define ALIGN           4
104#undef SIZE
105#undef TYPE
106#define SIZE(a,b)
107#define TYPE(a,b)
108#endif
109
110#if defined(ELF) || defined(SOL)
111#define OK              1
112#define ALIGN           16
113#endif
114
115#ifndef OK
116You need to define one of
117ELF - elf systems - linux-elf, NetBSD and DG-UX
118OUT - a.out systems - linux-a.out and FreeBSD
119SOL - solaris systems, which are elf with strange comment lines
120BSDI - a.out with a very primative version of as.
121#endif
122
123/* Let the Assembler begin :-) */
124EOF
125	}
126
1271;
128