xref: /onnv-gate/usr/src/common/openssl/crypto/perlasm/x86asm.pl (revision 2139:6243c3338933)
10Sstevel@tonic-gate#!/usr/local/bin/perl
20Sstevel@tonic-gate
30Sstevel@tonic-gate# require 'x86asm.pl';
40Sstevel@tonic-gate# &asm_init("cpp","des-586.pl");
50Sstevel@tonic-gate# XXX
60Sstevel@tonic-gate# XXX
70Sstevel@tonic-gate# main'asm_finish
80Sstevel@tonic-gate
90Sstevel@tonic-gatesub main'asm_finish
100Sstevel@tonic-gate	{
110Sstevel@tonic-gate	&file_end();
120Sstevel@tonic-gate	&asm_finish_cpp() if $cpp;
130Sstevel@tonic-gate	print &asm_get_output();
140Sstevel@tonic-gate	}
150Sstevel@tonic-gate
160Sstevel@tonic-gatesub main'asm_init
170Sstevel@tonic-gate	{
180Sstevel@tonic-gate	($type,$fn,$i386)=@_;
190Sstevel@tonic-gate	$filename=$fn;
200Sstevel@tonic-gate
21*2139Sjp161948	$elf=$cpp=$coff=$aout=$win32=$netware=$mwerks=0;
220Sstevel@tonic-gate	if (	($type eq "elf"))
230Sstevel@tonic-gate		{ $elf=1; require "x86unix.pl"; }
240Sstevel@tonic-gate	elsif (	($type eq "a.out"))
250Sstevel@tonic-gate		{ $aout=1; require "x86unix.pl"; }
26*2139Sjp161948	elsif (	($type eq "coff" or $type eq "gaswin"))
27*2139Sjp161948		{ $coff=1; require "x86unix.pl"; }
280Sstevel@tonic-gate	elsif (	($type eq "cpp"))
290Sstevel@tonic-gate		{ $cpp=1; require "x86unix.pl"; }
300Sstevel@tonic-gate	elsif (	($type eq "win32"))
310Sstevel@tonic-gate		{ $win32=1; require "x86ms.pl"; }
320Sstevel@tonic-gate	elsif (	($type eq "win32n"))
330Sstevel@tonic-gate		{ $win32=1; require "x86nasm.pl"; }
34*2139Sjp161948	elsif (	($type eq "nw-nasm"))
35*2139Sjp161948		{ $netware=1; require "x86nasm.pl"; }
36*2139Sjp161948	elsif (	($type eq "nw-mwasm"))
37*2139Sjp161948		{ $netware=1; $mwerks=1; require "x86nasm.pl"; }
380Sstevel@tonic-gate	else
390Sstevel@tonic-gate		{
400Sstevel@tonic-gate		print STDERR <<"EOF";
410Sstevel@tonic-gatePick one target type from
42*2139Sjp161948	elf	- Linux, FreeBSD, Solaris x86, etc.
43*2139Sjp161948	a.out	- OpenBSD, DJGPP, etc.
44*2139Sjp161948	coff	- GAS/COFF such as Win32 targets
450Sstevel@tonic-gate	win32	- Windows 95/Windows NT
460Sstevel@tonic-gate	win32n	- Windows 95/Windows NT NASM format
47*2139Sjp161948	nw-nasm - NetWare NASM format
48*2139Sjp161948	nw-mwasm- NetWare Metrowerks Assembler
490Sstevel@tonic-gateEOF
500Sstevel@tonic-gate		exit(1);
510Sstevel@tonic-gate		}
520Sstevel@tonic-gate
530Sstevel@tonic-gate	$pic=0;
540Sstevel@tonic-gate	for (@ARGV) {	$pic=1 if (/\-[fK]PIC/i);	}
550Sstevel@tonic-gate
560Sstevel@tonic-gate	&asm_init_output();
570Sstevel@tonic-gate
580Sstevel@tonic-gate&comment("Don't even think of reading this code");
590Sstevel@tonic-gate&comment("It was automatically generated by $filename");
600Sstevel@tonic-gate&comment("Which is a perl program used to generate the x86 assember for");
61*2139Sjp161948&comment("any of ELF, a.out, COFF, Win32, ...");
620Sstevel@tonic-gate&comment("eric <eay\@cryptsoft.com>");
630Sstevel@tonic-gate&comment("");
640Sstevel@tonic-gate
650Sstevel@tonic-gate	$filename =~ s/\.pl$//;
660Sstevel@tonic-gate	&file($filename);
670Sstevel@tonic-gate	}
680Sstevel@tonic-gate
690Sstevel@tonic-gatesub asm_finish_cpp
700Sstevel@tonic-gate	{
710Sstevel@tonic-gate	return unless $cpp;
720Sstevel@tonic-gate
730Sstevel@tonic-gate	local($tmp,$i);
740Sstevel@tonic-gate	foreach $i (&get_labels())
750Sstevel@tonic-gate		{
760Sstevel@tonic-gate		$tmp.="#define $i _$i\n";
770Sstevel@tonic-gate		}
780Sstevel@tonic-gate	print <<"EOF";
790Sstevel@tonic-gate/* Run the C pre-processor over this file with one of the following defined
800Sstevel@tonic-gate * ELF - elf object files,
810Sstevel@tonic-gate * OUT - a.out object files,
820Sstevel@tonic-gate * BSDI - BSDI style a.out object files
830Sstevel@tonic-gate * SOL - Solaris style elf
840Sstevel@tonic-gate */
850Sstevel@tonic-gate
860Sstevel@tonic-gate#define TYPE(a,b)       .type   a,b
870Sstevel@tonic-gate#define SIZE(a,b)       .size   a,b
880Sstevel@tonic-gate
890Sstevel@tonic-gate#if defined(OUT) || (defined(BSDI) && !defined(ELF))
900Sstevel@tonic-gate$tmp
910Sstevel@tonic-gate#endif
920Sstevel@tonic-gate
930Sstevel@tonic-gate#ifdef OUT
940Sstevel@tonic-gate#define OK	1
950Sstevel@tonic-gate#define ALIGN	4
960Sstevel@tonic-gate#if defined(__CYGWIN__) || defined(__DJGPP__)
970Sstevel@tonic-gate#undef SIZE
980Sstevel@tonic-gate#undef TYPE
990Sstevel@tonic-gate#define SIZE(a,b)
1000Sstevel@tonic-gate#define TYPE(a,b)	.def a; .scl 2; .type 32; .endef
1010Sstevel@tonic-gate#endif /* __CYGWIN || __DJGPP */
1020Sstevel@tonic-gate#endif
1030Sstevel@tonic-gate
1040Sstevel@tonic-gate#if defined(BSDI) && !defined(ELF)
1050Sstevel@tonic-gate#define OK              1
1060Sstevel@tonic-gate#define ALIGN           4
1070Sstevel@tonic-gate#undef SIZE
1080Sstevel@tonic-gate#undef TYPE
1090Sstevel@tonic-gate#define SIZE(a,b)
1100Sstevel@tonic-gate#define TYPE(a,b)
1110Sstevel@tonic-gate#endif
1120Sstevel@tonic-gate
1130Sstevel@tonic-gate#if defined(ELF) || defined(SOL)
1140Sstevel@tonic-gate#define OK              1
1150Sstevel@tonic-gate#define ALIGN           16
1160Sstevel@tonic-gate#endif
1170Sstevel@tonic-gate
1180Sstevel@tonic-gate#ifndef OK
1190Sstevel@tonic-gateYou need to define one of
1200Sstevel@tonic-gateELF - elf systems - linux-elf, NetBSD and DG-UX
1210Sstevel@tonic-gateOUT - a.out systems - linux-a.out and FreeBSD
1220Sstevel@tonic-gateSOL - solaris systems, which are elf with strange comment lines
1230Sstevel@tonic-gateBSDI - a.out with a very primative version of as.
1240Sstevel@tonic-gate#endif
1250Sstevel@tonic-gate
1260Sstevel@tonic-gate/* Let the Assembler begin :-) */
1270Sstevel@tonic-gateEOF
1280Sstevel@tonic-gate	}
1290Sstevel@tonic-gate
1300Sstevel@tonic-gate1;
131