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