x86asm.pl 2.2 KB

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