x86asm.pl 2.4 KB

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