worlda.s 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. //
  2. // worlda.s
  3. // x86 assembly-language server testing stuff
  4. //
  5. #include "asm_i386.h"
  6. #include "quakeasm.h"
  7. //include "d_ifacea.h"
  8. #if id386
  9. .data
  10. Ltemp: .long 0
  11. .text
  12. //----------------------------------------------------------------------
  13. // hull-point test
  14. //----------------------------------------------------------------------
  15. #define hull 4+8 // because only partially pushed
  16. #define num 8+4 // because only partially pushed
  17. #define p 12+12 // because only partially pushed
  18. .align 4
  19. .globl C(SV_HullPointContents)
  20. C(SV_HullPointContents):
  21. pushl %edi // preserve register variables
  22. movl num(%esp),%eax
  23. testl %eax,%eax
  24. js Lhquickout
  25. // float d;
  26. // dclipnode_t *node;
  27. // mplane_t *plane;
  28. pushl %ebx
  29. movl hull(%esp),%ebx
  30. pushl %ebp
  31. movl p(%esp),%edx
  32. movl hu_clipnodes(%ebx),%edi
  33. movl hu_planes(%ebx),%ebp
  34. subl %ebx,%ebx
  35. pushl %esi
  36. // %ebx: 0
  37. // %eax: num
  38. // %edx: p
  39. // %edi: hull->clipnodes
  40. // %ebp: hull->planes
  41. // while (num >= 0)
  42. // {
  43. Lhloop:
  44. // node = hull->clipnodes + num;
  45. // plane = hull->planes + node->planenum;
  46. // !!! if the size of dclipnode_t changes, the scaling of %eax needs to be
  47. // changed !!!
  48. movl nd_planenum(%edi,%eax,8),%ecx
  49. movl nd_children(%edi,%eax,8),%eax
  50. movl %eax,%esi
  51. rorl $16,%eax
  52. leal (%ecx,%ecx,4),%ecx
  53. // if (plane->type < 3)
  54. // d = p[plane->type] - plane->dist;
  55. movl pl_type(%ebp,%ecx,4),%bl
  56. cmpb $3,%bl
  57. jb Lnodot
  58. // else
  59. // d = DotProduct (plane->normal, p) - plane->dist;
  60. flds pl_normal(%ebp,%ecx,4)
  61. fmuls 0(%edx)
  62. flds pl_normal+4(%ebp,%ecx,4)
  63. fmuls 4(%edx)
  64. flds pl_normal+8(%ebp,%ecx,4)
  65. fmuls 8(%edx)
  66. fxch %st(1)
  67. faddp %st(0),%st(2)
  68. faddp %st(0),%st(1)
  69. fsubs pl_dist(%ebp,%ecx,4)
  70. jmp Lsub
  71. Lnodot:
  72. flds pl_dist(%ebp,%ecx,4)
  73. fsubrs (%edx,%ebx,4)
  74. Lsub:
  75. sarl $16,%eax
  76. sarl $16,%esi
  77. // if (d < 0)
  78. // num = node->children[1];
  79. // else
  80. // num = node->children[0];
  81. fstps Ltemp
  82. movl Ltemp,%ecx
  83. sarl $31,%ecx
  84. andl %ecx,%esi
  85. xorl $0xFFFFFFFF,%ecx
  86. andl %ecx,%eax
  87. orl %esi,%eax
  88. jns Lhloop
  89. // return num;
  90. Lhdone:
  91. popl %esi
  92. popl %ebp
  93. popl %ebx // restore register variables
  94. Lhquickout:
  95. popl %edi
  96. ret
  97. #endif // id386