x86_main.as 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. #
  2. # x86 format converters for HERMES
  3. # Some routines Copyright (c) 1998 Christian Nentwich ([email protected])
  4. # This source code is licensed under the GNU LGPL
  5. #
  6. # Please refer to the file COPYING.LIB contained in the distribution for
  7. # licensing conditions
  8. #
  9. .globl _ConvertX86
  10. .globl _ConvertX86Stretch
  11. .globl _x86return
  12. .globl _x86return_S
  13. .globl _Hermes_X86_CPU
  14. .data
  15. cpu_flags: .long 0
  16. .text
  17. .equ s_pixels, 0
  18. .equ s_width, 4
  19. .equ s_height, 8
  20. .equ s_add, 12
  21. .equ d_pixels, 16
  22. .equ d_width, 20
  23. .equ d_height, 24
  24. .equ d_add, 28
  25. .equ conv_func, 32
  26. .equ lookup, 36
  27. .equ s_pitch, 40
  28. .equ d_pitch, 44
  29. ## _ConvertX86:
  30. ## [ESP+8] ConverterInfo*
  31. ## --------------------------------------------------------------------------
  32. ##
  33. ## ConvertX86Stretch 'abuses' the following info structure fields:
  34. ## - d_pitch for the y increment
  35. ## - s_add for the x increment
  36. ## because they're unused anyway and this is thread safe.. (it's a per
  37. ## converter handle structure)
  38. _ConvertX86Stretch:
  39. pushl %ebp
  40. movl %esp,%ebp
  41. movl 8(%ebp),%ebp
  42. movl s_height(%ebp),%eax
  43. sall $16,%eax
  44. cdq
  45. idivl d_height(%ebp)
  46. movl %eax,d_pitch(%ebp)
  47. movl s_width(%ebp),%eax
  48. sall $16,%eax
  49. cdq
  50. idivl d_width(%ebp)
  51. movl %eax,s_add(%ebp)
  52. movl $0,s_height(%ebp)
  53. movl d_pixels(%ebp),%edi
  54. movl s_pixels(%ebp),%esi
  55. movl s_add(%ebp),%edx
  56. movl d_width(%ebp),%ecx
  57. jmp *conv_func(%ebp)
  58. .align 8
  59. _x86return_S:
  60. decl d_height(%ebp)
  61. jz endconvert_S
  62. movl s_height(%ebp),%eax
  63. addl d_add(%ebp),%edi
  64. addl d_pitch(%ebp),%eax
  65. movl %eax,%ebx
  66. shrl $16,%eax
  67. mull s_pitch(%ebp)
  68. andl $0x0ffff,%ebx
  69. movl %ebx,s_height(%ebp)
  70. addl %eax,%esi
  71. movl s_add(%ebp),%edx
  72. movl d_width(%ebp),%ecx
  73. jmp *conv_func(%ebp)
  74. endconvert_S:
  75. popl %ebp
  76. ret
  77. _ConvertX86:
  78. pushl %ebp
  79. movl %esp,%ebp
  80. movl 8(%ebp),%ebp
  81. movl s_pixels(%ebp),%esi
  82. movl d_width(%ebp),%ecx
  83. movl d_pixels(%ebp),%edi
  84. jmp *32(%ebp)
  85. .align 8
  86. _x86return:
  87. decl s_height(%ebp)
  88. jz endconvert
  89. movl d_width(%ebp),%ecx
  90. addl s_add(%ebp),%esi
  91. addl d_add(%ebp),%edi
  92. jmp *32(%ebp)
  93. endconvert:
  94. popl %ebp
  95. ret
  96. ## Hermes_X86_CPU returns the CPUID flags in eax
  97. _Hermes_X86_CPU:
  98. pushfl
  99. popl %eax
  100. movl %eax,%ecx
  101. xorl $0x040000,%eax
  102. pushl %eax
  103. popfl
  104. pushfl
  105. popl %eax
  106. xorl %ecx,%eax
  107. jz _Hermes_X86_CPU.L1 # Processor is 386
  108. pushl %ecx
  109. popfl
  110. movl %ecx,%eax
  111. xorl $0x200000,%eax
  112. pushl %eax
  113. popfl
  114. pushfl
  115. popl %eax
  116. xorl %ecx,%eax
  117. je _Hermes_X86_CPU.L1
  118. pusha
  119. movl $1,%eax
  120. cpuid
  121. movl %edx,cpu_flags
  122. popa
  123. movl cpu_flags,%eax
  124. _Hermes_X86_CPU.L1:
  125. ret