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