home *** CD-ROM | disk | FTP | other *** search
/ Executor 2.0 / executorv2.0.iso / pc / linux / extra / docs / maillist / text / archive.95 / text0590.txt < prev    next >
Encoding:
Text File  |  1996-04-02  |  2.4 KB  |  57 lines

  1.  
  2. [Note: this is a fairly technical reply to Jered's question, but there
  3.  are a bunch of assembler-heads on this list, so I thought I'd post it.
  4.  Most people will just want to skip this message.]
  5.  
  6. >>>>> "jered" == jered  <jered@MIT.EDU> writes:
  7.  
  8.     jered> I just saw on the linux kernel discuss meeting that 486es
  9.     jered> and higher have a special instruction for converting
  10.     jered> big-endian to/from little-endian.  Does anyone know if gcc
  11.     jered> (djgpp) uses this and optimizes for it, what sort of
  12.     jered> performance increase it might give, and if it would be
  13.     jered> worth anyone's while to have a 486-higher executable of
  14.     jered> Executor?
  15.  
  16. Jered is talking about the "bswap" instruction, which byte swaps a
  17. four-byte value in a register in one cycle.  It was added when the
  18. 80486 came out, so it isn't present on 80386's.  It's non-pairable on
  19. the Pentium.
  20.  
  21. gcc doesn't generate the "bswap" instruction, because it won't work on
  22. an 80386.  I don't know if gcc has any way of doing anything special
  23. for byte swaps anyway.  The -m486 flag isn't allowed to generate code
  24. that won't run on an 80386, so gcc couldn't generate a bswap.  From
  25. gcc.info:
  26.  
  27.  `-m486'
  28.  `-mno-486'
  29.       Control whether or not code is optimized for a 486 instead of an
  30.       386.  Code generated for an 486 will run on a 386 and vice versa.
  31.  
  32. Executor's C code uses inline assembly to byte swap with three rotate
  33. instructions, which works on both the 80386 and 80486+.  Our CPU
  34. emulator (syn68k) decides at runtime if you have an 80486 or better
  35. and generates bswap instructions "on the fly" if you do.  Otherwise,
  36. it generates three rotate instructions.
  37.  
  38. A version of Executor that didn't work on 80386's would be a little
  39. smaller and a little faster than the current one, but there's no
  40. reason to think the performance difference would be huge.  We
  41. benchmarked such a version long, long ago and found that an
  42. 80486-specific version was something like 5-10% faster.
  43.  
  44. Note that since NEXTSTEP/Intel only works on 80486's or better,
  45. Executor/NEXTSTEP/Intel assumes the presence of an 80486 and takes
  46. advantage of it.
  47.  
  48. The new, faster blitter I'm writing may take advantage of the bswap
  49. instruction, if present.  Once that's done, the CPU emulator and the
  50. graphics engine will both use bswap, so there won't be much
  51. performance to gain by creating an 80486-specific version of Executor.
  52.  
  53. Thanks for the suggestion, though.
  54.  
  55. -Mat
  56.  
  57.